diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/tafnode.cpp | 10 | ||||
| -rw-r--r-- | src/tafnode.h | 4 | ||||
| -rw-r--r-- | src/tafreader.cpp | 41 | ||||
| -rw-r--r-- | src/tafreader.h | 2 | ||||
| -rw-r--r-- | src/tafwriter.cpp | 15 |
5 files changed, 56 insertions, 16 deletions
diff --git a/src/tafnode.cpp b/src/tafnode.cpp index c04455b..ec51535 100644 --- a/src/tafnode.cpp +++ b/src/tafnode.cpp | |||
| @@ -141,9 +141,10 @@ const Bu::FString &Bu::TafProperty::getValue() const | |||
| 141 | return sValue; | 141 | return sValue; |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | Bu::TafComment::TafComment( const Bu::FString &sText ) : | 144 | Bu::TafComment::TafComment( const Bu::FString &sText, bool bEOL ) : |
| 145 | TafNode( typeComment ), | 145 | TafNode( typeComment ), |
| 146 | sText( sText ) | 146 | sText( sText ), |
| 147 | bEOL( bEOL ) | ||
| 147 | { | 148 | { |
| 148 | } | 149 | } |
| 149 | 150 | ||
| @@ -156,3 +157,8 @@ const Bu::FString &Bu::TafComment::getText() const | |||
| 156 | return sText; | 157 | return sText; |
| 157 | } | 158 | } |
| 158 | 159 | ||
| 160 | bool Bu::TafComment::isEOLStyle() const | ||
| 161 | { | ||
| 162 | return bEOL; | ||
| 163 | } | ||
| 164 | |||
diff --git a/src/tafnode.h b/src/tafnode.h index 585ba73..e2e1cc0 100644 --- a/src/tafnode.h +++ b/src/tafnode.h | |||
| @@ -98,13 +98,15 @@ namespace Bu | |||
| 98 | class TafComment : public TafNode | 98 | class TafComment : public TafNode |
| 99 | { | 99 | { |
| 100 | public: | 100 | public: |
| 101 | TafComment( const Bu::FString &sText ); | 101 | TafComment( const Bu::FString &sText, bool bEOL=false ); |
| 102 | virtual ~TafComment(); | 102 | virtual ~TafComment(); |
| 103 | 103 | ||
| 104 | const Bu::FString &getText() const; | 104 | const Bu::FString &getText() const; |
| 105 | bool isEOLStyle() const; | ||
| 105 | 106 | ||
| 106 | private: | 107 | private: |
| 107 | Bu::FString sText; | 108 | Bu::FString sText; |
| 109 | bool bEOL; | ||
| 108 | }; | 110 | }; |
| 109 | } | 111 | } |
| 110 | 112 | ||
diff --git a/src/tafreader.cpp b/src/tafreader.cpp index 5609f7c..efcb3d9 100644 --- a/src/tafreader.cpp +++ b/src/tafreader.cpp | |||
| @@ -49,6 +49,8 @@ void Bu::TafReader::groupContent( Bu::TafGroup *pGroup ) | |||
| 49 | return; | 49 | return; |
| 50 | else if( c == '/' && la == '*' ) | 50 | else if( c == '/' && la == '*' ) |
| 51 | pGroup->addChild( readComment() ); | 51 | pGroup->addChild( readComment() ); |
| 52 | else if( c == '/' && la == '/' ) | ||
| 53 | pGroup->addChild( readComment( true ) ); | ||
| 52 | else if( c == ':' ) | 54 | else if( c == ':' ) |
| 53 | throw TafException("Encountered stray ':' in taf stream."); | 55 | throw TafException("Encountered stray ':' in taf stream."); |
| 54 | else | 56 | else |
| @@ -71,22 +73,43 @@ Bu::TafProperty *Bu::TafReader::readProperty() | |||
| 71 | //printf(" %s = %s\n", sName.getStr(), sValue.getStr() ); | 73 | //printf(" %s = %s\n", sName.getStr(), sValue.getStr() ); |
| 72 | } | 74 | } |
| 73 | 75 | ||
| 74 | Bu::TafComment *Bu::TafReader::readComment() | 76 | Bu::TafComment *Bu::TafReader::readComment( bool bEOL ) |
| 75 | { | 77 | { |
| 76 | next(); | ||
| 77 | FString sCmnt; | 78 | FString sCmnt; |
| 78 | for(;;) | 79 | next(); |
| 80 | if( bEOL ) | ||
| 79 | { | 81 | { |
| 80 | next(); | 82 | for(;;) |
| 81 | if( c == '*' && la == '/' ) | ||
| 82 | { | 83 | { |
| 83 | next(); next(); | 84 | next(); |
| 84 | break; | 85 | if( c == '\n' && la == '\r' ) |
| 86 | { | ||
| 87 | next(); next(); | ||
| 88 | break; | ||
| 89 | } | ||
| 90 | else if( c == '\n' || c == '\r' ) | ||
| 91 | { | ||
| 92 | next(); | ||
| 93 | break; | ||
| 94 | } | ||
| 95 | sCmnt += c; | ||
| 96 | } | ||
| 97 | } | ||
| 98 | else | ||
| 99 | { | ||
| 100 | for(;;) | ||
| 101 | { | ||
| 102 | next(); | ||
| 103 | if( c == '*' && la == '/' ) | ||
| 104 | { | ||
| 105 | next(); next(); | ||
| 106 | break; | ||
| 107 | } | ||
| 108 | sCmnt += c; | ||
| 85 | } | 109 | } |
| 86 | sCmnt += c; | ||
| 87 | } | 110 | } |
| 88 | 111 | ||
| 89 | return new TafComment( sCmnt ); | 112 | return new TafComment( sCmnt, bEOL ); |
| 90 | } | 113 | } |
| 91 | 114 | ||
| 92 | Bu::FString Bu::TafReader::readStr() | 115 | Bu::FString Bu::TafReader::readStr() |
diff --git a/src/tafreader.h b/src/tafreader.h index da285ab..f722ca4 100644 --- a/src/tafreader.h +++ b/src/tafreader.h | |||
| @@ -23,7 +23,7 @@ namespace Bu | |||
| 23 | private: | 23 | private: |
| 24 | void groupContent( Bu::TafGroup *pNode ); | 24 | void groupContent( Bu::TafGroup *pNode ); |
| 25 | Bu::TafProperty *readProperty(); | 25 | Bu::TafProperty *readProperty(); |
| 26 | Bu::TafComment *readComment(); | 26 | Bu::TafComment *readComment( bool bEOL=false ); |
| 27 | void ws(); | 27 | void ws(); |
| 28 | bool isws(); | 28 | bool isws(); |
| 29 | void next(); | 29 | void next(); |
diff --git a/src/tafwriter.cpp b/src/tafwriter.cpp index b5690fc..c2fbc50 100644 --- a/src/tafwriter.cpp +++ b/src/tafwriter.cpp | |||
| @@ -65,9 +65,18 @@ void Bu::TafWriter::writeProperty( const Bu::TafProperty *pProp ) | |||
| 65 | void Bu::TafWriter::writeComment( const Bu::TafComment *pComment ) | 65 | void Bu::TafWriter::writeComment( const Bu::TafComment *pComment ) |
| 66 | { | 66 | { |
| 67 | ident(); | 67 | ident(); |
| 68 | sOut.write("/*", 2 ); | 68 | if( pComment->isEOLStyle() ) |
| 69 | sOut.write( pComment->getText().getStr(), pComment->getText().getSize() ); | 69 | { |
| 70 | sOut.write("*/ ", 3 ); | 70 | sOut.write("//", 2 ); |
| 71 | sOut.write( pComment->getText().getStr(), pComment->getText().getSize() ); | ||
| 72 | sOut.write("\n", 1 ); | ||
| 73 | } | ||
| 74 | else | ||
| 75 | { | ||
| 76 | sOut.write("/*", 2 ); | ||
| 77 | sOut.write( pComment->getText().getStr(), pComment->getText().getSize() ); | ||
| 78 | sOut.write("*/ ", 3 ); | ||
| 79 | } | ||
| 71 | } | 80 | } |
| 72 | 81 | ||
| 73 | void Bu::TafWriter::writeString( const Bu::FString &str ) | 82 | void Bu::TafWriter::writeString( const Bu::FString &str ) |
