ReactOS  0.4.11-dev-433-g473ca91
XMLStorage::Buffer Struct Reference

line buffer for XS-native parser More...

Public Member Functions

 Buffer ()
 
 ~Buffer ()
 
void reset ()
 
void append (int c)
 
const std::stringstr (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 More...
 

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

XMLStorage::Buffer::Buffer ( )
inline

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

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

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

88  {
89  free(_buffer);
90  }
#define free
Definition: debug_ros.c:5

Member Function Documentation

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

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

Referenced by XMLStorage::XMLReaderBase::parse().

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
void XMLStorage::Buffer::get_attributes ( XMLNode::AttributeMap attributes) const
inline

read attributes and values

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

Referenced by XMLStorage::XMLReaderBase::parse().

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 
178  p = get_xmlsym_end_utf8(p);
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 
187  p = get_xmlsym_end_utf8(p);
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
Definition: get.c:139
std::string _buffer_str
Definition: xs-native.cpp:223
XS_String DecodeXMLString(const std::string &str)
decode XML string literals
Definition: xmlstorage.cpp:478
const char * get_xmlsym_end_utf8(const char *p)
Definition: xmlstorage.cpp:682
GLsizei const GLfloat * value
Definition: glext.h:6069
char string[160]
Definition: util.h:11
GLfloat GLfloat p
Definition: glext.h:8902
XS_String XMLStorage::Buffer::get_tag ( ) const
inline

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

Referenced by XMLStorage::XMLReaderBase::parse().

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 
153  q = get_xmlsym_end_utf8(q);
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  }
std::string _buffer_str
Definition: xs-native.cpp:223
const char * get_xmlsym_end_utf8(const char *p)
Definition: xmlstorage.cpp:682
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLfloat GLfloat p
Definition: glext.h:8902
char * tag
Definition: main.c:59
bool XMLStorage::Buffer::has_CDEnd ( ) const
inline

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

Referenced by XMLStorage::XMLReaderBase::parse().

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
size_t XMLStorage::Buffer::len ( ) const
inline

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

126  {
127  return _wptr - _buffer;
128  }
void XMLStorage::Buffer::reset ( void  )
inline

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

Referenced by Buffer(), and XMLStorage::XMLReaderBase::parse().

93  {
94  _wptr = _buffer;
95  _buffer_str.erase();
96  }
std::string _buffer_str
Definition: xs-native.cpp:223
const std::string& XMLStorage::Buffer::str ( bool  utf8)
inline

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

Referenced by XMLStorage::XMLReaderBase::parse().

112  {
113 #if defined(_WIN32) && !defined(XS_STRING_UTF8)
114  if (utf8)
115 #endif
116  _buffer_str.assign(_buffer, _wptr-_buffer);
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  }
std::string _buffer_str
Definition: xs-native.cpp:223

Member Data Documentation

char* XMLStorage::Buffer::_buffer
protected

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

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

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().

size_t XMLStorage::Buffer::_len
protected

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

Referenced by append(), and Buffer().

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: