2002-10-24 10:47:49 +00:00
|
|
|
#ifndef __XML_H
|
|
|
|
#define __XML_H
|
2002-09-09 14:18:21 +00:00
|
|
|
|
|
|
|
class TXmlItem;
|
|
|
|
|
2007-08-21 09:07:11 +00:00
|
|
|
typedef bool (*XmlItemCallback)(TXmlItem& item, void* jolly);
|
2002-09-09 14:18:21 +00:00
|
|
|
|
|
|
|
class TXmlItem : public wxObject
|
|
|
|
{
|
2002-12-20 17:08:30 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS(TXmlItem);
|
|
|
|
|
2002-09-09 14:18:21 +00:00
|
|
|
wxString m_strTag, m_strText;
|
|
|
|
wxHashTable* m_Attributes;
|
|
|
|
wxList* m_Children;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
wxString GetWord(wxInputStream& input) const;
|
|
|
|
int ReadTag(wxInputStream& input);
|
|
|
|
|
|
|
|
TXmlItem& AddChild(TXmlItem* pItem);
|
|
|
|
|
|
|
|
public:
|
|
|
|
const wxString& GetTag() const { return m_strTag; }
|
|
|
|
void SetTag(const wxChar* strTag) { m_strTag = strTag; }
|
|
|
|
|
|
|
|
const wxString& GetText() const { return m_strText; }
|
|
|
|
void SetText(const wxChar* str) { m_strText = str; }
|
2002-10-24 10:47:49 +00:00
|
|
|
|
|
|
|
TXmlItem& AddEnclosedText(const wxChar* str);
|
2002-09-13 14:56:23 +00:00
|
|
|
wxString GetEnclosedText() const;
|
2002-09-09 14:18:21 +00:00
|
|
|
|
2002-10-24 10:47:49 +00:00
|
|
|
TXmlItem& SetAttr(const wxChar* strAttr, const wxChar* strVal);
|
2002-09-09 14:18:21 +00:00
|
|
|
wxString GetAttr(const wxChar* strAttr) const;
|
2003-09-11 07:16:13 +00:00
|
|
|
TXmlItem& SetAttr(const wxChar* strAttr, long nVal);
|
2002-09-09 14:18:21 +00:00
|
|
|
|
|
|
|
TXmlItem& AddChild(const wxChar* strTag);
|
2002-09-13 14:56:23 +00:00
|
|
|
TXmlItem& AddSoapString(const wxChar* name, const wxChar* value, bool typized = false);
|
|
|
|
TXmlItem& AddSoapInt(const wxChar* name, int value, bool typized = false);
|
2007-08-21 09:07:11 +00:00
|
|
|
wxString GetSoapString(const wxChar* name, const wxChar* def = "") const;
|
|
|
|
long GetSoapInt(const wxChar* name, long def = 0) const;
|
2002-09-09 14:18:21 +00:00
|
|
|
|
|
|
|
int GetChildren() const;
|
|
|
|
TXmlItem* GetChild(size_t n) const;
|
2002-12-20 17:08:30 +00:00
|
|
|
void RemoveLastChild();
|
2002-09-09 14:18:21 +00:00
|
|
|
|
|
|
|
bool Read(wxInputStream& input);
|
2002-10-24 10:47:49 +00:00
|
|
|
void Write(wxOutputStream& output, int nTab) const;
|
2002-09-09 14:18:21 +00:00
|
|
|
wxString AsString() const;
|
|
|
|
|
2002-10-24 10:47:49 +00:00
|
|
|
void Save(const wxChar* strFilename) const;
|
|
|
|
|
2007-08-21 09:07:11 +00:00
|
|
|
TXmlItem* ForEach(XmlItemCallback cb, void* jolly = NULL);
|
2002-09-09 14:18:21 +00:00
|
|
|
TXmlItem* FindFirst(const wxChar* strTag) const;
|
|
|
|
|
|
|
|
TXmlItem();
|
|
|
|
~TXmlItem();
|
|
|
|
};
|
|
|
|
|
2002-10-24 10:47:49 +00:00
|
|
|
TXmlItem& operator<<(TXmlItem& item, const wxChar* str);
|
|
|
|
|
2002-09-09 14:18:21 +00:00
|
|
|
wxOutputStream& operator<<(wxOutputStream& outf, const wxChar* str);
|
2002-10-24 10:47:49 +00:00
|
|
|
wxOutputStream& operator<<(wxOutputStream& outf, wxString str);
|
|
|
|
wxInputStream& operator>>(wxInputStream& inf, wxString& str);
|
|
|
|
void Spaces(wxOutputStream& outf, int nSpaces);
|
|
|
|
void WriteXmlString(wxOutputStream& outf, const wxChar* str);
|
|
|
|
int hex2int(const wxChar* str);
|
2002-09-09 14:18:21 +00:00
|
|
|
|
2002-10-24 10:47:49 +00:00
|
|
|
#define endl "\r\n";
|
2002-09-09 14:18:21 +00:00
|
|
|
|
|
|
|
#endif
|
2002-10-24 10:47:49 +00:00
|
|
|
|