TOC PREV NEXT INDEX


Binary String Types


XSD defines the following types that are mapped to a C binary type structure:
hexBinary
base64Binary
The type of structure used depends on whether or not a length facet is applied to the type. If a length facet is not used, or the length is a very large value (> 32K), a built-in type containing a pointer to a dynamic memory buffer is used to hold the binary data. The definition of this type in osSysTypes.h is as follows:

	typedef struct OSDynOctStr {
 
	   OSUINT32     numocts;
 
	   const OSOCTET* data;
 
	} OSDynOctStr;
 

The numocts member holds the length of the binary string and the data member holds the actual data.
For C++, a built-in class definition is used that extends this structure:

	class OSDynOctStrClass : public OSRTBaseType {
 
	 protected:
 
		OSUINT32 numocts;
 
		const OSOCTET* data;
 
	 public:
 
	   ...
 
	} ;
 

This class provides methods for getting and setting the data values as well as initialization through constructors and other utility methods.
If a length facet is used that restricts the size of the binary string to a value less than 32K, a custom type is generated that contains a static array to hold the data. The general form of this type is as follows:

      typedef struct TypeName {
 
         OSUINT32     numocts;
 
         OSOCTET      data[length];
 
      } TypeName;
 

In this case, TypeName would be the name of the type defined in the XSD specification and length would be the value of the length facet.
In the case of C++, a class is generated:

      class TypeName : public OSRTBaseType {
 
         OSUINT32     numocts;
 
         OSOCTET      data[length];
 
	   ...
 
      } ;
 

The general mappings for each case are as follows:

Dynamic Case (no length facet):
XSD type:
<xsd:simpleType name="TypeName">
 
   <restriction base="xsd:hexBinary"/>
 
</xsd:simpleType>
 
 
Generated C code:
typedef OSDynOctStr TypeName;
 

 
Generated C++ code:
class TypeName : public OSDynOctStrClass
 
{
 
   ...
 
} ;
 


Static Case (length restricted to 32K or less):
XSD type:
<xsd:simpleType name="TypeName">
 
   <xsd:restriction base="xsd:hexBinary">
 
      <xsd:length value="length"/>
 
   </xsd:restriction>
 
</xsd:simpleType>
 
 
Generated C code:
typedef struct TypeName {
 
   OSUINT32		 numocts;
 
   OSOCTET		data[length];
 
} TypeName;
 

 
Generated C++ code:
class TypeName : public OSRTBaseType {
 
   OSUINT32		 numocts;
 
   OSOCTET		data[length];
 
   ...
 
} ;
 


Note: in the static case, the maxLength facet will cause the same code to be generated with maxLength used for the size of the array.


Copyright © Objective Systems 2002-2008
This document may be distributed in any form, electronic or otherwise, provided that it is distributed in its entirety and that the copyright and this notice are included.

Objective Systems, Inc.

55 Dowlin Forge Road
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