ReactOS 0.4.16-dev-289-g096a551
XMLStorage::Buffer Struct Reference

line buffer for XS-native parser More...

Public Member Functions

 Buffer ()
 
 ~Buffer ()
 
void reset ()
 
void append (int c)
 
const std::string & str (bool utf8)
 
size_t len () const
 
bool has_CDEnd () const
 
XS_String get_tag () const
 
void get_attributes (XMLNode::AttributeMap &attributes) const
 read attributes and values
 

Protected Attributes

char_buffer
 
char_wptr
 
size_t _len
 
std::string _buffer_str
 

Detailed Description

line buffer for XS-native parser

Definition at line 77 of file xs-native.cpp.

Constructor & Destructor Documentation

◆ Buffer()

XMLStorage::Buffer::Buffer ( )
inline

Definition at line 79 of file xs-native.cpp.

80 {
81 _buffer = (char*) malloc(BUFFER_LEN);
83
84 reset();
85 }
#define malloc
Definition: debug_ros.c:4
#define BUFFER_LEN
Definition: utility.h:97

◆ ~Buffer()

XMLStorage::Buffer::~Buffer ( )
inline

Definition at line 87 of file xs-native.cpp.

88 {
90 }
#define free
Definition: debug_ros.c:5

Member Function Documentation

◆ append()

void XMLStorage::Buffer::append ( int  c)
inline

Definition at line 98 of file xs-native.cpp.

99 {
100 size_t wpos = _wptr-_buffer;
101
102 if (wpos >= _len) {
103 _len <<= 1;
104 _buffer = (char*) realloc(_buffer, _len);
105 _wptr = _buffer + wpos;
106 }
107
108 *_wptr++ = static_cast<char>(c);
109 }
#define realloc
Definition: debug_ros.c:6
#define c
Definition: ke_i.h:80

◆ get_attributes()

void XMLStorage::Buffer::get_attributes ( XMLNode::AttributeMap attributes) const
inline

read attributes and values

Definition at line 165 of file xs-native.cpp.

166 {
167 const char* p = _buffer_str.c_str();
168
169 // find end of tag name
170 if (*p == '<')
171 ++p;
172
173 if (*p == '/')
174 ++p;
175 else if (*p == '?')
176 ++p;
177
179
180 // read attributes from buffer
181 while(*p && *p!='>' && *p!='/') {
182 while(isspace((unsigned char)*p))
183 ++p;
184
185 const char* attr_name = p;
186
188
189 if (*p != '=')
190 break; //@TODO error handling
191
192 size_t attr_len = p - attr_name;
193
194 if (*++p!='"' && *p!='\'')
195 break; //@TODO error handling
196
197 char delim = *p;
198 const char* value = ++p;
199
200 while(*p && *p!=delim)
201 ++p;
202
203 size_t value_len = p - value;
204
205 if (*p)
206 ++p; // '"'
207
208#ifdef XS_STRING_UTF8
209 XS_String name_str(attr_name, attr_len);
210#else
211 XS_String name_str;
212 assign_utf8(name_str, attr_name, attr_len);
213#endif
214
215 attributes[name_str] = DecodeXMLString(std::string(value, value_len));
216 }
217 }
#define isspace(c)
Definition: acclib.h:69
GLfloat GLfloat p
Definition: glext.h:8902
const char * get_xmlsym_end_utf8(const char *p)
Definition: xmlstorage.cpp:682
XS_String DecodeXMLString(const std::string &str)
decode XML string literals
Definition: xmlstorage.cpp:478
std::string _buffer_str
Definition: xs-native.cpp:223
Definition: pdh_main.c:94

◆ get_tag()

XS_String XMLStorage::Buffer::get_tag ( ) const
inline

Definition at line 138 of file xs-native.cpp.

139 {
140 const char* p = _buffer_str.c_str();
141
142 if (*p == '<')
143 ++p;
144
145 if (*p == '/')
146 ++p;
147
148 const char* q = p;
149
150 if (*q == '?')
151 ++q;
152
154
155#ifdef XS_STRING_UTF8
156 return XS_String(p, q-p);
157#else
158 XS_String tag;
159 assign_utf8(tag, p, q-p);
160 return tag;
161#endif
162 }
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
Definition: ecma_167.h:138

◆ has_CDEnd()

bool XMLStorage::Buffer::has_CDEnd ( ) const
inline

Definition at line 130 of file xs-native.cpp.

131 {
132 //if (_wptr-_buffer < 3)
133 // return false;
134
135 return !strncmp(_wptr-3, CDATA_END, 3);
136 }
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define CDATA_END
Definition: xmlstorage.h:436

◆ len()

size_t XMLStorage::Buffer::len ( ) const
inline

Definition at line 125 of file xs-native.cpp.

126 {
127 return _wptr - _buffer;
128 }

◆ reset()

void XMLStorage::Buffer::reset ( )
inline

Definition at line 92 of file xs-native.cpp.

93 {
94 _wptr = _buffer;
95 _buffer_str.erase();
96 }

Referenced by Buffer().

◆ str()

const std::string & XMLStorage::Buffer::str ( bool  utf8)
inline

Definition at line 111 of file xs-native.cpp.

112 {
113#if defined(_WIN32) && !defined(XS_STRING_UTF8)
114 if (utf8)
115#endif
117#if defined(_WIN32) && !defined(XS_STRING_UTF8)
118 else
119 _buffer_str = get_utf8(_buffer, _wptr-_buffer);
120#endif
121
122 return _buffer_str;
123 }

Member Data Documentation

◆ _buffer

char* XMLStorage::Buffer::_buffer
protected

Definition at line 220 of file xs-native.cpp.

Referenced by append(), Buffer(), len(), reset(), str(), and ~Buffer().

◆ _buffer_str

std::string XMLStorage::Buffer::_buffer_str
protected

Definition at line 223 of file xs-native.cpp.

Referenced by get_attributes(), get_tag(), reset(), and str().

◆ _len

size_t XMLStorage::Buffer::_len
protected

Definition at line 222 of file xs-native.cpp.

Referenced by append(), and Buffer().

◆ _wptr

char* XMLStorage::Buffer::_wptr
protected

Definition at line 221 of file xs-native.cpp.

Referenced by append(), has_CDEnd(), len(), reset(), and str().


The documentation for this struct was generated from the following file: