BDE 4.14.0 Production release
Loading...
Searching...
No Matches
balxml_typesparserutil

Detailed Description

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 'parseDecimal': Parse a string using 'bdlat_FormattingMode::e_DEC'.
o 'parseDefault': Parse a string using
o 'parseHex': Parse a string using 'bdlat_FormattingMode::e_HEX'.
o 'parseList': Parse a string using
'bdlat_FormattingMode::e_IS_LIST'.
o 'parseText': Parse a string using 'bdlat_FormattingMode::e_TEXT'.
@ e_BASE64
Definition bdlat_formattingmode.h:113
@ e_DEFAULT
Definition bdlat_formattingmode.h:110
@ e_HEX
Definition bdlat_formattingmode.h:112
@ e_DEC
Definition bdlat_formattingmode.h:111
@ e_TEXT
Definition bdlat_formattingmode.h:114

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
bsls::Types::[Uint64|Int64] e_DEFAULT, e_DEC
float e_DEFAULT, e_DEC
double e_DEFAULT, e_DEC
bdldfp::Decimal64 e_DEFAULT, e_DEC
bsl::string e_DEFAULT, e_TEXT, e_BASE64, e_HEX
bdlt::Date e_DEFAULT
bdlt::DateTz e_DEFAULT
bdlt::Datetime e_DEFAULT
bdlt::DateTimeTz e_DEFAULT
bdlt::Time e_DEFAULT
bdlt::TimeTz e_DEFAULT
Variant2<DatetimeTz, Datetime> e_DEFAULT
bsl::vector<char> e_DEFAULT, e_BASE64, e_HEX, e_TEXT,
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
bsls::Types::[Uint64|Int64] e_DEC
bsl::string e_TEXT
'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=="; // "abcd" in Base64
const int INPUT_LENGTH = sizeof(INPUT) - 1;
INPUT,
INPUT_LENGTH);
assert(0 == retCode);
assert(4 == vec.size());
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