indent classes, align by spaces
This commit is contained in:
@@ -128,10 +128,10 @@
|
||||
class IgnoreBreaks
|
||||
{
|
||||
public:
|
||||
const char* m_first;
|
||||
const char* m_last;
|
||||
IgnoreBreaks( const char* first, const char* last ) : m_first( first ), m_last( last ){
|
||||
}
|
||||
const char* m_first;
|
||||
const char* m_last;
|
||||
IgnoreBreaks( const char* first, const char* last ) : m_first( first ), m_last( last ){
|
||||
}
|
||||
};
|
||||
|
||||
template<typename TextOutputStreamType>
|
||||
@@ -151,122 +151,122 @@ namespace
|
||||
class TreeXMLImporter : public TextOutputStream
|
||||
{
|
||||
public:
|
||||
virtual TreeXMLImporter& pushElement( const XMLElement& element ) = 0;
|
||||
virtual void popElement( const char* name ) = 0;
|
||||
virtual TreeXMLImporter& pushElement( const XMLElement& element ) = 0;
|
||||
virtual void popElement( const char* name ) = 0;
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class Storage
|
||||
{
|
||||
char m_storage[sizeof( Type )];
|
||||
char m_storage[sizeof( Type )];
|
||||
public:
|
||||
Type& get(){
|
||||
return *reinterpret_cast<Type*>( m_storage );
|
||||
}
|
||||
const Type& get() const {
|
||||
return *reinterpret_cast<const Type*>( m_storage );
|
||||
}
|
||||
Type& get(){
|
||||
return *reinterpret_cast<Type*>( m_storage );
|
||||
}
|
||||
const Type& get() const {
|
||||
return *reinterpret_cast<const Type*>( m_storage );
|
||||
}
|
||||
};
|
||||
|
||||
class BreakImporter : public TreeXMLImporter
|
||||
{
|
||||
public:
|
||||
BreakImporter( StringOutputStream& comment ){
|
||||
comment << '\n';
|
||||
}
|
||||
static const char* name(){
|
||||
return "n";
|
||||
}
|
||||
TreeXMLImporter& pushElement( const XMLElement& element ){
|
||||
ERROR_MESSAGE( PARSE_ERROR( element.name(), name() ) );
|
||||
return *this;
|
||||
}
|
||||
void popElement( const char* elementName ){
|
||||
ERROR_MESSAGE( PARSE_ERROR( elementName, name() ) );
|
||||
}
|
||||
std::size_t write( const char* data, std::size_t length ){
|
||||
return length;
|
||||
}
|
||||
BreakImporter( StringOutputStream& comment ){
|
||||
comment << '\n';
|
||||
}
|
||||
static const char* name(){
|
||||
return "n";
|
||||
}
|
||||
TreeXMLImporter& pushElement( const XMLElement& element ){
|
||||
ERROR_MESSAGE( PARSE_ERROR( element.name(), name() ) );
|
||||
return *this;
|
||||
}
|
||||
void popElement( const char* elementName ){
|
||||
ERROR_MESSAGE( PARSE_ERROR( elementName, name() ) );
|
||||
}
|
||||
std::size_t write( const char* data, std::size_t length ){
|
||||
return length;
|
||||
}
|
||||
};
|
||||
|
||||
class AttributeImporter : public TreeXMLImporter
|
||||
{
|
||||
StringOutputStream& m_comment;
|
||||
StringOutputStream& m_comment;
|
||||
|
||||
EntityClassAttribute* m_attribute;
|
||||
EntityClassAttribute* m_attribute;
|
||||
|
||||
public:
|
||||
AttributeImporter( StringOutputStream& comment, EntityClass* entityClass, const XMLElement& element ) : m_comment( comment ){
|
||||
const char* type = element.name();
|
||||
const char* key = element.attribute( "key" );
|
||||
const char* name = element.attribute( "name" );
|
||||
const char* value = element.attribute( "value" );
|
||||
AttributeImporter( StringOutputStream& comment, EntityClass* entityClass, const XMLElement& element ) : m_comment( comment ){
|
||||
const char* type = element.name();
|
||||
const char* key = element.attribute( "key" );
|
||||
const char* name = element.attribute( "name" );
|
||||
const char* value = element.attribute( "value" );
|
||||
|
||||
ASSERT_MESSAGE( !string_empty( key ), "key attribute not specified" );
|
||||
ASSERT_MESSAGE( !string_empty( name ), "name attribute not specified" );
|
||||
ASSERT_MESSAGE( !string_empty( key ), "key attribute not specified" );
|
||||
ASSERT_MESSAGE( !string_empty( name ), "name attribute not specified" );
|
||||
|
||||
m_attribute = &EntityClass_insertAttribute( *entityClass, key, EntityClassAttribute( type, name, value ) ).second;
|
||||
m_attribute = &EntityClass_insertAttribute( *entityClass, key, EntityClassAttribute( type, name, value ) ).second;
|
||||
|
||||
if ( string_equal( type, "flag" ) ) {
|
||||
std::size_t bit = atoi( element.attribute( "bit" ) );
|
||||
ASSERT_MESSAGE( bit < MAX_FLAGS, "invalid flag bit" );
|
||||
ASSERT_MESSAGE( string_empty( entityClass->flagnames[bit] ), "non-unique flag bit" );
|
||||
strcpy( entityClass->flagnames[bit], key );
|
||||
entityClass->flagAttributes[bit] = m_attribute;
|
||||
}
|
||||
else if( entityClass->fixedsize && string_equal( type, "model" ) ){
|
||||
entityClass->miscmodel_is = true;
|
||||
entityClass->m_miscmodel_key = key;
|
||||
}
|
||||
else if( string_equal( type, "angle" ) || string_equal( type, "angles" ) || string_equal( type, "direction" ) ){
|
||||
entityClass->has_angles = true;
|
||||
}
|
||||
if ( string_equal( type, "flag" ) ) {
|
||||
std::size_t bit = atoi( element.attribute( "bit" ) );
|
||||
ASSERT_MESSAGE( bit < MAX_FLAGS, "invalid flag bit" );
|
||||
ASSERT_MESSAGE( string_empty( entityClass->flagnames[bit] ), "non-unique flag bit" );
|
||||
strcpy( entityClass->flagnames[bit], key );
|
||||
entityClass->flagAttributes[bit] = m_attribute;
|
||||
}
|
||||
else if( entityClass->fixedsize && string_equal( type, "model" ) ){
|
||||
entityClass->miscmodel_is = true;
|
||||
entityClass->m_miscmodel_key = key;
|
||||
}
|
||||
else if( string_equal( type, "angle" ) || string_equal( type, "angles" ) || string_equal( type, "direction" ) ){
|
||||
entityClass->has_angles = true;
|
||||
}
|
||||
|
||||
m_comment << key;
|
||||
m_comment << " : ";
|
||||
}
|
||||
~AttributeImporter(){
|
||||
}
|
||||
TreeXMLImporter& pushElement( const XMLElement& element ){
|
||||
ERROR_MESSAGE( PARSE_ERROR( element.name(), "attribute" ) );
|
||||
return *this;
|
||||
}
|
||||
void popElement( const char* elementName ){
|
||||
ERROR_MESSAGE( PARSE_ERROR( elementName, "attribute" ) );
|
||||
}
|
||||
std::size_t write( const char* data, std::size_t length ){
|
||||
CopiedString& desc = m_attribute->m_description;
|
||||
if( desc.empty() ){
|
||||
desc = StringRange( data, data + length );
|
||||
m_comment << key;
|
||||
m_comment << " : ";
|
||||
}
|
||||
else{ // in case of special symbols, e.g. ", &apos, <, >, &, xml writes in a few steps
|
||||
desc = StringOutputStream()( desc.c_str(), StringRange( data, data + length ) );
|
||||
~AttributeImporter(){
|
||||
}
|
||||
TreeXMLImporter& pushElement( const XMLElement& element ){
|
||||
ERROR_MESSAGE( PARSE_ERROR( element.name(), "attribute" ) );
|
||||
return *this;
|
||||
}
|
||||
void popElement( const char* elementName ){
|
||||
ERROR_MESSAGE( PARSE_ERROR( elementName, "attribute" ) );
|
||||
}
|
||||
std::size_t write( const char* data, std::size_t length ){
|
||||
CopiedString& desc = m_attribute->m_description;
|
||||
if( desc.empty() ){
|
||||
desc = StringRange( data, data + length );
|
||||
}
|
||||
else{ // in case of special symbols, e.g. ", &apos, <, >, &, xml writes in a few steps
|
||||
desc = StringOutputStream()( desc.c_str(), StringRange( data, data + length ) );
|
||||
}
|
||||
|
||||
return m_comment.write( data, length );
|
||||
}
|
||||
return m_comment.write( data, length );
|
||||
}
|
||||
};
|
||||
|
||||
bool attributeSupported( const char* name ){
|
||||
return string_equal( name, "string" )
|
||||
|| string_equal( name, "array" )
|
||||
|| string_equal( name, "integer" )
|
||||
|| string_equal( name, "boolean" )
|
||||
|| string_equal( name, "integer2" )
|
||||
|| string_equal( name, "integer3" )
|
||||
|| string_equal( name, "real" )
|
||||
|| string_equal( name, "angle" )
|
||||
|| string_equal( name, "direction" )
|
||||
|| string_equal( name, "real3" )
|
||||
|| string_equal( name, "angles" )
|
||||
|| string_equal( name, "color" )
|
||||
|| string_equal( name, "target" )
|
||||
|| string_equal( name, "targetname" )
|
||||
|| string_equal( name, "sound" )
|
||||
|| string_equal( name, "texture" )
|
||||
|| string_equal( name, "model" )
|
||||
|| string_equal( name, "skin" )
|
||||
|| string_equal( name, "flag" );
|
||||
return string_equal( name, "string" )
|
||||
|| string_equal( name, "array" )
|
||||
|| string_equal( name, "integer" )
|
||||
|| string_equal( name, "boolean" )
|
||||
|| string_equal( name, "integer2" )
|
||||
|| string_equal( name, "integer3" )
|
||||
|| string_equal( name, "real" )
|
||||
|| string_equal( name, "angle" )
|
||||
|| string_equal( name, "direction" )
|
||||
|| string_equal( name, "real3" )
|
||||
|| string_equal( name, "angles" )
|
||||
|| string_equal( name, "color" )
|
||||
|| string_equal( name, "target" )
|
||||
|| string_equal( name, "targetname" )
|
||||
|| string_equal( name, "sound" )
|
||||
|| string_equal( name, "texture" )
|
||||
|| string_equal( name, "model" )
|
||||
|| string_equal( name, "skin" )
|
||||
|| string_equal( name, "flag" );
|
||||
}
|
||||
|
||||
typedef std::map<CopiedString, ListAttributeType> ListAttributeTypes;
|
||||
@@ -278,94 +278,94 @@ bool listAttributeSupported( ListAttributeTypes& listTypes, const char* name ){
|
||||
|
||||
class ClassImporter : public TreeXMLImporter
|
||||
{
|
||||
EntityClassCollector& m_collector;
|
||||
EntityClass* m_eclass;
|
||||
StringOutputStream m_comment;
|
||||
Storage<AttributeImporter> m_attribute;
|
||||
ListAttributeTypes& m_listTypes;
|
||||
EntityClassCollector& m_collector;
|
||||
EntityClass* m_eclass;
|
||||
StringOutputStream m_comment;
|
||||
Storage<AttributeImporter> m_attribute;
|
||||
ListAttributeTypes& m_listTypes;
|
||||
|
||||
public:
|
||||
ClassImporter( EntityClassCollector& collector, ListAttributeTypes& listTypes, const XMLElement& element ) : m_collector( collector ), m_listTypes( listTypes ){
|
||||
m_eclass = Eclass_Alloc();
|
||||
m_eclass->free = &Eclass_Free;
|
||||
ClassImporter( EntityClassCollector& collector, ListAttributeTypes& listTypes, const XMLElement& element ) : m_collector( collector ), m_listTypes( listTypes ){
|
||||
m_eclass = Eclass_Alloc();
|
||||
m_eclass->free = &Eclass_Free;
|
||||
|
||||
const char* name = element.attribute( "name" );
|
||||
ASSERT_MESSAGE( !string_empty( name ), "name attribute not specified for class" );
|
||||
m_eclass->name_set( name );
|
||||
const char* name = element.attribute( "name" );
|
||||
ASSERT_MESSAGE( !string_empty( name ), "name attribute not specified for class" );
|
||||
m_eclass->name_set( name );
|
||||
|
||||
const char* color = element.attribute( "color" );
|
||||
ASSERT_MESSAGE( !string_empty( name ), "color attribute not specified for class " << name );
|
||||
string_parse_vector3( color, m_eclass->color );
|
||||
eclass_capture_state( m_eclass );
|
||||
const char* color = element.attribute( "color" );
|
||||
ASSERT_MESSAGE( !string_empty( name ), "color attribute not specified for class " << name );
|
||||
string_parse_vector3( color, m_eclass->color );
|
||||
eclass_capture_state( m_eclass );
|
||||
|
||||
const char* model = element.attribute( "model" );
|
||||
if ( !string_empty( model ) ) {
|
||||
m_eclass->m_modelpath = StringOutputStream( 256 )( PathCleaned( model ) ).c_str();
|
||||
}
|
||||
const char* model = element.attribute( "model" );
|
||||
if ( !string_empty( model ) ) {
|
||||
m_eclass->m_modelpath = StringOutputStream( 256 )( PathCleaned( model ) ).c_str();
|
||||
}
|
||||
|
||||
const char* type = element.name();
|
||||
if ( string_equal( type, "point" ) ) {
|
||||
const char* box = element.attribute( "box" );
|
||||
ASSERT_MESSAGE( !string_empty( box ), "box attribute not found for class " << name );
|
||||
m_eclass->fixedsize = true;
|
||||
string_parse_vector( box, &m_eclass->mins.x(), &m_eclass->mins.x() + 6 );
|
||||
const char* type = element.name();
|
||||
if ( string_equal( type, "point" ) ) {
|
||||
const char* box = element.attribute( "box" );
|
||||
ASSERT_MESSAGE( !string_empty( box ), "box attribute not found for class " << name );
|
||||
m_eclass->fixedsize = true;
|
||||
string_parse_vector( box, &m_eclass->mins.x(), &m_eclass->mins.x() + 6 );
|
||||
}
|
||||
}
|
||||
}
|
||||
~ClassImporter(){
|
||||
m_eclass->m_comments = m_comment.c_str();
|
||||
m_collector.insert( m_eclass );
|
||||
~ClassImporter(){
|
||||
m_eclass->m_comments = m_comment.c_str();
|
||||
m_collector.insert( m_eclass );
|
||||
|
||||
for ( ListAttributeTypes::iterator i = m_listTypes.begin(); i != m_listTypes.end(); ++i )
|
||||
{
|
||||
m_collector.insert( ( *i ).first.c_str(), ( *i ).second );
|
||||
for ( ListAttributeTypes::iterator i = m_listTypes.begin(); i != m_listTypes.end(); ++i )
|
||||
{
|
||||
m_collector.insert( ( *i ).first.c_str(), ( *i ).second );
|
||||
}
|
||||
}
|
||||
}
|
||||
static const char* name(){
|
||||
return "class";
|
||||
}
|
||||
TreeXMLImporter& pushElement( const XMLElement& element ){
|
||||
if ( attributeSupported( element.name() ) || listAttributeSupported( m_listTypes, element.name() ) ) {
|
||||
constructor( m_attribute.get(), makeReference( m_comment ), m_eclass, element );
|
||||
return m_attribute.get();
|
||||
static const char* name(){
|
||||
return "class";
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_MESSAGE( PARSE_ERROR( element.name(), name() ) );
|
||||
return *this;
|
||||
TreeXMLImporter& pushElement( const XMLElement& element ){
|
||||
if ( attributeSupported( element.name() ) || listAttributeSupported( m_listTypes, element.name() ) ) {
|
||||
constructor( m_attribute.get(), makeReference( m_comment ), m_eclass, element );
|
||||
return m_attribute.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_MESSAGE( PARSE_ERROR( element.name(), name() ) );
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
}
|
||||
void popElement( const char* elementName ){
|
||||
if ( attributeSupported( elementName ) || listAttributeSupported( m_listTypes, elementName ) ) {
|
||||
destructor( m_attribute.get() );
|
||||
void popElement( const char* elementName ){
|
||||
if ( attributeSupported( elementName ) || listAttributeSupported( m_listTypes, elementName ) ) {
|
||||
destructor( m_attribute.get() );
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_MESSAGE( PARSE_ERROR( elementName, name() ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_MESSAGE( PARSE_ERROR( elementName, name() ) );
|
||||
std::size_t write( const char* data, std::size_t length ){
|
||||
return m_comment.write( data, length );
|
||||
}
|
||||
}
|
||||
std::size_t write( const char* data, std::size_t length ){
|
||||
return m_comment.write( data, length );
|
||||
}
|
||||
};
|
||||
|
||||
class ItemImporter : public TreeXMLImporter
|
||||
{
|
||||
public:
|
||||
ItemImporter( ListAttributeType& list, const XMLElement& element ){
|
||||
const char* name = element.attribute( "name" );
|
||||
const char* value = element.attribute( "value" );
|
||||
list.push_back( name, value );
|
||||
}
|
||||
TreeXMLImporter& pushElement( const XMLElement& element ){
|
||||
ERROR_MESSAGE( PARSE_ERROR( element.name(), "item" ) );
|
||||
return *this;
|
||||
}
|
||||
void popElement( const char* elementName ){
|
||||
ERROR_MESSAGE( PARSE_ERROR( elementName, "item" ) );
|
||||
}
|
||||
std::size_t write( const char* data, std::size_t length ){
|
||||
return length;
|
||||
}
|
||||
ItemImporter( ListAttributeType& list, const XMLElement& element ){
|
||||
const char* name = element.attribute( "name" );
|
||||
const char* value = element.attribute( "value" );
|
||||
list.push_back( name, value );
|
||||
}
|
||||
TreeXMLImporter& pushElement( const XMLElement& element ){
|
||||
ERROR_MESSAGE( PARSE_ERROR( element.name(), "item" ) );
|
||||
return *this;
|
||||
}
|
||||
void popElement( const char* elementName ){
|
||||
ERROR_MESSAGE( PARSE_ERROR( elementName, "item" ) );
|
||||
}
|
||||
std::size_t write( const char* data, std::size_t length ){
|
||||
return length;
|
||||
}
|
||||
};
|
||||
|
||||
bool isItem( const char* name ){
|
||||
@@ -374,41 +374,41 @@ bool isItem( const char* name ){
|
||||
|
||||
class ListAttributeImporter : public TreeXMLImporter
|
||||
{
|
||||
ListAttributeType* m_listType;
|
||||
Storage<ItemImporter> m_item;
|
||||
ListAttributeType* m_listType;
|
||||
Storage<ItemImporter> m_item;
|
||||
public:
|
||||
ListAttributeImporter( ListAttributeTypes& listTypes, const XMLElement& element ){
|
||||
const char* name = element.attribute( "name" );
|
||||
m_listType = &listTypes[name];
|
||||
}
|
||||
TreeXMLImporter& pushElement( const XMLElement& element ){
|
||||
if ( isItem( element.name() ) ) {
|
||||
constructor( m_item.get(), makeReference( *m_listType ), element );
|
||||
return m_item.get();
|
||||
ListAttributeImporter( ListAttributeTypes& listTypes, const XMLElement& element ){
|
||||
const char* name = element.attribute( "name" );
|
||||
m_listType = &listTypes[name];
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_MESSAGE( PARSE_ERROR( element.name(), "list" ) );
|
||||
return *this;
|
||||
TreeXMLImporter& pushElement( const XMLElement& element ){
|
||||
if ( isItem( element.name() ) ) {
|
||||
constructor( m_item.get(), makeReference( *m_listType ), element );
|
||||
return m_item.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_MESSAGE( PARSE_ERROR( element.name(), "list" ) );
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
}
|
||||
void popElement( const char* elementName ){
|
||||
if ( isItem( elementName ) ) {
|
||||
destructor( m_item.get() );
|
||||
void popElement( const char* elementName ){
|
||||
if ( isItem( elementName ) ) {
|
||||
destructor( m_item.get() );
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_MESSAGE( PARSE_ERROR( elementName, "list" ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_MESSAGE( PARSE_ERROR( elementName, "list" ) );
|
||||
std::size_t write( const char* data, std::size_t length ){
|
||||
return length;
|
||||
}
|
||||
}
|
||||
std::size_t write( const char* data, std::size_t length ){
|
||||
return length;
|
||||
}
|
||||
};
|
||||
|
||||
bool classSupported( const char* name ){
|
||||
return string_equal( name, "group" )
|
||||
|| string_equal( name, "point" );
|
||||
|| string_equal( name, "point" );
|
||||
}
|
||||
|
||||
bool listSupported( const char* name ){
|
||||
@@ -417,102 +417,102 @@ bool listSupported( const char* name ){
|
||||
|
||||
class ClassesImporter : public TreeXMLImporter
|
||||
{
|
||||
EntityClassCollector& m_collector;
|
||||
Storage<ClassImporter> m_class;
|
||||
Storage<ListAttributeImporter> m_list;
|
||||
ListAttributeTypes m_listTypes;
|
||||
EntityClassCollector& m_collector;
|
||||
Storage<ClassImporter> m_class;
|
||||
Storage<ListAttributeImporter> m_list;
|
||||
ListAttributeTypes m_listTypes;
|
||||
|
||||
public:
|
||||
ClassesImporter( EntityClassCollector& collector ) : m_collector( collector ){
|
||||
}
|
||||
static const char* name(){
|
||||
return "classes";
|
||||
}
|
||||
TreeXMLImporter& pushElement( const XMLElement& element ){
|
||||
if ( classSupported( element.name() ) ) {
|
||||
constructor( m_class.get(), makeReference( m_collector ), makeReference( m_listTypes ), element );
|
||||
return m_class.get();
|
||||
ClassesImporter( EntityClassCollector& collector ) : m_collector( collector ){
|
||||
}
|
||||
else if ( listSupported( element.name() ) ) {
|
||||
constructor( m_list.get(), makeReference( m_listTypes ), element );
|
||||
return m_list.get();
|
||||
static const char* name(){
|
||||
return "classes";
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_MESSAGE( PARSE_ERROR( element.name(), name() ) );
|
||||
return *this;
|
||||
TreeXMLImporter& pushElement( const XMLElement& element ){
|
||||
if ( classSupported( element.name() ) ) {
|
||||
constructor( m_class.get(), makeReference( m_collector ), makeReference( m_listTypes ), element );
|
||||
return m_class.get();
|
||||
}
|
||||
else if ( listSupported( element.name() ) ) {
|
||||
constructor( m_list.get(), makeReference( m_listTypes ), element );
|
||||
return m_list.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_MESSAGE( PARSE_ERROR( element.name(), name() ) );
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
}
|
||||
void popElement( const char* elementName ){
|
||||
if ( classSupported( elementName ) ) {
|
||||
destructor( m_class.get() );
|
||||
void popElement( const char* elementName ){
|
||||
if ( classSupported( elementName ) ) {
|
||||
destructor( m_class.get() );
|
||||
}
|
||||
else if ( listSupported( elementName ) ) {
|
||||
destructor( m_list.get() );
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_MESSAGE( PARSE_ERROR( elementName, name() ) );
|
||||
}
|
||||
}
|
||||
else if ( listSupported( elementName ) ) {
|
||||
destructor( m_list.get() );
|
||||
std::size_t write( const char* data, std::size_t length ){
|
||||
return length;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_MESSAGE( PARSE_ERROR( elementName, name() ) );
|
||||
}
|
||||
}
|
||||
std::size_t write( const char* data, std::size_t length ){
|
||||
return length;
|
||||
}
|
||||
};
|
||||
|
||||
class EclassXMLImporter : public TreeXMLImporter
|
||||
{
|
||||
EntityClassCollector& m_collector;
|
||||
Storage<ClassesImporter> m_classes;
|
||||
EntityClassCollector& m_collector;
|
||||
Storage<ClassesImporter> m_classes;
|
||||
|
||||
public:
|
||||
EclassXMLImporter( EntityClassCollector& collector ) : m_collector( collector ){
|
||||
}
|
||||
static const char* name(){
|
||||
return "classes";
|
||||
}
|
||||
TreeXMLImporter& pushElement( const XMLElement& element ){
|
||||
if ( string_equal( element.name(), ClassesImporter::name() ) ) {
|
||||
constructor( m_classes.get(), makeReference( m_collector ) );
|
||||
return m_classes.get();
|
||||
EclassXMLImporter( EntityClassCollector& collector ) : m_collector( collector ){
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_MESSAGE( PARSE_ERROR( element.name(), name() ) );
|
||||
return *this;
|
||||
static const char* name(){
|
||||
return "classes";
|
||||
}
|
||||
}
|
||||
void popElement( const char* elementName ){
|
||||
if ( string_equal( elementName, ClassesImporter::name() ) ) {
|
||||
destructor( m_classes.get() );
|
||||
TreeXMLImporter& pushElement( const XMLElement& element ){
|
||||
if ( string_equal( element.name(), ClassesImporter::name() ) ) {
|
||||
constructor( m_classes.get(), makeReference( m_collector ) );
|
||||
return m_classes.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_MESSAGE( PARSE_ERROR( element.name(), name() ) );
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_MESSAGE( PARSE_ERROR( elementName, name() ) );
|
||||
void popElement( const char* elementName ){
|
||||
if ( string_equal( elementName, ClassesImporter::name() ) ) {
|
||||
destructor( m_classes.get() );
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_MESSAGE( PARSE_ERROR( elementName, name() ) );
|
||||
}
|
||||
}
|
||||
std::size_t write( const char* data, std::size_t length ){
|
||||
return length;
|
||||
}
|
||||
}
|
||||
std::size_t write( const char* data, std::size_t length ){
|
||||
return length;
|
||||
}
|
||||
};
|
||||
|
||||
class TreeXMLImporterStack : public XMLImporter
|
||||
{
|
||||
std::vector< Reference<TreeXMLImporter> > m_importers;
|
||||
std::vector< Reference<TreeXMLImporter> > m_importers;
|
||||
public:
|
||||
TreeXMLImporterStack( TreeXMLImporter& importer ){
|
||||
m_importers.push_back( makeReference( importer ) );
|
||||
}
|
||||
void pushElement( const XMLElement& element ){
|
||||
m_importers.push_back( makeReference( m_importers.back().get().pushElement( element ) ) );
|
||||
}
|
||||
void popElement( const char* name ){
|
||||
m_importers.pop_back();
|
||||
m_importers.back().get().popElement( name );
|
||||
}
|
||||
std::size_t write( const char* buffer, std::size_t length ){
|
||||
return m_importers.back().get().write( buffer, length );
|
||||
}
|
||||
TreeXMLImporterStack( TreeXMLImporter& importer ){
|
||||
m_importers.push_back( makeReference( importer ) );
|
||||
}
|
||||
void pushElement( const XMLElement& element ){
|
||||
m_importers.push_back( makeReference( m_importers.back().get().pushElement( element ) ) );
|
||||
}
|
||||
void popElement( const char* name ){
|
||||
m_importers.pop_back();
|
||||
m_importers.back().get().popElement( name );
|
||||
}
|
||||
std::size_t write( const char* buffer, std::size_t length ){
|
||||
return m_importers.back().get().write( buffer, length );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -542,18 +542,18 @@ class EntityClassXMLDependencies : public GlobalFileSystemModuleRef, public Glob
|
||||
|
||||
class EclassXMLAPI
|
||||
{
|
||||
EntityClassScanner m_eclassxml;
|
||||
EntityClassScanner m_eclassxml;
|
||||
public:
|
||||
typedef EntityClassScanner Type;
|
||||
STRING_CONSTANT( Name, "xml" );
|
||||
typedef EntityClassScanner Type;
|
||||
STRING_CONSTANT( Name, "xml" );
|
||||
|
||||
EclassXMLAPI(){
|
||||
m_eclassxml.scanFile = &ScanFile;
|
||||
m_eclassxml.getExtension = &GetExtension;
|
||||
}
|
||||
EntityClassScanner* getTable(){
|
||||
return &m_eclassxml;
|
||||
}
|
||||
EclassXMLAPI(){
|
||||
m_eclassxml.scanFile = &ScanFile;
|
||||
m_eclassxml.getExtension = &GetExtension;
|
||||
}
|
||||
EntityClassScanner* getTable(){
|
||||
return &m_eclassxml;
|
||||
}
|
||||
};
|
||||
|
||||
typedef SingletonModule<EclassXMLAPI, EntityClassXMLDependencies> EclassXMLModule;
|
||||
|
||||
Reference in New Issue
Block a user