MCPcopy Create free account
hub / github.com/baldurk/renderdoc / HexDecode

Function HexDecode

renderdoc/serialise/codecs/xml_codec.cpp:187–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187static void HexDecode(const char *str, const char *end, bytebuf &out)
188{
189 out.reserve((end - str) / 2);
190
191 if(str[0] == '\n')
192 str++;
193
194 while(str + 1 < end)
195 {
196 if(IsHex(str[0]) && IsHex(str[1]))
197 {
198 out.push_back(byte((FromHex(str[0]) << 4) | FromHex(str[1])));
199
200 str += 2;
201
202 // allow a space after hex, as a byte group
203 if(str[0] == ' ')
204 str++;
205
206 // if we encounter more spaces though, it indicates the end of a line.
207 }
208 else
209 {
210 // on the first non-hex char we encounter, skip to the next newline. This might do nothing if
211 // the char itself was a newline.
212 while(str[0] != '\n' && str < end)
213 str++;
214
215 // the loop above terminates in two ways - when it encounters a newline or when it reaches the
216 // end of the string. We can just assume we encountered a newline and increment past it - if
217 // we're already past the end, going further past will still make us fail the loop condition
218 // and terminate.
219 str++;
220 }
221 }
222}
223
224static bool Obj2XML(pugi::xml_node &parent, SDObject &child)
225{

Callers 1

XML2StructuredFunction · 0.85

Calls 4

IsHexFunction · 0.85
FromHexFunction · 0.85
reserveMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected