MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / convertBytesToHexStr

Function convertBytesToHexStr

lib/common/hexstr.cpp:24–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24void convertBytesToHexStr(Span<const uint8_t> Src, std::string &Dst,
25 const uint32_t Padding, const bool IsLittleEndian) {
26 Dst.clear();
27 Dst.reserve(Src.size() * 2);
28 if (IsLittleEndian) {
29 for (auto It = Src.rbegin(); It != Src.rend(); It++) {
30 Dst += fmt::format("{:02x}", *It);
31 }
32 } else {
33 for (auto It = Src.begin(); It != Src.end(); It++) {
34 Dst += fmt::format("{:02x}", *It);
35 }
36 }
37 if (Dst.length() < Padding) {
38 Dst = std::string(Padding - Dst.length(), '0').append(Dst);
39 }
40}
41
42void convertValVecToHexStr(Span<const uint8_t> Src, std::string &Dst,
43 const uint32_t Padding) {

Callers 2

getPathMethod · 0.85
convertValVecToHexStrFunction · 0.85

Calls 6

rbeginMethod · 0.80
rendMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected