summaryrefslogtreecommitdiff
path: root/src/tafreader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tafreader.cpp')
-rw-r--r--src/tafreader.cpp47
1 files changed, 20 insertions, 27 deletions
diff --git a/src/tafreader.cpp b/src/tafreader.cpp
index 91aa9f2..3bca3d1 100644
--- a/src/tafreader.cpp
+++ b/src/tafreader.cpp
@@ -2,6 +2,8 @@
2#include "bu/exceptions.h" 2#include "bu/exceptions.h"
3#include "bu/fstring.h" 3#include "bu/fstring.h"
4 4
5using namespace Bu;
6
5Bu::TafReader::TafReader( Bu::Stream &sIn ) : 7Bu::TafReader::TafReader( Bu::Stream &sIn ) :
6 sIn( sIn ) 8 sIn( sIn )
7{ 9{
@@ -13,22 +15,18 @@ Bu::TafReader::~TafReader()
13{ 15{
14} 16}
15 17
18Bu::TafNode *Bu::TafReader::readNode()
19{
20}
21
16void Bu::TafReader::node() 22void Bu::TafReader::node()
17{ 23{
18 ws(); 24 ws();
19 if( c != '{' ) 25 if( c != '{' )
20 throw Bu::TafException("Expected '{'"); 26 throw TafException("Expected '{'");
21 next(); 27 next();
22 ws(); 28 ws();
23 Bu::FString sName; 29 FString sName = readStr();
24 for(;;)
25 {
26 if( c == ':' )
27 break;
28 else
29 sName += c;
30 next();
31 }
32 next(); 30 next();
33 printf("Node[%s]:\n", sName.getStr() ); 31 printf("Node[%s]:\n", sName.getStr() );
34 32
@@ -56,15 +54,7 @@ void Bu::TafReader::nodeContent()
56 54
57void Bu::TafReader::nodeProperty() 55void Bu::TafReader::nodeProperty()
58{ 56{
59 Bu::FString sName; 57 FString sName = readStr();
60 for(;;)
61 {
62 if( isws() || c == '=' )
63 break;
64 else
65 sName += c;
66 next();
67 }
68 ws(); 58 ws();
69 if( c != '=' ) 59 if( c != '=' )
70 { 60 {
@@ -72,8 +62,14 @@ void Bu::TafReader::nodeProperty()
72 return; 62 return;
73 } 63 }
74 next(); 64 next();
65 FString sValue = readStr();
66 printf(" %s = %s\n", sName.getStr(), sValue.getStr() );
67}
68
69Bu::FString Bu::TafReader::readStr()
70{
75 ws(); 71 ws();
76 Bu::FString sValue; 72 FString s;
77 if( c == '"' ) 73 if( c == '"' )
78 { 74 {
79 next(); 75 next();
@@ -98,7 +94,7 @@ void Bu::TafReader::nodeProperty()
98 } 94 }
99 else if( c == '"' ) 95 else if( c == '"' )
100 break; 96 break;
101 sValue += c; 97 s += c;
102 next(); 98 next();
103 } 99 }
104 next(); 100 next();
@@ -107,17 +103,14 @@ void Bu::TafReader::nodeProperty()
107 { 103 {
108 for(;;) 104 for(;;)
109 { 105 {
110 if( isws() || c == '}' || c == '{' ) 106 if( isws() || c == '}' || c == '{' || c == ':' || c == '=' )
111 break; 107 break;
112 sValue += c; 108 s += c;
113 next(); 109 next();
114 } 110 }
115 } 111 }
116 printf(" %s = %s\n", sName.getStr(), sValue.getStr() );
117}
118 112
119FString Bu::TafReader::readStr() 113 return s;
120{
121} 114}
122 115
123void Bu::TafReader::ws() 116void Bu::TafReader::ws()