3 #ifndef INCLUDE_NN_NLIB_TAGGEDTEXTPARSER_H_ 4 #define INCLUDE_NN_NLIB_TAGGEDTEXTPARSER_H_ 23 cur_ =
reinterpret_cast<unsigned char*
>(tagged_text);
26 is_elemtag_empty_ =
false;
34 NLIB_TAGGEDTEXTPARSER_NEXT:
35 if (is_elemtag_empty_) {
36 is_elemtag_empty_ =
false;
49 if (chr_ ==
'\0')
return END_DOCUMENT;
51 unsigned char* p = cur_;
53 if (c ==
'?' || c ==
'!') {
56 unsigned char* p2 = GotoGT(p);
57 if (*p2 ==
'\0')
goto NLIB_TAGGEDTEXTPARSER_ERROR;
60 cur_ = *p2 !=
'\0' ? p2 + 1 : p2;
61 goto NLIB_TAGGEDTEXTPARSER_NEXT;
62 }
else if (c ==
'/') {
66 unsigned char* p2 = SpotName(p);
68 unsigned char* p3 = GotoGT(p2);
69 if (*p3 ==
'\0')
goto NLIB_TAGGEDTEXTPARSER_ERROR;
72 text_ =
reinterpret_cast<const char*
>(p);
75 cur_ = *p3 !=
'\0' ? p3 + 1 : p3;
79 unsigned char* p2 = SpotName(p);
81 unsigned char* p3 = GotoSlashGT(p2);
82 if (*p3 ==
'\0')
goto NLIB_TAGGEDTEXTPARSER_ERROR;
86 if (*p3 !=
'>')
goto NLIB_TAGGEDTEXTPARSER_ERROR;
87 is_elemtag_empty_ =
true;
91 text_ =
reinterpret_cast<const char*
>(p);
94 cur_ = *p3 !=
'\0' ? p3 + 1 : p3;
99 unsigned char* p = cur_ - 1;
102 if (c ==
'<' || c ==
'\0') {
103 text_ =
reinterpret_cast<const char*
>(cur_ - 1);
105 cur_ = (chr_ !=
'\0') ? p + 1 : p;
106 unsigned char* pp = p - 1;
107 while (IsSpc(*pp)) --pp;
114 NLIB_TAGGEDTEXTPARSER_ERROR:
122 static bool IsSpc(
int c) {
124 static const char table[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0,
125 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
127 return (c <= 0x20 && table[c] != 0);
129 static unsigned char* SpotName(
unsigned char* p) {
130 static const char table[] = {
131 1, 0, 0, 0, 0, 0, 0, 0, 0,
133 0, 0, 0, 0, 0, 0, 0, 0, 0,
135 1, 0, 0, 0, 0, 0, 0, 0, 0,
137 0, 0, 0, 0, 0, 0, 0, 0, 0,
143 if (c < 0x40 && table[c] != 0)
return p;
147 static unsigned char* GotoGT(
unsigned char* p) {
150 if (c ==
'>' || c ==
'\0')
return p;
154 static unsigned char* GotoSlashGT(
unsigned char* p) {
157 if (c ==
'/' || c ==
'>' || c ==
'\0')
return p;
166 bool is_elemtag_empty_;
171 #endif // INCLUDE_NN_NLIB_TAGGEDTEXTPARSER_H_ TaggedTextParser(char *tagged_text)
Instantiates the object.
const char * GetText() const
Returns the pointer to the character data obtained by the GetNext function.
Event Next()
Gets the next element or text.
A simple parser for parsing XML-like tagged text.
A file that contains the configuration information for each development environment.
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.