mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2025-01-08 11:11:51 +00:00
Move "to_hex()" function from mkvinfo.cpp to the string formatting library
This commit is contained in:
parent
8d5af67a07
commit
af5680755e
@ -240,3 +240,15 @@ format_paragraph(const std::string &text_to_wrap,
|
||||
const char *break_chars) {
|
||||
return to_utf8(format_paragraph(to_wide(text_to_wrap), indent_column, to_wide(indent_first_line), to_wide(indent_following_lines), wrap_column, to_wide(break_chars)));
|
||||
}
|
||||
|
||||
std::string
|
||||
to_hex(const unsigned char *buf,
|
||||
size_t size) {
|
||||
static boost::format s_bf_to_hex("%|1$02x| ");
|
||||
|
||||
std::string hex("0x");
|
||||
for (size_t idx = 0; idx < size; ++idx)
|
||||
hex += (s_bf_to_hex % static_cast<unsigned int>(buf[idx])).str();
|
||||
|
||||
return hex;
|
||||
}
|
||||
|
@ -60,4 +60,10 @@ std::string to_string(uint64_t value);
|
||||
std::string to_string(double value, unsigned int precision);
|
||||
std::string to_string(int64_t numerator, int64_t denominator, unsigned int precision);
|
||||
|
||||
std::string to_hex(const unsigned char *buf, size_t size);
|
||||
inline std::string
|
||||
to_hex(const std::string &buf) {
|
||||
return to_hex(reinterpret_cast<const unsigned char *>(buf.c_str()), buf.length());
|
||||
}
|
||||
|
||||
#endif // __MTX_COMMON_STRING_FORMATTING_H
|
||||
|
@ -321,19 +321,6 @@ create_hexdump(const unsigned char *buf,
|
||||
return hex;
|
||||
}
|
||||
|
||||
static std::string
|
||||
to_hex(const unsigned char *buf,
|
||||
int size) {
|
||||
static boost::format s_bf_to_hex(" 0x%|1$02x|");
|
||||
|
||||
std::string hex;
|
||||
int b;
|
||||
for (b = 0; b < size; ++b)
|
||||
hex += (s_bf_to_hex % (int)buf[b]).str();
|
||||
|
||||
return hex;
|
||||
}
|
||||
|
||||
std::string
|
||||
create_codec_dependent_private_info(KaxCodecPrivate &c_priv,
|
||||
char track_type,
|
||||
|
Loading…
Reference in New Issue
Block a user