diff options
author | Mike Buland <eichlan@xagasoft.com> | 2009-10-16 12:59:45 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2009-10-16 12:59:45 +0000 |
commit | 96b07a22f5392f5d7f821f5743deb3d64bd94e89 (patch) | |
tree | f8610916735e2bc5304031168f724cde7d909653 | |
parent | 835c3420326a3a3a94baa8690bf09941182d29b0 (diff) | |
download | libbu++-96b07a22f5392f5d7f821f5743deb3d64bd94e89.tar.gz libbu++-96b07a22f5392f5d7f821f5743deb3d64bd94e89.tar.bz2 libbu++-96b07a22f5392f5d7f821f5743deb3d64bd94e89.tar.xz libbu++-96b07a22f5392f5d7f821f5743deb3d64bd94e89.zip |
Although this looks like a load of code changes, this represents no functional
change to the Taf system. Really all that's happened is I've broken out the
core taf data types into seperate files, and gone ahead and created a helpful
new header file ("taf.h") that will include the entire taf system, including
the reader and writer for you.
This means that a lot of programs will start complaining, but fortunately,
there's an easy solution, if it complains about taf, make sure to include taf.h
at the top, instead of other taf files and you'll be set.
The next set of changes will add lots of helpers to the taf system and change
the reader to read non-const structures, i.e. I'll actually add editing support
to created taf structures.
Diffstat (limited to '')
-rw-r--r-- | src/fbasicstring.h | 15 | ||||
-rw-r--r-- | src/taf.h | 11 | ||||
-rw-r--r-- | src/tafcomment.cpp | 30 | ||||
-rw-r--r-- | src/tafcomment.h | 35 | ||||
-rw-r--r-- | src/tafgroup.cpp | 164 | ||||
-rw-r--r-- | src/tafgroup.h | 65 | ||||
-rw-r--r-- | src/tafnode.cpp | 195 | ||||
-rw-r--r-- | src/tafnode.h | 82 | ||||
-rw-r--r-- | src/tafproperty.cpp | 30 | ||||
-rw-r--r-- | src/tafproperty.h | 35 | ||||
-rw-r--r-- | src/tafreader.cpp | 3 | ||||
-rw-r--r-- | src/tafreader.h | 8 | ||||
-rw-r--r-- | src/tafwriter.cpp | 3 | ||||
-rw-r--r-- | src/tests/taf.cpp | 3 | ||||
-rw-r--r-- | src/unit/taf.unit | 3 |
15 files changed, 396 insertions, 286 deletions
diff --git a/src/fbasicstring.h b/src/fbasicstring.h index cda507a..225bc80 100644 --- a/src/fbasicstring.h +++ b/src/fbasicstring.h | |||
@@ -1931,6 +1931,21 @@ namespace Bu | |||
1931 | ar.write( core->pFirst->pData, core->nLength*sizeof(chr) ); | 1931 | ar.write( core->pFirst->pData, core->nLength*sizeof(chr) ); |
1932 | } | 1932 | } |
1933 | } | 1933 | } |
1934 | /* | ||
1935 | void archive( class Archive &ar ) const | ||
1936 | { | ||
1937 | if( ar.isLoading() ) | ||
1938 | { | ||
1939 | } | ||
1940 | else | ||
1941 | { | ||
1942 | flatten(); | ||
1943 | |||
1944 | ar << core->nLength; | ||
1945 | if( core->nLength ) | ||
1946 | ar.write( core->pFirst->pData, core->nLength*sizeof(chr) ); | ||
1947 | } | ||
1948 | }*/ | ||
1934 | 1949 | ||
1935 | iterator begin() | 1950 | iterator begin() |
1936 | { | 1951 | { |
diff --git a/src/taf.h b/src/taf.h new file mode 100644 index 0000000..109275c --- /dev/null +++ b/src/taf.h | |||
@@ -0,0 +1,11 @@ | |||
1 | // | ||
2 | // There's no protection on this file, it just includes other files. | ||
3 | // | ||
4 | |||
5 | #include "bu/tafnode.h" | ||
6 | #include "bu/tafgroup.h" | ||
7 | #include "bu/tafproperty.h" | ||
8 | #include "bu/tafcomment.h" | ||
9 | #include "bu/tafreader.h" | ||
10 | #include "bu/tafwriter.h" | ||
11 | |||
diff --git a/src/tafcomment.cpp b/src/tafcomment.cpp new file mode 100644 index 0000000..03f382a --- /dev/null +++ b/src/tafcomment.cpp | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2008 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "bu/tafcomment.h" | ||
9 | |||
10 | Bu::TafComment::TafComment( const Bu::FString &sText, bool bEOL ) : | ||
11 | TafNode( typeComment ), | ||
12 | sText( sText ), | ||
13 | bEOL( bEOL ) | ||
14 | { | ||
15 | } | ||
16 | |||
17 | Bu::TafComment::~TafComment() | ||
18 | { | ||
19 | } | ||
20 | |||
21 | const Bu::FString &Bu::TafComment::getText() const | ||
22 | { | ||
23 | return sText; | ||
24 | } | ||
25 | |||
26 | bool Bu::TafComment::isEOLStyle() const | ||
27 | { | ||
28 | return bEOL; | ||
29 | } | ||
30 | |||
diff --git a/src/tafcomment.h b/src/tafcomment.h new file mode 100644 index 0000000..9f0534f --- /dev/null +++ b/src/tafcomment.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2008 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #ifndef BU_TAF_COMMENT_H | ||
9 | #define BU_TAF_COMMENT_H | ||
10 | |||
11 | #include <stdint.h> | ||
12 | #include "bu/tafnode.h" | ||
13 | |||
14 | namespace Bu | ||
15 | { | ||
16 | /** | ||
17 | * | ||
18 | *@ingroup Taf | ||
19 | */ | ||
20 | class TafComment : public TafNode | ||
21 | { | ||
22 | public: | ||
23 | TafComment( const Bu::FString &sText, bool bEOL=false ); | ||
24 | virtual ~TafComment(); | ||
25 | |||
26 | const Bu::FString &getText() const; | ||
27 | bool isEOLStyle() const; | ||
28 | |||
29 | private: | ||
30 | Bu::FString sText; | ||
31 | bool bEOL; | ||
32 | }; | ||
33 | } | ||
34 | |||
35 | #endif | ||
diff --git a/src/tafgroup.cpp b/src/tafgroup.cpp new file mode 100644 index 0000000..1837bd8 --- /dev/null +++ b/src/tafgroup.cpp | |||
@@ -0,0 +1,164 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2008 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "bu/tafgroup.h" | ||
9 | #include "bu/tafproperty.h" | ||
10 | #include "bu/tafcomment.h" | ||
11 | |||
12 | Bu::TafGroup::TafGroup( const Bu::FString &sName ) : | ||
13 | TafNode( typeGroup ), | ||
14 | sName( sName ) | ||
15 | { | ||
16 | } | ||
17 | |||
18 | Bu::TafGroup::~TafGroup() | ||
19 | { | ||
20 | for( NodeList::iterator i = lChildren.begin(); i != lChildren.end(); i++ ) | ||
21 | { | ||
22 | delete (*i); | ||
23 | } | ||
24 | } | ||
25 | |||
26 | const Bu::FString &Bu::TafGroup::getName() const | ||
27 | { | ||
28 | return sName; | ||
29 | } | ||
30 | |||
31 | void Bu::TafGroup::setName( const Bu::FString &sName ) | ||
32 | { | ||
33 | this->sName = sName; | ||
34 | } | ||
35 | |||
36 | Bu::TafNode *Bu::TafGroup::addChild( Bu::TafNode *pNode ) | ||
37 | { | ||
38 | switch( pNode->getType() ) | ||
39 | { | ||
40 | case typeGroup: | ||
41 | addChild( (Bu::TafGroup *)pNode ); | ||
42 | break; | ||
43 | |||
44 | case typeProperty: | ||
45 | addChild( (Bu::TafProperty *)pNode ); | ||
46 | break; | ||
47 | |||
48 | case typeComment: | ||
49 | addChild( (Bu::TafComment *)pNode ); | ||
50 | break; | ||
51 | } | ||
52 | |||
53 | return pNode; | ||
54 | } | ||
55 | |||
56 | Bu::TafGroup *Bu::TafGroup::addChild( TafGroup *pNode ) | ||
57 | { | ||
58 | TafGroup *pGroup = (TafGroup *)pNode; | ||
59 | if( !hChildren.has( pGroup->getName() ) ) | ||
60 | hChildren.insert( pGroup->getName(), GroupList() ); | ||
61 | hChildren.get( pGroup->getName() ).append( pGroup ); | ||
62 | lChildren.append( pNode ); | ||
63 | return pNode; | ||
64 | } | ||
65 | |||
66 | Bu::TafProperty *Bu::TafGroup::addChild( TafProperty *pNode ) | ||
67 | { | ||
68 | TafProperty *pProperty = (TafProperty *)pNode; | ||
69 | if( !hProp.has( pProperty->getName() ) ) | ||
70 | hProp.insert( pProperty->getName(), PropList() ); | ||
71 | hProp.get( pProperty->getName() ).append( pProperty->getValue() ); | ||
72 | lChildren.append( pNode ); | ||
73 | return pNode; | ||
74 | } | ||
75 | |||
76 | Bu::TafComment *Bu::TafGroup::addChild( TafComment *pNode ) | ||
77 | { | ||
78 | lChildren.append( pNode ); | ||
79 | return pNode; | ||
80 | } | ||
81 | |||
82 | Bu::TafGroup *Bu::TafGroup::addGroup( const Bu::FString &sName ) | ||
83 | { | ||
84 | return addChild( new TafGroup( sName ) ); | ||
85 | } | ||
86 | |||
87 | Bu::TafProperty *Bu::TafGroup::addProperty( | ||
88 | const Bu::FString &sName, const Bu::FString &sValue ) | ||
89 | { | ||
90 | return addChild( new TafProperty( sName, sValue ) ); | ||
91 | } | ||
92 | |||
93 | bool Bu::TafGroup::hasChild( const Bu::FString &sName ) const | ||
94 | { | ||
95 | return hChildren.has( sName ); | ||
96 | } | ||
97 | |||
98 | const Bu::TafGroup::GroupList &Bu::TafGroup::getChildren( const Bu::FString &sName ) const | ||
99 | { | ||
100 | try { | ||
101 | return hChildren.get( sName ); | ||
102 | } catch( Bu::HashException &e ) | ||
103 | { | ||
104 | throw Bu::TafException("No children of group \"%s\" match \"%s\".", | ||
105 | this->sName.getStr(), sName.getStr() ); | ||
106 | } | ||
107 | } | ||
108 | |||
109 | const Bu::TafGroup::NodeList &Bu::TafGroup::getChildren() const | ||
110 | { | ||
111 | return lChildren; | ||
112 | } | ||
113 | |||
114 | const Bu::TafGroup *Bu::TafGroup::getChild( const Bu::FString &sName ) const | ||
115 | { | ||
116 | try { | ||
117 | return hChildren.get( sName ).first(); | ||
118 | } catch( Bu::HashException &e ) | ||
119 | { | ||
120 | throw Bu::TafException("No children of group \"%s\" match \"%s\".", | ||
121 | this->sName.getStr(), sName.getStr() ); | ||
122 | } | ||
123 | } | ||
124 | |||
125 | bool Bu::TafGroup::hasProperty( const Bu::FString &sName ) const | ||
126 | { | ||
127 | return hProp.has( sName ); | ||
128 | } | ||
129 | |||
130 | const Bu::TafGroup::PropList &Bu::TafGroup::getProperties( const Bu::FString &sName ) const | ||
131 | { | ||
132 | try { | ||
133 | return hProp.get( sName ); | ||
134 | } catch( Bu::HashException &e ) | ||
135 | { | ||
136 | throw Bu::TafException("No properties of group \"%s\" match \"%s\".", | ||
137 | this->sName.getStr(), sName.getStr() ); | ||
138 | } | ||
139 | } | ||
140 | |||
141 | const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName ) const | ||
142 | { | ||
143 | try { | ||
144 | return hProp.get( sName ).first(); | ||
145 | } catch( Bu::HashException &e ) | ||
146 | { | ||
147 | throw Bu::TafException("No properties of group \"%s\" match \"%s\".", | ||
148 | this->sName.getStr(), sName.getStr() ); | ||
149 | } | ||
150 | } | ||
151 | |||
152 | const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName, | ||
153 | const Bu::FString &sDef ) const | ||
154 | { | ||
155 | try | ||
156 | { | ||
157 | return hProp.get( sName ).first(); | ||
158 | } | ||
159 | catch( Bu::HashException &e ) | ||
160 | { | ||
161 | return sDef; | ||
162 | } | ||
163 | } | ||
164 | |||
diff --git a/src/tafgroup.h b/src/tafgroup.h new file mode 100644 index 0000000..6a50d11 --- /dev/null +++ b/src/tafgroup.h | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2008 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #ifndef BU_TAF_GROUP_H | ||
9 | #define BU_TAF_GROUP_H | ||
10 | |||
11 | #include <stdint.h> | ||
12 | #include "bu/tafnode.h" | ||
13 | #include "bu/fstring.h" | ||
14 | #include "bu/hash.h" | ||
15 | #include "bu/list.h" | ||
16 | |||
17 | namespace Bu | ||
18 | { | ||
19 | class TafProperty; | ||
20 | class TafComment; | ||
21 | /** | ||
22 | * | ||
23 | *@ingroup Taf | ||
24 | */ | ||
25 | class TafGroup : public TafNode | ||
26 | { | ||
27 | public: | ||
28 | typedef Bu::List<Bu::FString> PropList; | ||
29 | typedef Bu::Hash<Bu::FString, PropList> PropHash; | ||
30 | typedef Bu::List<class Bu::TafGroup *> GroupList; | ||
31 | typedef Bu::Hash<Bu::FString, GroupList> GroupHash; | ||
32 | typedef Bu::List<class Bu::TafNode *> NodeList; | ||
33 | |||
34 | TafGroup( const Bu::FString &sName ); | ||
35 | virtual ~TafGroup(); | ||
36 | |||
37 | const Bu::FString &getName() const; | ||
38 | void setName( const Bu::FString &sName ); | ||
39 | |||
40 | bool hasProperty( const Bu::FString &sName ) const; | ||
41 | const Bu::FString &getProperty( const Bu::FString &sName ) const; | ||
42 | const Bu::FString &getProperty( const Bu::FString &sName, | ||
43 | const Bu::FString &sDef ) const; | ||
44 | const PropList &getProperties( const Bu::FString &sName ) const; | ||
45 | bool hasChild( const Bu::FString &sName ) const; | ||
46 | const TafGroup *getChild( const Bu::FString &sName ) const; | ||
47 | const GroupList &getChildren( const Bu::FString &sName ) const; | ||
48 | TafNode *addChild( TafNode *pNode ); | ||
49 | TafGroup *addChild( TafGroup *pNode ); | ||
50 | TafProperty *addChild( TafProperty *pNode ); | ||
51 | TafComment *addChild( TafComment *pNode ); | ||
52 | TafGroup *addGroup( const Bu::FString &sName ); | ||
53 | TafProperty *addProperty( | ||
54 | const Bu::FString &sName, const Bu::FString &sValue ); | ||
55 | const NodeList &getChildren() const; | ||
56 | |||
57 | private: | ||
58 | Bu::FString sName; | ||
59 | PropHash hProp; | ||
60 | GroupHash hChildren; | ||
61 | NodeList lChildren; | ||
62 | }; | ||
63 | } | ||
64 | |||
65 | #endif | ||
diff --git a/src/tafnode.cpp b/src/tafnode.cpp index 8ea2e95..e7711fb 100644 --- a/src/tafnode.cpp +++ b/src/tafnode.cpp | |||
@@ -23,198 +23,3 @@ Bu::TafNode::NodeType Bu::TafNode::getType() const | |||
23 | return eType; | 23 | return eType; |
24 | } | 24 | } |
25 | 25 | ||
26 | Bu::TafGroup::TafGroup( const Bu::FString &sName ) : | ||
27 | TafNode( typeGroup ), | ||
28 | sName( sName ) | ||
29 | { | ||
30 | } | ||
31 | |||
32 | Bu::TafGroup::~TafGroup() | ||
33 | { | ||
34 | for( NodeList::iterator i = lChildren.begin(); i != lChildren.end(); i++ ) | ||
35 | { | ||
36 | delete (*i); | ||
37 | } | ||
38 | } | ||
39 | |||
40 | const Bu::FString &Bu::TafGroup::getName() const | ||
41 | { | ||
42 | return sName; | ||
43 | } | ||
44 | |||
45 | void Bu::TafGroup::setName( const Bu::FString &sName ) | ||
46 | { | ||
47 | this->sName = sName; | ||
48 | } | ||
49 | |||
50 | Bu::TafNode *Bu::TafGroup::addChild( Bu::TafNode *pNode ) | ||
51 | { | ||
52 | switch( pNode->getType() ) | ||
53 | { | ||
54 | case typeGroup: | ||
55 | addChild( (Bu::TafGroup *)pNode ); | ||
56 | break; | ||
57 | |||
58 | case typeProperty: | ||
59 | addChild( (Bu::TafProperty *)pNode ); | ||
60 | break; | ||
61 | |||
62 | case typeComment: | ||
63 | addChild( (Bu::TafComment *)pNode ); | ||
64 | break; | ||
65 | } | ||
66 | |||
67 | return pNode; | ||
68 | } | ||
69 | |||
70 | Bu::TafGroup *Bu::TafGroup::addChild( TafGroup *pNode ) | ||
71 | { | ||
72 | TafGroup *pGroup = (TafGroup *)pNode; | ||
73 | if( !hChildren.has( pGroup->getName() ) ) | ||
74 | hChildren.insert( pGroup->getName(), GroupList() ); | ||
75 | hChildren.get( pGroup->getName() ).append( pGroup ); | ||
76 | lChildren.append( pNode ); | ||
77 | return pNode; | ||
78 | } | ||
79 | |||
80 | Bu::TafProperty *Bu::TafGroup::addChild( TafProperty *pNode ) | ||
81 | { | ||
82 | TafProperty *pProperty = (TafProperty *)pNode; | ||
83 | if( !hProp.has( pProperty->getName() ) ) | ||
84 | hProp.insert( pProperty->getName(), PropList() ); | ||
85 | hProp.get( pProperty->getName() ).append( pProperty->getValue() ); | ||
86 | lChildren.append( pNode ); | ||
87 | return pNode; | ||
88 | } | ||
89 | |||
90 | Bu::TafComment *Bu::TafGroup::addChild( TafComment *pNode ) | ||
91 | { | ||
92 | lChildren.append( pNode ); | ||
93 | return pNode; | ||
94 | } | ||
95 | |||
96 | Bu::TafGroup *Bu::TafGroup::addGroup( const Bu::FString &sName ) | ||
97 | { | ||
98 | return addChild( new TafGroup( sName ) ); | ||
99 | } | ||
100 | |||
101 | Bu::TafProperty *Bu::TafGroup::addProperty( | ||
102 | const Bu::FString &sName, const Bu::FString &sValue ) | ||
103 | { | ||
104 | return addChild( new TafProperty( sName, sValue ) ); | ||
105 | } | ||
106 | |||
107 | bool Bu::TafGroup::hasChild( const Bu::FString &sName ) const | ||
108 | { | ||
109 | return hChildren.has( sName ); | ||
110 | } | ||
111 | |||
112 | const Bu::TafGroup::GroupList &Bu::TafGroup::getChildren( const Bu::FString &sName ) const | ||
113 | { | ||
114 | try { | ||
115 | return hChildren.get( sName ); | ||
116 | } catch( Bu::HashException &e ) | ||
117 | { | ||
118 | throw Bu::TafException("No children of group \"%s\" match \"%s\".", | ||
119 | this->sName.getStr(), sName.getStr() ); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | const Bu::TafGroup::NodeList &Bu::TafGroup::getChildren() const | ||
124 | { | ||
125 | return lChildren; | ||
126 | } | ||
127 | |||
128 | const Bu::TafGroup *Bu::TafGroup::getChild( const Bu::FString &sName ) const | ||
129 | { | ||
130 | try { | ||
131 | return hChildren.get( sName ).first(); | ||
132 | } catch( Bu::HashException &e ) | ||
133 | { | ||
134 | throw Bu::TafException("No children of group \"%s\" match \"%s\".", | ||
135 | this->sName.getStr(), sName.getStr() ); | ||
136 | } | ||
137 | } | ||
138 | |||
139 | bool Bu::TafGroup::hasProperty( const Bu::FString &sName ) const | ||
140 | { | ||
141 | return hProp.has( sName ); | ||
142 | } | ||
143 | |||
144 | const Bu::TafGroup::PropList &Bu::TafGroup::getProperties( const Bu::FString &sName ) const | ||
145 | { | ||
146 | try { | ||
147 | return hProp.get( sName ); | ||
148 | } catch( Bu::HashException &e ) | ||
149 | { | ||
150 | throw Bu::TafException("No properties of group \"%s\" match \"%s\".", | ||
151 | this->sName.getStr(), sName.getStr() ); | ||
152 | } | ||
153 | } | ||
154 | |||
155 | const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName ) const | ||
156 | { | ||
157 | try { | ||
158 | return hProp.get( sName ).first(); | ||
159 | } catch( Bu::HashException &e ) | ||
160 | { | ||
161 | throw Bu::TafException("No properties of group \"%s\" match \"%s\".", | ||
162 | this->sName.getStr(), sName.getStr() ); | ||
163 | } | ||
164 | } | ||
165 | |||
166 | const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName, | ||
167 | const Bu::FString &sDef ) const | ||
168 | { | ||
169 | try | ||
170 | { | ||
171 | return hProp.get( sName ).first(); | ||
172 | } | ||
173 | catch( Bu::HashException &e ) | ||
174 | { | ||
175 | return sDef; | ||
176 | } | ||
177 | } | ||
178 | |||
179 | Bu::TafProperty::TafProperty( const Bu::FString &sName, const Bu::FString &sValue ) : | ||
180 | TafNode( typeProperty ), | ||
181 | sName( sName ), | ||
182 | sValue( sValue ) | ||
183 | { | ||
184 | } | ||
185 | |||
186 | Bu::TafProperty::~TafProperty() | ||
187 | { | ||
188 | } | ||
189 | |||
190 | const Bu::FString &Bu::TafProperty::getName() const | ||
191 | { | ||
192 | return sName; | ||
193 | } | ||
194 | |||
195 | const Bu::FString &Bu::TafProperty::getValue() const | ||
196 | { | ||
197 | return sValue; | ||
198 | } | ||
199 | |||
200 | Bu::TafComment::TafComment( const Bu::FString &sText, bool bEOL ) : | ||
201 | TafNode( typeComment ), | ||
202 | sText( sText ), | ||
203 | bEOL( bEOL ) | ||
204 | { | ||
205 | } | ||
206 | |||
207 | Bu::TafComment::~TafComment() | ||
208 | { | ||
209 | } | ||
210 | |||
211 | const Bu::FString &Bu::TafComment::getText() const | ||
212 | { | ||
213 | return sText; | ||
214 | } | ||
215 | |||
216 | bool Bu::TafComment::isEOLStyle() const | ||
217 | { | ||
218 | return bEOL; | ||
219 | } | ||
220 | |||
diff --git a/src/tafnode.h b/src/tafnode.h index f6d2ea9..5aa5082 100644 --- a/src/tafnode.h +++ b/src/tafnode.h | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <stdint.h> | 11 | #include <stdint.h> |
12 | #include "bu/fstring.h" | 12 | #include "bu/fstring.h" |
13 | #include "bu/hash.h" | 13 | #include "bu/hash.h" |
14 | #include "bu/list.h" | ||
15 | #include "bu/exceptionbase.h" | 14 | #include "bu/exceptionbase.h" |
16 | 15 | ||
17 | namespace Bu | 16 | namespace Bu |
@@ -40,87 +39,6 @@ namespace Bu | |||
40 | private: | 39 | private: |
41 | NodeType eType; | 40 | NodeType eType; |
42 | }; | 41 | }; |
43 | |||
44 | class TafProperty; | ||
45 | class TafComment; | ||
46 | /** | ||
47 | * | ||
48 | *@ingroup Taf | ||
49 | */ | ||
50 | class TafGroup : public TafNode | ||
51 | { | ||
52 | public: | ||
53 | typedef Bu::List<Bu::FString> PropList; | ||
54 | typedef Bu::Hash<Bu::FString, PropList> PropHash; | ||
55 | typedef Bu::List<class Bu::TafGroup *> GroupList; | ||
56 | typedef Bu::Hash<Bu::FString, GroupList> GroupHash; | ||
57 | typedef Bu::List<class Bu::TafNode *> NodeList; | ||
58 | |||
59 | TafGroup( const Bu::FString &sName ); | ||
60 | virtual ~TafGroup(); | ||
61 | |||
62 | const Bu::FString &getName() const; | ||
63 | void setName( const Bu::FString &sName ); | ||
64 | |||
65 | bool hasProperty( const Bu::FString &sName ) const; | ||
66 | const Bu::FString &getProperty( const Bu::FString &sName ) const; | ||
67 | const Bu::FString &getProperty( const Bu::FString &sName, | ||
68 | const Bu::FString &sDef ) const; | ||
69 | const PropList &getProperties( const Bu::FString &sName ) const; | ||
70 | bool hasChild( const Bu::FString &sName ) const; | ||
71 | const TafGroup *getChild( const Bu::FString &sName ) const; | ||
72 | const GroupList &getChildren( const Bu::FString &sName ) const; | ||
73 | TafNode *addChild( TafNode *pNode ); | ||
74 | TafGroup *addChild( TafGroup *pNode ); | ||
75 | TafProperty *addChild( TafProperty *pNode ); | ||
76 | TafComment *addChild( TafComment *pNode ); | ||
77 | TafGroup *addGroup( const Bu::FString &sName ); | ||
78 | TafProperty *addProperty( | ||
79 | const Bu::FString &sName, const Bu::FString &sValue ); | ||
80 | const NodeList &getChildren() const; | ||
81 | |||
82 | private: | ||
83 | Bu::FString sName; | ||
84 | PropHash hProp; | ||
85 | GroupHash hChildren; | ||
86 | NodeList lChildren; | ||
87 | }; | ||
88 | |||
89 | /** | ||
90 | * | ||
91 | *@ingroup Taf | ||
92 | */ | ||
93 | class TafProperty : public TafNode | ||
94 | { | ||
95 | public: | ||
96 | TafProperty( const Bu::FString &sName, const Bu::FString &sValue ); | ||
97 | virtual ~TafProperty(); | ||
98 | |||
99 | const Bu::FString &getName() const; | ||
100 | const Bu::FString &getValue() const; | ||
101 | |||
102 | private: | ||
103 | Bu::FString sName; | ||
104 | Bu::FString sValue; | ||
105 | }; | ||
106 | |||
107 | /** | ||
108 | * | ||
109 | *@ingroup Taf | ||
110 | */ | ||
111 | class TafComment : public TafNode | ||
112 | { | ||
113 | public: | ||
114 | TafComment( const Bu::FString &sText, bool bEOL=false ); | ||
115 | virtual ~TafComment(); | ||
116 | |||
117 | const Bu::FString &getText() const; | ||
118 | bool isEOLStyle() const; | ||
119 | |||
120 | private: | ||
121 | Bu::FString sText; | ||
122 | bool bEOL; | ||
123 | }; | ||
124 | } | 42 | } |
125 | 43 | ||
126 | #endif | 44 | #endif |
diff --git a/src/tafproperty.cpp b/src/tafproperty.cpp new file mode 100644 index 0000000..855c5bb --- /dev/null +++ b/src/tafproperty.cpp | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2008 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "bu/tafproperty.h" | ||
9 | |||
10 | Bu::TafProperty::TafProperty( const Bu::FString &sName, const Bu::FString &sValue ) : | ||
11 | TafNode( typeProperty ), | ||
12 | sName( sName ), | ||
13 | sValue( sValue ) | ||
14 | { | ||
15 | } | ||
16 | |||
17 | Bu::TafProperty::~TafProperty() | ||
18 | { | ||
19 | } | ||
20 | |||
21 | const Bu::FString &Bu::TafProperty::getName() const | ||
22 | { | ||
23 | return sName; | ||
24 | } | ||
25 | |||
26 | const Bu::FString &Bu::TafProperty::getValue() const | ||
27 | { | ||
28 | return sValue; | ||
29 | } | ||
30 | |||
diff --git a/src/tafproperty.h b/src/tafproperty.h new file mode 100644 index 0000000..3589a58 --- /dev/null +++ b/src/tafproperty.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2008 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #ifndef BU_TAF_PROPERTY_H | ||
9 | #define BU_TAF_PROPERTY_H | ||
10 | |||
11 | #include <stdint.h> | ||
12 | #include "bu/tafnode.h" | ||
13 | |||
14 | namespace Bu | ||
15 | { | ||
16 | /** | ||
17 | * | ||
18 | *@ingroup Taf | ||
19 | */ | ||
20 | class TafProperty : public TafNode | ||
21 | { | ||
22 | public: | ||
23 | TafProperty( const Bu::FString &sName, const Bu::FString &sValue ); | ||
24 | virtual ~TafProperty(); | ||
25 | |||
26 | const Bu::FString &getName() const; | ||
27 | const Bu::FString &getValue() const; | ||
28 | |||
29 | private: | ||
30 | Bu::FString sName; | ||
31 | Bu::FString sValue; | ||
32 | }; | ||
33 | } | ||
34 | |||
35 | #endif | ||
diff --git a/src/tafreader.cpp b/src/tafreader.cpp index ebf54c1..f3265ab 100644 --- a/src/tafreader.cpp +++ b/src/tafreader.cpp | |||
@@ -5,8 +5,9 @@ | |||
5 | * terms of the license contained in the file LICENSE. | 5 | * terms of the license contained in the file LICENSE. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include "bu/tafreader.h" | 8 | #include "bu/taf.h" |
9 | #include "bu/fstring.h" | 9 | #include "bu/fstring.h" |
10 | #include "bu/stream.h" | ||
10 | 11 | ||
11 | #include <stdlib.h> | 12 | #include <stdlib.h> |
12 | 13 | ||
diff --git a/src/tafreader.h b/src/tafreader.h index 53ab6d4..286ee39 100644 --- a/src/tafreader.h +++ b/src/tafreader.h | |||
@@ -9,12 +9,16 @@ | |||
9 | #define BU_TAF_READER_H | 9 | #define BU_TAF_READER_H |
10 | 10 | ||
11 | #include <stdint.h> | 11 | #include <stdint.h> |
12 | #include "bu/tafnode.h" | ||
13 | #include "bu/stream.h" | ||
14 | #include "bu/fstring.h" | 12 | #include "bu/fstring.h" |
15 | 13 | ||
16 | namespace Bu | 14 | namespace Bu |
17 | { | 15 | { |
16 | class TafNode; | ||
17 | class TafGroup; | ||
18 | class TafProperty; | ||
19 | class TafComment; | ||
20 | class Stream; | ||
21 | |||
18 | /** | 22 | /** |
19 | * | 23 | * |
20 | *@ingroup Taf | 24 | *@ingroup Taf |
diff --git a/src/tafwriter.cpp b/src/tafwriter.cpp index 82d39e5..c5fc730 100644 --- a/src/tafwriter.cpp +++ b/src/tafwriter.cpp | |||
@@ -5,8 +5,7 @@ | |||
5 | * terms of the license contained in the file LICENSE. | 5 | * terms of the license contained in the file LICENSE. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include "bu/tafwriter.h" | 8 | #include "bu/taf.h" |
9 | #include "bu/tafnode.h" | ||
10 | #include "bu/stream.h" | 9 | #include "bu/stream.h" |
11 | 10 | ||
12 | Bu::TafWriter::TafWriter( Bu::Stream &sOut ) : | 11 | Bu::TafWriter::TafWriter( Bu::Stream &sOut ) : |
diff --git a/src/tests/taf.cpp b/src/tests/taf.cpp index 45a6430..deadfb2 100644 --- a/src/tests/taf.cpp +++ b/src/tests/taf.cpp | |||
@@ -5,8 +5,7 @@ | |||
5 | * terms of the license contained in the file LICENSE. | 5 | * terms of the license contained in the file LICENSE. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include "bu/tafreader.h" | 8 | #include "bu/taf.h" |
9 | #include "bu/tafwriter.h" | ||
10 | #include "bu/file.h" | 9 | #include "bu/file.h" |
11 | 10 | ||
12 | int main( int argc, char *argv[] ) | 11 | int main( int argc, char *argv[] ) |
diff --git a/src/unit/taf.unit b/src/unit/taf.unit index 5588c85..eeddd53 100644 --- a/src/unit/taf.unit +++ b/src/unit/taf.unit | |||
@@ -7,8 +7,7 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "bu/file.h" | 9 | #include "bu/file.h" |
10 | #include "bu/tafreader.h" | 10 | #include "bu/taf.h" |
11 | #include "bu/tafwriter.h" | ||
12 | #include "bu/membuf.h" | 11 | #include "bu/membuf.h" |
13 | 12 | ||
14 | #include <string.h> | 13 | #include <string.h> |