|
template<class TYPE > |
static const char * | bdlat_TypeName_Imp::className (const TYPE *) |
| Overloads for basic class types.
|
|
template<class TYPE > |
static const char * | bdlat_TypeName_Imp::name (const TYPE *) |
| Generic implementation for non-fundamental types.
|
|
static const char * | bdlat_TypeName_Imp::name (const bool *) |
| Overloads for fundamental types and char pointers.
|
|
static const char * | bdlat_TypeName_Imp::name (const char *) |
|
static const char * | bdlat_TypeName_Imp::name (const unsigned char *) |
|
static const char * | bdlat_TypeName_Imp::name (const signed char *) |
|
static const char * | bdlat_TypeName_Imp::name (const short *) |
|
static const char * | bdlat_TypeName_Imp::name (const unsigned short *) |
|
static const char * | bdlat_TypeName_Imp::name (const int *) |
|
static const char * | bdlat_TypeName_Imp::name (const unsigned int *) |
|
static const char * | bdlat_TypeName_Imp::name (const long *) |
|
static const char * | bdlat_TypeName_Imp::name (const unsigned long *) |
|
static const char * | bdlat_TypeName_Imp::name (const bsls::Types::Int64 *) |
|
static const char * | bdlat_TypeName_Imp::name (const bsls::Types::Uint64 *) |
|
static const char * | bdlat_TypeName_Imp::name (const float *) |
|
static const char * | bdlat_TypeName_Imp::name (const double *) |
|
static const char * | bdlat_TypeName_Imp::name (const bdldfp::Decimal64 *) |
|
static const char * | bdlat_TypeName_Imp::name (const char *const *) |
|
static const char * | bdlat_TypeName_Imp::name (const signed char *const *) |
|
static const char * | bdlat_TypeName_Imp::name (const unsigned char *const *) |
|
static const char * | bdlat_TypeName_Imp::name (const bsl::string *) |
|
static const char * | bdlat_TypeName_Imp::name (const bdlt::Date *) |
|
static const char * | bdlat_TypeName_Imp::name (const bdlt::DateTz *) |
|
static const char * | bdlat_TypeName_Imp::name (const bdlt::Datetime *) |
|
static const char * | bdlat_TypeName_Imp::name (const bdlt::DatetimeTz *) |
|
static const char * | bdlat_TypeName_Imp::name (const bdlt::Time *) |
|
static const char * | bdlat_TypeName_Imp::name (const bdlt::TimeTz *) |
|
template<class TYPE > |
static const char * | bdlat_TypeName_Imp::name (const bsl::vector< TYPE > *) |
|
template<class TYPE > |
static const char * | bdlat_TypeName_Imp::xsdName (const TYPE *object, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const bool *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const char *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const unsigned short *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const int *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const unsigned int *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const long *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const unsigned long *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const bsls::Types::Int64 *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const bsls::Types::Uint64 *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const char *const *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const signed char *const *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const unsigned char *const *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const bdlt::Date *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const bdlt::DateTz *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const bdlt::Datetime *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const bdlt::DatetimeTz *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const bdlt::Time *, int format) |
|
static const char * | bdlat_TypeName_Imp::xsdName (const bdlt::TimeTz *, int format) |
|
template<class TYPE > |
static const char * | bdlat_TypeName::className (const TYPE &object) |
|
template<class TYPE > |
static const char * | bdlat_TypeName::name (const TYPE &object) |
|
template<class TYPE > |
static const char * | bdlat_TypeName::xsdName (const TYPE &object, int format) |
|
Outline
Purpose
Provide string representations for data type names.
Classes
- See also
- http://www.w3.org/TR/xmlschema-2/#built-in-datatypes
Description
This component defines a structure bdlat_TypeName
which provides a namespace for functions returning information about the object types. Functions in this namespace allow users to get access to three categories of information:
- class name from the metadata associated with the object type
- generic type name
- XML/XSD type name, based on object type and formatting mode.
Class Name Information
The template function className
returns the object class name from the metadata associated with given object type. Metadata is available for the C++ types that have one the following traits:
'bdlat_TypeTraitBasicChoice'
'bdlat_TypeTraitBasicSequence'
'bdlat_TypeTraitBasicCustomizedType'
'bdlat_TypeTraitBasicEnumeration'
If metadata is not available for the object type, the function className
returns 0 unless the function bdlat_TypeName_className
is overloaded by developer.
Overloable Class Name Functions For User Defined Classes
To provide the custom name for the given user-defined C++ class, the developer should overload the template function bdlat_TypeName_className
for this type in the namespace where the type is defined.
WARNING! Do not extend bdlat_TypeName_Overloadable
namespace.
Generic Type Name Information
The template functions name
returns the generic type name for the given object. The generic type name is one of the following:
o predefined name for fundamental types
o class name from 'bdlat_TypeName_className', if such function returns a
non-null value
o name obtained from 'type_info' object provided by C++ runtime, if no
class name is available
XSD Type Name Information
The template functions xsdName
returns the XML/XSD type name, based on the object type and formatting mode. The returned value is one of the following:
o predefined name for built-in XSD types
o class name from 'bdlat_TypeName_className', if such function returns
a non-null value
o the "anyType" string, if no class name is available
This component also defines the XSD names for the following C++ types and formatting modes:
C++ Type Formatting Mode XML Name
-------- --------------- --------
bool DEFAULT/DEC/TEXT boolean
char DEFAULT/DEC byte
char TEXT string
unsigned char DEFAULT/DEC unsignedByte
short DEFAULT/DEC short
short TEXT string
unsigned short DEFAULT/DEC unsignedShort
int DEFAULT/DEC int
unsigned int DEFAULT/DEC unsignedInt
float DEFAULT float
float DEC decimal
double DEFAULT double
double DEC decimal
bdldflp::Decimal64 DEFAULT Decimal64
Definition bdlt_datetz.h:162
Definition bdlt_date.h:294
Definition bdlt_datetimetz.h:308
Definition bdlt_datetime.h:331
Definition bdlt_timetz.h:190
Definition bdlt_time.h:196
Definition bslstl_string.h:1281
Definition bslstl_vector.h:1025
unsigned long long Uint64
Definition bsls_types.h:137
long long Int64
Definition bsls_types.h:132
Usage
This section illustrates intended use of this component.
Example 1: Basic Usage
We begin by creating abbreviations for formatting modes and by declaring objects of a number of types:
int main() {
short theShort;
unsigned theUint;
float theFloat;
const char *theCharPtr;
None of these types are generated types with metadata, so className
will return a null pointer for each of them:
static const char * className(const TYPE &object)
Definition bdlat_typename.h:1017
The name
function will never return a null pointer. For each of the fundamental and vocabulary types, it returns the known type name. For vector types, it returns the appropriate "vector<X>" string:
assert(0 == bsl::strcmp("unsigned int",
assert(0 == bsl::strcmp("const char*",
assert(0 == bsl::strcmp("bdlt::DatetimeTz",
assert(0 == bsl::strcmp("vector<char>",
assert(0 == bsl::strcmp("vector<string>",
static const char * name(const TYPE &object)
Definition bdlat_typename.h:1028
Each of the above types except vector<string>
has one or more corresponding XSD types. The XSD type is affected by a formatting mode so that, for example, a vector<char>
can be represented as a text string (formatting mode TEXT
) or as a sequence of binary bytes (formatting mode HEX
or BASE64
).
assert(0 == bsl::strcmp("short",
assert(0 == bsl::strcmp("unsignedInt",
assert(0 == bsl::strcmp("float",
assert(0 == bsl::strcmp("decimal",
assert(0 == bsl::strcmp("base64Binary",
assert(0 == bsl::strcmp("string",
static const char * xsdName(const TYPE &object, int format)
Definition bdlat_typename.h:1039
For types that have not corresponding XSD type, xsdName
returns "anyType", regardless of formatting mode:
assert(0 == bsl::strcmp("anyType",
return 0;
}
If we create our own class:
namespace MyNamespace {
class MyClass {
};
Then we can assign it a printable name by overloading the bdlat_TypeName_className
function in the class's namespace:
const char *bdlat_TypeName_className(const MyClass&) {
return "MyClass";
}
}
Note that bdlat_TypeName_className
must return a string that is valid and does not change for remaining duration the program. The overloaded bdlat_TypeName_className
function is automatically used for name
and xsdName
, as well as for className
:
int main()
{
MyNamespace::MyClass myClassObj;
assert(0 == bsl::strcmp("MyClass",
assert(0 == bsl::strcmp("MyClass",
return 0;
}
◆ className() [1/2]
template<class TYPE >
const char * bdlat_TypeName::className |
( |
const TYPE & |
object | ) |
|
|
inlinestatic |
◆ className() [2/2]
template<class TYPE >
const char * bdlat_TypeName_Imp::className |
( |
const TYPE * |
object | ) |
|
|
inlinestatic |
◆ name() [1/28]
◆ name() [2/28]
const char * bdlat_TypeName_Imp::name |
( |
const bdlt::Date * |
| ) |
|
|
inlinestatic |
◆ name() [3/28]
◆ name() [4/28]
◆ name() [5/28]
const char * bdlat_TypeName_Imp::name |
( |
const bdlt::DateTz * |
| ) |
|
|
inlinestatic |
◆ name() [6/28]
const char * bdlat_TypeName_Imp::name |
( |
const bdlt::Time * |
| ) |
|
|
inlinestatic |
◆ name() [7/28]
const char * bdlat_TypeName_Imp::name |
( |
const bdlt::TimeTz * |
| ) |
|
|
inlinestatic |
◆ name() [8/28]
const char * bdlat_TypeName_Imp::name |
( |
const bool * |
| ) |
|
|
inlinestatic |
◆ name() [9/28]
const char * bdlat_TypeName_Imp::name |
( |
const bsl::string * |
| ) |
|
|
inlinestatic |
◆ name() [10/28]
template<class TYPE >
const char * bdlat_TypeName_Imp::name |
( |
const bsl::vector< TYPE > * |
| ) |
|
|
static |
Specialization for vectors. Return the null-terminated string constructed by replacing the "X" in the string "vector<X>" with the result of calling name
on an object of the specified TYPE
. If the constructed string exceeds 100 characters, then truncate to 100 characters. Note that TYPE
may itself be a vector, leading to a recursive call to this function.
◆ name() [11/28]
◆ name() [12/28]
◆ name() [13/28]
const char * bdlat_TypeName_Imp::name |
( |
const char * |
| ) |
|
|
inlinestatic |
◆ name() [14/28]
const char * bdlat_TypeName_Imp::name |
( |
const char *const * |
| ) |
|
|
inlinestatic |
◆ name() [15/28]
const char * bdlat_TypeName_Imp::name |
( |
const double * |
| ) |
|
|
inlinestatic |
◆ name() [16/28]
const char * bdlat_TypeName_Imp::name |
( |
const float * |
| ) |
|
|
inlinestatic |
◆ name() [17/28]
const char * bdlat_TypeName_Imp::name |
( |
const int * |
| ) |
|
|
inlinestatic |
◆ name() [18/28]
const char * bdlat_TypeName_Imp::name |
( |
const long * |
| ) |
|
|
inlinestatic |
◆ name() [19/28]
const char * bdlat_TypeName_Imp::name |
( |
const short * |
| ) |
|
|
inlinestatic |
◆ name() [20/28]
const char * bdlat_TypeName_Imp::name |
( |
const signed char * |
| ) |
|
|
inlinestatic |
◆ name() [21/28]
const char * bdlat_TypeName_Imp::name |
( |
const signed char *const * |
| ) |
|
|
inlinestatic |
◆ name() [22/28]
template<class TYPE >
const char * bdlat_TypeName::name |
( |
const TYPE & |
object | ) |
|
|
inlinestatic |
Return a null-terminated string containing the name of the specified TYPE
. If TYPE
is a fundamental type, string, date, time, or datetime, then return a canonical representation of the type's name. Otherwise, if className
applied to the specified object
returns a non-null value, then return that value. Otherwise, return typeid(TYPE).name()
. Note that the returned name refers to the static TYPE
, not to the dynamic type of object
.
◆ name() [23/28]
template<class TYPE >
const char * bdlat_TypeName_Imp::name |
( |
const TYPE * |
type_p | ) |
|
|
inlinestatic |
◆ name() [24/28]
const char * bdlat_TypeName_Imp::name |
( |
const unsigned char * |
| ) |
|
|
inlinestatic |
◆ name() [25/28]
const char * bdlat_TypeName_Imp::name |
( |
const unsigned char *const * |
| ) |
|
|
inlinestatic |
◆ name() [26/28]
const char * bdlat_TypeName_Imp::name |
( |
const unsigned int * |
| ) |
|
|
inlinestatic |
◆ name() [27/28]
const char * bdlat_TypeName_Imp::name |
( |
const unsigned long * |
| ) |
|
|
inlinestatic |
◆ name() [28/28]
const char * bdlat_TypeName_Imp::name |
( |
const unsigned short * |
| ) |
|
|
inlinestatic |
◆ xsdName() [1/20]
const char * bdlat_TypeName_Imp::xsdName |
( |
const bdlt::Date * |
, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
◆ xsdName() [2/20]
const char * bdlat_TypeName_Imp::xsdName |
( |
const bdlt::Datetime * |
, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
◆ xsdName() [3/20]
const char * bdlat_TypeName_Imp::xsdName |
( |
const bdlt::DatetimeTz * |
, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
◆ xsdName() [4/20]
const char * bdlat_TypeName_Imp::xsdName |
( |
const bdlt::DateTz * |
, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
◆ xsdName() [5/20]
const char * bdlat_TypeName_Imp::xsdName |
( |
const bdlt::Time * |
, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
◆ xsdName() [6/20]
const char * bdlat_TypeName_Imp::xsdName |
( |
const bdlt::TimeTz * |
, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
◆ xsdName() [7/20]
const char * bdlat_TypeName_Imp::xsdName |
( |
const bool * |
, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
Overloads for fundamental types and some predefined types using the specified format
.
◆ xsdName() [8/20]
◆ xsdName() [9/20]
◆ xsdName() [10/20]
const char * bdlat_TypeName_Imp::xsdName |
( |
const char * |
, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
◆ xsdName() [11/20]
const char * bdlat_TypeName_Imp::xsdName |
( |
const char *const * |
, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
◆ xsdName() [12/20]
const char * bdlat_TypeName_Imp::xsdName |
( |
const int * |
, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
◆ xsdName() [13/20]
const char * bdlat_TypeName_Imp::xsdName |
( |
const long * |
, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
◆ xsdName() [14/20]
const char * bdlat_TypeName_Imp::xsdName |
( |
const signed char *const * |
, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
◆ xsdName() [15/20]
template<class TYPE >
const char * bdlat_TypeName::xsdName |
( |
const TYPE & |
object, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
Return a null-terminated text string containing the name of the specified TYPE
with the specified format
as it would appear in an XML Schema (XSD) element declaration. The format
is interpreted as the bit-wise OR of one or more of the values defined in the bdlat_formattingmode component. Formatting mode bits outside of bdlat_FormattingMode::TYPE_MASK
are ignored. If the specified object
corresponds to one of the XSD built-in types, then return the XSD type's name. Otherwise, if className(object)
returns a non-null value, then return that value. Otherwise, return "anyType". The behavior is undefined unless the format
is valid for the specified TYPE
.
◆ xsdName() [16/20]
template<class TYPE >
const char * bdlat_TypeName_Imp::xsdName |
( |
const TYPE * |
object, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
Generic implementation for non-fundamental and not predefined types using the specified object
and format
.
◆ xsdName() [17/20]
const char * bdlat_TypeName_Imp::xsdName |
( |
const unsigned char *const * |
, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
◆ xsdName() [18/20]
const char * bdlat_TypeName_Imp::xsdName |
( |
const unsigned int * |
, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
◆ xsdName() [19/20]
const char * bdlat_TypeName_Imp::xsdName |
( |
const unsigned long * |
, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |
◆ xsdName() [20/20]
const char * bdlat_TypeName_Imp::xsdName |
( |
const unsigned short * |
, |
|
|
int |
format |
|
) |
| |
|
inlinestatic |