Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ACE_CDR_BASE_H
00029 #define ACE_CDR_BASE_H
00030
00031 #include "ace/pre.h"
00032
00033 #include "ace/config-all.h"
00034
00035 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00036 # pragma once
00037 #endif
00038
00039 #include "ace/Basic_Types.h"
00040 #include "ace/Default_Constants.h"
00041
00042 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00043
00044
00045
00046 #if defined ACE_LITTLE_ENDIAN
00047 # define ACE_CDR_BYTE_ORDER 1
00048
00049 #else
00050 # define ACE_CDR_BYTE_ORDER 0
00051
00052 #endif
00053
00054 class ACE_Message_Block;
00055
00056
00057
00058
00059
00060
00061
00062 class ACE_Export ACE_CDR
00063 {
00064 public:
00065
00066
00067
00068
00069
00070 enum
00071 {
00072
00073
00074
00075
00076 OCTET_SIZE = 1,
00077 SHORT_SIZE = 2,
00078 LONG_SIZE = 4,
00079 LONGLONG_SIZE = 8,
00080 LONGDOUBLE_SIZE = 16,
00081
00082 OCTET_ALIGN = 1,
00083 SHORT_ALIGN = 2,
00084 LONG_ALIGN = 4,
00085 LONGLONG_ALIGN = 8,
00086
00087
00088 LONGDOUBLE_ALIGN = 8,
00089
00090
00091
00092 MAX_ALIGNMENT = 8,
00093
00094
00095
00096
00097
00098
00099
00100 DEFAULT_BUFSIZE = ACE_DEFAULT_CDR_BUFSIZE,
00101
00102
00103
00104 EXP_GROWTH_MAX = ACE_DEFAULT_CDR_EXP_GROWTH_MAX,
00105
00106
00107
00108
00109 LINEAR_GROWTH_CHUNK = ACE_DEFAULT_CDR_LINEAR_GROWTH_CHUNK
00110 };
00111
00112
00113
00114
00115
00116
00117
00118 enum Byte_Order
00119 {
00120
00121 BYTE_ORDER_BIG_ENDIAN = 0,
00122
00123 BYTE_ORDER_LITTLE_ENDIAN = 1,
00124
00125 BYTE_ORDER_NATIVE = ACE_CDR_BYTE_ORDER
00126 };
00127
00128
00129
00130
00131
00132
00133
00134 static void swap_2 (char const *orig, char *target);
00135 static void swap_4 (char const *orig, char *target);
00136 static void swap_8 (char const *orig, char *target);
00137 static void swap_16 (char const *orig, char *target);
00138 static void swap_2_array (char const *orig,
00139 char *target,
00140 size_t length);
00141 static void swap_4_array (char const *orig,
00142 char *target,
00143 size_t length);
00144 static void swap_8_array (char const *orig,
00145 char *target,
00146 size_t length);
00147 static void swap_16_array (char const *orig,
00148 char *target,
00149 size_t length);
00150
00151
00152
00153 static void mb_align (ACE_Message_Block *mb);
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 static size_t first_size (size_t minsize);
00166
00167
00168
00169 static size_t next_size (size_t minsize);
00170
00171
00172
00173
00174
00175
00176
00177
00178 static int grow (ACE_Message_Block *mb, size_t minsize);
00179
00180
00181
00182
00183
00184
00185
00186
00187 static int consolidate (ACE_Message_Block *dst,
00188 const ACE_Message_Block *src);
00189
00190 static size_t total_length (const ACE_Message_Block *begin,
00191 const ACE_Message_Block *end);
00192
00193
00194
00195
00196
00197
00198
00199
00200 typedef bool Boolean;
00201 typedef unsigned char Octet;
00202 typedef char Char;
00203 typedef ACE_WCHAR_T WChar;
00204 typedef ACE_INT16 Short;
00205 typedef ACE_UINT16 UShort;
00206 typedef ACE_INT32 Long;
00207 typedef ACE_UINT32 ULong;
00208 typedef ACE_UINT64 ULongLong;
00209
00210 # if (defined (_MSC_VER)) || (defined (__BORLANDC__))
00211 typedef __int64 LongLong;
00212 # elif ACE_SIZEOF_LONG == 8 && !defined(_CRAYMPP)
00213 typedef long LongLong;
00214 # elif defined(__TANDEM)
00215 typedef long long LongLong;
00216 # elif ACE_SIZEOF_LONG_LONG == 8 && !defined (ACE_LACKS_LONGLONG_T)
00217 # if defined (sun) && !defined (ACE_LACKS_U_LONGLONG_T)
00218
00219
00220
00221 typedef longlong_t LongLong;
00222 # else
00223 typedef long long LongLong;
00224 # endif
00225 # else
00226 # define NONNATIVE_LONGLONG
00227 struct ACE_Export LongLong
00228 {
00229 # if defined (ACE_BIG_ENDIAN)
00230 ACE_CDR::Long h;
00231 ACE_CDR::Long l;
00232 # else
00233 ACE_CDR::Long l;
00234 ACE_CDR::Long h;
00235 # endif
00236
00237
00238
00239
00240
00241
00242
00243 bool operator== (const LongLong &rhs) const;
00244 bool operator!= (const LongLong &rhs) const;
00245
00246 };
00247 # endif
00248
00249 # if defined (NONNATIVE_LONGLONG)
00250 # define ACE_CDR_LONGLONG_INITIALIZER {0,0}
00251 # else
00252 # define ACE_CDR_LONGLONG_INITIALIZER 0
00253 # endif
00254
00255 # if ACE_SIZEOF_FLOAT == 4
00256 typedef float Float;
00257 # else
00258 struct Float
00259 {
00260 # if ACE_SIZEOF_INT == 4
00261
00262 unsigned int f;
00263 # else
00264
00265 char f[4];
00266 # if defined(_UNICOS) && !defined(_CRAYMPP)
00267 Float (void);
00268 Float (const float &init);
00269 Float & operator= (const float &rhs);
00270 bool operator!= (const Float &rhs) const;
00271 # endif
00272 # endif
00273 };
00274 # endif
00275
00276 # if ACE_SIZEOF_DOUBLE == 8
00277 typedef double Double;
00278 # else
00279 struct Double
00280 {
00281 # if ACE_SIZEOF_LONG == 8
00282
00283 unsigned long f;
00284 # else
00285
00286 char f[8];
00287 # endif
00288 };
00289 # endif
00290
00291
00292
00293
00294
00295
00296 # if ACE_SIZEOF_LONG_DOUBLE == 16
00297 typedef long double LongDouble;
00298 # define ACE_CDR_LONG_DOUBLE_INITIALIZER 0
00299 # define ACE_CDR_LONG_DOUBLE_ASSIGNMENT(LHS, RHS) LHS = RHS
00300 # else
00301 # define NONNATIVE_LONGDOUBLE
00302 # define ACE_CDR_LONG_DOUBLE_INITIALIZER {{0}}
00303 # define ACE_CDR_LONG_DOUBLE_ASSIGNMENT(LHS, RHS) LHS.assign (RHS)
00304 struct ACE_Export LongDouble
00305 {
00306
00307
00308
00309
00310
00311
00312
00313
00314 # if defined (ACE_CDR_IMPLEMENT_WITH_NATIVE_DOUBLE) && \
00315 (ACE_CDR_IMPLEMENT_WITH_NATIVE_DOUBLE == 1)
00316 typedef double NativeImpl;
00317 # else
00318 typedef long double NativeImpl;
00319 # endif
00320
00321 char ld[16];
00322
00323 LongDouble& assign (const NativeImpl& rhs);
00324 LongDouble& assign (const LongDouble& rhs);
00325
00326 bool operator== (const LongDouble &rhs) const;
00327 bool operator!= (const LongDouble &rhs) const;
00328
00329 LongDouble& operator*= (const NativeImpl rhs) {
00330 return this->assign (static_cast<NativeImpl> (*this) * rhs);
00331 }
00332 LongDouble& operator/= (const NativeImpl rhs) {
00333 return this->assign (static_cast<NativeImpl> (*this) / rhs);
00334 }
00335 LongDouble& operator+= (const NativeImpl rhs) {
00336 return this->assign (static_cast<NativeImpl> (*this) + rhs);
00337 }
00338 LongDouble& operator-= (const NativeImpl rhs) {
00339 return this->assign (static_cast<NativeImpl> (*this) - rhs);
00340 }
00341 LongDouble& operator++ () {
00342 return this->assign (static_cast<NativeImpl> (*this) + 1);
00343 }
00344 LongDouble& operator-- () {
00345 return this->assign (static_cast<NativeImpl> (*this) - 1);
00346 }
00347 LongDouble operator++ (int) {
00348 LongDouble ldv = *this;
00349 this->assign (static_cast<NativeImpl> (*this) + 1);
00350 return ldv;
00351 }
00352 LongDouble operator-- (int) {
00353 LongDouble ldv = *this;
00354 this->assign (static_cast<NativeImpl> (*this) - 1);
00355 return ldv;
00356 }
00357
00358 operator NativeImpl () const;
00359 };
00360 # endif
00361
00362
00363
00364 #if !defined (ACE_CDR_GIOP_MAJOR_VERSION)
00365 # define ACE_CDR_GIOP_MAJOR_VERSION 1
00366 #endif
00367
00368 #if !defined (ACE_CDR_GIOP_MINOR_VERSION)
00369 # define ACE_CDR_GIOP_MINOR_VERSION 2
00370 #endif
00371 };
00372
00373 ACE_END_VERSIONED_NAMESPACE_DECL
00374
00375 #if defined (__ACE_INLINE__)
00376 # include "ace/CDR_Base.inl"
00377 #endif
00378
00379
00380 #include "ace/post.h"
00381
00382 #endif