22 #ifndef NDN_CXX_UTIL_STRING_HELPER_HPP 
   23 #define NDN_CXX_UTIL_STRING_HELPER_HPP 
   33   using std::invalid_argument::invalid_argument;
 
   46 printHex(std::ostream& os, uint64_t num, 
bool wantUpperCase = 
false);
 
   56 printHex(std::ostream& os, span<const uint8_t> buffer, 
bool wantUpperCase = 
true);
 
   78 printHex(std::ostream& os, 
const uint8_t* buffer, 
size_t length, 
bool wantUpperCase = 
true)
 
   80   printHex(os, {buffer, length}, wantUpperCase);
 
  107     printHex(os, hex.m_value, os.flags() & std::ostream::uppercase);
 
  122 toHex(span<const uint8_t> buffer, 
bool wantUpperCase = 
true);
 
  143 toHex(
const uint8_t* buffer, 
size_t length, 
bool wantUpperCase = 
true)
 
  145   return toHex({buffer, length}, wantUpperCase);
 
  155 fromHex(
const std::string& hexString);
 
  161 toHexChar(
unsigned int n, 
bool wantUpperCase = 
true) noexcept
 
  163   return wantUpperCase ?
 
  164          "0123456789ABCDEF"[n & 0xf] :
 
  165          "0123456789abcdef"[n & 0xf];
 
  174   return (c >= 
'0' && c <= 
'9') ? int(c - 
'0') :
 
  175          (c >= 
'A' && c <= 
'F') ? 
int(c - 
'A' + 10) :
 
  176          (c >= 
'a' && c <= 
'f') ? 
int(c - 
'a' + 10) :
 
  197 escape(
const std::string& str);
 
  200 escape(std::ostream& os, 
const char* str, 
size_t len);
 
  219 unescape(std::ostream& os, 
const char* str, 
size_t len);
 
#define NDN_CXX_NODISCARD
 
Helper class to convert a number to hexadecimal format, for use with stream insertion operators.
 
constexpr AsHex(uint64_t val) noexcept
 
friend std::ostream & operator<<(std::ostream &os, const AsHex &hex)
 
void printHex(std::ostream &os, uint64_t num, bool wantUpperCase)
Output the hex representation of num to the output stream os.
 
shared_ptr< Buffer > fromHex(const std::string &hexString)
Convert the hex string to buffer.
 
std::string toHex(span< const uint8_t > buffer, bool wantUpperCase)
Return a string containing the hex representation of the bytes in buffer.
 
std::string unescape(const std::string &str)
Decode a percent-encoded string.
 
constexpr int fromHexChar(char c) noexcept
Convert the hex character c to an integer in [0, 15], or -1 if it's not a hex character.
 
constexpr char toHexChar(unsigned int n, bool wantUpperCase=true) noexcept
Convert (the least significant nibble of) n to the corresponding hex character.
 
std::string escape(const std::string &str)
Percent-encode a string.