Go to the documentation of this file.00001
00020 #ifndef DOIL_CORBA_BASICTYPECONVERSION_H
00021 #define DOIL_CORBA_BASICTYPECONVERSION_H
00022
00023 #include <coil/stringutil.h>
00024 #include <doil/corba/CORBA.h>
00025
00026
00027
00028 inline bool local_to_corba(const short int _from, ::CORBA::Short& _to)
00029 {
00030 _to = _from;
00031 return true;
00032 }
00033
00034 inline bool local_to_corba(const unsigned short _from, ::CORBA::UShort& _to)
00035 {
00036 _to = _from;
00037 return true;
00038 }
00039
00040 inline bool local_to_corba(const long int _from, ::CORBA::Long& _to)
00041 {
00042 _to = _from;
00043 return true;
00044 }
00045
00046 inline bool local_to_corba(const unsigned long int _from, ::CORBA::ULong& _to)
00047 {
00048 _to = _from;
00049 return true;
00050 }
00051
00052 inline bool local_to_corba(const float _from, ::CORBA::Float& _to)
00053 {
00054 _to = _from;
00055 return true;
00056 }
00057
00058 inline bool local_to_corba(const double _from, ::CORBA::Double& _to)
00059 {
00060 _to = _from;
00061 return true;
00062 }
00063
00064 inline bool local_to_corba(const char _from, ::CORBA::Char& _to)
00065 {
00066 _to = _from;
00067 return true;
00068 }
00069
00070 inline bool local_to_corba(const bool _from, ::CORBA::Boolean& _to)
00071 {
00072 _to = _from;
00073 return true;
00074 }
00075
00076 inline bool local_to_corba(const unsigned char _from, ::CORBA::Octet& _to)
00077 {
00078 _to = _from;
00079 return true;
00080 }
00081
00082 #if defined ORB_IS_TAO
00083 #elif defined ORB_IS_OMNIORB
00084 inline bool local_to_corba(const std::string& _from, ::CORBA::String_member& _to)
00085 {
00086 _to.out() = ::CORBA::string_dup(_from.c_str());
00087 return true;
00088 }
00089
00090
00091 inline bool local_to_corba(const std::string& _from, _CORBA_String_element::_CORBA_String_element _to)
00092 {
00093 _to.out() = ::CORBA::string_dup(_from.c_str());
00094 return true;
00095 }
00096 #elif defined ORB_IS_MICO
00097 #elif defined ORB_IS_ORBIT2
00098 #endif
00099 inline bool local_to_corba(const ::std::string& _from, char*& _to)
00100 {
00101 _to = ::CORBA::string_dup(_from.c_str());
00102 return true;
00103 }
00104
00105 inline bool local_to_corba(const std::string& _from, ::CORBA::Any& _to)
00106 {
00107 _to <<= ::CORBA::Any::from_string(_from.c_str(), _from.size());
00108 return true;
00109 }
00110
00111 inline bool local_to_corba(const std::string& _from, CORBA::TypeCode* _to)
00112 {
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 return true;
00162 }
00163
00164
00165
00166 inline bool corba_to_local(const ::CORBA::Short _from, short& _to)
00167 {
00168 _to = _from;
00169 return true;
00170 }
00171
00172 inline bool corba_to_local(const ::CORBA::UShort _from, unsigned short& _to)
00173 {
00174 _to = _from;
00175 return true;
00176 }
00177
00178 inline bool corba_to_local(const ::CORBA::Long _from, int& _to)
00179 {
00180 _to = _from;
00181 return true;
00182 }
00183
00184 inline bool corba_to_local(const ::CORBA::ULong _from, unsigned int& _to)
00185 {
00186 _to = _from;
00187 return true;
00188 }
00189
00190 inline bool corba_to_local(const ::CORBA::Float _from, float& _to)
00191 {
00192 _to = _from;
00193 return true;
00194 }
00195
00196 inline bool corba_to_local(const ::CORBA::Double _from, double& _to)
00197 {
00198 _to = _from;
00199 return true;
00200 }
00201
00202 inline bool corba_to_local(const ::CORBA::Char _from, char& _to)
00203 {
00204 _to = _from;
00205 return true;
00206 }
00207
00208 inline bool corba_to_local(const ::CORBA::Boolean _from, unsigned char& _to)
00209 {
00210 _to = _from;
00211 return true;
00212 }
00213
00214 inline bool corba_to_local(const ::CORBA::Octet _from, unsigned char& _to)
00215 {
00216 _to = _from;
00217 return true;
00218 }
00219
00220 inline bool corba_to_local(const ::CORBA::Boolean _from, bool& _to)
00221 {
00222 _to = _from;
00223 return true;
00224 }
00225
00226 inline bool corba_to_local(const char* _from, std::string& _to)
00227 {
00228 _to = _from;
00229 return true;
00230 }
00231
00232
00233
00234
00235
00236
00237 inline bool corba_to_local(const ::CORBA::Any& _from, std::string& _to)
00238 {
00239 const char* str;
00240 if (_from >>= str)
00241 {
00242 _to = str;
00243 return true;
00244 }
00245 ::CORBA::Short short_var;
00246 if (_from >>= short_var)
00247 {
00248 _to = ::coil::otos(short_var);
00249 return true;
00250 }
00251 ::CORBA::UShort ushort_var;
00252 if (_from >>= ushort_var)
00253 {
00254 _to = ::coil::otos(ushort_var);
00255 return true;
00256 }
00257 ::CORBA::Long long_var;
00258 if (_from >>= long_var)
00259 {
00260 _to = ::coil::otos(long_var);
00261 return true;
00262 }
00263 ::CORBA::ULong ulong_var;
00264 if (_from >>= ulong_var)
00265 {
00266 _to = ::coil::otos(ulong_var);
00267 return true;
00268 }
00269 ::CORBA::Float float_var;
00270 if (_from >>= float_var)
00271 {
00272 _to = ::coil::otos(float_var);
00273 return true;
00274 }
00275 ::CORBA::Double double_var;
00276 if (_from >>= double_var)
00277 {
00278 _to = ::coil::otos(double_var);
00279 return true;
00280 }
00281 }
00282
00283 inline bool
00284 corba_to_local(const CORBA::TypeCode_member& _from, std::string& _to)
00285 {
00286 try
00287 {
00288 _to = _from->name();
00289 return true;
00290 }
00291 catch ( ::CORBA::TypeCode::BadKind& e )
00292 {
00293 return false;
00294 }
00295 return true;
00296 }
00297
00298
00299 #endif // DOIL_CORBA_UTIL_H