MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / PrintString

Method PrintString

Engine/source/persistence/taml/fsTinyXml.cpp:286–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286void PrettyXMLPrinter::PrintString(const char* p, bool restricted)
287{
288 // Look for runs of bytes between entities to print.
289 const char* q = p;
290
291 if (mProcessEntities) {
292 const bool* flag = restricted ? mRestrictedEntityFlag : mEntityFlag;
293 while (*q) {
294 TIXMLASSERT(p <= q);
295 // Remember, char is sometimes signed. (How many times has that bitten me?)
296 if (*q > 0 && *q < ENTITY_RANGE) {
297 // Check for entities. If one is found, flush
298 // the stream up until the entity, write the
299 // entity, and keep looking.
300 if (flag[static_cast<unsigned char>(*q)]) {
301 while (p < q) {
302 const size_t delta = q - p;
303 const int toPrint = (INT_MAX < delta) ? INT_MAX : static_cast<int>(delta);
304 mInnerPrinter.Write(p, toPrint);
305 p += toPrint;
306 }
307 bool entityPatternPrinted = false;
308 for (int i = 0; i < NUM_ENTITIES; ++i) {
309 if (entities[i].value == *q) {
310 mInnerPrinter.Putc('&');
311 mInnerPrinter.Write(entities[i].pattern, entities[i].length);
312 mInnerPrinter.Putc(';');
313 entityPatternPrinted = true;
314 break;
315 }
316 }
317 if (!entityPatternPrinted) {
318 // TIXMLASSERT( entityPatternPrinted ) causes gcc -Wunused-but-set-variable in release
319 TIXMLASSERT(false);
320 }
321 ++p;
322 }
323 }
324 ++q;
325 TIXMLASSERT(p <= q);
326 }
327 // Flush the remaining string. This will be the entire
328 // string if an entity wasn't found.
329 if (p < q) {
330 const size_t delta = q - p;
331 const int toPrint = (INT_MAX < delta) ? INT_MAX : static_cast<int>(delta);
332 mInnerPrinter.Write(p, toPrint);
333 }
334 }
335 else {
336 mInnerPrinter.Write(p);
337 }
338}
339
340bool PrettyXMLPrinter::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
341{

Callers

nothing calls this directly

Calls 2

WriteMethod · 0.45
PutcMethod · 0.45

Tested by

no test coverage detected