NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
string-helper.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_STRING_HELPER_HPP
23 #define NDN_STRING_HELPER_HPP
24 
25 #include "../common.hpp"
26 #include "../encoding/buffer.hpp"
27 
28 namespace ndn {
29 
30 class StringHelperError : public std::invalid_argument
31 {
32 public:
33  explicit
34  StringHelperError(const std::string& what)
35  : std::invalid_argument(what)
36  {
37  }
38 };
39 
57 void
58 printHex(std::ostream& os, const uint8_t* buffer, size_t length, bool isUpperCase = true);
59 
67 void
68 printHex(std::ostream& os, const Buffer& buffer, bool isUpperCase = true);
69 
86 std::string
87 toHex(const uint8_t* buffer, size_t length, bool isUpperCase = true);
88 
95 std::string
96 toHex(const Buffer& buffer, bool isUpperCase = true);
97 
104 shared_ptr<const Buffer>
105 fromHex(const std::string& hexString);
106 
110 void
111 trimLeft(std::string& str);
112 
116 void
117 trimRight(std::string& str);
118 
122 void
123 trim(std::string& str);
124 
128 int
129 fromHexChar(uint8_t c);
130 
142 std::string
143 unescape(const std::string& str);
144 
145 } // namespace ndn
146 
147 #endif // NDN_STRING_HELPER_HPP
Copyright (c) 2011-2015 Regents of the University of California.
STL namespace.
void printHex(std::ostream &os, const uint8_t *buffer, size_t length, bool isUpperCase)
Output the hex representation of the bytes in array to the output stream os.
StringHelperError(const std::string &what)
std::string toHex(const uint8_t *buffer, size_t length, bool isUpperCase)
Return the hex representation of the bytes in array.
std::string unescape(const std::string &str)
Decode a percent-encoded string.
void trimRight(std::string &str)
Modify str in place to erase whitespace on the right.
void trim(std::string &str)
Modify str in place to erase whitespace on the left and right.
void trimLeft(std::string &str)
Modify str in place to erase whitespace on the left.
int fromHexChar(uint8_t c)
Convert the hex character to an integer from 0 to 15, or -1 if not a hex character.
shared_ptr< const Buffer > fromHex(const std::string &hexString)
Convert the hex string to buffer.
Class representing a general-use automatically managed/resized buffer.
Definition: buffer.hpp:44