A CDR stream for calculating size of the representation. More...
#include <CDR_Size.h>
Public Member Functions | |
ACE_SizeCDR (ACE_CDR::Octet major_version=ACE_CDR_GIOP_MAJOR_VERSION, ACE_CDR::Octet minor_version=ACE_CDR_GIOP_MINOR_VERSION) | |
Default constructor. | |
bool | good_bit (void) const |
Returns false if an error has ocurred. | |
void | reset (void) |
Reset current size. | |
size_t | total_length (void) const |
Return current size. | |
ACE_CDR::Boolean | write_boolean (ACE_CDR::Boolean x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_char (ACE_CDR::Char x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_wchar (ACE_CDR::WChar x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_octet (ACE_CDR::Octet x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_short (ACE_CDR::Short x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_ushort (ACE_CDR::UShort x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_long (ACE_CDR::Long x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_ulong (ACE_CDR::ULong x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_longlong (const ACE_CDR::LongLong &x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_ulonglong (const ACE_CDR::ULongLong &x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_float (ACE_CDR::Float x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_double (const ACE_CDR::Double &x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_longdouble (const ACE_CDR::LongDouble &x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_string (const ACE_CDR::Char *x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_string (ACE_CDR::ULong len, const ACE_CDR::Char *x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_string (const ACE_CString &x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_wstring (const ACE_CDR::WChar *x) |
For string we offer methods that accept a precomputed length. | |
ACE_CDR::Boolean | write_wstring (ACE_CDR::ULong length, const ACE_CDR::WChar *x) |
For string we offer methods that accept a precomputed length. | |
| |
bool | good_bit_ |
Set to false when an error ocurrs. | |
size_t | size_ |
Current size. | |
ACE_CDR::Octet | major_version_ |
GIOP version information. | |
ACE_CDR::Octet | minor_version_ |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_boolean_array (const ACE_CDR::Boolean *x, ACE_CDR::ULong length) |
ACE_CDR::Boolean | write_char_array (const ACE_CDR::Char *x, ACE_CDR::ULong length) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_wchar_array (const ACE_CDR::WChar *x, ACE_CDR::ULong length) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_octet_array (const ACE_CDR::Octet *x, ACE_CDR::ULong length) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_short_array (const ACE_CDR::Short *x, ACE_CDR::ULong length) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_ushort_array (const ACE_CDR::UShort *x, ACE_CDR::ULong length) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_long_array (const ACE_CDR::Long *x, ACE_CDR::ULong length) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_ulong_array (const ACE_CDR::ULong *x, ACE_CDR::ULong length) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_longlong_array (const ACE_CDR::LongLong *x, ACE_CDR::ULong length) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_ulonglong_array (const ACE_CDR::ULongLong *x, ACE_CDR::ULong length) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_float_array (const ACE_CDR::Float *x, ACE_CDR::ULong length) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_double_array (const ACE_CDR::Double *x, ACE_CDR::ULong length) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_longdouble_array (const ACE_CDR::LongDouble *x, ACE_CDR::ULong length) |
Set to false when an error ocurrs. | |
void | adjust (size_t size) |
void | adjust (size_t size, size_t align) |
ACE_SizeCDR (const ACE_SizeCDR &rhs) | |
disallow copying... | |
ACE_SizeCDR & | operator= (const ACE_SizeCDR &rhs) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_1 (const ACE_CDR::Octet *x) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_2 (const ACE_CDR::UShort *x) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_4 (const ACE_CDR::ULong *x) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_8 (const ACE_CDR::ULongLong *x) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_16 (const ACE_CDR::LongDouble *x) |
Set to false when an error ocurrs. | |
ACE_CDR::Boolean | write_array (const void *x, size_t size, size_t align, ACE_CDR::ULong length) |
ACE_CDR::Boolean | write_wchar_array_i (const ACE_CDR::WChar *x, ACE_CDR::ULong length) |
Set to false when an error ocurrs. |
A CDR stream for calculating size of the representation.
Definition at line 47 of file CDR_Size.h.
ACE_SizeCDR::ACE_SizeCDR | ( | ACE_CDR::Octet | major_version = ACE_CDR_GIOP_MAJOR_VERSION , |
|
ACE_CDR::Octet | minor_version = ACE_CDR_GIOP_MINOR_VERSION | |||
) | [inline] |
Default constructor.
Definition at line 10 of file CDR_Size.inl.
: good_bit_ (true), size_ (0), major_version_ (major_version), minor_version_ (minor_version) { }
ACE_SizeCDR::ACE_SizeCDR | ( | const ACE_SizeCDR & | rhs | ) | [private] |
disallow copying...
void ACE_SizeCDR::adjust | ( | size_t | size | ) |
Adjust to size and count <size> octets.
Definition at line 239 of file CDR_Size.cpp.
void ACE_SizeCDR::adjust | ( | size_t | size, | |
size_t | align | |||
) |
As above, but now the size and alignment requirements may be different.
Definition at line 245 of file CDR_Size.cpp.
bool ACE_SizeCDR::good_bit | ( | void | ) | const [inline] |
Returns false
if an error has ocurred.
Definition at line 20 of file CDR_Size.inl.
{ return this->good_bit_; }
ACE_SizeCDR& ACE_SizeCDR::operator= | ( | const ACE_SizeCDR & | rhs | ) | [private] |
Set to false when an error ocurrs.
void ACE_SizeCDR::reset | ( | void | ) | [inline] |
size_t ACE_SizeCDR::total_length | ( | void | ) | const [inline] |
ACE_CDR::Boolean ACE_SizeCDR::write_1 | ( | const ACE_CDR::Octet * | x | ) | [private] |
Set to false when an error ocurrs.
Definition at line 166 of file CDR_Size.cpp.
{ this->adjust (1); return true; }
ACE_CDR::Boolean ACE_SizeCDR::write_16 | ( | const ACE_CDR::LongDouble * | x | ) | [private] |
Set to false when an error ocurrs.
Definition at line 194 of file CDR_Size.cpp.
{ this->adjust (ACE_CDR::LONGDOUBLE_SIZE, ACE_CDR::LONGDOUBLE_ALIGN); return true; }
ACE_CDR::Boolean ACE_SizeCDR::write_2 | ( | const ACE_CDR::UShort * | x | ) | [private] |
Set to false when an error ocurrs.
Definition at line 173 of file CDR_Size.cpp.
{ this->adjust (ACE_CDR::SHORT_SIZE); return true; }
ACE_CDR::Boolean ACE_SizeCDR::write_4 | ( | const ACE_CDR::ULong * | x | ) | [private] |
Set to false when an error ocurrs.
Definition at line 180 of file CDR_Size.cpp.
{ this->adjust (ACE_CDR::LONG_SIZE); return true; }
ACE_CDR::Boolean ACE_SizeCDR::write_8 | ( | const ACE_CDR::ULongLong * | x | ) | [private] |
Set to false when an error ocurrs.
Definition at line 187 of file CDR_Size.cpp.
{ this->adjust (ACE_CDR::LONGLONG_SIZE); return true; }
ACE_CDR::Boolean ACE_SizeCDR::write_array | ( | const void * | x, | |
size_t | size, | |||
size_t | align, | |||
ACE_CDR::ULong | length | |||
) | [private] |
write an array of length elements, each of size bytes and the start aligned at a multiple of <align>. The elements are assumed to be packed with the right alignment restrictions. It is mostly designed for buffers of the basic types.
This operation uses <memcpy>; as explained above it is expected that using assignment is faster that <memcpy> for one element, but for several elements <memcpy> should be more efficient, it could be interesting to find the break even point and optimize for that case, but that would be too platform dependent.
Definition at line 218 of file CDR_Size.cpp.
ACE_CDR::Boolean ACE_SizeCDR::write_boolean | ( | ACE_CDR::Boolean | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 47 of file CDR_Size.inl.
{ return (ACE_CDR::Boolean) this->write_octet (x ? (ACE_CDR::Octet) 1 : (ACE_CDR::Octet) 0); }
ACE_CDR::Boolean ACE_SizeCDR::write_boolean_array | ( | const ACE_CDR::Boolean * | x, | |
ACE_CDR::ULong | length | |||
) |
Definition at line 231 of file CDR_Size.cpp.
{ this->adjust (length, 1); return true; }
ACE_CDR::Boolean ACE_SizeCDR::write_char | ( | ACE_CDR::Char | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 53 of file CDR_Size.inl.
{ // Note: translator framework is not supported. // return this->write_1 (reinterpret_cast<const ACE_CDR::Octet*> (&x)); }
ACE_CDR::Boolean ACE_SizeCDR::write_char_array | ( | const ACE_CDR::Char * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Set to false when an error ocurrs.
Definition at line 143 of file CDR_Size.inl.
{ // Note: translator framework is not supported. // return this->write_array (x, ACE_CDR::OCTET_SIZE, ACE_CDR::OCTET_ALIGN, length); }
ACE_CDR::Boolean ACE_SizeCDR::write_double | ( | const ACE_CDR::Double & | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 105 of file CDR_Size.inl.
{ const void *temp = &x; return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (temp)); }
ACE_CDR::Boolean ACE_SizeCDR::write_double_array | ( | const ACE_CDR::Double * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Set to false when an error ocurrs.
Definition at line 257 of file CDR_Size.inl.
{ return this->write_array (x, ACE_CDR::LONGLONG_SIZE, ACE_CDR::LONGLONG_ALIGN, length); }
ACE_CDR::Boolean ACE_SizeCDR::write_float | ( | ACE_CDR::Float | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 98 of file CDR_Size.inl.
{ const void *temp = &x; return this->write_4 (reinterpret_cast<const ACE_CDR::ULong *> (temp)); }
ACE_CDR::Boolean ACE_SizeCDR::write_float_array | ( | const ACE_CDR::Float * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Set to false when an error ocurrs.
Definition at line 246 of file CDR_Size.inl.
{ return this->write_array (x, ACE_CDR::LONG_SIZE, ACE_CDR::LONG_ALIGN, length); }
ACE_CDR::Boolean ACE_SizeCDR::write_long | ( | ACE_CDR::Long | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 73 of file CDR_Size.inl.
{ return this->write_4 (reinterpret_cast<const ACE_CDR::ULong*> (&x)); }
ACE_CDR::Boolean ACE_SizeCDR::write_long_array | ( | const ACE_CDR::Long * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Set to false when an error ocurrs.
Definition at line 206 of file CDR_Size.inl.
{ return this->write_array (x, ACE_CDR::LONG_SIZE, ACE_CDR::LONG_ALIGN, length); }
ACE_CDR::Boolean ACE_SizeCDR::write_longdouble | ( | const ACE_CDR::LongDouble & | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 112 of file CDR_Size.inl.
{ const void *temp = &x; return this->write_16 (reinterpret_cast<const ACE_CDR::LongDouble*> (temp)); }
ACE_CDR::Boolean ACE_SizeCDR::write_longdouble_array | ( | const ACE_CDR::LongDouble * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Set to false when an error ocurrs.
Definition at line 267 of file CDR_Size.inl.
{ return this->write_array (x, ACE_CDR::LONGDOUBLE_SIZE, ACE_CDR::LONGDOUBLE_ALIGN, length); }
ACE_CDR::Boolean ACE_SizeCDR::write_longlong | ( | const ACE_CDR::LongLong & | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 85 of file CDR_Size.inl.
{ return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (&x)); }
ACE_CDR::Boolean ACE_SizeCDR::write_longlong_array | ( | const ACE_CDR::LongLong * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Set to false when an error ocurrs.
Definition at line 226 of file CDR_Size.inl.
{ return this->write_array (x, ACE_CDR::LONGLONG_SIZE, ACE_CDR::LONGLONG_ALIGN, length); }
ACE_CDR::Boolean ACE_SizeCDR::write_octet | ( | ACE_CDR::Octet | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 41 of file CDR_Size.inl.
{ return this->write_1 (reinterpret_cast<const ACE_CDR::Octet *> (&x)); }
ACE_CDR::Boolean ACE_SizeCDR::write_octet_array | ( | const ACE_CDR::Octet * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Set to false when an error ocurrs.
Definition at line 176 of file CDR_Size.inl.
{ return this->write_array (x, ACE_CDR::OCTET_SIZE, ACE_CDR::OCTET_ALIGN, length); }
ACE_CDR::Boolean ACE_SizeCDR::write_short | ( | ACE_CDR::Short | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 61 of file CDR_Size.inl.
{ return this->write_2 (reinterpret_cast<const ACE_CDR::UShort*> (&x)); }
ACE_CDR::Boolean ACE_SizeCDR::write_short_array | ( | const ACE_CDR::Short * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Set to false when an error ocurrs.
Definition at line 186 of file CDR_Size.inl.
{ return this->write_array (x, ACE_CDR::SHORT_SIZE, ACE_CDR::SHORT_ALIGN, length); }
ACE_CDR::Boolean ACE_SizeCDR::write_string | ( | ACE_CDR::ULong | len, | |
const ACE_CDR::Char * | x | |||
) |
For string we offer methods that accept a precomputed length.
Definition at line 85 of file CDR_Size.cpp.
{ // Note: translator framework is not supported. // if (len != 0) { if (this->write_ulong (len + 1)) return this->write_char_array (x, len + 1); } else { // Be nice to programmers: treat nulls as empty strings not // errors. (OMG-IDL supports languages that don't use the C/C++ // notion of null v. empty strings; nulls aren't part of the OMG-IDL // string model.) if (this->write_ulong (1)) return this->write_char (0); } return (this->good_bit_ = false); }
ACE_CDR::Boolean ACE_SizeCDR::write_string | ( | const ACE_CString & | x | ) |
For string we offer methods that accept a precomputed length.
Definition at line 109 of file CDR_Size.cpp.
{ // @@ Leave this method in here, not the `.i' file so that we don't // have to unnecessarily pull in the `ace/SString.h' header. return this->write_string (static_cast<ACE_CDR::ULong> (x.length ()), x.c_str()); }
ACE_CDR::Boolean ACE_SizeCDR::write_string | ( | const ACE_CDR::Char * | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 119 of file CDR_Size.inl.
{ if (x != 0) { const ACE_CDR::ULong len = static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x)); return this->write_string (len, x); } return this->write_string (0, 0); }
ACE_CDR::Boolean ACE_SizeCDR::write_ulong | ( | ACE_CDR::ULong | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 79 of file CDR_Size.inl.
{ return this->write_4 (reinterpret_cast<const ACE_CDR::ULong*> (&x)); }
ACE_CDR::Boolean ACE_SizeCDR::write_ulong_array | ( | const ACE_CDR::ULong * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Set to false when an error ocurrs.
Definition at line 216 of file CDR_Size.inl.
{ return this->write_array (x, ACE_CDR::LONG_SIZE, ACE_CDR::LONG_ALIGN, length); }
ACE_CDR::Boolean ACE_SizeCDR::write_ulonglong | ( | const ACE_CDR::ULongLong & | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 91 of file CDR_Size.inl.
{ const void *temp = &x; return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong *> (temp)); }
ACE_CDR::Boolean ACE_SizeCDR::write_ulonglong_array | ( | const ACE_CDR::ULongLong * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Set to false when an error ocurrs.
Definition at line 236 of file CDR_Size.inl.
{ return this->write_array (x, ACE_CDR::LONGLONG_SIZE, ACE_CDR::LONGLONG_ALIGN, length); }
ACE_CDR::Boolean ACE_SizeCDR::write_ushort | ( | ACE_CDR::UShort | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 67 of file CDR_Size.inl.
{ return this->write_2 (reinterpret_cast<const ACE_CDR::UShort*> (&x)); }
ACE_CDR::Boolean ACE_SizeCDR::write_ushort_array | ( | const ACE_CDR::UShort * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Set to false when an error ocurrs.
Definition at line 196 of file CDR_Size.inl.
{ return this->write_array (x, ACE_CDR::SHORT_SIZE, ACE_CDR::SHORT_ALIGN, length); }
ACE_CDR::Boolean ACE_SizeCDR::write_wchar | ( | ACE_CDR::WChar | x | ) |
For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean ACE_SizeCDR::write_wchar_array | ( | const ACE_CDR::WChar * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Set to false when an error ocurrs.
Definition at line 155 of file CDR_Size.inl.
{ // Note: translator framework is not supported. // if (ACE_OutputCDR::wchar_maxbytes () == 0) { errno = EACCES; return (ACE_CDR::Boolean) (this->good_bit_ = false); } if (ACE_OutputCDR::wchar_maxbytes () == sizeof (ACE_CDR::WChar)) return this->write_array (x, sizeof (ACE_CDR::WChar), sizeof (ACE_CDR::WChar) == 2 ? ACE_CDR::SHORT_ALIGN : ACE_CDR::LONG_ALIGN, length); return this->write_wchar_array_i (x,length); }
ACE_CDR::Boolean ACE_SizeCDR::write_wchar_array_i | ( | const ACE_CDR::WChar * | x, | |
ACE_CDR::ULong | length | |||
) | [private] |
Set to false when an error ocurrs.
Definition at line 202 of file CDR_Size.cpp.
{ if (length == 0) return true; size_t const align = (ACE_OutputCDR::wchar_maxbytes () == 2) ? ACE_CDR::SHORT_ALIGN : ACE_CDR::OCTET_ALIGN; this->adjust (ACE_OutputCDR::wchar_maxbytes () * length, align); return true; }
ACE_CDR::Boolean ACE_SizeCDR::write_wstring | ( | const ACE_CDR::WChar * | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 131 of file CDR_Size.inl.
{ if (x != 0) { ACE_CDR::ULong len = static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x)); return this->write_wstring (len, x); } return this->write_wstring (0, 0); }
ACE_CDR::Boolean ACE_SizeCDR::write_wstring | ( | ACE_CDR::ULong | length, | |
const ACE_CDR::WChar * | x | |||
) |
For string we offer methods that accept a precomputed length.
Definition at line 118 of file CDR_Size.cpp.
{ // Note: translator framework is not supported. // if (ACE_OutputCDR::wchar_maxbytes () == 0) { errno = EACCES; return (this->good_bit_ = false); } if (static_cast<ACE_CDR::Short> (this->major_version_) == 1 && static_cast<ACE_CDR::Short> (this->minor_version_) == 2) { if (x != 0) { //In GIOP 1.2 the length field contains the number of bytes //the wstring occupies rather than number of wchars //Taking sizeof might not be a good way! This is a temporary fix. ACE_CDR::Boolean good_ulong = this->write_ulong ( ACE_Utils::truncate_cast<ACE_CDR::ULong> ( ACE_OutputCDR::wchar_maxbytes () * len)); if (good_ulong) { return this->write_wchar_array (x, len); } } else { //In GIOP 1.2 zero length wstrings are legal return this->write_ulong (0); } } else if (x != 0) { if (this->write_ulong (len + 1)) return this->write_wchar_array (x, len + 1); } else if (this->write_ulong (1)) return this->write_wchar (0); return (this->good_bit_ = false); }
bool ACE_SizeCDR::good_bit_ [private] |
Set to false when an error ocurrs.
Definition at line 166 of file CDR_Size.h.
ACE_CDR::Octet ACE_SizeCDR::major_version_ [protected] |
GIOP version information.
Definition at line 173 of file CDR_Size.h.
ACE_CDR::Octet ACE_SizeCDR::minor_version_ [protected] |
Set to false when an error ocurrs.
Definition at line 174 of file CDR_Size.h.
size_t ACE_SizeCDR::size_ [private] |
Current size.
Definition at line 169 of file CDR_Size.h.