DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
gflags_hex_bytes.cc
1 // Copyright 2017 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #include "packager/app/gflags_hex_bytes.h"
8 
9 #include "packager/base/strings/string_number_conversions.h"
10 
11 namespace shaka {
12 
13 bool ValidateHexString(const char* flagname,
14  const std::string& value,
15  std::vector<uint8_t>* value_bytes) {
16  std::vector<uint8_t> temp_value_bytes;
17  if (!value.empty() && !base::HexStringToBytes(value, &temp_value_bytes)) {
18  printf("Invalid hex string for --%s: %s\n", flagname, value.c_str());
19  return false;
20  }
21  value_bytes->swap(temp_value_bytes);
22  return true;
23 }
24 
25 } // namespace shaka