MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / escapeString

Function escapeString

src/simulate/runtime_string.cpp:433–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

431 }
432
433 string escapeString ( const string & input, bool das_escape ) {
434 const char* str = input.c_str();
435 const char* strEnd = str + input.length();
436 string result;
437 result.reserve(input.size());
438 for( ; str < strEnd; ++str ) {
439 auto ch = uint8_t(*str);
440 switch ( ch ) {
441 case '\"': result.append("\\\""); break;
442 case '\\': result.append("\\\\"); break;
443 case '\b': result.append("\\b"); break;
444 case '\v': result.append("\\v"); break;
445 case '\f': result.append("\\f"); break;
446 case '\n': result.append("\\n"); break;
447 case '\r': result.append("\\r"); break;
448 case '\t': result.append("\\t"); break;
449 case '{': if (das_escape) result.append("\\{"); else result.append("{"); break;
450 case '}': if (das_escape) result.append("\\}"); else result.append("}"); break;
451 default:
452 if ( ch <= 0x1f ) {
453 result.append("\\u00");
454 const char tohex[] = "0123456789abcdef";
455 result.append(1,tohex[ch>>4]);
456 result.append(1,tohex[ch&15]);
457 } else {
458 result.append(1, ch);
459 }
460 break;
461 }
462 }
463 return result;
464 }
465
466 static string getFewLines ( const char* st, uint32_t stlen, int ROW, int COL, int /*LROW*/, int LCOL, int TAB ) {
467 TextWriter text;

Callers 8

argMethod · 0.85
StringMethod · 0.85
beforeTableValueMethod · 0.85
presentStrFunction · 0.85
visitMethod · 0.85
builtin_string_escapeFunction · 0.85
StringMethod · 0.85

Calls 5

c_strMethod · 0.45
lengthMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected