Sirikata
|
A class that replaces text out of an Ogre DataStream as it is read Currently does the simple thing by reading the entire document as a string whenever data is requested. More...
#include <ReplacingDataStream.hpp>
Public Member Functions | |
void | preprocessData (std::vector< Ogre::String > &provides, std::vector< Ogre::String > &depends_on) |
This function accelerates the precomputation of material mangling and returns depends and provides lists to boot. | |
ReplacingDataStream (Ogre::DataStreamPtr &input, const Ogre::String &destination, const Ogre::NameValuePairList *textureAliases) | |
The ReplacingDataStream constructs a file that will transparently modify a material as it reads it. | |
virtual | ~ReplacingDataStream () |
virtual size_t | read (void *buf, size_t count) |
virtual Ogre::String | getAsString (void) |
virtual void | skip (long count) |
virtual void | seek (size_t pos) |
virtual size_t | tell (void) const |
virtual bool | eof (void) const |
virtual void | close (void) |
Protected Member Functions | |
void | verifyData () const |
loads in and replaces the data | |
virtual void | replace_reference (Ogre::String &retval, const Ogre::String &input, Ogre::String::size_type &pwhere, Ogre::String::const_iterator second_input, const Ogre::String &filename) |
This function gets a callback from the ReplacingDataStream whenever a script file name is encountered it is defined as a noop but is used in replace_material tools. | |
virtual void | replace_texture_reference (Ogre::String &retval, const Ogre::String &input, Ogre::String::size_type &pwhere, Ogre::String::const_iterator second_input, bool texture_instead_of_source, const Ogre::String &filename) |
This function gets a callback from the ReplacingDataStream whenever a source (Vertex Program) or texture file name is encountered it is defined as a noop but is used in replace_material tools. | |
virtual Ogre::String | full_replace_lexeme (const Ogre::String &input, Ogre::String::size_type where_lexeme_start, Ogre::String::size_type &return_lexeme_end, const Ogre::String &filename) |
This function gets a callback from the ReplacingDataStream whenever a material name depended-on is encountered it uses this callback to replace internal material references with the now-known corresponding hash or third level name Thusly a if a material meru://foo@bar/baz defined program Foo and used it here then it would transform Foo into meru://foo@bar/baz:Foo. | |
virtual Ogre::String | replace_lexeme (const Ogre::String &input, Ogre::String::size_type where_lexeme_start, Ogre::String::size_type &return_lexeme_end, const Ogre::String &filename) |
This function gets a callback from the ReplacingDataStream whenever a material name that the material provides is encountered it uses this callback to replace the provided material with a mangling such that if a material meru://foo@bar/baz defined program Foo and used it later then it would transform Foo into meru://foo@bar/baz:Foo. | |
virtual Ogre::String | replaceData (Ogre::String) |
Replaces items after Naming-type tokens with the DataStream filename and __ and it replaces references to those likewise. | |
Static Protected Member Functions | |
static void | find_lexeme (const Ogre::String &input, Ogre::String::size_type &where_lexeme_start, Ogre::String::size_type &return_lexeme_end) |
Protected Attributes | |
Ogre::String | dataAsString |
Ogre::DataStreamPtr | file |
Ogre::MemoryDataStreamPtr | helper |
std::vector< Ogre::String > | provides |
std::vector< Ogre::String > | depends_on |
const Ogre::NameValuePairList * | mTextureAliases |
Transfer::URI | mSourceURI |
A class that replaces text out of an Ogre DataStream as it is read Currently does the simple thing by reading the entire document as a string whenever data is requested.
This is what the parser down the line does anyway in current ogre so it's not an efficiency issue This class may be inherited and replaceData overwritten but the default implementation of replaceData works appropriately for the meru file naming conventions for ogre materials.
Sirikata::Graphics::ReplacingDataStream::ReplacingDataStream | ( | Ogre::DataStreamPtr & | input, |
const Ogre::String & | destination, | ||
const Ogre::NameValuePairList * | textureAliases | ||
) |
The ReplacingDataStream constructs a file that will transparently modify a material as it reads it.
input | is another datastream this one piggy-backs on |
destination | is the filename that the material will come to represent |
textureAliases | is a list of textures thirdname->first name list so that efficient materials can refer to the first names directly |
References mSourceURI, and mTextureAliases.
Sirikata::Graphics::ReplacingDataStream::~ReplacingDataStream | ( | ) | [virtual] |
void Sirikata::Graphics::ReplacingDataStream::close | ( | void | ) | [virtual] |
References dataAsString, file, and helper.
bool Sirikata::Graphics::ReplacingDataStream::eof | ( | void | ) | const [virtual] |
References helper, and verifyData().
void Sirikata::Graphics::ReplacingDataStream::find_lexeme | ( | const Ogre::String & | input, |
Ogre::String::size_type & | where_lexeme_start, | ||
Ogre::String::size_type & | return_lexeme_end | ||
) | [static, protected] |
Referenced by full_replace_lexeme(), replace_lexeme(), replace_reference(), replace_texture_reference(), and replaceData().
Ogre::String Sirikata::Graphics::ReplacingDataStream::full_replace_lexeme | ( | const Ogre::String & | input, |
Ogre::String::size_type | where_lexeme_start, | ||
Ogre::String::size_type & | return_lexeme_end, | ||
const Ogre::String & | filename | ||
) | [protected, virtual] |
This function gets a callback from the ReplacingDataStream whenever a material name depended-on is encountered it uses this callback to replace internal material references with the now-known corresponding hash or third level name Thusly a if a material meru://foo@bar/baz defined program Foo and used it here then it would transform Foo into meru://foo@bar/baz:Foo.
input | is passed from ReplacingDataStream as the entire data |
where_lexeme_start | is passed from ReplacingDataStream as where the current material name was discovered |
return_lexeme_end | is returned from this function after find_lexeme is run to tear out the material name |
filename | is the name of the current material which is not used in this context |
References find_lexeme(), and Sirikata::Graphics::replaceColonSlashSlash().
Referenced by replaceData().
Ogre::String Sirikata::Graphics::ReplacingDataStream::getAsString | ( | void | ) | [virtual] |
References dataAsString, and verifyData().
void Sirikata::Graphics::ReplacingDataStream::preprocessData | ( | std::vector< Ogre::String > & | provides, |
std::vector< Ogre::String > & | depends_on | ||
) |
This function accelerates the precomputation of material mangling and returns depends and provides lists to boot.
References depends_on, provides, and verifyData().
size_t Sirikata::Graphics::ReplacingDataStream::read | ( | void * | buf, |
size_t | count | ||
) | [virtual] |
References helper, and verifyData().
Ogre::String Sirikata::Graphics::ReplacingDataStream::replace_lexeme | ( | const Ogre::String & | input, |
Ogre::String::size_type | where_lexeme_start, | ||
Ogre::String::size_type & | return_lexeme_end, | ||
const Ogre::String & | filename | ||
) | [protected, virtual] |
This function gets a callback from the ReplacingDataStream whenever a material name that the material provides is encountered it uses this callback to replace the provided material with a mangling such that if a material meru://foo@bar/baz defined program Foo and used it later then it would transform Foo into meru://foo@bar/baz:Foo.
input | is passed from ReplacingDataStream as the entire data |
where_lexeme_start | is passed from ReplacingDataStream as where the current material name was discovered |
return_lexeme_end | is returned from this function after find_lexeme is run to tear out the material when replacing it name |
filename | is the name of the current script which is not used in this context |
References find_lexeme(), provides, and Sirikata::Graphics::replaceColonSlashSlash().
Referenced by replaceData().
void Sirikata::Graphics::ReplacingDataStream::replace_reference | ( | Ogre::String & | retval, |
const Ogre::String & | input, | ||
Ogre::String::size_type & | pwhere, | ||
Ogre::String::const_iterator | second_input, | ||
const Ogre::String & | filename | ||
) | [protected, virtual] |
This function gets a callback from the ReplacingDataStream whenever a script file name is encountered it is defined as a noop but is used in replace_material tools.
retval | will return the name of the material as it is modified by firstOrThirdLevelName |
input | is passed from ReplacingDataStream as the entire data |
pwhere | is the location where the material was discovered and may be shifted to where the next input should be read if something is returned in retval |
second_input | is passed from ReplacingDataStream as where the current material file name was discovered |
filename | is the name of the current script which is not used in this context |
References CDN_REPLACING_MATERIAL_STREAM_HINT, find_lexeme(), mSourceURI, mTextureAliases, and Sirikata::JS::JSPresence::toString().
Referenced by replaceData().
void Sirikata::Graphics::ReplacingDataStream::replace_texture_reference | ( | Ogre::String & | retval, |
const Ogre::String & | input, | ||
Ogre::String::size_type & | pwhere, | ||
Ogre::String::const_iterator | second_input, | ||
bool | texture_instead_of_source, | ||
const Ogre::String & | filename | ||
) | [protected, virtual] |
This function gets a callback from the ReplacingDataStream whenever a source (Vertex Program) or texture file name is encountered it is defined as a noop but is used in replace_material tools.
retval | will return the name of the material as it is modified by firstOrThirdLevelName |
input | is passed from ReplacingDataStream as the entire data |
pwhere | is the location where the material was discovered and may be shifted to where the next input should be read if something is returned in retval |
second_input | is passed from ReplacingDataStream as where the current source or texture file name was discovered |
texture_instead_of_source | currently unused |
filename | is the name of the current script which is not used in this context |
References find_lexeme(), mSourceURI, mTextureAliases, and Sirikata::JS::JSPresence::toString().
Referenced by replaceData().
Ogre::String Sirikata::Graphics::ReplacingDataStream::replaceData | ( | Ogre::String | input | ) | [protected, virtual] |
Replaces items after Naming-type tokens with the DataStream filename and __ and it replaces references to those likewise.
file 0xbadf00d with material hair is transformed as follows: vertex_program swirl cg { } material hair { vertex_program_ref swirl; fragment_program_ref file://0xbeefd00d/hair } becomes vertex_program badf00d__swirl cg{ } material bad00d__hair { vertex_program_ref badf00d__swirl fragment_program_ref beefd00d__hair }
References Sirikata::Logging::error, find_lexeme(), Sirikata::Graphics::find_space_colon_space(), full_replace_lexeme(), mSourceURI, mTextureAliases, Sirikata::Graphics::next_eol(), replace_lexeme(), replace_reference(), replace_texture_reference(), SILOG, and Sirikata::JS::JSPresence::toString().
Referenced by verifyData().
void Sirikata::Graphics::ReplacingDataStream::seek | ( | size_t | pos | ) | [virtual] |
References helper, and verifyData().
void Sirikata::Graphics::ReplacingDataStream::skip | ( | long | count | ) | [virtual] |
References helper, and verifyData().
size_t Sirikata::Graphics::ReplacingDataStream::tell | ( | void | ) | const [virtual] |
References helper, and verifyData().
void Sirikata::Graphics::ReplacingDataStream::verifyData | ( | ) | const [protected] |
loads in and replaces the data
References dataAsString, file, helper, and replaceData().
Referenced by eof(), getAsString(), preprocessData(), read(), seek(), skip(), and tell().
Ogre::String Sirikata::Graphics::ReplacingDataStream::dataAsString [protected] |
Referenced by close(), getAsString(), and verifyData().
std::vector<Ogre::String> Sirikata::Graphics::ReplacingDataStream::depends_on [protected] |
Referenced by preprocessData().
Ogre::DataStreamPtr Sirikata::Graphics::ReplacingDataStream::file [protected] |
Referenced by close(), and verifyData().
Ogre::MemoryDataStreamPtr Sirikata::Graphics::ReplacingDataStream::helper [protected] |
Referenced by replace_reference(), replace_texture_reference(), replaceData(), and ReplacingDataStream().
const Ogre::NameValuePairList* Sirikata::Graphics::ReplacingDataStream::mTextureAliases [protected] |
Referenced by replace_reference(), replace_texture_reference(), replaceData(), and ReplacingDataStream().
std::vector<Ogre::String> Sirikata::Graphics::ReplacingDataStream::provides [protected] |
Referenced by preprocessData(), and replace_lexeme().