赤紫蘇 2.
赤紫蘇、忍坂2における組み込み型
赤紫蘇、忍坂2で定義される単純型とC++クラス、また、XML Schemaにおける特殊なクラス(xs:anyTypeなど)について、扱いを示します。
赤紫蘇の組み込み型
赤紫蘇はライブラリ本体の機能として、以下のC++組み込み型、文字列型のシリアライズを行うことができます。
leafクラスは、xiso::leaf<単純型>として使用することができます。
| 整数 | 最小値 | 最大値 | XML Schema組み込み型との対応 |
| char | -128 | 127 | xs:byte |
| unsigned char | 0 | 255 | xs:unsignedByte |
| short | -32768 | 32767 | xs:short |
| unsigned short | 0 | 65535 | xs:unsigned short |
| long | -2^31 | 2^31 - 1 | xs:int, xs:integer |
| unsinged long | 0 | 2^32 - 1 | xs:unsignedInt |
| LONGLONG (long long) |
-2^63 | 2^63 - 1 | xs:long |
| ULONGLONG (unsigned long long) |
0 | 2^64 - 1 | xs:unsignedLong |
| int | *1 | *1 | 対応する型はなし |
| ブール型 | 値 | XML Schema組み込み型との対応 |
| bool | true false 0 1 (シリアライズ時にはtrue/falseが使われる。) |
xs:boolean |
| 浮動小数点型 | XML Schema組み込み型との対応 |
| float | xs:float |
| double | xs:double |
| 文字列型 | XML Schema組み込み型との対応 |
| std::string | xs:string |
赤紫蘇では、シリアライザブルなオブジェクトがXMLスキーマの構造を表現できるように、以下のクラスを定義しています。
以下のクラスもシリアライザブルです。
| 赤紫蘇組み込み型 | XML Schema組み込み型との対応 |
| aka::nill | 対応無し。空要素を明示的に指定するために使用 |
| aka::any | xs:anyType |
| aka::any_array | xs:anyTypeの配列版 |
| aka::item | xs:choiceの子要素を表現するために使用 |
| aka::deep_ptr<> | スマートポインタ。 ただし、コピー時には、保持するポインタのコピーも作成する。 minOccurs=0 maxOccurs=1の場合にのみ、使用可。 |
忍坂2の組み込み型
XML Schemaの組み込み型は、現時点では、xs:QNameを除き、単純に、std::stringにマッピングされています。
また、読み込み、書き出しのロジックは、単なる文字列に対する処理を流用しています。
(現時点での対応。設定ファイルにより書き換え可能になる予定。leafクラスの追加実装により妥当性検証は可能となる。)
| XML Schema組み込み型 | マップされるC++クラス | leafクラス*2 |
| base64Binary | std::string | |
| hexBinary | std::string | |
| string | std::string | |
| normalizedString | std::string | |
| token | std::string | |
| positiveInteger | std::string | |
| negativeInteger | std::string | |
| nonPositiveInteger | std::string | |
| positiveInteger | std::string | |
| nonNegativeInteger | std::string | |
| decimal | std::string | |
| time | std::string | |
| dateTime | std::string | |
| duration | std::string | |
| time | std::string | |
| dateTime | std::string | |
| duration | std::string | |
| gMonth | std::string | |
| gYear | std::string | |
| gYearMonth | std::string | |
| gDay | std::string | |
| gMonthDay | std::string | |
| Name | std::string | |
| QName | aka::qname | xs::QNameLeaf, xs::QNameRefLeaf |
| NCName | std::string | |
| anyURI | std::string | |
| language | std::string | |
| ID | std::string | |
| IDREF | std::string | |
| IDREFS | std::string | |
| ENTITY | std::string | |
| ENTITIES | std::string | |
| NOTATION | std::string | |
| NMTOKEN | std::string | |
| NMTOKENS | std::string |
*2 : 空欄の場足、xs::leaf<std::string>が用いられる。