diff options
Diffstat (limited to 'ace')
-rw-r--r-- | ace/CDR_Stream.cpp | 224 | ||||
-rw-r--r-- | ace/CDR_Stream.h | 15 | ||||
-rw-r--r-- | ace/Codeset_Registry.cpp | 6 | ||||
-rw-r--r-- | ace/Codeset_Registry.h | 42 | ||||
-rw-r--r-- | ace/Codeset_Registry.inl | 8 | ||||
-rw-r--r-- | ace/Codeset_Registry_db.cpp | 7 |
6 files changed, 157 insertions, 145 deletions
diff --git a/ace/CDR_Stream.cpp b/ace/CDR_Stream.cpp index 8f1c9c2ec05..226c38c2806 100644 --- a/ace/CDR_Stream.cpp +++ b/ace/CDR_Stream.cpp @@ -109,6 +109,12 @@ ACE_OutputCDR::wchar_maxbytes (int maxbytes) ACE_OutputCDR::wchar_maxbytes_ = maxbytes; } +/*static*/ int +ACE_OutputCDR::wchar_maxbytes () +{ + return ACE_OutputCDR::wchar_maxbytes_; +} + int ACE_OutputCDR::grow_and_adjust (size_t size, size_t align, @@ -186,27 +192,27 @@ ACE_OutputCDR::write_wchar (ACE_CDR::WChar x) { ACE_CDR::Octet len = ACE_static_cast (ACE_CDR::Octet, ACE_OutputCDR::wchar_maxbytes_); if (this->write_1 (&len)) - { - if (ACE_OutputCDR::wchar_maxbytes_ == sizeof(ACE_CDR::WChar)) - return this->write_octet_array (ACE_reinterpret_cast - (const ACE_CDR::Octet*, &x), - ACE_static_cast (ACE_CDR::ULong, len)); - else - if (ACE_OutputCDR::wchar_maxbytes_ == 2) - { - ACE_CDR::Short sx = ACE_static_cast(ACE_CDR::Short,x); - return this->write_octet_array(ACE_reinterpret_cast - (const ACE_CDR::Octet*, &sx), - ACE_static_cast (ACE_CDR::ULong, len)); - } - else - { - ACE_CDR::Octet ox = ACE_static_cast(ACE_CDR::Octet,x); - return this->write_octet_array(ACE_reinterpret_cast - (const ACE_CDR::Octet*, &ox), - ACE_static_cast (ACE_CDR::ULong, len)); - } - } + { + if (ACE_OutputCDR::wchar_maxbytes_ == sizeof(ACE_CDR::WChar)) + return this->write_octet_array (ACE_reinterpret_cast + (const ACE_CDR::Octet*, &x), + ACE_static_cast (ACE_CDR::ULong, len)); + else + if (ACE_OutputCDR::wchar_maxbytes_ == 2) + { + ACE_CDR::Short sx = ACE_static_cast(ACE_CDR::Short,x); + return this->write_octet_array(ACE_reinterpret_cast + (const ACE_CDR::Octet*, &sx), + ACE_static_cast (ACE_CDR::ULong, len)); + } + else + { + ACE_CDR::Octet ox = ACE_static_cast(ACE_CDR::Octet,x); + return this->write_octet_array(ACE_reinterpret_cast + (const ACE_CDR::Octet*, &ox), + ACE_static_cast (ACE_CDR::ULong, len)); + } + } } else if (ACE_static_cast (ACE_CDR::Short, minor_version_) == 0) { // wchar is not allowed with GIOP 1.0. @@ -219,7 +225,7 @@ ACE_OutputCDR::write_wchar (ACE_CDR::WChar x) { ACE_CDR::Short sx = ACE_static_cast(ACE_CDR::Short,x); return this->write_2 (ACE_reinterpret_cast (const ACE_CDR::UShort *, - &sx)); + &sx)); } ACE_CDR::Octet ox = ACE_static_cast (ACE_CDR::Octet,x); return this->write_1 (ACE_reinterpret_cast (const ACE_CDR::Octet *, &ox)); @@ -503,7 +509,7 @@ ACE_OutputCDR::write_16 (const ACE_CDR::LongDouble *x) ACE_CDR::Boolean ACE_OutputCDR::write_wchar_array_i (const ACE_CDR::WChar *x, - ACE_CDR::ULong length) + ACE_CDR::ULong length) { if (length == 0) return 1; @@ -515,26 +521,26 @@ ACE_OutputCDR::write_wchar_array_i (const ACE_CDR::WChar *x, if (this->adjust (ACE_OutputCDR::wchar_maxbytes_ * length, align, buf) == 0) { if (ACE_OutputCDR::wchar_maxbytes_ == 2) - { - ACE_CDR::UShort *sb = ACE_reinterpret_cast(ACE_CDR::UShort *, buf); - for (size_t i = 0; i < length; i++) + { + ACE_CDR::UShort *sb = ACE_reinterpret_cast(ACE_CDR::UShort *, buf); + for (size_t i = 0; i < length; i++) #if !defined (ACE_ENABLE_SWAP_ON_WRITE) - sb[i] = ACE_static_cast (ACE_CDR::UShort, x[i]); + sb[i] = ACE_static_cast (ACE_CDR::UShort, x[i]); #else - if (!this->do_byte_swap_) - sb[i] = ACE_static_cast (ACE_CDR::UShort, x[i]);; - else - { - ACE_CDR::UShort sx = ACE_static_cast (ACE_CDR::UShort, x[i]); - ACE_CDR::swap_2 (ACE_reinterpret_cast(char *,&sx),&buf[i*2]); - } + if (!this->do_byte_swap_) + sb[i] = ACE_static_cast (ACE_CDR::UShort, x[i]);; + else + { + ACE_CDR::UShort sx = ACE_static_cast (ACE_CDR::UShort, x[i]); + ACE_CDR::swap_2 (ACE_reinterpret_cast(char *,&sx),&buf[i*2]); + } #endif /* ACE_DISABLE_SWAP_ON_READ */ - } + } else - { - for (size_t i = 0; i < length; i++) - buf[i] = ACE_static_cast (ACE_CDR::Octet, x[i]); - } + { + for (size_t i = 0; i < length; i++) + buf[i] = ACE_static_cast (ACE_CDR::Octet, x[i]); + } return this->good_bit_; } return 0; @@ -890,21 +896,21 @@ ACE_InputCDR::read_wchar (ACE_CDR::WChar& x) { if (ACE_static_cast (ACE_CDR::Short, major_version_) == 1 && ACE_static_cast (ACE_CDR::Short, minor_version_) == 2) - { - ACE_CDR::Octet len; + { + ACE_CDR::Octet len; - if (this->read_1 (&len)) - return this->read_octet_array - (ACE_reinterpret_cast (ACE_CDR::Octet*, &x), - ACE_static_cast (ACE_CDR::ULong, len)); - else - return (this->good_bit_ = 0); - } + if (this->read_1 (&len)) + return this->read_octet_array + (ACE_reinterpret_cast (ACE_CDR::Octet*, &x), + ACE_static_cast (ACE_CDR::ULong, len)); + else + return (this->good_bit_ = 0); + } if (sizeof (ACE_CDR::WChar) == 2) - return this->read_2 (ACE_reinterpret_cast (ACE_CDR::UShort *, &x)); + return this->read_2 (ACE_reinterpret_cast (ACE_CDR::UShort *, &x)); else - return this->read_4 (ACE_reinterpret_cast (ACE_CDR::ULong *, &x)); + return this->read_4 (ACE_reinterpret_cast (ACE_CDR::ULong *, &x)); } if (ACE_static_cast (ACE_CDR::Short, major_version_) == 1 @@ -913,52 +919,52 @@ ACE_InputCDR::read_wchar (ACE_CDR::WChar& x) ACE_CDR::Octet len; if (this->read_1 (&len)) - { - if (len == 2) - { - ACE_CDR::Short sx; - if (this->read_octet_array - (ACE_reinterpret_cast (ACE_CDR::Octet*, &sx), - ACE_static_cast (ACE_CDR::ULong, len))) - { - x = ACE_static_cast(ACE_CDR::WChar, sx); - return 1; - } - } - else - { - ACE_CDR::Octet ox; - if (this->read_octet_array - (ACE_reinterpret_cast (ACE_CDR::Octet*, &ox), - ACE_static_cast (ACE_CDR::ULong, len))) - { - x = ACE_static_cast(ACE_CDR::WChar, ox); - return 1; - } - } - } + { + if (len == 2) + { + ACE_CDR::Short sx; + if (this->read_octet_array + (ACE_reinterpret_cast (ACE_CDR::Octet*, &sx), + ACE_static_cast (ACE_CDR::ULong, len))) + { + x = ACE_static_cast(ACE_CDR::WChar, sx); + return 1; + } + } + else + { + ACE_CDR::Octet ox; + if (this->read_octet_array + (ACE_reinterpret_cast (ACE_CDR::Octet*, &ox), + ACE_static_cast (ACE_CDR::ULong, len))) + { + x = ACE_static_cast(ACE_CDR::WChar, ox); + return 1; + } + } + } } else { if (ACE_OutputCDR::wchar_maxbytes_ == 2) - { - ACE_CDR::Short sx; - if (this->read_2 (ACE_reinterpret_cast (ACE_CDR::UShort *, &sx))) - { - x = ACE_static_cast(ACE_CDR::WChar, sx); - return 1; - } - } + { + ACE_CDR::UShort sx; + if (this->read_2 (ACE_reinterpret_cast (ACE_CDR::UShort *, &sx))) + { + x = ACE_static_cast(ACE_CDR::WChar, sx); + return 1; + } + } else - { - ACE_CDR::Octet ox; - if (this->read_1 (&ox)) - { - x = ACE_static_cast(ACE_CDR::WChar, ox); - return 1; - } - - } + { + ACE_CDR::Octet ox; + if (this->read_1 (&ox)) + { + x = ACE_static_cast(ACE_CDR::WChar, ox); + return 1; + } + + } } return (this->good_bit_ = 0); } @@ -1145,7 +1151,7 @@ ACE_InputCDR::read_array (void* x, ACE_CDR::Boolean ACE_InputCDR::read_wchar_array_i (ACE_CDR::WChar* x, - ACE_CDR::ULong length) + ACE_CDR::ULong length) { if (length == 0) return 1; @@ -1157,27 +1163,27 @@ ACE_InputCDR::read_wchar_array_i (ACE_CDR::WChar* x, if (this->adjust (ACE_OutputCDR::wchar_maxbytes_ * length, align, buf) == 0) { if (ACE_OutputCDR::wchar_maxbytes_ == 2) - { - ACE_CDR::UShort *sb = ACE_reinterpret_cast(ACE_CDR::UShort *, buf); - for (size_t i = 0; i < length; i++) + { + ACE_CDR::UShort *sb = ACE_reinterpret_cast(ACE_CDR::UShort *, buf); + for (size_t i = 0; i < length; i++) #if defined (ACE_DISABLE_SWAP_ON_READ) - x[i] = ACE_static_cast (ACE_CDR::WChar, sb[i]); + x[i] = ACE_static_cast (ACE_CDR::WChar, sb[i]); #else - if (!this->do_byte_swap_) - x[i] = ACE_static_cast (ACE_CDR::WChar, sb[i]); - else - { - ACE_CDR::UShort sx; - ACE_CDR::swap_2 (&buf[i*2], ACE_reinterpret_cast(char *,&sx)); - x[i] = ACE_static_cast (ACE_CDR::WChar,sx); - } + if (!this->do_byte_swap_) + x[i] = ACE_static_cast (ACE_CDR::WChar, sb[i]); + else + { + ACE_CDR::UShort sx; + ACE_CDR::swap_2 (&buf[i*2], ACE_reinterpret_cast(char *,&sx)); + x[i] = ACE_static_cast (ACE_CDR::WChar,sx); + } #endif /* ACE_DISABLE_SWAP_ON_READ */ - } + } else - { - for (size_t i = 0; i < length; i++) - x[i] = ACE_static_cast (ACE_CDR::WChar, buf[i]); - } + { + for (size_t i = 0; i < length; i++) + x[i] = ACE_static_cast (ACE_CDR::Octet, buf[i]); + } return this->good_bit_; } return 0; diff --git a/ace/CDR_Stream.h b/ace/CDR_Stream.h index 6d1884fb550..dd4983c99a6 100644 --- a/ace/CDR_Stream.h +++ b/ace/CDR_Stream.h @@ -323,15 +323,22 @@ public: */ int align_write_ptr (size_t alignment); - /// Access the codeset translators. They can be nil! + /// Access the codeset translators. They can be null! ACE_Char_Codeset_Translator *char_translator (void) const; ACE_WChar_Codeset_Translator *wchar_translator (void) const; - /// Set the codeset translators. + /// Set the char codeset translator. void char_translator (ACE_Char_Codeset_Translator *); + /// Set the wchar codeset translator. void wchar_translator (ACE_WChar_Codeset_Translator *); + + /// set the global size of serialized wchars. This may be different + /// than the size of a wchar_t. static void wchar_maxbytes (int ); + /// access the serialized size of wchars. + static int wchar_maxbytes (void); + /** * Return alignment of the wr_ptr(), with respect to the start of * the CDR stream. This is not the same as the alignment of @@ -401,7 +408,7 @@ private: ACE_CDR::Boolean write_wchar_array_i (const ACE_CDR::WChar* x, - ACE_CDR::ULong length); + ACE_CDR::ULong length); /** @@ -917,7 +924,7 @@ private: * a default translator. */ ACE_CDR::Boolean read_wchar_array_i (ACE_CDR::WChar * x, - ACE_CDR::ULong length); + ACE_CDR::ULong length); /// Move the rd_ptr ahead by <offset> bytes. void rd_ptr (size_t offset); diff --git a/ace/Codeset_Registry.cpp b/ace/Codeset_Registry.cpp index 780f388d6e7..be7df8bc8d9 100644 --- a/ace/Codeset_Registry.cpp +++ b/ace/Codeset_Registry.cpp @@ -22,7 +22,7 @@ ACE_RCSID(ace, Codeset_Registry, "$Id$"); -ACE_CDR::Boolean +int ACE_Codeset_Registry::locale_to_registry_i (const ACE_CString &locale, ACE_CDR::ULong &codeset_id, ACE_CDR::UShort *num_sets, @@ -47,7 +47,7 @@ ACE_Codeset_Registry::locale_to_registry_i (const ACE_CString &locale, return 1; } -ACE_CDR::Boolean +int ACE_Codeset_Registry::registry_to_locale_i (ACE_CDR::ULong codeset_id, ACE_CString &locale, ACE_CDR::UShort *num_sets, @@ -72,7 +72,7 @@ ACE_Codeset_Registry::registry_to_locale_i (ACE_CDR::ULong codeset_id, return 1; } -ACE_CDR::Boolean +int ACE_Codeset_Registry::is_compatible_i (ACE_CDR::ULong codeset_id, ACE_CDR::ULong other) { diff --git a/ace/Codeset_Registry.h b/ace/Codeset_Registry.h index a54104d8af0..6f7ad62ac7d 100644 --- a/ace/Codeset_Registry.h +++ b/ace/Codeset_Registry.h @@ -42,22 +42,22 @@ public: // based on a locale string, find the registry value and optional codeset // collection. This wraps the dce_cs_loc_to_rgy function, or emulates it. - static ACE_CDR::Boolean locale_to_registry (const ACE_CString &locale, - ACE_CDR::ULong &codeset_id, - ACE_CDR::UShort * = 0, - ACE_CDR::UShort ** = 0); + static int locale_to_registry (const ACE_CString &locale, + ACE_CDR::ULong &codeset_id, + ACE_CDR::UShort * = 0, + ACE_CDR::UShort ** = 0); // based on a registry value, find the locale string and optional codeset // collection. This wraps the dce_cs_rgy_to_loc function, or emulates it. - static ACE_CDR::Boolean registry_to_locale (ACE_CDR::ULong codeset_id, - ACE_CString &locale, - ACE_CDR::UShort * = 0, - ACE_CDR::UShort ** = 0); + static int registry_to_locale (ACE_CDR::ULong codeset_id, + ACE_CString &locale, + ACE_CDR::UShort * = 0, + ACE_CDR::UShort ** = 0); // tell if two codesets are compatible. This wraps the //rpc_cs_char_set_compat_check function. - static ACE_CDR::Boolean is_compatible (ACE_CDR::ULong codeset_id, - ACE_CDR::ULong other); + static int is_compatible (ACE_CDR::ULong codeset_id, + ACE_CDR::ULong other); // return the max number of bytes required to represent a single character. // This wraps the rpc_rgy_get_max_bytes function. @@ -78,16 +78,16 @@ private: static size_t num_registry_entries_; static registry_entry registry_db_[]; - static ACE_CDR::Boolean locale_to_registry_i (const ACE_CString &locale, - ACE_CDR::ULong &codeset_id, - ACE_CDR::UShort * = 0, - ACE_CDR::UShort ** = 0); - static ACE_CDR::Boolean registry_to_locale_i (ACE_CDR::ULong codeset_id, - ACE_CString &locale, - ACE_CDR::UShort * = 0, - ACE_CDR::UShort ** = 0); - static ACE_CDR::Boolean is_compatible_i (ACE_CDR::ULong codeset_id, - ACE_CDR::ULong other); + static int locale_to_registry_i (const ACE_CString &locale, + ACE_CDR::ULong &codeset_id, + ACE_CDR::UShort * = 0, + ACE_CDR::UShort ** = 0); + static int registry_to_locale_i (ACE_CDR::ULong codeset_id, + ACE_CString &locale, + ACE_CDR::UShort * = 0, + ACE_CDR::UShort ** = 0); + static int is_compatible_i (ACE_CDR::ULong codeset_id, + ACE_CDR::ULong other); static ACE_CDR::Short get_max_bytes_i (ACE_CDR::ULong codeset_id); }; @@ -97,5 +97,3 @@ private: #include "ace/post.h" #endif /* ACE_CODESET_REGISTRY_H */ - - diff --git a/ace/Codeset_Registry.inl b/ace/Codeset_Registry.inl index dec0b97a08d..47aaf7280ca 100644 --- a/ace/Codeset_Registry.inl +++ b/ace/Codeset_Registry.inl @@ -15,7 +15,7 @@ //============================================================================= ACE_INLINE -ACE_CDR::Boolean +int ACE_Codeset_Registry::locale_to_registry(const ACE_CString &locale, ACE_CDR::ULong &codeset_id, ACE_CDR::UShort *num_sets, @@ -28,7 +28,7 @@ ACE_Codeset_Registry::locale_to_registry(const ACE_CString &locale, num_sets, char_sets, &result); - return (result == dce_cs_c_ok) ? OK : UNKNOWN; + return (result == dce_cs_c_ok) ? 1 : 0; #else return ACE_Codeset_Registry::locale_to_registry_i (locale, codeset_id, @@ -40,7 +40,7 @@ ACE_Codeset_Registry::locale_to_registry(const ACE_CString &locale, // based on a registry value, find the locale string and optional codeset // collection. This wraps the dce_cs_rgy_to_loc function, or emulates it. ACE_INLINE -ACE_CDR::Boolean +int ACE_Codeset_Registry::registry_to_locale(ACE_CDR::ULong codeset_id, ACE_CString &locale, ACE_CDR::UShort *num_sets, @@ -68,7 +68,7 @@ ACE_Codeset_Registry::registry_to_locale(ACE_CDR::ULong codeset_id, // tell if two codesets are compatible. This wraps the //rpc_cs_char_set_compat_check function. ACE_INLINE -ACE_CDR::Boolean +int ACE_Codeset_Registry::is_compatible (ACE_CDR::ULong codeset_id, ACE_CDR::ULong other) { diff --git a/ace/Codeset_Registry_db.cpp b/ace/Codeset_Registry_db.cpp index 239e7f1c792..7386ba39e5e 100644 --- a/ace/Codeset_Registry_db.cpp +++ b/ace/Codeset_Registry_db.cpp @@ -16,8 +16,9 @@ ACE_Codeset_Registry::registry_entry ACE_Codeset_Registry::registry_db_[] = { {"ISO 8859-1:1987; Latin Alphabet No. 1","ASCII",0x00010001,1,{0x0011},1}, - {"IBM-1047 (CCSID 01047); Latin-1 Open System","EBCDIC",0x10020417,1,{0x0011},1} + {"IBM-1047 (CCSID 01047); Latin-1 Open System","EBCDIC",0x10020417,1,{0x0011},1}, + {"ISO/IEC 10646-1:1993; UCS-4, Level 1","UCS-4",0x00010104,1,{0x1000},4}, + {"ISO/IEC 10646-1:1993; UTF-16, UCS Transformation Format 16-bit form","Unicode",0x00010109,1,{0x1000},2} }; -size_t ACE_Codeset_Registry::num_registry_entries_ = 2; - +size_t ACE_Codeset_Registry::num_registry_entries_ = 4; |