Outline
Purpose
Provide a utility for parsing types using XML formatting.
Classes
- See also
- http://www.w3.org/TR/xmlschema-2/
Description
The balxml::TypesParserUtil
struct provided by this component contains the following functions:
o 'parse': Parse a string using the supplied formatting mode.
o 'parseBase64': Parse a string using
o 'parseDefault': Parse a string using
o 'parseList': Parse a string using
'bdlat_FormattingMode::e_IS_LIST'.
The input strings are parsed according to each type's lexical representation as described in the XML Schema Specification, which is available at http://www.w3.org/TR/xmlschema-2/
.
The following C++ Type / Formatting Mode combinations are supported by this component:
C++ Type Formatting Mode
-------- ---------------
bool e_DEFAULT, e_DEC, e_TEXT
char e_DEFAULT, e_DEC, e_TEXT
unsigned char e_DEFAULT, e_DEC
[unsigned] short e_DEFAULT, e_DEC
[unsigned] int e_DEFAULT, e_DEC
[unsigned] long e_DEFAULT, e_DEC
float e_DEFAULT, e_DEC
double e_DEFAULT, e_DEC
bdlt::DateTimeTz e_DEFAULT
Variant2<DatetimeTz, Datetime> e_DEFAULT
e_IS_LIST
Definition bdlb_variant.h:2514
Definition bdldfp_decimal.h:1834
Definition bdlt_datetz.h:162
Definition bdlt_date.h:294
Definition bdlt_datetime.h:331
Definition bdlt_timetz.h:190
Definition bdlt_time.h:196
Definition bslstl_string.h:1281
Definition bslstl_vector.h:1025
Definition bsls_types.h:118
In addition to the types listed above, this component also recognizes the following bdlat
type categories:
'bdlat' Type Category Formatting Mode
--------------------- ---------------
Array e_IS_LIST
CustomizedType Base type's formatting modes
DynamicType Runtime type's formatting modes
Enumeration e_DEFAULT, e_TEXT, e_DECIMAL
When bdlat_FormattingMode::e_DEFAULT
is used, the actual formatting mode selected is based on the following mapping:
C++ Type Default Formatting Mode
-------- -----------------------
bool e_DEC or e_TEXT
[unsigned] char e_DEC
[unsigned] short e_DEC
[unsigned] int e_DEC
[unsigned] long e_DEC
'bdlat' Type Category Default Formatting Mode
--------------------- -----------------------
Enumeration e_TEXT
Usage
The following snippets of code illustrate how to parse a Base64 string into an bsl::vector<char>
:
#include <cassert>
#include <vector>
using namespace BloombergLP;
void usageExample()
{
const char INPUT[] = "YWJjZA==";
const int INPUT_LENGTH = sizeof(INPUT) - 1;
INPUT,
INPUT_LENGTH);
assert(0 == retCode);
assert('a' == vec[0]);
assert('b' == vec[1]);
assert('c' == vec[2]);
assert('d' == vec[3]);
}
size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the number of elements in this vector.
Definition bslstl_vector.h:2664
static int parseBase64(TYPE *result, const char *input, int inputLength)
Definition balxml_typesparserutil.h:1000