Provide push parser for hex types.
More...
Detailed Description
- Outline
-
-
- Purpose:
- Provide push parser for hex types.
-
- Classes:
-
- See also:
-
- Description:
- The
balxml::HexParser
class template provided by this component can be used to parse Hex characters into one of the supported Hex types, which are bsl::vector<char>
and bsl::string
. The TYPE
parameter can be one of these two types.
- Note that if you need a way to encode binary data into ASCII, the
bdlde_base64encoder
and bdlde_base64decoder
components are likely a more efficient solution.
- This class template is a model of the
PushParser
concept, which contains the following methods: int beginParse(TYPE *object);
int endParse();
template <typename INPUT_ITERATOR>
int pushCharacters(INPUT_ITERATOR begin, INPUT_ITERATOR end);
-
- Usage:
- The following snippets of code illustrate the usage of this component. Suppose you had an input stream that contained Hex data. The following
loadFromHexStream
function loads this data into an bsl::vector<char>
blob: The following function demonstrates the loadFromHexStream
function: #include <sstream>
void usageExample()
{
const char INPUT[] = "0F3B296A";
bsl::vector<char> vec;
bsl::istringstream iss(INPUT);
int result = loadFromHexStream(&vec, iss);
assert(0 == result);
assert(4 == vec.size());
assert(0x0F == vec[0]);
assert(0x3B == vec[1]);
assert(0x29 == vec[2]);
assert(0x6A == vec[3]);
}