#include <ace/CDR.h>
class ACE_CDR {
public:
enum{ OCTET_SIZE = 1, SHORT_SIZE = 2, LONG_SIZE = 4, LONGLONG_SIZE = 8, LONGDOUBLE_SIZE = 16, OCTET_ALIGN = 1, SHORT_ALIGN = 2, LONG_ALIGN = 4, LONGLONG_ALIGN = 8, LONGDOUBLE_ALIGN = 8, MAX_ALIGNMENT = 8, DEFAULT_BUFSIZE = ACE_DEFAULT_CDR_BUFSIZE, EXP_GROWTH_MAX = ACE_DEFAULT_CDR_EXP_GROWTH_MAX, LINEAR_GROWTH_CHUNK = ACE_DEFAULT_CDR_LINEAR_GROWTH_CHUNK };static void swap_2 (const char *orig, char *target);
static void swap_4 (const char *orig, char *target);
static void swap_8 (const char *orig, char *target);
static void swap_16 (const char *orig, char *target);
static void mb_align (ACE_Message_Block *mb);
static int grow (ACE_Message_Block *mb, size_t minsize);
static size_t total_length ( const ACE_Message_Block *begin, const ACE_Message_Block *end );
typedef unsigned long Boolean;
typedef u_char Boolean;
typedef u_char Octet;
typedef char Char;
typedef ACE_OS::WChar WChar;
typedef ACE_INT16 Short;
typedef ACE_UINT16 UShort;
typedef ACE_INT32 Long;
typedef ACE_UINT32 ULong;
typedef ACE_UINT64 ULongLong;
typedef __int64 LongLong;
typedef long LongLong;
typedef longlong_t LongLong;
typedef long long LongLong;
typedef float Float;
struct Float {
public:
u_int f;
char f[4];
};
typedef double Double;
typedef long double LongDouble;
};
This implementation assumes that the native numeric representation is two's complement for integers, IEEE single/double for floats. Also that characters are in ISO Latin/1.
Note that CDR itself makes no such assumptions, but this implementation makes such assumptions for reasons of efficiency. Careful enhancements could preserve that efficiency where the assumptions are true, yet still allow the code to work when they aren't true.
The implementation expects that buffers are aligned according to the strongest CDR alignment restriction.
NOTE: this does everything "CDR 1.1" does ... that is, it supports the five extended OMG-IDL data types in UNO Appendix A, which provide richer arithmetic types (64 bit integers, "quad precision" FP) and UNICODE-based characters and strings. Those types are not standard parts of OMG-IDL at this time.
THREADING NOTE: CDR data structures must be protected against concurrent access by their owning thread.
static void swap_2 (const char *orig, char *target);
static void swap_4 (const char *orig, char *target);
static void swap_8 (const char *orig, char *target);
static void swap_16 (const char *orig, char *target);
static void mb_align (ACE_Message_Block *mb);
static int grow (ACE_Message_Block *mb, size_t minsize);
minsize
bytes.
If minsize
is zero the size is increased by an amount at least
large enough to contain any of the basic IDL types. Return -1 on
failure, 0 on success.
static size_t total_length (
const ACE_Message_Block *begin,
const ACE_Message_Block *end
);
Definitions of the IDL basic types, for use in the CDR classes. The cleanest way to avoid complaints from all compilers is to define them all. This is non-compliant, but a nasty bout with Green Hills C++68000 1.8.8 forces us into it.
typedef unsigned long Boolean;
typedef u_char Boolean;
typedef u_char Octet;
typedef char Char;
typedef ACE_OS::WChar WChar;
typedef ACE_INT16 Short;
typedef ACE_UINT16 UShort;
typedef ACE_INT32 Long;
typedef ACE_UINT32 ULong;
typedef ACE_UINT64 ULongLong;
typedef __int64 LongLong;
typedef long LongLong;
sun #defines u_longlong_t, maybe other platforms do also. Use it, at least with g++, so that its -pedantic doesn't complain about no ANSI C++ long long.
typedef longlong_t LongLong;
LynxOS 2.5.0 and Linux don't have u_longlong_t.
typedef long long LongLong;
If "long long" isn't native, programs can't use these data types in normal arithmetic expressions. If any particular application can cope with the loss of range, it can define conversion operators itself.
typedef float Float;
typedef double Double;
94-9-32 Appendix A defines a 128 bit floating point "long double" data type, with greatly extended precision and four more bits of exponent (compared to "double"). This is an IDL extension, not yet standard.
typedef long double LongDouble;
gokhale@cs.wustl.edu
and Carlos O'Ryan coryan@cs.wustl.edu
for TAO. ACE version by Jeff Parsons parsons@cs.wustl.edu
and Istvan Buki istvan.buki@euronet.be
.