diff options
Diffstat (limited to '')
| -rw-r--r-- | src/tafreader.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/tafreader.cpp b/src/tafreader.cpp index 5fe303b..1187176 100644 --- a/src/tafreader.cpp +++ b/src/tafreader.cpp | |||
| @@ -5,10 +5,9 @@ | |||
| 5 | using namespace Bu; | 5 | using namespace Bu; |
| 6 | 6 | ||
| 7 | Bu::TafReader::TafReader( Bu::Stream &sIn ) : | 7 | Bu::TafReader::TafReader( Bu::Stream &sIn ) : |
| 8 | c( 0 ), | ||
| 8 | sIn( sIn ) | 9 | sIn( sIn ) |
| 9 | { | 10 | { |
| 10 | next(); | ||
| 11 | node(); | ||
| 12 | } | 11 | } |
| 13 | 12 | ||
| 14 | Bu::TafReader::~TafReader() | 13 | Bu::TafReader::~TafReader() |
| @@ -16,55 +15,58 @@ Bu::TafReader::~TafReader() | |||
| 16 | 15 | ||
| 17 | } | 16 | } |
| 18 | 17 | ||
| 19 | Bu::TafNode *Bu::TafReader::readNode() | 18 | Bu::TafNode *Bu::TafReader::getNode() |
| 20 | { | ||
| 21 | } | ||
| 22 | |||
| 23 | void Bu::TafReader::node() | ||
| 24 | { | 19 | { |
| 20 | if( c == 0 ) next(); | ||
| 21 | TafNode *pNode = new TafNode(); | ||
| 25 | ws(); | 22 | ws(); |
| 26 | if( c != '{' ) | 23 | if( c != '{' ) |
| 27 | throw TafException("Expected '{'"); | 24 | throw TafException("Expected '{'"); |
| 28 | next(); | 25 | next(); |
| 29 | ws(); | 26 | ws(); |
| 30 | FString sName = readStr(); | 27 | FString sName = readStr(); |
| 28 | pNode->setName( sName ); | ||
| 31 | next(); | 29 | next(); |
| 32 | printf("Node[%s]:\n", sName.getStr() ); | 30 | //printf("Node[%s]:\n", sName.getStr() ); |
| 33 | 31 | ||
| 34 | nodeContent(); | 32 | nodeContent( pNode ); |
| 35 | 33 | ||
| 36 | if( c != '}' ) | 34 | if( c != '}' ) |
| 37 | throw TafException("Expected '}'"); | 35 | throw TafException("Expected '}'"); |
| 38 | 36 | ||
| 39 | next(); | 37 | next(); |
| 38 | |||
| 39 | return pNode; | ||
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | void Bu::TafReader::nodeContent() | 42 | void Bu::TafReader::nodeContent( Bu::TafNode *pNode ) |
| 43 | { | 43 | { |
| 44 | for(;;) | 44 | for(;;) |
| 45 | { | 45 | { |
| 46 | ws(); | 46 | ws(); |
| 47 | if( c == '{' ) | 47 | if( c == '{' ) |
| 48 | node(); | 48 | pNode->addChild( getNode() ); |
| 49 | else if( c == '}' ) | 49 | else if( c == '}' ) |
| 50 | return; | 50 | return; |
| 51 | else | 51 | else |
| 52 | nodeProperty(); | 52 | nodeProperty( pNode ); |
| 53 | } | 53 | } |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | void Bu::TafReader::nodeProperty() | 56 | void Bu::TafReader::nodeProperty( Bu::TafNode *pNode ) |
| 57 | { | 57 | { |
| 58 | FString sName = readStr(); | 58 | FString sName = readStr(); |
| 59 | ws(); | 59 | ws(); |
| 60 | if( c != '=' ) | 60 | if( c != '=' ) |
| 61 | { | 61 | { |
| 62 | printf(" %s (true)\n", sName.getStr() ); | 62 | //printf(" %s (true)\n", sName.getStr() ); |
| 63 | pNode->setProperty( sName, "" ); | ||
| 63 | return; | 64 | return; |
| 64 | } | 65 | } |
| 65 | next(); | 66 | next(); |
| 66 | FString sValue = readStr(); | 67 | FString sValue = readStr(); |
| 67 | printf(" %s = %s\n", sName.getStr(), sValue.getStr() ); | 68 | pNode->setProperty( sName, sValue ); |
| 69 | //printf(" %s = %s\n", sName.getStr(), sValue.getStr() ); | ||
| 68 | } | 70 | } |
| 69 | 71 | ||
| 70 | Bu::FString Bu::TafReader::readStr() | 72 | Bu::FString Bu::TafReader::readStr() |
