diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-06-27 18:11:13 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-06-27 18:11:13 +0000 |
commit | c86c0cf088492e02431dffb1f860ff2f6faa492d (patch) | |
tree | 1191879314028bb8f58daf45d48dacc6ba9ea583 /src/tafwriter.cpp | |
parent | 5ec9a131e12d021c42b46b601f5e79502485bebb (diff) | |
download | libbu++-c86c0cf088492e02431dffb1f860ff2f6faa492d.tar.gz libbu++-c86c0cf088492e02431dffb1f860ff2f6faa492d.tar.bz2 libbu++-c86c0cf088492e02431dffb1f860ff2f6faa492d.tar.xz libbu++-c86c0cf088492e02431dffb1f860ff2f6faa492d.zip |
The taf system is new and improved. The writer works, we added C++ style
comment blocks, and it retains the order of all nodes.
Diffstat (limited to 'src/tafwriter.cpp')
-rw-r--r-- | src/tafwriter.cpp | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/tafwriter.cpp b/src/tafwriter.cpp index ac42d3d..6b505ef 100644 --- a/src/tafwriter.cpp +++ b/src/tafwriter.cpp | |||
@@ -9,16 +9,54 @@ Bu::TafWriter::~TafWriter() | |||
9 | { | 9 | { |
10 | } | 10 | } |
11 | 11 | ||
12 | void Bu::TafWriter::writeNode( Bu::TafNode *pRoot ) | 12 | void Bu::TafWriter::writeGroup( const Bu::TafGroup *pRoot ) |
13 | { | 13 | { |
14 | sOut.write("{", 1 ); | 14 | sOut.write("{", 1 ); |
15 | writeString( pRoot->getName().getStr() ); | 15 | writeString( pRoot->getName() ); |
16 | sOut.write(": ", 2 ); | 16 | sOut.write(": ", 2 ); |
17 | const Bu::TafGroup::NodeList &nl = pRoot->getChildren(); | ||
18 | for( Bu::TafGroup::NodeList::const_iterator i = nl.begin(); i != nl.end(); i++ ) | ||
19 | { | ||
20 | switch( (*i)->getType() ) | ||
21 | { | ||
22 | case Bu::TafNode::typeGroup: | ||
23 | writeGroup( (Bu::TafGroup *)(*i) ); | ||
24 | break; | ||
25 | |||
26 | case Bu::TafNode::typeProperty: | ||
27 | writeProperty( (Bu::TafProperty *)(*i) ); | ||
28 | break; | ||
29 | |||
30 | case Bu::TafNode::typeComment: | ||
31 | writeComment( (Bu::TafComment *)(*i) ); | ||
32 | break; | ||
33 | } | ||
34 | } | ||
17 | sOut.write("}", 1 ); | 35 | sOut.write("}", 1 ); |
18 | } | 36 | } |
19 | 37 | ||
38 | void Bu::TafWriter::writeProperty( const Bu::TafProperty *pProp ) | ||
39 | { | ||
40 | writeString( pProp->getName() ); | ||
41 | if( pProp->getValue().getStr() != NULL ) | ||
42 | { | ||
43 | sOut.write("=", 1 ); | ||
44 | writeString( pProp->getValue() ); | ||
45 | } | ||
46 | sOut.write(" ", 1 ); | ||
47 | } | ||
48 | |||
49 | void Bu::TafWriter::writeComment( const Bu::TafComment *pComment ) | ||
50 | { | ||
51 | sOut.write("/*", 2 ); | ||
52 | sOut.write( pComment->getText().getStr(), pComment->getText().getSize() ); | ||
53 | sOut.write("*/ ", 3 ); | ||
54 | } | ||
55 | |||
20 | void Bu::TafWriter::writeString( const Bu::FString &str ) | 56 | void Bu::TafWriter::writeString( const Bu::FString &str ) |
21 | { | 57 | { |
58 | if( str.getStr() == NULL ) | ||
59 | return; | ||
22 | sOut.write("\"", 1 ); | 60 | sOut.write("\"", 1 ); |
23 | for( const char *s = str.getStr(); *s; s++ ) | 61 | for( const char *s = str.getStr(); *s; s++ ) |
24 | { | 62 | { |