Skip to content

Commit 23af7a1

Browse files
committed
lib: add string,string_view specific bin2hex overloads
1 parent c1fb4a0 commit 23af7a1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

include/gromox/util.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ extern GX_EXPORT bool parse_bool(const char *s);
8181
extern GX_EXPORT std::string bin2cstr(const void *, size_t);
8282
extern GX_EXPORT std::string bin2txt(const void *, size_t);
8383
extern GX_EXPORT std::string bin2hex(const void *, size_t);
84+
inline std::string bin2hex(const std::string_view &s) { return bin2hex(s.data(), s.size()); }
85+
inline std::string bin2hex(const std::string &s) { return bin2hex(s.data(), s.size()); }
8486
template<typename T> std::string bin2hex(const T &x) { return bin2hex(&x, sizeof(x)); }
8587
extern GX_EXPORT std::string hex2bin(std::string_view, hex2bin_mode = HEX2BIN_EMPTY);
8688
extern GX_EXPORT void rfc1123_dstring(char *, size_t, time_t = 0);

tools/edb2mt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ static void do_namedprops(mbox_state &mbs)
371371
static void do_propblob(TPROPVAL_ARRAY &props, const std::string &blob)
372372
{
373373
if (blob.size() < 6 || memcmp(&blob[0], "ProP\x00\x04", 6) != 0) {
374-
fprintf(stderr, "Unrecognized propblob content: %s\n", bin2hex(blob.data(), blob.size()).c_str());
374+
fprintf(stderr, "Unrecognized propblob content: %s\n", bin2hex(blob).c_str());
375375
return;
376376
}
377377
TPROPVAL_ARRAY new_props;
@@ -525,7 +525,7 @@ static void do_folder(mbox_state &mbs, const edb_folder &folder)
525525
{
526526
tree(mbs.depth);
527527
if (g_show_tree)
528-
tlog("[fld=%s]\n", bin2hex(folder.fid.data(), folder.fid.size()).c_str());
528+
tlog("[fld=%s]\n", bin2hex(folder.fid).c_str());
529529
++mbs.depth;
530530
gi_print(mbs.depth, folder.props, ee_get_propname);
531531
for (const auto &child_id : folder.children)

0 commit comments

Comments
 (0)