1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
ACE_INLINE
CDR::CDR (u_char *buf,
u_int len,
int byte_order,
int consume_buf)
// Constructor ... buffer must be aligned for the strictest CDR
// alignment requirement, since the algorithms used here only
// maintain alignment with respect to &buffer [0].
//
// Yes, that complicates the grow() primitive.
: real_buffer(buf),
do_free(consume_buf),
do_byteswap(byte_order != MY_BYTE_SEX)
{
ptr_arith_t temp = (ptr_arith_t) buf;
temp += MAX_ALIGNMENT - 1;
temp &= ~((ptr_arith_t) MAX_ALIGNMENT - 1);
buffer = next = (u_char *) temp;
remaining = len - (u_int) (buffer - real_buffer);
length = remaining;
}
ACE_INLINE
CDR::~CDR (void)
{
if (do_free)
delete real_buffer;
}
ACE_INLINE void *
CDR::operator new (size_t, void *_FAR p)
{
return p;
}
ACE_INLINE void *
CDR::operator new (size_t s)
{
return ::operator new (s);
}
ACE_INLINE void
CDR::operator delete (void *p)
{
::operator delete (p);
}
ACE_INLINE CORBA_Boolean
CDR::put_char (CORBA_Char c)
{
return put_byte ((char) c);
}
ACE_INLINE CORBA_Boolean
CDR::put_wchar (CORBA_WChar wc)
{
// "wchar_t" isn't always 2 bytes, such systems might need further
// conversion (e.g. hosts with multibyte characters native, rather
// than UNICODE)
return put_short ((short) wc);
}
ACE_INLINE CORBA_Boolean
CDR::put_boolean (CORBA_Boolean b)
{
return put_byte ((char) (b != CORBA_B_FALSE));
}
ACE_INLINE CORBA_Boolean
CDR::put_octet (CORBA_Octet o)
{
return put_byte ((char) o);
}
ACE_INLINE CORBA_Boolean
CDR::put_ushort (CORBA_UShort s)
{
return put_short ((CORBA_Short) s);
}
ACE_INLINE CORBA_Boolean
CDR::put_ulong (CORBA_ULong l)
{
return put_long ((CORBA_Long) l);
}
ACE_INLINE CORBA_Boolean
CDR::put_ulonglong (const CORBA_ULongLong &ll)
{
return put_longlong ((CORBA_LongLong &) ll);
}
ACE_INLINE CORBA_Boolean
CDR::put_float (float f)
{
return put_long (*(CORBA_Long *) &f);
}
ACE_INLINE CORBA_Boolean
CDR::put_double (const double &d)
{
return put_longlong (*(CORBA_LongLong *) &d);
}
ACE_INLINE CORBA_Boolean
CDR::get_char (CORBA_Char &o)
{
return this->get_byte ((char &) o);
}
ACE_INLINE CORBA_Boolean
CDR::get_wchar (CORBA_WChar &wc)
{
short s;
// wchar_t isn't always "short"
CORBA_Boolean retval = this->get_short (s);
wc = s;
return retval;
}
ACE_INLINE CORBA_Boolean
CDR::get_boolean (CORBA_Boolean &b)
{
CORBA_Char c;
//
// CORBA_Boolean is rarely 'char'
//
CORBA_Boolean retval = this->get_char (c);
b = (c == 1);
return retval;
}
ACE_INLINE CORBA_Boolean
CDR::get_octet (CORBA_Octet &o)
{
return this->get_byte ((char &) o);
}
ACE_INLINE CORBA_Boolean
CDR::get_ushort (CORBA_UShort &s)
{
return this->get_short ((short&) s);
}
ACE_INLINE CORBA_Boolean
CDR::get_ulong (CORBA_ULong &l)
{
return this->get_long ((CORBA_Long &) l);
}
ACE_INLINE CORBA_Boolean
CDR::get_ulonglong (const CORBA_ULongLong &ull)
{
return this->get_longlong ((CORBA_LongLong &) ull);
}
ACE_INLINE CORBA_Boolean
CDR::get_float (float &f)
{
return this->get_long ((CORBA_Long &) f);
}
ACE_INLINE CORBA_Boolean
CDR::get_double (double &d)
{
return this->get_longlong ((CORBA_LongLong &) d);
}
ACE_INLINE CORBA_Boolean
CDR::skip_bytes (u_int nbytes)
{
if (remaining < nbytes)
return CORBA_B_FALSE;
remaining -= nbytes;
next += nbytes;
return CORBA_B_TRUE;
}
ACE_INLINE void
CDR::setup_encapsulation (u_char *buf, u_int len)
{
// Also used when interpreting typecodes, but more generally when
// getting ready to read from encapsulations. In such cases the
// buffer alignment guarantees must be provided by the caller, this
// code doesn't verify them. These streams are "read only".
next = buf + 1;
remaining = len - 1;
do_byteswap = (*buf != MY_BYTE_SEX);
do_free = 0;
}
ACE_INLINE size_t
CDR::bytes_remaining (void)
{
return remaining;
}
|