//--------------------------------------------------------- void CSG_MetaData::_Save(wxXmlNode *pNode) const { int i; //----------------------------------------------------- pNode->SetName (CSG_String(Get_Name().Length() ? Get_Name() : CSG_String("NODE")).c_str()); pNode->SetContent(Get_Content().c_str()); if( Get_Content().Length() > 0 || (Get_Property_Count() == 0 && Get_Children_Count() == 0) ) { wxXmlNode *pChild = new wxXmlNode(pNode, wxXML_TEXT_NODE, SG_T("TEXT")); pChild->SetContent(Get_Content().c_str()); } //----------------------------------------------------- for(i=0; i<Get_Property_Count(); i++) { pNode->AddAttribute(Get_Property_Name(i).c_str(), Get_Property(i)); } //----------------------------------------------------- for(i=Get_Children_Count()-1; i>=0; i--) { Get_Child(i)->_Save(new wxXmlNode(pNode, wxXML_ELEMENT_NODE, Get_Child(i)->Get_Name().c_str())); } }
//--------------------------------------------------------- bool CSG_MetaData::Get_Property(const CSG_String &Name, CSG_String &Value) const { const SG_Char *cString = Get_Property(Name); if( cString ) { Value = cString; return( true ); } return( false ); }
//--------------------------------------------------------- bool CSG_MetaData::Cmp_Property(const CSG_String &Name, const CSG_String &String, bool bNoCase) const { CSG_String s; return( Get_Property(Name, s) && (bNoCase ? !s.CmpNoCase(String) : !s.Cmp(String)) ); }
bool CSG_MetaData::Get_Property(const CSG_String &Name, int &Value) const { CSG_String s; return( Get_Property(Name, s) && s.asInt(Value) ); }
bool CSG_MetaData::Get_Property(const CSG_String &Name, double &Value) const { CSG_String s; return( Get_Property(Name, s) && s.asDouble(Value) ); }
//--------------------------------------------------------- void CSG_MetaData::_Save(wxXmlNode *pNode) const { int i; pNode->SetName (Get_Name().Length() ? SG_String_To_UTF8(Get_Name()).c_str() : SG_T("NODE")); pNode->SetContent(SG_String_To_UTF8(Get_Content()).c_str()); if( Get_Content().Length() > 0 ) { wxXmlNode *pChild = new wxXmlNode(pNode, wxXML_TEXT_NODE, SG_T("TEXT"));// SG_String_To_UTF8(Get_Name()).c_str()); pChild->SetContent(SG_String_To_UTF8(Get_Content()).c_str()); } //----------------------------------------------------- for(i=0; i<Get_Property_Count(); i++) { pNode->AddProperty(SG_String_To_UTF8(Get_Property_Name(i)).c_str(), SG_String_To_UTF8(Get_Property(i)).c_str()); } //----------------------------------------------------- for(i=Get_Children_Count()-1; i>=0; i--) { if( Get_Child(i)->Get_Content().Length() > 0 || Get_Child(i)->Get_Children_Count() > 0 ) { wxXmlNode *pChild = new wxXmlNode(pNode, wxXML_ELEMENT_NODE, SG_String_To_UTF8(Get_Child(i)->Get_Name()).c_str()); Get_Child(i)->_Save(pChild); } } }