ParseInfo


Description

Compiles registration information for each shader found in the file list returned by QueryParserSettings (available via the FileName attribute).

This callback is fired each time a file is parsed. Once Softimage has gotten the list of files to parse from the QueryParserSettings callback, it begins parsing files and for each file this callback registers the shader definitions it finds in the file.

Tip To get a shader definition to appear in the preset manager, you need to populate the Category attribute with a category label where you want the shader definition to appear in the preset manager. You can also set a more user-friendly name for your shader via the DisplayName attribute.


Applies To

Custom Shaders


Syntax

public class <plugin-item_name>

{

	public bool ParseInfo( Context in_context )

	{

		...

	}

}
CStatus <plugin-item_name>_ParseInfo( CRef& in_context ) 

{ 

	... 

}
function <plugin-item_name>_ParseInfo( in_context ) 

{ 

	... 

}
def <plugin-item_name>_ParseInfo( in_context ):

	...
Function <plugin-item_name>_ParseInfo( in_context )

	...

End Function
sub <plugin-item_name>_ParseInfo 

{ 

	my $in_context = shift; 

}

<plugin-item-name> is the parser name specified in the call to PluginRegistrar.RegisterShaderLanguageParser with any spaces converted to underscores. For example, if you register a parser in a plug-in called "My Parser", the callback function names start with "My_Parser".


Parameters

Parameter Language Type Description
in_context Scripting and C# Context Use the Context.SetAttribute method to get basic information, such as Category, DisplayName, etc.
C++ CRef& Use the Context::SetAttribute method to get basic information, such as Category, DisplayName, etc.


Context Attributes

Attribute Get/Set Description
Filename Gets a String or CString The full path of the file to parse.
ClassName Sets a String or CString The class name of the shader. This is used to build the ShaderDef.ProgID with the parser name and version number in this form: "ParserName.ClassName.MajorVersion.MinorVersion".
MajorVersion Sets a Long or ULONG The major version of the shader definition. This is used to build the ShaderDef.ProgID with the parser name, class name and minor version number in this form: "ParserName.ClassName.MajorVersion.MinorVersion".
MinorVersion Sets a Long or ULONG The minor version of the shader definition. This is used to build the ShaderDef.ProgID with the parser name, class name and major version number in this form: "ParserName.ClassName.MajorVersion.MinorVersion".
Category Sets a String or CString The category to use in the Preset Manager.
DisplayName Sets a String or CString The display name to use in the Preset Manager.
Errors Sets a String or CString The parser can output parse errors.
Warnings Sets a String or CString The parser can output parse warnings.
{XXXX-XXXX-XXXX-XXXX} or simple string attribute name Sets a String or CString You can set a custom shader attribute in the ShaderDef by setting a string repesenting a GUID or the name of any attribute.


Example

SICALLBACK UtShaderLanguageParser_ParseInfo( CRef& in_ctxt )

{

	XSI::Context ctxt(in_ctxt);



	XSI::CString strFilename = ctxt.GetAttribute( L"FileName" );

	std::ifstream in( strFilename.GetAsciiString() );

	if(!in) 

	{

		ctxt.PutAttribute( L"Errors", L"Cannot open file: " + strFilename + L"\n" );

		return CStatus::Fail;

	}



	// Read the first line to get the progid.

	char buf[255];

	in.getline( buf, 255 );

	if( strlen( buf ) > 0 )

	{

		CSIString str(buf);

		std::vector<CSIString> tokens;

		str.Split( L" ", tokens );

		if( tokens.size() == 3 )

		{

			// Set the ProgID information

			XSI::CString strClassName( (LPCWSTR)tokens[0] );

			ULONG ulMajorVersion = wcstoul( (LPCWSTR)tokens[1], NULL, 10 );

			ULONG ulMinorVersion = wcstoul( (LPCWSTR)tokens[2], NULL, 10 );

			ctxt.PutAttribute( L"ClassName",  strClassName );

			ctxt.PutAttribute( L"MajorVersion", ulMajorVersion );

			ctxt.PutAttribute( L"MinorVersion", ulMinorVersion );



			// Set the Category and Display Name

			ctxt.PutAttribute( L"Category", L"SLTest" );

			ctxt.PutAttribute( L"DisplayName", strClassName ); // Same as class name



			// Setting a user attribute

			ctxt.PutAttribute( L"{F2EF07FE-1B57-4245-BF08-F5556212BFDF}", L"User data" ); 

		}

		else

		{

			ctxt.PutAttribute( L"Errors", L"Invalid ProgID at Line 1: " + strFilename + L"\n" );

			in.close();

			return CStatus::Fail;

		}

	}

	else

	{

		ctxt.PutAttribute( L"Errors", L"Invalid ProgID at Line 1: " + strFilename + L"\n" );

		in.close();

		return CStatus::Fail;

	}



	in.close();



	return CStatus::OK;

}


See Also