RageFileBasic

This commit is contained in:
Glenn Maynard
2004-12-18 05:37:53 +00:00
parent b609af7cce
commit 6cd9622e05
2 changed files with 19 additions and 12 deletions
+15 -9
View File
@@ -479,7 +479,7 @@ char* XNode::Load( const char* pszXml, PARSEINFO *pi /*= &piDefault*/ )
// Coder Date Desc // Coder Date Desc
// bro 2002-10-29 // bro 2002-10-29
//======================================================== //========================================================
bool XAttr::GetXML( RageFile &f, DISP_OPT *opt /*= &optDefault*/ ) bool XAttr::GetXML( RageFileBasic &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;
} }
@@ -493,7 +493,7 @@ bool XAttr::GetXML( RageFile &f, DISP_OPT *opt /*= &optDefault*/ )
// Coder Date Desc // Coder Date Desc
// bro 2002-10-29 // bro 2002-10-29
//======================================================== //========================================================
bool XNode::GetXML( RageFile &f, DISP_OPT *opt /*= &optDefault*/ ) bool XNode::GetXML( RageFileBasic &f, DISP_OPT *opt /*= &optDefault*/ )
{ {
// tab // tab
if( opt && opt->newline ) if( opt && opt->newline )
@@ -1211,14 +1211,8 @@ bool XNode::LoadFromFile( CString sFile, PARSEINFO *pi )
return true; return true;
} }
bool XNode::SaveToFile( CString sFile, DISP_OPT *opt ) bool XNode::SaveToFile( RageFileBasic &f, DISP_OPT *opt )
{ {
RageFile f;
if( !f.Open(sFile, RageFile::WRITE) )
{
LOG->Warn("Couldn't open %s for writing: %s", sFile.c_str(), f.GetError().c_str() );
return false;
}
f.PutLine( "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" ); f.PutLine( "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" );
if( !opt->stylesheet.empty() ) if( !opt->stylesheet.empty() )
f.PutLine( "<?xml-stylesheet type=\"text/xsl\" href=\"" + opt->stylesheet + "\"?>" ); f.PutLine( "<?xml-stylesheet type=\"text/xsl\" href=\"" + opt->stylesheet + "\"?>" );
@@ -1229,6 +1223,18 @@ bool XNode::SaveToFile( CString sFile, DISP_OPT *opt )
return true; return true;
} }
bool XNode::SaveToFile( CString sFile, DISP_OPT *opt )
{
RageFile f;
if( !f.Open(sFile, RageFile::WRITE) )
{
LOG->Warn("Couldn't open %s for writing: %s", sFile.c_str(), f.GetError().c_str() );
return false;
}
return SaveToFile( f, opt );
}
bool XIsEmptyString( const char* str ) bool XIsEmptyString( const char* str )
{ {
CString s(str); CString s(str);
+4 -3
View File
@@ -21,7 +21,7 @@
#include <vector> #include <vector>
struct DateTime; struct DateTime;
class RageFile; class RageFileBasic;
struct XAttr; struct XAttr;
typedef std::vector<XAttr*> XAttrs; typedef std::vector<XAttr*> XAttrs;
@@ -117,7 +117,7 @@ struct XAttr
XNode* parent; XNode* parent;
bool GetXML( RageFile &f, DISP_OPT *opt = &optDefault ); bool GetXML( RageFileBasic &f, DISP_OPT *opt = &optDefault );
}; };
// XMLNode structure // XMLNode structure
@@ -146,10 +146,11 @@ struct XNode
// Load/Save XML // Load/Save XML
char* Load( const char* pszXml, PARSEINFO *pi = &piDefault ); char* Load( const char* pszXml, PARSEINFO *pi = &piDefault );
char* LoadAttributes( const char* pszAttrs, PARSEINFO *pi = &piDefault ); char* LoadAttributes( const char* pszAttrs, PARSEINFO *pi = &piDefault );
bool GetXML( RageFile &f, DISP_OPT *opt = &optDefault ); bool GetXML( RageFileBasic &f, DISP_OPT *opt = &optDefault );
bool LoadFromFile( CString sFile, PARSEINFO *pi = &piDefault ); bool LoadFromFile( CString sFile, PARSEINFO *pi = &piDefault );
bool SaveToFile( CString sFile, DISP_OPT *opt = &optDefault ); bool SaveToFile( CString sFile, DISP_OPT *opt = &optDefault );
bool SaveToFile( RageFileBasic &f, DISP_OPT *opt = &optDefault );
// in own attribute list // in own attribute list
const XAttr *GetAttr( const char* attrname ) const; const XAttr *GetAttr( const char* attrname ) const;