aboutsummaryrefslogtreecommitdiff
path: root/src/tafwriter.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tafwriter.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/tafwriter.cpp b/src/tafwriter.cpp
index 6b505ef..fe29490 100644
--- a/src/tafwriter.cpp
+++ b/src/tafwriter.cpp
@@ -1,7 +1,8 @@
1#include "tafwriter.h" 1#include "tafwriter.h"
2 2
3Bu::TafWriter::TafWriter( Bu::Stream &sOut ) : 3Bu::TafWriter::TafWriter( Bu::Stream &sOut ) :
4 sOut( sOut ) 4 sOut( sOut ),
5 iDepth( 0 )
5{ 6{
6} 7}
7 8
@@ -9,11 +10,19 @@ Bu::TafWriter::~TafWriter()
9{ 10{
10} 11}
11 12
13void Bu::TafWriter::ident()
14{
15 for( int j = 0; j < iDepth; j++ )
16 sOut.write(" ", 4 );
17}
18
12void Bu::TafWriter::writeGroup( const Bu::TafGroup *pRoot ) 19void Bu::TafWriter::writeGroup( const Bu::TafGroup *pRoot )
13{ 20{
21 ident();
14 sOut.write("{", 1 ); 22 sOut.write("{", 1 );
15 writeString( pRoot->getName() ); 23 writeString( pRoot->getName() );
16 sOut.write(": ", 2 ); 24 sOut.write(":\n", 2 );
25 iDepth++;
17 const Bu::TafGroup::NodeList &nl = pRoot->getChildren(); 26 const Bu::TafGroup::NodeList &nl = pRoot->getChildren();
18 for( Bu::TafGroup::NodeList::const_iterator i = nl.begin(); i != nl.end(); i++ ) 27 for( Bu::TafGroup::NodeList::const_iterator i = nl.begin(); i != nl.end(); i++ )
19 { 28 {
@@ -32,22 +41,26 @@ void Bu::TafWriter::writeGroup( const Bu::TafGroup *pRoot )
32 break; 41 break;
33 } 42 }
34 } 43 }
35 sOut.write("}", 1 ); 44 iDepth--;
45 ident();
46 sOut.write("}\n", 2 );
36} 47}
37 48
38void Bu::TafWriter::writeProperty( const Bu::TafProperty *pProp ) 49void Bu::TafWriter::writeProperty( const Bu::TafProperty *pProp )
39{ 50{
51 ident();
40 writeString( pProp->getName() ); 52 writeString( pProp->getName() );
41 if( pProp->getValue().getStr() != NULL ) 53 if( pProp->getValue().getStr() != NULL )
42 { 54 {
43 sOut.write("=", 1 ); 55 sOut.write("=", 1 );
44 writeString( pProp->getValue() ); 56 writeString( pProp->getValue() );
45 } 57 }
46 sOut.write(" ", 1 ); 58 sOut.write("\n", 1 );
47} 59}
48 60
49void Bu::TafWriter::writeComment( const Bu::TafComment *pComment ) 61void Bu::TafWriter::writeComment( const Bu::TafComment *pComment )
50{ 62{
63 ident();
51 sOut.write("/*", 2 ); 64 sOut.write("/*", 2 );
52 sOut.write( pComment->getText().getStr(), pComment->getText().getSize() ); 65 sOut.write( pComment->getText().getStr(), pComment->getText().getSize() );
53 sOut.write("*/ ", 3 ); 66 sOut.write("*/ ", 3 );