MCPcopy Create free account
hub / github.com/bcndev/bytecoin / from_hex_or_throw

Function from_hex_or_throw

src/common/StringTools.cpp:48–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48void from_hex_or_throw(const std::string &text, void *data, size_t buffer_size) {
49 if (text.size() != buffer_size * 2)
50 throw std::runtime_error("from_hex: Wrong string size (" + common::to_string(text.size()) + ") must be " +
51 common::to_string(buffer_size * 2));
52 for (size_t i = 0; i < buffer_size; ++i)
53 static_cast<uint8_t *>(data)[i] = (from_hex(text[i * 2]) << 4) | from_hex(text[i * 2 + 1]);
54}
55
56bool from_hex(const std::string &text, void *data, size_t buffer_size) {
57 if (text.size() != buffer_size * 2)

Callers 1

binaryMethod · 0.85

Calls 3

from_hexFunction · 0.85
to_stringFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected