00001
#ifndef ACSUTIL_ANY_AIDE_H
00002
#define ACSUTIL_ANY_AIDE_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00028
#ifndef __cplusplus
00029
#error This is a C++ include file and cannot be used from plain C
00030
#endif
00031
00032
00036
#include <sstream>
00037
#include <tao/AnyTypeCode/Any.h>
00038
#include <tao/AnyTypeCode/TypeCode.h>
00039
00045 class AnyAide
00046 {
00047
public:
00048
00055 struct WrongTemplateParameter
00056 {
00057 std::string
correctParameter;
00058 };
00059
00065 struct UnsupportedType
00066 {
00067 std::string
type;
00068 };
00069
00070
00077
static CORBA::TCKind
00078
getRealType(
const CORBA::Any&);
00079
00095
static std::string
00096
getId(
const CORBA::Any&);
00097
00109
static std::string
00110
anyToString(
const CORBA::Any&,
unsigned short precision=0);
00111
00124
template <
class T>
00125
static T
00126 getValue(
const CORBA::Any& any)
00127 {
00128 T returnVal;
00129
00130
if((any >>= returnVal)==
false)
00131 {
00132
00133
00134
WrongTemplateParameter except;
00135 except.
correctParameter =
getId(any);
00136
throw except;
00137 }
00138
return returnVal;
00139 }
00140
00148
template <
class T>
00149
static void
00150 setValue(CORBA::Any& any,
00151
const T& value)
00152 {
00153 any <<= value;
00154 }
00155
00156
00157
00158
00159
00160
00164
static bool
00165
isNull(
const CORBA::Any&);
00166
00170
static bool
00171
isString(
const CORBA::Any&);
00172
00176
static bool
00177
isDouble(
const CORBA::Any&);
00178
00182
static bool
00183
isFloat(
const CORBA::Any&);
00184
00188
static bool
00189
isLong(
const CORBA::Any&);
00190
00194
static bool
00195
isLongLong(
const CORBA::Any&);
00196
00200
static bool
00201
isULongLong(
const CORBA::Any&);
00202
00206
static bool
00207
isULong(
const CORBA::Any&);
00208
00212
static bool
00213
isPattern(
const CORBA::Any&);
00214
00218
static bool
00219
isDoubleSeq(
const CORBA::Any&);
00220
00224
static bool
00225
isLongSeq(
const CORBA::Any&);
00226
00230
static bool
00231
isStringSeq(
const CORBA::Any&);
00232
00236
static bool
00237
isFloatSeq(
const CORBA::Any&);
00238
00242
static bool
00243
isEnum(
const CORBA::Any&);
00244
00248
static bool
00249
isStruct(
const CORBA::Any&);
00250
00251
00252
00253
00254
00255
00256
00257
00258
00260 static const std::string
nullType_m;
00261
00263 static const std::string
stringType_m;
00264
00266 static const std::string
doubleType_m;
00267
00269 static const std::string
floatType_m;
00270
00272 static const std::string
longType_m;
00273
00275 static const std::string
longLongType_m;
00276
00278 static const std::string
uLongLongType_m;
00279
00281 static const std::string
uLongType_m;
00282
00284 static const std::string
patternType_m;
00285
00287 static const std::string
doubleSeqType_m;
00288
00290 static const std::string
longSeqType_m;
00291
00293 static const std::string
stringSeqType_m;
00294
00296 static const std::string
floatSeqType_m;
00297
00304 static const std::string
unknownType_m;
00305
00306
00307
private:
00313
static std::string
00314
enumToString(
const CORBA::Any&);
00315
00316 };
00317
00318
#endif