diff options
author | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
---|---|---|
committer | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
commit | bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch) | |
tree | 38a92061c0793434c4be189f1d70c3458b6bc41d /tags/cpp-sdo-1.0.incubating-M3/runtime/core/src/commonj/sdo/DataTypeInfo.h |
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tags/cpp-sdo-1.0.incubating-M3/runtime/core/src/commonj/sdo/DataTypeInfo.h')
-rw-r--r-- | tags/cpp-sdo-1.0.incubating-M3/runtime/core/src/commonj/sdo/DataTypeInfo.h | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/tags/cpp-sdo-1.0.incubating-M3/runtime/core/src/commonj/sdo/DataTypeInfo.h b/tags/cpp-sdo-1.0.incubating-M3/runtime/core/src/commonj/sdo/DataTypeInfo.h new file mode 100644 index 0000000000..b85ce57389 --- /dev/null +++ b/tags/cpp-sdo-1.0.incubating-M3/runtime/core/src/commonj/sdo/DataTypeInfo.h @@ -0,0 +1,137 @@ +/* +* +* Copyright 2007 The Apache Software Foundation or its licensors, as applicable. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* $Rev$ $Date$ */ + +#ifndef _DATATYPEINFO_H_ +#define _DATATYPEINFO_H_ + +#include "commonj/sdo/SDODate.h" +#include "commonj/sdo/SDOString.h" + +namespace commonj +{ + namespace sdo + { + + // The DataTypeInfo class provides types that encapsulate the various + // primitive data types that SDO uses to represent the user level data + // types defined in the specification. The central artifact is a union + // of all the C++ data types that are used to represent SDO data + // types. This is augmented by enumerations that provide a convenient + // way to label a particular type, plus a method to retrieve a text + // representation of each enumeration value. + + // There are three different array-like primitive data types. + // 1. CString: An array of char, terminated by a 0 ie a C style string. + // 2. ByteArray: An array of bytes. Similar to 1. but without the null + // terminator. + // 3. String: An array of wchar_t, terminated by a 0. In the SDOValue + // class, the first two are stored in an SDOString (ie std::string), + // while the third is stored explicitly as a pointer to a buffer. + + class DataTypeInfo + { + public: + // The values of TrueDataType are used as subscripts for an array + // so they must a) start at zero and b) be contiguous. Elsewhere, + // TDTWideString is used as the definition of the largest + // TrueDatatype value, so if any constants are added beyond it the + // code that depends on it will have to be changed. + enum TrueDataType + { + TDTbool = 0, + TDTchar = 1, + TDTwchar_t = 2, + TDTshort = 3, + TDTlong = 4, + TDTint64_t = 5, + TDTfloat = 6, + TDTdouble = 7, + TDTSDODate = 8, + TDTCString = 9, + TDTByteArray = 10, + TDTWideString = 11 + }; + + enum PseudoDataType + { + PDTunset = -2, + PDTnull = -1 + }; + + // This enum identifies what C++ datatype is present in the union. + // It does not necessarily say what the SDO type is. Since it is + // possible for a value to be either unset or null there are + // enumerations for those cases too. This enum is effectively a + // union of the two previous enums where TrueDataType includes + // just those data types that can actually have values, while + // PseudoDataType includes just null and unset. This allows for + // methods that have to be told which type to create and for which + // unset and null are inappropriate. + enum RawDataType + { + SDOunset = PDTunset, + SDOnull = PDTnull, + SDObool = TDTbool, + SDOchar = TDTchar, + SDOwchar_t = TDTwchar_t, + SDOshort = TDTshort, + SDOlong = TDTlong, + SDOint64_t = TDTint64_t, + SDOfloat = TDTfloat, + SDOdouble = TDTdouble, + SDOSDODate = TDTSDODate, + SDOCString = TDTCString, + SDOByteArray = TDTByteArray, + SDOWideString = TDTWideString, + }; + + // Entities with copy constructors/destructors are not allowed in a union, + // since in general, the compiler doesn't know what type is + // actually in there so it can't know which constructor/destructor + // to call, hence the use of pointers for dates and strings + union SDODataTypeUnion + { + bool Boolean; + char Character; + wchar_t WideChar; + short Short; + long Integer; + int64_t Int64; + float Float; + long double Double; + SDODate* Date; + SDOString* TextString; + struct + { + wchar_t* data; + unsigned int length; + } WideString; + }; + + static const SDOString& convertTypeEnumToString(TrueDataType dataType); + + private: + // Array of text strings that correspond to TrueDataType enumeration values + static SDO_API const SDOString rawTypeNames[]; + + }; + } // End - namespace sdo +} // End - namespace commonj + +#endif // _DATATYPEINFO_H_ |