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