04c645854d
Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/trunk@20181 c028cbd2-c16b-5b4b-a496-9718f37d4682
88 lines
2.2 KiB
C++
Executable File
88 lines
2.2 KiB
C++
Executable File
#ifndef __XML_H
|
|
#define __XML_H
|
|
|
|
#ifndef __ASSOC_H
|
|
#include <assoc.h>
|
|
#endif
|
|
|
|
class TXmlItem;
|
|
|
|
typedef bool (*XmlItemCallback)(TXmlItem& item, long jolly);
|
|
|
|
class TXmlItem : public TObject
|
|
{
|
|
|
|
TString m_strTag;
|
|
TString* m_strText;
|
|
TAssoc_array* m_Attributes;
|
|
TArray* m_Children;
|
|
|
|
protected:
|
|
bool GetWord(istream& input, TString& str) const;
|
|
int ReadTag(istream& input);
|
|
|
|
TXmlItem& AddChild(TXmlItem* pItem);
|
|
|
|
public:
|
|
const TString& GetTag() const { return m_strTag; }
|
|
void SetTag(const char* strTag) { m_strTag = strTag; }
|
|
|
|
const TString& GetText() const
|
|
{
|
|
if (m_strText != NULL)
|
|
return *m_strText;
|
|
return EMPTY_STRING;
|
|
}
|
|
void SetText(const char* str)
|
|
{
|
|
if (m_strText == NULL)
|
|
m_strText = new TString(str);
|
|
else
|
|
*m_strText = str;
|
|
}
|
|
|
|
TXmlItem& AddEnclosedText(const char* str);
|
|
bool GetEnclosedText(TString& str) const;
|
|
|
|
TXmlItem& SetAttr(const char* strAttr, const char* strVal);
|
|
const TString& GetAttr(const char* strAttr) const;
|
|
TXmlItem& SetAttr(const char* strAttr, int n);
|
|
TXmlItem& SetColorAttr(const char* strAttr, COLOR rgb);
|
|
int GetIntAttr(const char* strAttr, int def = 0) const;
|
|
TXmlItem& SetAttr(const char* strAttr, bool yes);
|
|
bool GetBoolAttr(const char* strAttr) const;
|
|
|
|
TXmlItem& AddChild(const char* strTag);
|
|
TXmlItem& AddSoapString(const char* name, const char* value, bool typized = false);
|
|
TXmlItem& AddSoapInt(const char* name, int value, bool typized = false);
|
|
|
|
int GetChildren() const;
|
|
TXmlItem* GetChild(size_t n) const;
|
|
void RemoveLastChild();
|
|
|
|
void Destroy();
|
|
bool Read(istream& input);
|
|
void Write(ostream& output, int nTab) const;
|
|
void AsString(TString& str) const;
|
|
|
|
void Save(const char* strFilename) const;
|
|
bool Load(const char* strFilename);
|
|
|
|
TXmlItem* ForEach(XmlItemCallback cb, long jolly = 0);
|
|
TXmlItem* FindFirst(const char* strTag) const; // Recursive
|
|
TXmlItem* FindFirstChild(const char* strTag) const; // First level only
|
|
|
|
TXmlItem();
|
|
~TXmlItem();
|
|
};
|
|
|
|
TXmlItem& operator<<(TXmlItem& item, const char* str);
|
|
void Spaces(ostream& outf, int nSpaces);
|
|
void WriteXmlString(ostream& outf, const char* str);
|
|
void WriteXmlColor(ostream& outf, COLOR rgb);
|
|
int hex2int(const char* str);
|
|
void save_html_head(ostream& out, const char* title);
|
|
|
|
#endif
|
|
|