MCPcopy Create free account
hub / github.com/NVIDIA/DALI / escape_string

Function escape_string

include/dali/core/python_util.h:26–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24namespace dali {
25
26inline void escape_string(std::ostream &os, const char *str) {
27 const char hex[] = "0123456789abcdef";
28 while (unsigned char c = *str++) {
29 switch (c) {
30 case '\n':
31 os << "\\n";
32 break;
33 case '\r':
34 os << "\\r";
35 break;
36 case '\t':
37 os << "\\t";
38 break;
39 case '\\':
40 os << "\\\\";
41 break;
42 case '\'':
43 os << "\\\'";
44 break;
45 case '\"':
46 os << "\\\"";
47 break;
48 default:
49 if (c >= 32 && c < 128)
50 os << c;
51 else
52 os << "\\x" << hex[c >> 4] << hex[c&15];
53 break;
54 }
55 }
56}
57
58inline void escape_string(std::ostream &os, const std::string &s) {
59 escape_string(os, s.c_str());

Callers 2

TensorLayoutReprFunction · 0.85
python_reprFunction · 0.85

Calls 1

c_strMethod · 0.45

Tested by

no test coverage detected