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

Function ParseStringValue

dali/util/numpy.cc:85–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85std::string ParseStringValue(const char*& input, char delim_start = '\'', char delim_end = '\'') {
86 DALI_ENFORCE(*input++ == delim_start, make_string("Expected \'", delim_start, "\'"));
87 std::string out;
88 for (; *input != '\0'; input++) {
89 if (*input == '\\') {
90 input++;
91 DALI_ENFORCE(*input != '\0', "Unexpected end of string after escape character.");
92 switch (*input) {
93 case '\\':
94 out += '\\';
95 break;
96 case '\'':
97 out += '\'';
98 break;
99 case '\t':
100 out += '\t';
101 break;
102 case '\n':
103 out += '\n';
104 break;
105 case '\"':
106 out += '\"';
107 break;
108 default:
109 out += '\\';
110 out += *input;
111 break;
112 }
113 } else if (*input == delim_end) {
114 break;
115 } else {
116 out += *input;
117 }
118 }
119 DALI_ENFORCE(*input++ == delim_end, make_string("Expected \'", delim_end, "\'"));
120 return out;
121}
122
123void ParseHeaderContents(HeaderData& target, const std::string_view header) {
124 target.shape = {};

Callers 1

ParseHeaderContentsFunction · 0.85

Calls 1

make_stringFunction · 0.50

Tested by

no test coverage detected