MCPcopy Create free account
hub / github.com/MaxBelkov/visualsyslog / GetStr

Method GetStr

sourcecommon/tinyxml2.cpp:164–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162
163
164const char* StrPair::GetStr()
165{
166 if ( _flags & NEEDS_FLUSH ) {
167 *_end = 0;
168 _flags ^= NEEDS_FLUSH;
169
170 if ( _flags ) {
171 char* p = _start; // the read pointer
172 char* q = _start; // the write pointer
173
174 while( p < _end ) {
175 if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR ) {
176 // CR-LF pair becomes LF
177 // CR alone becomes LF
178 // LF-CR becomes LF
179 if ( *(p+1) == LF ) {
180 p += 2;
181 }
182 else {
183 ++p;
184 }
185 *q++ = LF;
186 }
187 else if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) {
188 if ( *(p+1) == CR ) {
189 p += 2;
190 }
191 else {
192 ++p;
193 }
194 *q++ = LF;
195 }
196 else if ( (_flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) {
197 // Entities handled by tinyXML2:
198 // - special entities in the entity table [in/out]
199 // - numeric character reference [in]
200 // &#20013; or &#x4e2d;
201
202 if ( *(p+1) == '#' ) {
203 const int buflen = 10;
204 char buf[buflen] = { 0 };
205 int len = 0;
206 p = const_cast<char*>( XMLUtil::GetCharacterRef( p, buf, &len ) );
207 TIXMLASSERT( 0 <= len && len <= buflen );
208 TIXMLASSERT( q + len <= p );
209 memcpy( q, buf, len );
210 q += len;
211 }
212 else {
213 int i=0;
214 for(; i<NUM_ENTITIES; ++i ) {
215 const Entity& entity = entities[i];
216 if ( strncmp( p + 1, entity.pattern, entity.length ) == 0
217 && *( p + entity.length + 1 ) == ';' ) {
218 // Found an entity - convert.
219 *q = entity.value;
220 ++q;
221 p += entity.length + 2;

Callers 3

ValueMethod · 0.80
ParseDeepMethod · 0.80
NameMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected