TOC PREV NEXT INDEX


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:integer with no constraints results in the generation of an "OSINT32" type which is standard C signed 32-bit integer type. The general mapping is as follows:
XSD type:
<xsd:simpleType name="TypeName">
 
   <restriction base="xsd:integer"/>
 
</xsd:simpleType>
 
 
Generated C code:
typedef OSINT32 TypeName;
 

 
Generated C++ code:
class TypeName : public OSBaseType {
 
   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"/>
 
        </xsd:restriction>
 
     </xsd:simpleType>
 

 
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 following table shows the types that would be used for the different range values:
Min Lower Bound
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
OSINT32
int
(signed 32-bit integer)
0
4294967295
OSUINT32
unsigned int
(unsigned 32-bit integer)



Objective Systems, Inc.

102 Pickering Way, Suite #506
Exton, Pennsylvania 19341
http://www.obj-sys.com
Phone: (484) 875-9841
Toll-free: (877) 307-6855 (US only)
Fax: (484) 875-9830
info@obj-sys.com
TOC PREV NEXT INDEX