Main Page Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members Related Pages

# aka_simpleType

Akaxiso's simple type is a text node surrounded by tags like the following XML document.

    <?xml version="1.0"?>
    <simpletype>VALUE</simpletype>

Akaxiso does not support mixed text nodes, therefore any serializable text node is always a simpleType.

To use a serializable simpleType, declare/implement a leaf class as a derivation of aka2::simpletype<>.
Here's the sample of a leaf class for long value.
If reading a given text or writing to std::ostream fail, throw aka2::error.

    struct long_leaf : aka2::simpletype<long> {
      void write_text(const void *elm, std::ostream &ostm, aka::entity_complements &ecomps) {
        const long &value = *static_cast<long*>(elm);
        ostm << value;
      }
      void read_text(void *elm, const std::string &entity, aka::entity_compliments &ecomps) {
        long &value = *static_cast<long*>(elm);
        aka::isstream istm(entity);
        istm >> value;
        if (istm.fail())
          throw aka::error("Failed to read long value.", __FILE__, __LINE__);
      }
    };

You may need additional information to read/write text values, which aka2::entity_complements give. aka2::entity_complements class supports

- namespace URI-prefix association,
- xs:ID check,
- user-defined entity_complement.

Akaxiso has predefined leaf classes for builtin types.

    ------------------------------------------------------------
    Numeric types          min           max   XML-Schema type
    char                  -128           128   xs:byte
    unsigned char            0           255   xs:unsignedByte
    short               -32768         32767   xs:short
    unsigned short           0         65535   xs:unsignedShort
    long           -2147483648    2147483647   xs:int, xs:integer
    unsigned long            0        2^32-1   xs:unsignedInt,
    LONGLONG             -2^63        2^63-1   xs:long,
    ULONGLONG                0        2^64-1   xs:unsignedLong,
    int                  compiler-dependent.   (Not mapped.)
    ------------------------------------------------------------
    boolean type
    bool     true/false (0/1)     xs:boolean
    ------------------------------------------------------------
    floating-point number
    float
    double
    ------------------------------------------------------------
    string type.
    std::string
    ------------------------------------------------------------
    aka::nill  empty type.
    ------------------------------------------------------------