diff options
Diffstat (limited to '')
| -rw-r--r-- | src/stable/tafwriter.cpp | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/src/stable/tafwriter.cpp b/src/stable/tafwriter.cpp index 00d9f68..f17a237 100644 --- a/src/stable/tafwriter.cpp +++ b/src/stable/tafwriter.cpp | |||
| @@ -9,8 +9,8 @@ | |||
| 9 | #include "bu/stream.h" | 9 | #include "bu/stream.h" |
| 10 | 10 | ||
| 11 | Bu::TafWriter::TafWriter( Bu::Stream &sOut ) : | 11 | Bu::TafWriter::TafWriter( Bu::Stream &sOut ) : |
| 12 | sOut( sOut ), | 12 | sOut( sOut ), |
| 13 | iDepth( 0 ) | 13 | iDepth( 0 ) |
| 14 | { | 14 | { |
| 15 | } | 15 | } |
| 16 | 16 | ||
| @@ -20,81 +20,81 @@ Bu::TafWriter::~TafWriter() | |||
| 20 | 20 | ||
| 21 | void Bu::TafWriter::ident() | 21 | void Bu::TafWriter::ident() |
| 22 | { | 22 | { |
| 23 | for( int j = 0; j < iDepth; j++ ) | 23 | for( int j = 0; j < iDepth; j++ ) |
| 24 | sOut.write(" ", 4 ); | 24 | sOut.write(" ", 4 ); |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | void Bu::TafWriter::writeGroup( const Bu::TafGroup *pRoot ) | 27 | void Bu::TafWriter::writeGroup( const Bu::TafGroup *pRoot ) |
| 28 | { | 28 | { |
| 29 | ident(); | 29 | ident(); |
| 30 | sOut.write("{", 1 ); | 30 | sOut.write("{", 1 ); |
| 31 | if( pRoot->getName().isSet() ) | 31 | if( pRoot->getName().isSet() ) |
| 32 | writeString( pRoot->getName() ); | 32 | writeString( pRoot->getName() ); |
| 33 | sOut.write(":\n", 2 ); | 33 | sOut.write(":\n", 2 ); |
| 34 | iDepth++; | 34 | iDepth++; |
| 35 | const Bu::TafGroup::NodeList &nl = pRoot->getChildren(); | 35 | const Bu::TafGroup::NodeList &nl = pRoot->getChildren(); |
| 36 | for( Bu::TafGroup::NodeList::const_iterator i = nl.begin(); i != nl.end(); i++ ) | 36 | for( Bu::TafGroup::NodeList::const_iterator i = nl.begin(); i != nl.end(); i++ ) |
| 37 | { | 37 | { |
| 38 | switch( (*i)->getType() ) | 38 | switch( (*i)->getType() ) |
| 39 | { | 39 | { |
| 40 | case Bu::TafNode::typeGroup: | 40 | case Bu::TafNode::typeGroup: |
| 41 | writeGroup( (Bu::TafGroup *)(*i) ); | 41 | writeGroup( (Bu::TafGroup *)(*i) ); |
| 42 | break; | 42 | break; |
| 43 | 43 | ||
| 44 | case Bu::TafNode::typeProperty: | 44 | case Bu::TafNode::typeProperty: |
| 45 | writeProperty( (Bu::TafProperty *)(*i) ); | 45 | writeProperty( (Bu::TafProperty *)(*i) ); |
| 46 | break; | 46 | break; |
| 47 | 47 | ||
| 48 | case Bu::TafNode::typeComment: | 48 | case Bu::TafNode::typeComment: |
| 49 | writeComment( (Bu::TafComment *)(*i) ); | 49 | writeComment( (Bu::TafComment *)(*i) ); |
| 50 | break; | 50 | break; |
| 51 | } | 51 | } |
| 52 | } | 52 | } |
| 53 | iDepth--; | 53 | iDepth--; |
| 54 | ident(); | 54 | ident(); |
| 55 | sOut.write("}\n", 2 ); | 55 | sOut.write("}\n", 2 ); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | void Bu::TafWriter::writeProperty( const Bu::TafProperty *pProp ) | 58 | void Bu::TafWriter::writeProperty( const Bu::TafProperty *pProp ) |
| 59 | { | 59 | { |
| 60 | ident(); | 60 | ident(); |
| 61 | if( !pProp->getName().isEmpty() ) | 61 | if( !pProp->getName().isEmpty() ) |
| 62 | { | 62 | { |
| 63 | writeString( pProp->getName() ); | 63 | writeString( pProp->getName() ); |
| 64 | sOut.write("=", 1 ); | 64 | sOut.write("=", 1 ); |
| 65 | writeString( pProp->getValue() ); | 65 | writeString( pProp->getValue() ); |
| 66 | } | 66 | } |
| 67 | else | 67 | else |
| 68 | { | 68 | { |
| 69 | writeString( pProp->getValue() ); | 69 | writeString( pProp->getValue() ); |
| 70 | } | 70 | } |
| 71 | sOut.write("\n", 1 ); | 71 | sOut.write("\n", 1 ); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | void Bu::TafWriter::writeComment( const Bu::TafComment *pComment ) | 74 | void Bu::TafWriter::writeComment( const Bu::TafComment *pComment ) |
| 75 | { | 75 | { |
| 76 | ident(); | 76 | ident(); |
| 77 | if( pComment->isEOLStyle() ) | 77 | if( pComment->isEOLStyle() ) |
| 78 | { | 78 | { |
| 79 | sOut.write("//", 2 ); | 79 | sOut.write("//", 2 ); |
| 80 | sOut.write( pComment->getText().getStr(), pComment->getText().getSize() ); | 80 | sOut.write( pComment->getText().getStr(), pComment->getText().getSize() ); |
| 81 | sOut.write("\n", 1 ); | 81 | sOut.write("\n", 1 ); |
| 82 | } | 82 | } |
| 83 | else | 83 | else |
| 84 | { | 84 | { |
| 85 | sOut.write("/*", 2 ); | 85 | sOut.write("/*", 2 ); |
| 86 | sOut.write( pComment->getText().getStr(), pComment->getText().getSize() ); | 86 | sOut.write( pComment->getText().getStr(), pComment->getText().getSize() ); |
| 87 | sOut.write("*/ ", 3 ); | 87 | sOut.write("*/ ", 3 ); |
| 88 | } | 88 | } |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | void Bu::TafWriter::writeString( const Bu::String &str ) | 91 | void Bu::TafWriter::writeString( const Bu::String &str ) |
| 92 | { | 92 | { |
| 93 | sOut.write("\"", 1 ); | 93 | sOut.write("\"", 1 ); |
| 94 | for( Bu::String::const_iterator s = str.begin(); s != str.end(); s++ ) | 94 | for( Bu::String::const_iterator s = str.begin(); s != str.end(); s++ ) |
| 95 | { | 95 | { |
| 96 | if( *s == '\"' ) | 96 | if( *s == '\"' ) |
| 97 | sOut.write("\\\"", 2 ); | 97 | sOut.write("\\\"", 2 ); |
| 98 | else if( *s == '\\' ) | 98 | else if( *s == '\\' ) |
| 99 | sOut.write("\\\\", 2 ); | 99 | sOut.write("\\\\", 2 ); |
| 100 | else if( *s < 32 || *s > 126 ) | 100 | else if( *s < 32 || *s > 126 ) |
