summaryrefslogtreecommitdiff
path: root/src/smlnode.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/smlnode.h')
-rw-r--r--src/smlnode.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/smlnode.h b/src/smlnode.h
new file mode 100644
index 0000000..92dd65e
--- /dev/null
+++ b/src/smlnode.h
@@ -0,0 +1,41 @@
1#ifndef SML_NODE_H
2#define SML_NODE_H
3
4#include <bu/string.h>
5#include <bu/list.h>
6
7class SmlNode
8{
9friend Bu::Formatter &operator<<( Bu::Formatter &f, const SmlNode &n );
10public:
11 enum Type
12 {
13 typeRoot,
14 typeText,
15 typeTag,
16 };
17
18 SmlNode( Type eType, const Bu::String &sText=Bu::String(), SmlNode *pParent=NULL );
19 virtual ~SmlNode();
20
21 static SmlNode *parse( const Bu::String &sSrc );
22
23 typedef Bu::List<SmlNode *> SmlNodeList;
24
25 SmlNode *append( Type type, const Bu::String &sText );
26 SmlNode *getParent() { return pParent; }
27
28 Type getType() const { return eType; }
29 Bu::String getText() const { return sText; }
30 const SmlNodeList &getChildren() const { return lChildren; }
31
32private:
33 Type eType;
34 Bu::String sText;
35 SmlNodeList lChildren;
36 SmlNode *pParent;
37};
38
39Bu::Formatter &operator<<( Bu::Formatter &f, const SmlNode &n );
40
41#endif