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

Detailed Description

Outline

Purpose

Provide an attribute class to configure ISO 8601 string parsing.

Classes

See also
bdlt_iso8601util, bdlt_iso8601utilconfiguration

Description

This component provides an unconstrained (value-semantic) attribute class, bdlt::Iso8601UtilParseConfiguration, that may be used to configure various aspects of generated ISO 8601 strings.

Attributes

Name Type Default
---------------- ---- -------
relaxed bool false
basic bool false

Note that in parsing, the : between the hour and minute fields of the time zone is always optional.

Usage

This section illustrates intended use of this component.

Our type, Iso8601UtilParseConfiguration, has two boolean attributes, basic and relaxed.

Definition bdlt_iso8601utilparseconfiguration.h:158

A default configured object has both attributes being false:

Config c;
assert(!c.basic());
assert(!c.relaxed());

The setBasic sets the basic attribute, leaves the relaxed attribute alone:

Config c2 = c.setBasic();
assert( c.basic());
assert(!c.relaxed());

setBasic and setRelaxed take a boolean argument that defaults to true:

for (int ii = 0; ii < 16; ++ii) {
const bool basic = ii & 1;
const bool relaxed = ii & 2;
const bool basicB = ii & 4;
const bool relaxedB = ii & 8;
// 'c' can have any valid state at this point.
const Config& c3 = c.setBasic(basic);
assert(&c3 != &c); // copy, not reference, returned
const Config& c4 = c.setRelaxed(relaxed);
assert(&c4 != &c); // copy, not reference, returned
assert(c.basic() == basic);
assert(c.relaxed() == relaxed);
c.setRelaxed(relaxedB);
c.setBasic(basicB);
assert(c.relaxed() == relaxedB);
assert(c.basic() == basicB);
Config d = c; // copy 'c' to 'd'
assert(d.relaxed() == relaxedB);
assert(d.basic() == basicB);
assert(d == c);
assert(&d != &c); // 'd' is a copy, not a reference
d.setBasic(); // defaults to 'true'
d.setRelaxed(); // defaults to 'true'
assert(d.basic() == true);
assert(d.relaxed() == true);
}