Visualization Library v1.0.3A lightweight C++ OpenGL middleware for 2D/3D graphics |
[Download] [Tutorials] [All Classes] [Grouped Classes] |
Translates an arbitrary set of vl::Object (and subclasses) into VLB and VLT format. More...
#include <VLXSerializer.hpp>
Public Types | |
enum | EError { NoError, ImportError, ExportError, ReadError, WriteError } |
Public Member Functions | |
VLXSerializer () | |
const char * | errorString () const |
bool | saveVLT (const String &path, const Object *obj, bool start_fresh=true) |
bool | saveVLT (VirtualFile *file, const Object *obj, bool start_fresh=true) |
bool | saveVLB (const String &path, const Object *obj, bool start_fresh=true) |
bool | saveVLB (VirtualFile *file, const Object *obj, bool start_fresh=true) |
ref< Object > | loadVLT (const String &path, bool start_fresh=true) |
ref< Object > | loadVLT (VirtualFile *file, bool start_fresh=true) |
ref< Object > | loadVLB (const String &path, bool start_fresh=true) |
ref< Object > | loadVLB (VirtualFile *file, bool start_fresh=true) |
Object * | importVLX (const VLXStructure *st) |
VLXStructure * | exportVLX (const Object *obj) |
bool | canExport (const Object *obj) const |
bool | canImport (const VLXStructure *st) const |
void | registerImportedStructure (const VLXStructure *st, Object *obj) |
void | registerExportedObject (const Object *obj, VLXStructure *st) |
Object * | getImportedStructure (const VLXStructure *st) |
VLXStructure * | getExportedObject (const Object *obj) |
VLXRegistry * | registry () |
The VLXRegistry used by the serializer, by default set to vl::defVLXRegistry(). | |
const VLXRegistry * | registry () const |
The VLXRegistry used by the serializer, by default set to vl::defVLXRegistry(). | |
void | setRegistry (const VLXRegistry *registry) |
The VLXRegistry used by the serializer, by default set to vl::defVLXRegistry(). | |
std::map< std::string, VLXValue > & | metadata () |
The metadata to be imported or exported. | |
const std::map< std::string, VLXValue > & | metadata () const |
The metadata to be imported or exported. | |
VLXValue * | getMetadata (const char *key) |
Returns the value of the given metadata key or NULL if no such metadata was found. | |
const VLXValue * | getMetadata (const char *key) const |
Returns the value of the given metadata key or NULL if no such metadata was found. | |
void | reset () |
std::string | generateID (const char *prefix) |
void | setError (EError err) |
Sets a serialization error. | |
EError | error () const |
The last signaled error. | |
void | signalImportError (const String &str) |
void | signalExportError (const String &str) |
void | setDocumentURL (const String &location) |
The URL of the document used to resolve document-relative file paths. | |
const String & | documentURL () const |
The URL of the document used to resolve document-relative file paths. | |
void | resolvePath (std::string &path) |
If the given path starts with "this:" then the "this:" prefix is replaced with the documentURL(), otherwise the path is left unchanged. | |
void | setDirective (const char *directive, const char *value) |
Sets a serialization directive that can be used by VLXClassWrapper objects to program the serialization process. | |
void | eraseDirective (const char *directive) |
Removes a serialization directive. | |
const std::string & | directive (const char *directive) const |
Returns the value of a serialization directive. | |
bool | hasDirective (const char *directive) |
Returns true if the given directive has been set. | |
void | eraseAllDirectives () |
Erases all previously set directives. |
Translates an arbitrary set of vl::Object (and subclasses) into VLB and VLT format.
Definition at line 45 of file VLXSerializer.hpp.
Definition at line 50 of file VLXSerializer.hpp.
vl::VLXSerializer::VLXSerializer | ( | ) | [inline] |
Definition at line 53 of file VLXSerializer.hpp.
References vl::defVLXRegistry().
const char * VLXSerializer::errorString | ( | ) | const |
Definition at line 426 of file VLXSeriailzer.cpp.
References ExportError, ImportError, NoError, ReadError, and WriteError.
Referenced by vl::loadVLB(), vl::loadVLT(), vl::saveVLB(), and vl::saveVLT().
Definition at line 203 of file VLXSeriailzer.cpp.
References vl::ref< T >::get().
Referenced by vl::saveVLT().
bool VLXSerializer::saveVLT | ( | VirtualFile * | file, |
const Object * | obj, | ||
bool | start_fresh = true |
||
) |
Definition at line 209 of file VLXSeriailzer.cpp.
References vl::VirtualFile::close(), error(), exportVLX(), metadata(), NoError, vl::OM_WriteOnly, vl::VirtualFile::open(), vl::VirtualFile::path(), reset(), vl::VLXVisitorExportToVLT::setIDSet(), vl::VLXVisitorCountIDs::setIDSet(), vl::VLXValue::String, vl::VLXVisitorExportToVLT::text(), vl::String::toStdString(), vl::VirtualFile::write(), WriteError, and vl::VLXVisitorExportToVLT::writeHeader().
Definition at line 274 of file VLXSeriailzer.cpp.
References vl::ref< T >::get().
Referenced by vl::saveVLB().
bool VLXSerializer::saveVLB | ( | VirtualFile * | file, |
const Object * | obj, | ||
bool | start_fresh = true |
||
) |
Definition at line 280 of file VLXSeriailzer.cpp.
References vl::VirtualFile::close(), exportVLX(), metadata(), NoError, reset(), vl::VLXVisitorExportToVLB::setIDSet(), vl::VLXVisitorCountIDs::setIDSet(), vl::VLXValue::String, vl::String::toStdString(), and vl::VLXVisitorExportToVLB::writeHeader().
Definition at line 338 of file VLXSeriailzer.cpp.
References vl::ref< T >::get(), and vl::locateFile().
Referenced by vl::loadVLT().
ref< Object > VLXSerializer::loadVLT | ( | VirtualFile * | file, |
bool | start_fresh = true |
||
) |
Definition at line 344 of file VLXSeriailzer.cpp.
References vl::VirtualFile::close(), ImportError, importVLX(), metadata(), NULL, vl::VirtualFile::path(), reset(), setDocumentURL(), setError(), vl::BufferedStream< Element_Type, Chunk_Size >::setInputFile(), and vl::VLXParserVLT::tokenizer().
Definition at line 382 of file VLXSeriailzer.cpp.
References vl::ref< T >::get(), and vl::locateFile().
Referenced by vl::loadVLB().
ref< Object > VLXSerializer::loadVLB | ( | VirtualFile * | file, |
bool | start_fresh = true |
||
) |
Definition at line 388 of file VLXSeriailzer.cpp.
References vl::VirtualFile::close(), ImportError, importVLX(), metadata(), NULL, vl::VirtualFile::path(), reset(), setDocumentURL(), setError(), and vl::VLXParserVLB::setInputFile().
Object * VLXSerializer::importVLX | ( | const VLXStructure * | st ) |
Definition at line 50 of file VLXSeriailzer.cpp.
References error(), vl::ref< T >::get(), getImportedStructure(), ImportError, vl::VLXRegistry::importRegistry(), vl::VLXClassWrapper::importVLX(), NULL, registry(), setError(), vl::VLXTaggedValue::tag(), VL_CHECK, and VL_TRAP.
Referenced by vl::VLXClassWrapper_Actor::importActor(), vl::VLXClassWrapper_Camera::importCamera(), vl::VLXClassWrapper_ClipPlane::importClipPlane(), vl::VLXClassWrapper_DrawCall::importDrawCall(), vl::VLXClassWrapper_Effect::importEffect(), vl::VLXClassWrapper_Geometry::importGeometry(), vl::VLXClassWrapper_GLSLProgram::importGLSLProgram(), vl::VLXClassWrapper_Light::importLight(), vl::VLXClassWrapper_ResourceDatabase::importResourceDatabase(), vl::VLXClassWrapper_Shader::importShader(), vl::VLXClassWrapper_Texture::importTexture(), vl::VLXClassWrapper_TextureSampler::importTextureSampler(), vl::VLXClassWrapper_Transform::importTransform(), vl::VLXClassWrapper_VertexAttribInfo::importVLX(), loadVLB(), and loadVLT().
VLXStructure * VLXSerializer::exportVLX | ( | const Object * | obj ) |
Definition at line 87 of file VLXSeriailzer.cpp.
References error(), ExportError, vl::VLXRegistry::exportRegistry(), vl::VLXClassWrapper::exportVLX(), vl::ref< T >::get(), getExportedObject(), NULL, registry(), setError(), VL_CHECK, and VL_TRAP.
Referenced by vl::VLXClassWrapper_Effect::export_ShaderPasses(), vl::VLXClassWrapper_Actor::exportActor(), vl::VLXClassWrapper_Camera::exportCamera(), vl::VLXClassWrapper_ClipPlane::exportClipPlane(), vl::VLXClassWrapper_DrawCall::exportDrawCall(), vl::VLXClassWrapper_DrawCall::exportDrawCallBase(), vl::VLXClassWrapper_Effect::exportEffect(), vl::VLXClassWrapper_Geometry::exportGeometry(), vl::VLXClassWrapper_GLSLProgram::exportGLSLProgram(), vl::VLXClassWrapper_Light::exportLight(), vl::VLXClassWrapper_ResourceDatabase::exportResourceDatabase(), vl::VLXClassWrapper_Shader::exportShader(), vl::VLXClassWrapper_Texture::exportTexture(), vl::VLXClassWrapper_TextureSampler::exportTextureSampler(), vl::VLXClassWrapper_Transform::exportTransform(), vl::VLXClassWrapper_VertexAttribInfo::exportVertexAttribInfo(), saveVLB(), and saveVLT().
bool VLXSerializer::canExport | ( | const Object * | obj ) | const |
Definition at line 124 of file VLXSeriailzer.cpp.
References vl::VLXRegistry::exportRegistry(), and registry().
Referenced by vl::VLXClassWrapper_ResourceDatabase::exportResourceDatabase(), and vl::VLXClassWrapper_Shader::exportShader().
bool VLXSerializer::canImport | ( | const VLXStructure * | st ) | const |
Definition at line 132 of file VLXSeriailzer.cpp.
References vl::VLXRegistry::importRegistry(), registry(), and vl::VLXTaggedValue::tag().
Referenced by vl::VLXClassWrapper_Actor::importActor().
void VLXSerializer::registerImportedStructure | ( | const VLXStructure * | st, |
Object * | obj | ||
) |
Definition at line 140 of file VLXSeriailzer.cpp.
References VL_CHECK.
Referenced by vl::VLXClassWrapper_TextureSampler::importVLX(), vl::VLXClassWrapper_TexParameter::importVLX(), vl::VLXClassWrapper_Texture::importVLX(), vl::VLXClassWrapper_ActorEventCallback::importVLX(), vl::VLXClassWrapper_Material::importVLX(), vl::VLXClassWrapper_Normal::importVLX(), vl::VLXClassWrapper_SecondaryColor::importVLX(), vl::VLXClassWrapper_Color::importVLX(), vl::VLXClassWrapper_VertexAttrib::importVLX(), vl::VLXClassWrapper_GLSLShader::importVLX(), vl::VLXClassWrapper_GLSLProgram::importVLX(), vl::VLXClassWrapper_ClipPlane::importVLX(), vl::VLXClassWrapper_Light::importVLX(), vl::VLXClassWrapper_Transform::importVLX(), vl::VLXClassWrapper_Viewport::importVLX(), vl::VLXClassWrapper_Camera::importVLX(), vl::VLXClassWrapper_Actor::importVLX(), vl::VLXClassWrapper_Effect::importVLX(), vl::VLXClassWrapper_LODEvaluator::importVLX(), vl::VLXClassWrapper_Shader::importVLX(), vl::VLXClassWrapper_Uniform::importVLX(), vl::VLXClassWrapper_ResourceDatabase::importVLX(), vl::VLXClassWrapper_PatchParameter::importVLX(), vl::VLXClassWrapper_DrawCall::importVLX(), vl::VLXClassWrapper_VertexAttribInfo::importVLX(), vl::VLXClassWrapper_Geometry::importVLX(), and vl::VLXClassWrapper_Array::importVLX().
void VLXSerializer::registerExportedObject | ( | const Object * | obj, |
VLXStructure * | st | ||
) |
Definition at line 146 of file VLXSeriailzer.cpp.
References VL_CHECK.
Referenced by vl::VLXClassWrapper_TextureSampler::exportVLX(), vl::VLXClassWrapper_TexParameter::exportVLX(), vl::VLXClassWrapper_Texture::exportVLX(), vl::VLXClassWrapper_ActorEventCallback::exportVLX(), vl::VLXClassWrapper_Material::exportVLX(), vl::VLXClassWrapper_Normal::exportVLX(), vl::VLXClassWrapper_SecondaryColor::exportVLX(), vl::VLXClassWrapper_Color::exportVLX(), vl::VLXClassWrapper_VertexAttrib::exportVLX(), vl::VLXClassWrapper_GLSLShader::exportVLX(), vl::VLXClassWrapper_GLSLProgram::exportVLX(), vl::VLXClassWrapper_ClipPlane::exportVLX(), vl::VLXClassWrapper_Light::exportVLX(), vl::VLXClassWrapper_Transform::exportVLX(), vl::VLXClassWrapper_Viewport::exportVLX(), vl::VLXClassWrapper_Camera::exportVLX(), vl::VLXClassWrapper_Actor::exportVLX(), vl::VLXClassWrapper_Effect::exportVLX(), vl::VLXClassWrapper_LODEvaluator::exportVLX(), vl::VLXClassWrapper_Shader::exportVLX(), vl::VLXClassWrapper_Uniform::exportVLX(), vl::VLXClassWrapper_ResourceDatabase::exportVLX(), vl::VLXClassWrapper_PatchParameter::exportVLX(), vl::VLXClassWrapper_DrawCall::exportVLX(), vl::VLXClassWrapper_VertexAttribInfo::exportVLX(), vl::VLXClassWrapper_Geometry::exportVLX(), and vl::VLXClassWrapper_Array::exportVLX().
Object * VLXSerializer::getImportedStructure | ( | const VLXStructure * | st ) |
Definition at line 152 of file VLXSeriailzer.cpp.
References NULL, and VL_CHECK.
Referenced by importVLX().
VLXStructure * VLXSerializer::getExportedObject | ( | const Object * | obj ) |
Definition at line 164 of file VLXSeriailzer.cpp.
References NULL, and VL_CHECK.
Referenced by exportVLX().
VLXRegistry* vl::VLXSerializer::registry | ( | ) | [inline] |
The VLXRegistry used by the serializer, by default set to vl::defVLXRegistry().
Definition at line 93 of file VLXSerializer.hpp.
Referenced by canExport(), canImport(), exportVLX(), and importVLX().
const VLXRegistry* vl::VLXSerializer::registry | ( | ) | const [inline] |
The VLXRegistry used by the serializer, by default set to vl::defVLXRegistry().
Definition at line 96 of file VLXSerializer.hpp.
void vl::VLXSerializer::setRegistry | ( | const VLXRegistry * | registry ) | [inline] |
The VLXRegistry used by the serializer, by default set to vl::defVLXRegistry().
Definition at line 99 of file VLXSerializer.hpp.
std::map< std::string, VLXValue >& vl::VLXSerializer::metadata | ( | ) | [inline] |
const std::map< std::string, VLXValue >& vl::VLXSerializer::metadata | ( | ) | const [inline] |
The metadata to be imported or exported.
Definition at line 105 of file VLXSerializer.hpp.
VLXValue* vl::VLXSerializer::getMetadata | ( | const char * | key ) | [inline] |
Returns the value of the given metadata key or NULL if no such metadata was found.
Definition at line 108 of file VLXSerializer.hpp.
References NULL.
const VLXValue* vl::VLXSerializer::getMetadata | ( | const char * | key ) | const [inline] |
Returns the value of the given metadata key or NULL if no such metadata was found.
Definition at line 118 of file VLXSerializer.hpp.
References NULL.
void vl::VLXSerializer::reset | ( | ) | [inline] |
std::string VLXSerializer::generateID | ( | const char * | prefix ) |
Definition at line 196 of file VLXSeriailzer.cpp.
Referenced by vl::VLXClassWrapper_Array::export_ArrayT(), vl::VLXClassWrapper_TextureSampler::exportVLX(), vl::VLXClassWrapper_TexParameter::exportVLX(), vl::VLXClassWrapper_Texture::exportVLX(), vl::VLXClassWrapper_ActorEventCallback::exportVLX(), vl::VLXClassWrapper_Material::exportVLX(), vl::VLXClassWrapper_Normal::exportVLX(), vl::VLXClassWrapper_SecondaryColor::exportVLX(), vl::VLXClassWrapper_Color::exportVLX(), vl::VLXClassWrapper_VertexAttrib::exportVLX(), vl::VLXClassWrapper_GLSLShader::exportVLX(), vl::VLXClassWrapper_GLSLProgram::exportVLX(), vl::VLXClassWrapper_ClipPlane::exportVLX(), vl::VLXClassWrapper_Light::exportVLX(), vl::VLXClassWrapper_Transform::exportVLX(), vl::VLXClassWrapper_Viewport::exportVLX(), vl::VLXClassWrapper_Camera::exportVLX(), vl::VLXClassWrapper_Actor::exportVLX(), vl::VLXClassWrapper_Effect::exportVLX(), vl::VLXClassWrapper_LODEvaluator::exportVLX(), vl::VLXClassWrapper_Shader::exportVLX(), vl::VLXClassWrapper_Uniform::exportVLX(), vl::VLXClassWrapper_ResourceDatabase::exportVLX(), vl::VLXClassWrapper_PatchParameter::exportVLX(), vl::VLXClassWrapper_DrawCall::exportVLX(), vl::VLXClassWrapper_VertexAttribInfo::exportVLX(), and vl::VLXClassWrapper_Geometry::exportVLX().
void vl::VLXSerializer::setError | ( | EError | err ) | [inline] |
Sets a serialization error.
Definition at line 138 of file VLXSerializer.hpp.
Referenced by exportVLX(), importVLX(), loadVLB(), loadVLT(), signalExportError(), signalImportError(), vl::vlx_EClearColorMode(), vl::vlx_EClearFlags(), vl::vlx_EColorMaterial(), vl::vlx_EDepthTextureMode(), vl::vlx_EEnable(), vl::vlx_EPolygonFace(), vl::vlx_EPrimitiveType(), vl::vlx_EProjectionMatrixType(), vl::vlx_ETexCompareFunc(), vl::vlx_ETexCompareMode(), vl::vlx_ETexParamFilter(), vl::vlx_ETexParamWrap(), vl::vlx_ETextureDimension(), vl::vlx_ETextureFormat(), vl::vlx_EUniformType(), and vl::vlx_EVertexAttribInterpretation().
EError vl::VLXSerializer::error | ( | ) | const [inline] |
The last signaled error.
Definition at line 141 of file VLXSerializer.hpp.
Referenced by exportVLX(), importVLX(), vl::loadVLB(), vl::loadVLT(), vl::saveVLB(), vl::saveVLT(), saveVLT(), signalExportError(), and signalImportError().
void VLXSerializer::signalImportError | ( | const String & | str ) |
Definition at line 176 of file VLXSeriailzer.cpp.
References error(), ImportError, and setError().
Referenced by vl::VLXClassWrapper_ActorEventCallback::importActorEventCallback(), vl::VLXClassWrapper_DrawCall::importDrawCall(), vl::VLXClassWrapper_Geometry::importGeometry(), vl::VLXClassWrapper_ResourceDatabase::importResourceDatabase(), vl::VLXClassWrapper_Uniform::importUniform(), vl::VLXClassWrapper_ActorEventCallback::importVLX(), vl::VLXClassWrapper_GLSLShader::importVLX(), vl::VLXClassWrapper_DrawCall::importVLX(), vl::VLXClassWrapper_VertexAttribInfo::importVLX(), and vl::VLXClassWrapper_Array::importVLX().
void VLXSerializer::signalExportError | ( | const String & | str ) |
Definition at line 186 of file VLXSeriailzer.cpp.
References error(), ExportError, and setError().
Referenced by vl::VLXClassWrapper_ActorEventCallback::exportActorEventCallback(), vl::VLXClassWrapper_LODEvaluator::exportLODEvaluator(), and vl::VLXClassWrapper_Array::exportVLX().
void vl::VLXSerializer::setDocumentURL | ( | const String & | location ) | [inline] |
The URL of the document used to resolve document-relative file paths.
Definition at line 148 of file VLXSerializer.hpp.
const String& vl::VLXSerializer::documentURL | ( | ) | const [inline] |
The URL of the document used to resolve document-relative file paths.
Definition at line 151 of file VLXSerializer.hpp.
Referenced by resolvePath().
void VLXSerializer::resolvePath | ( | std::string & | path ) |
If the given path starts with "this:" then the "this:" prefix is replaced with the documentURL(), otherwise the path is left unchanged.
Definition at line 439 of file VLXSeriailzer.cpp.
References documentURL(), vl::String::extractPath(), vl::String::fromStdString(), vl::String::normalizeSlashes(), vl::String::right(), vl::String::startsWith(), and vl::String::toStdString().
Referenced by vl::VLXClassWrapper_GLSLShader::importGLSLShader(), and vl::VLXClassWrapper_Texture::importTexture().
void vl::VLXSerializer::setDirective | ( | const char * | directive, |
const char * | value | ||
) | [inline] |
Sets a serialization directive that can be used by VLXClassWrapper objects to program the serialization process.
Directives are essentially a way to pass options to VLXClassWrapper objects, which can read them from the VLXSerializer they are using.
Definition at line 158 of file VLXSerializer.hpp.
void vl::VLXSerializer::eraseDirective | ( | const char * | directive ) | [inline] |
Removes a serialization directive.
Definition at line 161 of file VLXSerializer.hpp.
const std::string& vl::VLXSerializer::directive | ( | const char * | directive ) | const [inline] |
Returns the value of a serialization directive.
Definition at line 164 of file VLXSerializer.hpp.
bool vl::VLXSerializer::hasDirective | ( | const char * | directive ) | [inline] |
Returns true if the given directive has been set.
Definition at line 175 of file VLXSerializer.hpp.
void vl::VLXSerializer::eraseAllDirectives | ( | ) | [inline] |
Erases all previously set directives.
Definition at line 178 of file VLXSerializer.hpp.