Integer Types

XSD defines several integer types including integer, byte, unsignedByte, positiveInteger, etc.. Each of these types is mapped to a C type depending on the following factors:

By default, an xsd:integerwith no constraints results in the generation of an "OSINT32" type which is a standard C signed 32-bit integer type. The general mapping is as follows:

XSD type:

   <xsd:simpleType name="TypeName"> 
      <restriction base="xsd:integer"/>

Generated C code:

   typedef OSINT32 TypeName;

Generated C++ code:

   class TypeName : public OSRTBaseType {
      OSINT32 value;
   } ;

Value range facets will alter the C type used to represent a given integer value. The smallest integer type that can hold the constrained value will always be used. For example, the following declaration declares an integer to hold a value between 2 and 10 (inclusive):

   <xsd:simpleType name="Int_2_to_10">
      <xsd:restriction base="xsd:integer">
         <xsd:minInclusive value="2"/>
         <xsd:maxInclusive value="10"/>

In this case, a byte type (unsigned char) could be used to hold the value because it must be between 2 and 10 (a signed byte could also be used but an unsigned value is always used whenever negative numbers are not required). Other value ranges would cause different integer types to be used that provide the most efficient amount of storage.

The <typemap>declarations can be used to map an integer number type to a string type. This can be done at global or schema level. This mapping configuration can be used to preserve the format of integer numbers after decoding and reencoding.

For example, to map xsd:short types to string:


The following table shows the types that would be used for the different range values:

Min Lower Bound1 Max Upper Bound C Type (rtx) C Type (base)
-128 127 OSINT8 char (signed 8-bit int)
0 255 OSUINT8 unsigned char (unsigned 8-bit number)
-32768 32767 OSINT16 short (signed 16-bit int)
0 65535 OSUINT16 unsigned short (unsigned 16-bit int)
-2147483648 2147483647 2147483647 OSINT32 int (signed 32-bit integer)
0 4294967295 OSUINT32 unsigned int (unsigned 32-bit integer)