diff options
Diffstat (limited to '')
-rw-r--r-- | src/entities/bu-class | 46 | ||||
-rw-r--r-- | src/list.h | 20 | ||||
-rw-r--r-- | src/tafdocument.cpp | 9 | ||||
-rw-r--r-- | src/tafdocument.h | 22 | ||||
-rw-r--r-- | src/tafnode.cpp | 16 | ||||
-rw-r--r-- | src/tafnode.h | 17 | ||||
-rw-r--r-- | src/tafreader.cpp | 47 | ||||
-rw-r--r-- | src/tafreader.h | 12 |
8 files changed, 125 insertions, 64 deletions
diff --git a/src/entities/bu-class b/src/entities/bu-class new file mode 100644 index 0000000..81e3d25 --- /dev/null +++ b/src/entities/bu-class | |||
@@ -0,0 +1,46 @@ | |||
1 | <?xml version="1.1" ?> | ||
2 | <entity desc="Basic cpp class, with optional parent class. (.cpp+.h)"> | ||
3 | <param name="name" required="yes" desc="Name of the class"/> | ||
4 | <param name="parent" required="no" desc="Name of the parent class"/> | ||
5 | <file | ||
6 | name="header" | ||
7 | filename="{=name:%tolower}.h" | ||
8 | >#ifndef {=name:%uccsplit:%toupper}_H | ||
9 | #define {=name:%uccsplit:%toupper}_H | ||
10 | |||
11 | #include <stdint.h> | ||
12 | |||
13 | {?parent:"#include \"{=parent:%tolower}.h\" | ||
14 | |||
15 | "}namespace Bu | ||
16 | { | ||
17 | /** | ||
18 | * | ||
19 | */ | ||
20 | class {=name}{?parent:" : public {=parent}"} | ||
21 | { | ||
22 | public: | ||
23 | {=name}(); | ||
24 | virtual ~{=name}(); | ||
25 | |||
26 | private: | ||
27 | |||
28 | }; | ||
29 | } | ||
30 | |||
31 | #endif | ||
32 | </file> | ||
33 | <file | ||
34 | name="source" | ||
35 | filename="{=name:%tolower}.cpp" | ||
36 | >#include "bu/{=name:%tolower}.h" | ||
37 | |||
38 | Bu::{=name}::{=name}() | ||
39 | { | ||
40 | } | ||
41 | |||
42 | Bu::{=name}::~{=name}() | ||
43 | { | ||
44 | } | ||
45 | </file> | ||
46 | </entity> | ||
@@ -344,6 +344,26 @@ namespace Bu | |||
344 | { | 344 | { |
345 | return nSize; | 345 | return nSize; |
346 | } | 346 | } |
347 | |||
348 | value &first() | ||
349 | { | ||
350 | return *pFirst->pValue; | ||
351 | } | ||
352 | |||
353 | const value &first() const | ||
354 | { | ||
355 | return *pFirst->pValue; | ||
356 | } | ||
357 | |||
358 | value &last() | ||
359 | { | ||
360 | return *pLast->pValue; | ||
361 | } | ||
362 | |||
363 | const value &last() const | ||
364 | { | ||
365 | return *pLast->pValue; | ||
366 | } | ||
347 | 367 | ||
348 | private: | 368 | private: |
349 | Link *pFirst; | 369 | Link *pFirst; |
diff --git a/src/tafdocument.cpp b/src/tafdocument.cpp deleted file mode 100644 index bd44dd5..0000000 --- a/src/tafdocument.cpp +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | #include "tafdocument.h" | ||
2 | |||
3 | Bu::TafDocument::TafDocument() | ||
4 | { | ||
5 | } | ||
6 | |||
7 | Bu::TafDocument::~TafDocument() | ||
8 | { | ||
9 | } | ||
diff --git a/src/tafdocument.h b/src/tafdocument.h deleted file mode 100644 index 171f829..0000000 --- a/src/tafdocument.h +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | #ifndef BU_TAF_DOCUMENT_H | ||
2 | #define BU_TAF_DOCUMENT_H | ||
3 | |||
4 | #include <stdint.h> | ||
5 | |||
6 | namespace Bu | ||
7 | { | ||
8 | /** | ||
9 | * | ||
10 | */ | ||
11 | class TafDocument | ||
12 | { | ||
13 | public: | ||
14 | TafDocument(); | ||
15 | virtual ~TafDocument(); | ||
16 | |||
17 | private: | ||
18 | |||
19 | }; | ||
20 | } | ||
21 | |||
22 | #endif | ||
diff --git a/src/tafnode.cpp b/src/tafnode.cpp index c9756ec..01880d9 100644 --- a/src/tafnode.cpp +++ b/src/tafnode.cpp | |||
@@ -7,3 +7,19 @@ Bu::TafNode::TafNode() | |||
7 | Bu::TafNode::~TafNode() | 7 | Bu::TafNode::~TafNode() |
8 | { | 8 | { |
9 | } | 9 | } |
10 | |||
11 | void Bu::TafNode::setProperty( Bu::FString sName, Bu::FString sValue ) | ||
12 | { | ||
13 | if( hProp.has( sName ) ) | ||
14 | { | ||
15 | hProp.insert( sName, PropList() ); | ||
16 | } | ||
17 | |||
18 | hProp.get( sName ).append( sValue ); | ||
19 | } | ||
20 | |||
21 | const Bu::TafNode::PropList &Bu::TafNode::getProperty( const Bu::FString &sName ) | ||
22 | { | ||
23 | return hProp.get( sName ); | ||
24 | } | ||
25 | |||
diff --git a/src/tafnode.h b/src/tafnode.h index 34f5289..e962e88 100644 --- a/src/tafnode.h +++ b/src/tafnode.h | |||
@@ -2,6 +2,9 @@ | |||
2 | #define BU_TAF_NODE_H | 2 | #define BU_TAF_NODE_H |
3 | 3 | ||
4 | #include <stdint.h> | 4 | #include <stdint.h> |
5 | #include "bu/fstring.h" | ||
6 | #include "bu/hash.h" | ||
7 | #include "bu/list.h" | ||
5 | 8 | ||
6 | namespace Bu | 9 | namespace Bu |
7 | { | 10 | { |
@@ -11,11 +14,23 @@ namespace Bu | |||
11 | class TafNode | 14 | class TafNode |
12 | { | 15 | { |
13 | public: | 16 | public: |
17 | typedef Bu::List<Bu::FString> PropList; | ||
18 | typedef Bu::Hash<Bu::FString, PropList> PropHash; | ||
19 | typedef Bu::List<TafNode *> NodeList; | ||
20 | typedef Bu::Hash<Bu::FString, NodeList> NodeHash; | ||
21 | |||
22 | public: | ||
14 | TafNode(); | 23 | TafNode(); |
15 | virtual ~TafNode(); | 24 | virtual ~TafNode(); |
16 | 25 | ||
17 | private: | 26 | void setProperty( Bu::FString sName, Bu::FString sValue ); |
27 | const PropList &getProperty( const Bu::FString &sName ); | ||
18 | 28 | ||
29 | private: | ||
30 | Bu::FString sName; | ||
31 | PropHash hProp; | ||
32 | NodeHash hChildren; | ||
19 | }; | 33 | }; |
20 | } | 34 | } |
35 | |||
21 | #endif | 36 | #endif |
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 | ||
5 | using namespace Bu; | ||
6 | |||
5 | Bu::TafReader::TafReader( Bu::Stream &sIn ) : | 7 | Bu::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 | ||
18 | Bu::TafNode *Bu::TafReader::readNode() | ||
19 | { | ||
20 | } | ||
21 | |||
16 | void Bu::TafReader::node() | 22 | void 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 | ||
57 | void Bu::TafReader::nodeProperty() | 55 | void 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 | |||
69 | Bu::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 | ||
119 | FString Bu::TafReader::readStr() | 113 | return s; |
120 | { | ||
121 | } | 114 | } |
122 | 115 | ||
123 | void Bu::TafReader::ws() | 116 | void Bu::TafReader::ws() |
diff --git a/src/tafreader.h b/src/tafreader.h index 127b571..4da800c 100644 --- a/src/tafreader.h +++ b/src/tafreader.h | |||
@@ -2,20 +2,23 @@ | |||
2 | #define BU_TAF_READER_H | 2 | #define BU_TAF_READER_H |
3 | 3 | ||
4 | #include <stdint.h> | 4 | #include <stdint.h> |
5 | #include "bu/tafdocument.h" | 5 | #include "bu/tafnode.h" |
6 | #include "bu/stream.h" | 6 | #include "bu/stream.h" |
7 | #include "bu/fstring.h" | ||
7 | 8 | ||
8 | namespace Bu | 9 | namespace Bu |
9 | { | 10 | { |
10 | /** | 11 | /** |
11 | * | 12 | * |
12 | */ | 13 | */ |
13 | class TafReader : public Bu::TafDocument | 14 | class TafReader |
14 | { | 15 | { |
15 | public: | 16 | public: |
16 | TafReader( Bu::Stream &sIn ); | 17 | TafReader( Bu::Stream &sIn ); |
17 | virtual ~TafReader(); | 18 | virtual ~TafReader(); |
18 | 19 | ||
20 | Bu::TafNode *readNode(); | ||
21 | |||
19 | private: | 22 | private: |
20 | void node(); | 23 | void node(); |
21 | void nodeContent(); | 24 | void nodeContent(); |
@@ -23,10 +26,9 @@ namespace Bu | |||
23 | void ws(); | 26 | void ws(); |
24 | bool isws(); | 27 | bool isws(); |
25 | void next(); | 28 | void next(); |
26 | FString readStr(); | 29 | Bu::FString readStr(); |
27 | char c; | 30 | char c; |
28 | Stream &sIn; | 31 | Bu::Stream &sIn; |
29 | |||
30 | }; | 32 | }; |
31 | } | 33 | } |
32 | 34 | ||