get rid of ugly pointer typedefs
This commit is contained in:
+57
-58
@@ -26,7 +26,7 @@ static const XENTITY x_EntityTable[] = {
|
|||||||
|
|
||||||
PARSEINFO piDefault;
|
PARSEINFO piDefault;
|
||||||
DISP_OPT optDefault;
|
DISP_OPT optDefault;
|
||||||
XENTITYS entityDefault((LPXENTITY)x_EntityTable, sizeof(x_EntityTable)/sizeof(x_EntityTable[0]) );
|
XENTITYS entityDefault((XENTITY*)x_EntityTable, sizeof(x_EntityTable)/sizeof(x_EntityTable[0]) );
|
||||||
|
|
||||||
// skip spaces
|
// skip spaces
|
||||||
char* tcsskip( const char* psz )
|
char* tcsskip( const char* psz )
|
||||||
@@ -158,7 +158,7 @@ void XNode::Close()
|
|||||||
|
|
||||||
for( i = 0 ; i < childs.size(); i ++)
|
for( i = 0 ; i < childs.size(); i ++)
|
||||||
{
|
{
|
||||||
LPXNode p = childs[i];
|
XNode *p = childs[i];
|
||||||
if( p )
|
if( p )
|
||||||
{
|
{
|
||||||
delete p; childs[i] = NULL;
|
delete p; childs[i] = NULL;
|
||||||
@@ -168,7 +168,7 @@ void XNode::Close()
|
|||||||
|
|
||||||
for( i = 0 ; i < attrs.size(); i ++)
|
for( i = 0 ; i < attrs.size(); i ++)
|
||||||
{
|
{
|
||||||
LPXAttr p = attrs[i];
|
XAttr *p = attrs[i];
|
||||||
if( p )
|
if( p )
|
||||||
{
|
{
|
||||||
delete p; attrs[i] = NULL;
|
delete p; attrs[i] = NULL;
|
||||||
@@ -189,7 +189,7 @@ void XNode::Close()
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
char* XNode::LoadAttributes( const char* pszAttrs , LPPARSEINFO pi /*= &piDefault*/)
|
char* XNode::LoadAttributes( const char* pszAttrs , PARSEINFO *pi /*= &piDefault*/)
|
||||||
{
|
{
|
||||||
char* xml = (char*)pszAttrs;
|
char* xml = (char*)pszAttrs;
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ char* XNode::LoadAttributes( const char* pszAttrs , LPPARSEINFO pi /*= &piDefaul
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPXAttr attr = new XAttr;
|
XAttr *attr = new XAttr;
|
||||||
attr->parent = this;
|
attr->parent = this;
|
||||||
|
|
||||||
// XML Attr Name
|
// XML Attr Name
|
||||||
@@ -286,7 +286,7 @@ char* XNode::LoadAttributes( const char* pszAttrs , LPPARSEINFO pi /*= &piDefaul
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
char* XNode::Load( const char* pszXml, LPPARSEINFO pi /*= &piDefault*/ )
|
char* XNode::Load( const char* pszXml, PARSEINFO *pi /*= &piDefault*/ )
|
||||||
{
|
{
|
||||||
// Close it
|
// Close it
|
||||||
Close();
|
Close();
|
||||||
@@ -379,7 +379,7 @@ char* XNode::Load( const char* pszXml, LPPARSEINFO pi /*= &piDefault*/ )
|
|||||||
// generate child nodes
|
// generate child nodes
|
||||||
while( xml && *xml )
|
while( xml && *xml )
|
||||||
{
|
{
|
||||||
LPXNode node = new XNode;
|
XNode *node = new XNode;
|
||||||
node->parent = this;
|
node->parent = this;
|
||||||
|
|
||||||
xml = node->Load( xml,pi );
|
xml = node->Load( xml,pi );
|
||||||
@@ -489,7 +489,7 @@ char* XNode::Load( const char* pszXml, LPPARSEINFO pi /*= &piDefault*/ )
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
bool XAttr::GetXML( RageFile &f, LPDISP_OPT opt /*= &optDefault*/ )
|
bool XAttr::GetXML( RageFile &f, DISP_OPT *opt /*= &optDefault*/ )
|
||||||
{
|
{
|
||||||
return f.Write(name + "='" + (opt->reference_value&&opt->entitys?opt->entitys->Entity2Ref(value):value) + "' ") != -1;
|
return f.Write(name + "='" + (opt->reference_value&&opt->entitys?opt->entitys->Entity2Ref(value):value) + "' ") != -1;
|
||||||
}
|
}
|
||||||
@@ -503,9 +503,8 @@ bool XAttr::GetXML( RageFile &f, LPDISP_OPT opt /*= &optDefault*/ )
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
bool XNode::GetXML( RageFile &f, LPDISP_OPT opt /*= &optDefault*/ )
|
bool XNode::GetXML( RageFile &f, DISP_OPT *opt /*= &optDefault*/ )
|
||||||
{
|
{
|
||||||
|
|
||||||
// tab
|
// tab
|
||||||
if( opt && opt->newline )
|
if( opt && opt->newline )
|
||||||
{
|
{
|
||||||
@@ -632,11 +631,11 @@ void XNode::SetValue(const DateTime &v) { value = v.GetString(); }
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
const LPXAttr XNode::GetAttr( const char* attrname ) const
|
const XAttr *XNode::GetAttr( const char* attrname ) const
|
||||||
{
|
{
|
||||||
for( unsigned i = 0 ; i < attrs.size(); i++ )
|
for( unsigned i = 0 ; i < attrs.size(); i++ )
|
||||||
{
|
{
|
||||||
LPXAttr attr = attrs[i];
|
XAttr *attr = attrs[i];
|
||||||
if( attr )
|
if( attr )
|
||||||
{
|
{
|
||||||
if( attr->name == attrname )
|
if( attr->name == attrname )
|
||||||
@@ -646,11 +645,11 @@ const LPXAttr XNode::GetAttr( const char* attrname ) const
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPXAttr XNode::GetAttr( const char* attrname )
|
XAttr *XNode::GetAttr( const char* attrname )
|
||||||
{
|
{
|
||||||
for( unsigned i = 0 ; i < attrs.size(); i++ )
|
for( unsigned i = 0 ; i < attrs.size(); i++ )
|
||||||
{
|
{
|
||||||
LPXAttr attr = attrs[i];
|
XAttr *attr = attrs[i];
|
||||||
if( attr )
|
if( attr )
|
||||||
{
|
{
|
||||||
if( attr->name == attrname )
|
if( attr->name == attrname )
|
||||||
@@ -674,7 +673,7 @@ XAttrs XNode::GetAttrs( const char* name )
|
|||||||
XAttrs attrs;
|
XAttrs attrs;
|
||||||
for( unsigned i = 0 ; i < attrs.size(); i++ )
|
for( unsigned i = 0 ; i < attrs.size(); i++ )
|
||||||
{
|
{
|
||||||
LPXAttr attr = attrs[i];
|
XAttr *attr = attrs[i];
|
||||||
if( attr )
|
if( attr )
|
||||||
{
|
{
|
||||||
if( attr->name == name )
|
if( attr->name == name )
|
||||||
@@ -695,7 +694,7 @@ XAttrs XNode::GetAttrs( const char* name )
|
|||||||
//========================================================
|
//========================================================
|
||||||
const char* XNode::GetAttrValue( const char* attrname )
|
const char* XNode::GetAttrValue( const char* attrname )
|
||||||
{
|
{
|
||||||
LPXAttr attr = GetAttr( attrname );
|
XAttr *attr = GetAttr( attrname );
|
||||||
return attr ? (const char*)attr->value : NULL;
|
return attr ? (const char*)attr->value : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -718,7 +717,7 @@ XNodes XNode::GetChilds( const char* name )
|
|||||||
XNodes nodes;
|
XNodes nodes;
|
||||||
for( unsigned i = 0 ; i < childs.size(); i++ )
|
for( unsigned i = 0 ; i < childs.size(); i++ )
|
||||||
{
|
{
|
||||||
LPXNode node = childs[i];
|
XNode *node = childs[i];
|
||||||
if( node )
|
if( node )
|
||||||
{
|
{
|
||||||
if( node->name == name )
|
if( node->name == name )
|
||||||
@@ -737,7 +736,7 @@ XNodes XNode::GetChilds( const char* name )
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
LPXNode XNode::GetChild( int i )
|
XNode *XNode::GetChild( int i )
|
||||||
{
|
{
|
||||||
if( i >= 0 && i < (int)childs.size() )
|
if( i >= 0 && i < (int)childs.size() )
|
||||||
return childs[i];
|
return childs[i];
|
||||||
@@ -767,11 +766,11 @@ int XNode::GetChildCount()
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
LPXNode XNode::GetChild( const char* name )
|
XNode *XNode::GetChild( const char* name )
|
||||||
{
|
{
|
||||||
for( unsigned i = 0 ; i < childs.size(); i++ )
|
for( unsigned i = 0 ; i < childs.size(); i++ )
|
||||||
{
|
{
|
||||||
LPXNode node = childs[i];
|
XNode *node = childs[i];
|
||||||
if( node )
|
if( node )
|
||||||
{
|
{
|
||||||
if( node->name == name )
|
if( node->name == name )
|
||||||
@@ -781,11 +780,11 @@ LPXNode XNode::GetChild( const char* name )
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LPXNode XNode::GetChild( const char* name ) const
|
const XNode *XNode::GetChild( const char* name ) const
|
||||||
{
|
{
|
||||||
for( unsigned i = 0 ; i < childs.size(); i++ )
|
for( unsigned i = 0 ; i < childs.size(); i++ )
|
||||||
{
|
{
|
||||||
LPXNode node = childs[i];
|
XNode *node = childs[i];
|
||||||
if( node )
|
if( node )
|
||||||
{
|
{
|
||||||
if( node->name == name )
|
if( node->name == name )
|
||||||
@@ -806,19 +805,19 @@ const LPXNode XNode::GetChild( const char* name ) const
|
|||||||
//========================================================
|
//========================================================
|
||||||
const char* XNode::GetChildValue( const char* name )
|
const char* XNode::GetChildValue( const char* name )
|
||||||
{
|
{
|
||||||
LPXNode node = GetChild( name );
|
XNode *node = GetChild( name );
|
||||||
return (node != NULL)? (const char*)node->value : NULL;
|
return (node != NULL)? (const char*)node->value : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPXAttr XNode::GetChildAttr( const char* name, const char* attrname )
|
XAttr *XNode::GetChildAttr( const char* name, const char* attrname )
|
||||||
{
|
{
|
||||||
LPXNode node = GetChild(name);
|
XNode *node = GetChild(name);
|
||||||
return node ? node->GetAttr(attrname) : NULL;
|
return node ? node->GetAttr(attrname) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* XNode::GetChildAttrValue( const char* name, const char* attrname )
|
const char* XNode::GetChildAttrValue( const char* name, const char* attrname )
|
||||||
{
|
{
|
||||||
LPXAttr attr = GetChildAttr( name, attrname );
|
XAttr *attr = GetChildAttr( name, attrname );
|
||||||
return attr ? (const char*)attr->value : NULL;
|
return attr ? (const char*)attr->value : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,7 +831,7 @@ const char* XNode::GetChildAttrValue( const char* name, const char* attrname )
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
XNodes::iterator XNode::GetChildIterator( LPXNode node )
|
XNodes::iterator XNode::GetChildIterator( XNode *node )
|
||||||
{
|
{
|
||||||
XNodes::iterator it = childs.begin();
|
XNodes::iterator it = childs.begin();
|
||||||
for( ; it != childs.end() ; ++(it) )
|
for( ; it != childs.end() ; ++(it) )
|
||||||
@@ -852,11 +851,11 @@ XNodes::iterator XNode::GetChildIterator( LPXNode node )
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
LPXNode XNode::AppendChild( const char* name, const char* value ) { XNode *p = new XNode; p->name = name; p->value = value; return AppendChild( p ); }
|
XNode *XNode::AppendChild( const char* name, const char* value ) { XNode *p = new XNode; p->name = name; p->value = value; return AppendChild( p ); }
|
||||||
LPXNode XNode::AppendChild( const char* name, float value ) { XNode *p = new XNode; p->name = name; p->SetValue( value ); return AppendChild( p ); }
|
XNode *XNode::AppendChild( const char* name, float value ) { XNode *p = new XNode; p->name = name; p->SetValue( value ); return AppendChild( p ); }
|
||||||
LPXNode XNode::AppendChild( const char* name, int value ) { XNode *p = new XNode; p->name = name; p->SetValue( value ); return AppendChild( p ); }
|
XNode *XNode::AppendChild( const char* name, int value ) { XNode *p = new XNode; p->name = name; p->SetValue( value ); return AppendChild( p ); }
|
||||||
LPXNode XNode::AppendChild( const char* name, unsigned value ) { XNode *p = new XNode; p->name = name; p->SetValue( value ); return AppendChild( p ); }
|
XNode *XNode::AppendChild( const char* name, unsigned value ) { XNode *p = new XNode; p->name = name; p->SetValue( value ); return AppendChild( p ); }
|
||||||
LPXNode XNode::AppendChild( const char* name, const DateTime &value ) { XNode *p = new XNode; p->name = name; p->SetValue( value ); return AppendChild( p ); }
|
XNode *XNode::AppendChild( const char* name, const DateTime &value ) { XNode *p = new XNode; p->name = name; p->SetValue( value ); return AppendChild( p ); }
|
||||||
|
|
||||||
//========================================================
|
//========================================================
|
||||||
// Name : AppendChild
|
// Name : AppendChild
|
||||||
@@ -867,7 +866,7 @@ LPXNode XNode::AppendChild( const char* name, const DateTime &value ) { XNode *p
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
LPXNode XNode::AppendChild( LPXNode node )
|
XNode *XNode::AppendChild( XNode *node )
|
||||||
{
|
{
|
||||||
node->parent = this;
|
node->parent = this;
|
||||||
childs.push_back( node );
|
childs.push_back( node );
|
||||||
@@ -883,7 +882,7 @@ LPXNode XNode::AppendChild( LPXNode node )
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
bool XNode::RemoveChild( LPXNode node )
|
bool XNode::RemoveChild( XNode *node )
|
||||||
{
|
{
|
||||||
XNodes::iterator it = GetChildIterator( node );
|
XNodes::iterator it = GetChildIterator( node );
|
||||||
if( it != childs.end() )
|
if( it != childs.end() )
|
||||||
@@ -904,7 +903,7 @@ bool XNode::RemoveChild( LPXNode node )
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
LPXAttr XNode::GetAttr( int i )
|
XAttr *XNode::GetAttr( int i )
|
||||||
{
|
{
|
||||||
if( i >= 0 && i < (int)attrs.size() )
|
if( i >= 0 && i < (int)attrs.size() )
|
||||||
return attrs[i];
|
return attrs[i];
|
||||||
@@ -915,12 +914,12 @@ LPXAttr XNode::GetAttr( int i )
|
|||||||
// Name : GetAttrIterator
|
// Name : GetAttrIterator
|
||||||
// Desc : get attribute iterator
|
// Desc : get attribute iterator
|
||||||
// Param :
|
// Param :
|
||||||
// Return : std::vector<LPXAttr>::iterator
|
// Return : std::vector<XAttr*>::iterator
|
||||||
//--------------------------------------------------------
|
//--------------------------------------------------------
|
||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
XAttrs::iterator XNode::GetAttrIterator( LPXAttr attr )
|
XAttrs::iterator XNode::GetAttrIterator( XAttr *attr )
|
||||||
{
|
{
|
||||||
XAttrs::iterator it = attrs.begin();
|
XAttrs::iterator it = attrs.begin();
|
||||||
for( ; it != attrs.end() ; ++(it) )
|
for( ; it != attrs.end() ; ++(it) )
|
||||||
@@ -940,7 +939,7 @@ XAttrs::iterator XNode::GetAttrIterator( LPXAttr attr )
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
LPXAttr XNode::AppendAttr( LPXAttr attr )
|
XAttr *XNode::AppendAttr( XAttr *attr )
|
||||||
{
|
{
|
||||||
attr->parent = this;
|
attr->parent = this;
|
||||||
attrs.push_back( attr );
|
attrs.push_back( attr );
|
||||||
@@ -956,7 +955,7 @@ LPXAttr XNode::AppendAttr( LPXAttr attr )
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
bool XNode::RemoveAttr( LPXAttr attr )
|
bool XNode::RemoveAttr( XAttr *attr )
|
||||||
{
|
{
|
||||||
XAttrs::iterator it = GetAttrIterator( attr );
|
XAttrs::iterator it = GetAttrIterator( attr );
|
||||||
if( it != attrs.end() )
|
if( it != attrs.end() )
|
||||||
@@ -977,9 +976,9 @@ bool XNode::RemoveAttr( LPXAttr attr )
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
LPXNode XNode::CreateNode( const char* name /*= NULL*/, const char* value /*= NULL*/ )
|
XNode *XNode::CreateNode( const char* name /*= NULL*/, const char* value /*= NULL*/ )
|
||||||
{
|
{
|
||||||
LPXNode node = new XNode;
|
XNode *node = new XNode;
|
||||||
node->name = name;
|
node->name = name;
|
||||||
node->value = value;
|
node->value = value;
|
||||||
return node;
|
return node;
|
||||||
@@ -994,9 +993,9 @@ LPXNode XNode::CreateNode( const char* name /*= NULL*/, const char* value /*= NU
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
LPXAttr XNode::CreateAttr( const char* name /*= NULL*/, const char* value /*= NULL*/ )
|
XAttr *XNode::CreateAttr( const char* name /*= NULL*/, const char* value /*= NULL*/ )
|
||||||
{
|
{
|
||||||
LPXAttr attr = new XAttr;
|
XAttr *attr = new XAttr;
|
||||||
attr->name = name;
|
attr->name = name;
|
||||||
attr->value = value;
|
attr->value = value;
|
||||||
return attr;
|
return attr;
|
||||||
@@ -1011,14 +1010,14 @@ LPXAttr XNode::CreateAttr( const char* name /*= NULL*/, const char* value /*= NU
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
LPXAttr XNode::AppendAttr( const char* name /*= NULL*/, const char* value /*= NULL*/ )
|
XAttr *XNode::AppendAttr( const char* name /*= NULL*/, const char* value /*= NULL*/ )
|
||||||
{
|
{
|
||||||
return AppendAttr( CreateAttr( name, value ) );
|
return AppendAttr( CreateAttr( name, value ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
LPXAttr XNode::AppendAttr( const char* name, float value ){ return AppendAttr(name,ssprintf("%f",value)); }
|
XAttr *XNode::AppendAttr( const char* name, float value ){ return AppendAttr(name,ssprintf("%f",value)); }
|
||||||
LPXAttr XNode::AppendAttr( const char* name, int value ) { return AppendAttr(name,ssprintf("%d",value)); }
|
XAttr *XNode::AppendAttr( const char* name, int value ) { return AppendAttr(name,ssprintf("%d",value)); }
|
||||||
LPXAttr XNode::AppendAttr( const char* name, unsigned value ) { return AppendAttr(name,ssprintf("%u",value)); }
|
XAttr *XNode::AppendAttr( const char* name, unsigned value ) { return AppendAttr(name,ssprintf("%u",value)); }
|
||||||
|
|
||||||
//========================================================
|
//========================================================
|
||||||
// Name : DetachChild
|
// Name : DetachChild
|
||||||
@@ -1029,7 +1028,7 @@ LPXAttr XNode::AppendAttr( const char* name, unsigned value ) { return AppendAtt
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
LPXNode XNode::DetachChild( LPXNode node )
|
XNode *XNode::DetachChild( XNode *node )
|
||||||
{
|
{
|
||||||
XNodes::iterator it = GetChildIterator( node );
|
XNodes::iterator it = GetChildIterator( node );
|
||||||
if( it != childs.end() )
|
if( it != childs.end() )
|
||||||
@@ -1049,7 +1048,7 @@ LPXNode XNode::DetachChild( LPXNode node )
|
|||||||
// Coder Date Desc
|
// Coder Date Desc
|
||||||
// bro 2002-10-29
|
// bro 2002-10-29
|
||||||
//========================================================
|
//========================================================
|
||||||
LPXAttr XNode::DetachAttr( LPXAttr attr )
|
XAttr *XNode::DetachAttr( XAttr *attr )
|
||||||
{
|
{
|
||||||
XAttrs::iterator it = GetAttrIterator( attr );
|
XAttrs::iterator it = GetAttrIterator( attr );
|
||||||
if( it != attrs.end() )
|
if( it != attrs.end() )
|
||||||
@@ -1060,23 +1059,23 @@ LPXAttr XNode::DetachAttr( LPXAttr attr )
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
XENTITYS::XENTITYS( LPXENTITY entities, int count )
|
XENTITYS::XENTITYS( XENTITY *entities, int count )
|
||||||
{
|
{
|
||||||
for( int i = 0; i < count; i++)
|
for( int i = 0; i < count; i++)
|
||||||
push_back( entities[i] );
|
push_back( entities[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
LPXENTITY XENTITYS::GetEntity( int entity )
|
XENTITY *XENTITYS::GetEntity( int entity )
|
||||||
{
|
{
|
||||||
for( unsigned i = 0 ; i < size(); i ++ )
|
for( unsigned i = 0 ; i < size(); i ++ )
|
||||||
{
|
{
|
||||||
if( at(i).entity == entity )
|
if( at(i).entity == entity )
|
||||||
return LPXENTITY(&at(i));
|
return (XENTITY *) (&at(i));
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPXENTITY XENTITYS::GetEntity( char* entity )
|
XENTITY *XENTITYS::GetEntity( char* entity )
|
||||||
{
|
{
|
||||||
for( unsigned i = 0 ; i < size(); i ++ )
|
for( unsigned i = 0 ; i < size(); i ++ )
|
||||||
{
|
{
|
||||||
@@ -1086,7 +1085,7 @@ LPXENTITY XENTITYS::GetEntity( char* entity )
|
|||||||
if( *ref++ != *ps++ )
|
if( *ref++ != *ps++ )
|
||||||
break;
|
break;
|
||||||
if( ref && !*ref ) // found!
|
if( ref && !*ref ) // found!
|
||||||
return LPXENTITY(&at(i));
|
return (XENTITY *) (&at(i));
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1107,7 +1106,7 @@ int XENTITYS::Ref2Entity( const char* estr, char* str, int strlen )
|
|||||||
char* ps_end = ps+strlen;
|
char* ps_end = ps+strlen;
|
||||||
while( pes && *pes && ps < ps_end )
|
while( pes && *pes && ps < ps_end )
|
||||||
{
|
{
|
||||||
LPXENTITY ent = GetEntity( pes );
|
XENTITY *ent = GetEntity( pes );
|
||||||
if( ent )
|
if( ent )
|
||||||
{
|
{
|
||||||
// copy entity meanning char
|
// copy entity meanning char
|
||||||
@@ -1131,7 +1130,7 @@ int XENTITYS::Entity2Ref( const char* str, char* estr, int estrlen )
|
|||||||
char* pes_end = pes+estrlen;
|
char* pes_end = pes+estrlen;
|
||||||
while( ps && *ps && pes < pes_end )
|
while( ps && *ps && pes < pes_end )
|
||||||
{
|
{
|
||||||
LPXENTITY ent = GetEntity( *ps );
|
XENTITY *ent = GetEntity( *ps );
|
||||||
if( ent )
|
if( ent )
|
||||||
{
|
{
|
||||||
// copy entity string
|
// copy entity string
|
||||||
@@ -1194,7 +1193,7 @@ CString XEntity2Ref( const char* str )
|
|||||||
return entityDefault.Entity2Ref( str );
|
return entityDefault.Entity2Ref( str );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XNode::LoadFromFile( CString sFile, LPPARSEINFO pi )
|
bool XNode::LoadFromFile( CString sFile, PARSEINFO *pi )
|
||||||
{
|
{
|
||||||
RageFile f;
|
RageFile f;
|
||||||
if( !f.Open(sFile, RageFile::READ) )
|
if( !f.Open(sFile, RageFile::READ) )
|
||||||
@@ -1219,7 +1218,7 @@ bool XNode::LoadFromFile( CString sFile, LPPARSEINFO pi )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XNode::SaveToFile( CString sFile, LPDISP_OPT opt )
|
bool XNode::SaveToFile( CString sFile, DISP_OPT *opt )
|
||||||
{
|
{
|
||||||
RageFile f;
|
RageFile f;
|
||||||
if( !f.Open(sFile, RageFile::WRITE) )
|
if( !f.Open(sFile, RageFile::WRITE) )
|
||||||
|
|||||||
+42
-49
@@ -24,11 +24,9 @@ struct DateTime;
|
|||||||
class RageFile;
|
class RageFile;
|
||||||
|
|
||||||
struct XAttr;
|
struct XAttr;
|
||||||
typedef XAttr* LPXAttr;
|
typedef std::vector<XAttr*> XAttrs;
|
||||||
typedef std::vector<LPXAttr> XAttrs;
|
|
||||||
struct XNode;
|
struct XNode;
|
||||||
typedef XNode* LPXNode;
|
typedef std::vector<XNode*> XNodes;
|
||||||
typedef std::vector<LPXNode> XNodes, *LPXNodes;
|
|
||||||
|
|
||||||
// Entity Encode/Decode Support
|
// Entity Encode/Decode Support
|
||||||
struct XENTITY
|
struct XENTITY
|
||||||
@@ -37,12 +35,11 @@ struct XENTITY
|
|||||||
TCHAR ref[10]; // entity reference ( & " etc )
|
TCHAR ref[10]; // entity reference ( & " etc )
|
||||||
int ref_len; // entity reference length
|
int ref_len; // entity reference length
|
||||||
};
|
};
|
||||||
typedef XENTITY* LPXENTITY;
|
|
||||||
|
|
||||||
struct XENTITYS : public std::vector<XENTITY>
|
struct XENTITYS : public std::vector<XENTITY>
|
||||||
{
|
{
|
||||||
LPXENTITY GetEntity( int entity );
|
XENTITY *GetEntity( int entity );
|
||||||
LPXENTITY GetEntity( char* entity );
|
XENTITY *GetEntity( char* entity );
|
||||||
int GetEntityCount( const char* str );
|
int GetEntityCount( const char* str );
|
||||||
int Ref2Entity( const char* estr, char* str, int strlen );
|
int Ref2Entity( const char* estr, char* str, int strlen );
|
||||||
int Entity2Ref( const char* str, char* estr, int estrlen );
|
int Entity2Ref( const char* str, char* estr, int estrlen );
|
||||||
@@ -50,9 +47,8 @@ struct XENTITYS : public std::vector<XENTITY>
|
|||||||
CString Entity2Ref( const char* str );
|
CString Entity2Ref( const char* str );
|
||||||
|
|
||||||
XENTITYS(){};
|
XENTITYS(){};
|
||||||
XENTITYS( LPXENTITY entities, int count );
|
XENTITYS( XENTITY *entities, int count );
|
||||||
};
|
};
|
||||||
typedef XENTITYS* LPXENTITYS;
|
|
||||||
extern XENTITYS entityDefault;
|
extern XENTITYS entityDefault;
|
||||||
CString XRef2Entity( const char* estr );
|
CString XRef2Entity( const char* estr );
|
||||||
CString XEntity2Ref( const char* str );
|
CString XEntity2Ref( const char* str );
|
||||||
@@ -72,7 +68,7 @@ struct PARSEINFO
|
|||||||
{
|
{
|
||||||
bool trim_value; // [set] do trim when parse?
|
bool trim_value; // [set] do trim when parse?
|
||||||
bool entity_value; // [set] do convert from reference to entity? ( < -> < )
|
bool entity_value; // [set] do convert from reference to entity? ( < -> < )
|
||||||
LPXENTITYS entitys; // [set] entity table for entity decode
|
XENTITYS *entitys; // [set] entity table for entity decode
|
||||||
TCHAR escape_value; // [set] escape value (default '\\')
|
TCHAR escape_value; // [set] escape value (default '\\')
|
||||||
|
|
||||||
char* xml; // [get] xml source
|
char* xml; // [get] xml source
|
||||||
@@ -83,7 +79,6 @@ struct PARSEINFO
|
|||||||
|
|
||||||
PARSEINFO() { trim_value = true; entity_value = true; entitys = &entityDefault; xml = NULL; erorr_occur = false; error_pointer = NULL; error_code = PIE_PARSE_WELFORMED; escape_value = 0; }
|
PARSEINFO() { trim_value = true; entity_value = true; entitys = &entityDefault; xml = NULL; erorr_occur = false; error_pointer = NULL; error_code = PIE_PARSE_WELFORMED; escape_value = 0; }
|
||||||
};
|
};
|
||||||
typedef PARSEINFO* LPPARSEINFO;
|
|
||||||
extern PARSEINFO piDefault;
|
extern PARSEINFO piDefault;
|
||||||
|
|
||||||
// display optional environment
|
// display optional environment
|
||||||
@@ -91,13 +86,12 @@ struct DISP_OPT
|
|||||||
{
|
{
|
||||||
bool newline; // newline when new tag
|
bool newline; // newline when new tag
|
||||||
bool reference_value; // do convert from entity to reference ( < -> < )
|
bool reference_value; // do convert from entity to reference ( < -> < )
|
||||||
LPXENTITYS entitys; // entity table for entity encode
|
XENTITYS *entitys; // entity table for entity encode
|
||||||
CString stylesheet; // empty string = none
|
CString stylesheet; // empty string = none
|
||||||
|
|
||||||
int tab_base; // internal usage
|
int tab_base; // internal usage
|
||||||
DISP_OPT() { newline = true; reference_value = true; entitys = &entityDefault; tab_base = 0; }
|
DISP_OPT() { newline = true; reference_value = true; entitys = &entityDefault; tab_base = 0; }
|
||||||
};
|
};
|
||||||
typedef DISP_OPT* LPDISP_OPT;
|
|
||||||
extern DISP_OPT optDefault;
|
extern DISP_OPT optDefault;
|
||||||
|
|
||||||
// XAttr : Attribute Implementation
|
// XAttr : Attribute Implementation
|
||||||
@@ -114,9 +108,8 @@ struct XAttr
|
|||||||
|
|
||||||
XNode* parent;
|
XNode* parent;
|
||||||
|
|
||||||
bool GetXML( RageFile &f, LPDISP_OPT opt = &optDefault );
|
bool GetXML( RageFile &f, DISP_OPT *opt = &optDefault );
|
||||||
};
|
};
|
||||||
typedef XAttr* LPXAttr;
|
|
||||||
|
|
||||||
// XMLNode structure
|
// XMLNode structure
|
||||||
struct XNode
|
struct XNode
|
||||||
@@ -137,21 +130,21 @@ struct XNode
|
|||||||
void SetValue(const DateTime &v);
|
void SetValue(const DateTime &v);
|
||||||
|
|
||||||
// internal variables
|
// internal variables
|
||||||
LPXNode parent; // parent node
|
XNode *parent; // parent node
|
||||||
XNodes childs; // child node
|
XNodes childs; // child node
|
||||||
XAttrs attrs; // attributes
|
XAttrs attrs; // attributes
|
||||||
|
|
||||||
// Load/Save XML
|
// Load/Save XML
|
||||||
char* Load( const char* pszXml, LPPARSEINFO pi = &piDefault );
|
char* Load( const char* pszXml, PARSEINFO *pi = &piDefault );
|
||||||
char* LoadAttributes( const char* pszAttrs, LPPARSEINFO pi = &piDefault );
|
char* LoadAttributes( const char* pszAttrs, PARSEINFO *pi = &piDefault );
|
||||||
bool GetXML( RageFile &f, LPDISP_OPT opt = &optDefault );
|
bool GetXML( RageFile &f, DISP_OPT *opt = &optDefault );
|
||||||
|
|
||||||
bool LoadFromFile( CString sFile, LPPARSEINFO pi = &piDefault );
|
bool LoadFromFile( CString sFile, PARSEINFO *pi = &piDefault );
|
||||||
bool SaveToFile( CString sFile, LPDISP_OPT opt = &optDefault );
|
bool SaveToFile( CString sFile, DISP_OPT *opt = &optDefault );
|
||||||
|
|
||||||
// in own attribute list
|
// in own attribute list
|
||||||
const LPXAttr GetAttr( const char* attrname ) const;
|
const XAttr *GetAttr( const char* attrname ) const;
|
||||||
LPXAttr GetAttr( const char* attrname );
|
XAttr *GetAttr( const char* attrname );
|
||||||
const char* GetAttrValue( const char* attrname );
|
const char* GetAttrValue( const char* attrname );
|
||||||
bool GetAttrValue(const char* name,CString &out) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; }
|
bool GetAttrValue(const char* name,CString &out) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; }
|
||||||
bool GetAttrValue(const char* name,int &out) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; }
|
bool GetAttrValue(const char* name,int &out) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; }
|
||||||
@@ -162,8 +155,8 @@ struct XNode
|
|||||||
XAttrs GetAttrs( const char* name );
|
XAttrs GetAttrs( const char* name );
|
||||||
|
|
||||||
// in one level child nodes
|
// in one level child nodes
|
||||||
const LPXNode GetChild( const char* name ) const;
|
const XNode *GetChild( const char* name ) const;
|
||||||
LPXNode GetChild( const char* name );
|
XNode *GetChild( const char* name );
|
||||||
const char* GetChildValue( const char* name );
|
const char* GetChildValue( const char* name );
|
||||||
bool GetChildValue(const char* name,CString &out) const { const XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; }
|
bool GetChildValue(const char* name,CString &out) const { const XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; }
|
||||||
bool GetChildValue(const char* name,int &out) const { const XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; }
|
bool GetChildValue(const char* name,int &out) const { const XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; }
|
||||||
@@ -174,38 +167,38 @@ struct XNode
|
|||||||
XNodes GetChilds( const char* name );
|
XNodes GetChilds( const char* name );
|
||||||
XNodes GetChilds();
|
XNodes GetChilds();
|
||||||
|
|
||||||
LPXAttr GetChildAttr( const char* name, const char* attrname );
|
XAttr *GetChildAttr( const char* name, const char* attrname );
|
||||||
const char* GetChildAttrValue( const char* name, const char* attrname );
|
const char* GetChildAttrValue( const char* name, const char* attrname );
|
||||||
|
|
||||||
// modify DOM
|
// modify DOM
|
||||||
int GetChildCount();
|
int GetChildCount();
|
||||||
LPXNode GetChild( int i );
|
XNode *GetChild( int i );
|
||||||
XNodes::iterator GetChildIterator( LPXNode node );
|
XNodes::iterator GetChildIterator( XNode *node );
|
||||||
LPXNode CreateNode( const char* name = NULL, const char* value = NULL );
|
XNode *CreateNode( const char* name = NULL, const char* value = NULL );
|
||||||
LPXNode AppendChild( const char* name = NULL, const char* value = NULL );
|
XNode *AppendChild( const char* name = NULL, const char* value = NULL );
|
||||||
LPXNode AppendChild( const char* name, float value );
|
XNode *AppendChild( const char* name, float value );
|
||||||
LPXNode AppendChild( const char* name, int value );
|
XNode *AppendChild( const char* name, int value );
|
||||||
LPXNode AppendChild( const char* name, unsigned value );
|
XNode *AppendChild( const char* name, unsigned value );
|
||||||
LPXNode AppendChild( const char* name, const DateTime &value );
|
XNode *AppendChild( const char* name, const DateTime &value );
|
||||||
LPXNode AppendChild( LPXNode node );
|
XNode *AppendChild( XNode *node );
|
||||||
bool RemoveChild( LPXNode node );
|
bool RemoveChild( XNode *node );
|
||||||
LPXNode DetachChild( LPXNode node );
|
XNode *DetachChild( XNode *node );
|
||||||
|
|
||||||
|
|
||||||
LPXAttr GetAttr( int i );
|
XAttr *GetAttr( int i );
|
||||||
XAttrs::iterator GetAttrIterator( LPXAttr node );
|
XAttrs::iterator GetAttrIterator( XAttr *node );
|
||||||
LPXAttr CreateAttr( const char* anem = NULL, const char* value = NULL );
|
XAttr *CreateAttr( const char* anem = NULL, const char* value = NULL );
|
||||||
LPXAttr AppendAttr( const char* name = NULL, const char* value = NULL );
|
XAttr *AppendAttr( const char* name = NULL, const char* value = NULL );
|
||||||
LPXAttr AppendAttr( const char* name, float value );
|
XAttr *AppendAttr( const char* name, float value );
|
||||||
LPXAttr AppendAttr( const char* name, int value );
|
XAttr *AppendAttr( const char* name, int value );
|
||||||
LPXAttr AppendAttr( const char* name, unsigned value );
|
XAttr *AppendAttr( const char* name, unsigned value );
|
||||||
LPXAttr AppendAttr( const char* name, const DateTime &value );
|
XAttr *AppendAttr( const char* name, const DateTime &value );
|
||||||
LPXAttr AppendAttr( LPXAttr attr );
|
XAttr *AppendAttr( XAttr *attr );
|
||||||
bool RemoveAttr( LPXAttr attr );
|
bool RemoveAttr( XAttr *attr );
|
||||||
LPXAttr DetachAttr( LPXAttr attr );
|
XAttr *DetachAttr( XAttr *attr );
|
||||||
|
|
||||||
// operator overloads
|
// operator overloads
|
||||||
LPXNode operator [] ( int i ) { return GetChild(i); }
|
XNode* operator [] ( int i ) { return GetChild(i); }
|
||||||
|
|
||||||
XNode() { parent = NULL; }
|
XNode() { parent = NULL; }
|
||||||
~XNode();
|
~XNode();
|
||||||
|
|||||||
Reference in New Issue
Block a user