7 #include <packager/utils/absl_flag_hexbytes.h>
12 #include <absl/flags/flag.h>
13 #include <absl/flags/parse.h>
14 #include <absl/flags/usage.h>
15 #include <absl/strings/ascii.h>
16 #include <absl/strings/escaping.h>
17 #include <absl/strings/str_format.h>
18 #include <absl/strings/str_join.h>
19 #include <absl/strings/str_split.h>
21 #include <packager/utils/hex_parser.h>
26 bool AbslParseFlag(absl::string_view text, HexBytes* flag, std::string* error) {
27 std::string hexString(text);
28 absl::RemoveExtraAsciiWhitespace(&hexString);
30 if (hexString.empty()) {
31 flag->bytes = std::vector<uint8_t>(0, 0);
36 if (!shaka::ValidHexStringToBytes(hexString, &bytesRaw)) {
37 *error =
"Invalid hex string";
41 absl::string_view hex_str_view(bytesRaw);
42 absl::Span<const uint8_t> span(
43 reinterpret_cast<const uint8_t*
>(hex_str_view.data()),
45 flag->bytes = std::vector<uint8_t>(span.begin(), span.end());
50 std::string AbslUnparseFlag(
const HexBytes& flag) {
52 for (
const auto byte : flag.bytes) {
53 absl::StrAppendFormat(&result,
"%02x",
byte);
All the methods that are virtual are virtual for mocking.