diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-07-03 00:28:59 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-07-03 00:28:59 +0000 |
commit | ac517a2b7625e0aa0862679e961c6349f859ea3b (patch) | |
tree | e3e27a6b9bd5e2be6150088495c91fc91786ad9d /src/tafwriter.cpp | |
parent | f8d4301e9fa4f3709258505941e37fab2eadadc6 (diff) | |
parent | bd865cee5f89116c1f054cd0e5c275e97c2d0a9b (diff) | |
download | libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.gz libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.bz2 libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.xz libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.zip |
The reorg is being put in trunk, I think it's ready. Now we just get to find
out how many applications won't work anymore :)
Diffstat (limited to 'src/tafwriter.cpp')
-rw-r--r-- | src/tafwriter.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/tafwriter.cpp b/src/tafwriter.cpp new file mode 100644 index 0000000..6b505ef --- /dev/null +++ b/src/tafwriter.cpp | |||
@@ -0,0 +1,70 @@ | |||
1 | #include "tafwriter.h" | ||
2 | |||
3 | Bu::TafWriter::TafWriter( Bu::Stream &sOut ) : | ||
4 | sOut( sOut ) | ||
5 | { | ||
6 | } | ||
7 | |||
8 | Bu::TafWriter::~TafWriter() | ||
9 | { | ||
10 | } | ||
11 | |||
12 | void Bu::TafWriter::writeGroup( const Bu::TafGroup *pRoot ) | ||
13 | { | ||
14 | sOut.write("{", 1 ); | ||
15 | writeString( pRoot->getName() ); | ||
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 | } | ||
35 | sOut.write("}", 1 ); | ||
36 | } | ||
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 | |||
56 | void Bu::TafWriter::writeString( const Bu::FString &str ) | ||
57 | { | ||
58 | if( str.getStr() == NULL ) | ||
59 | return; | ||
60 | sOut.write("\"", 1 ); | ||
61 | for( const char *s = str.getStr(); *s; s++ ) | ||
62 | { | ||
63 | if( *s == '\"' ) | ||
64 | sOut.write("\\\"", 2 ); | ||
65 | else | ||
66 | sOut.write( s, 1 ); | ||
67 | } | ||
68 | sOut.write("\"", 1 ); | ||
69 | } | ||
70 | |||