diff options
author | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-04-24 01:26:37 +0000 |
---|---|---|
committer | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-04-24 01:26:37 +0000 |
commit | 40531ce58e2a840274a47af7e887764b2f10cfc9 (patch) | |
tree | 4f4f2bad32410216cda5647a59e75883209d376a | |
parent | 455a8ee4b5dd8b211196580fe82001f675e7e226 (diff) | |
download | ATCD-40531ce58e2a840274a47af7e887764b2f10cfc9.tar.gz |
ChangeLogTag:Sun Apr 23 18:14:33 2000 Darrell Brunsch <brunsch@uci.edu>
-rw-r--r-- | ChangeLog | 28 | ||||
-rw-r--r-- | ChangeLogs/ChangeLog-02a | 28 | ||||
-rw-r--r-- | ChangeLogs/ChangeLog-03a | 28 | ||||
-rw-r--r-- | ace/Local_Name_Space.cpp | 7 | ||||
-rw-r--r-- | ace/Local_Name_Space.h | 4 | ||||
-rw-r--r-- | ace/Local_Name_Space_T.h | 4 | ||||
-rw-r--r-- | ace/Name_Space.cpp | 3 | ||||
-rw-r--r-- | ace/Name_Space.h | 4 | ||||
-rw-r--r-- | ace/Naming_Context.cpp | 3 | ||||
-rw-r--r-- | ace/Naming_Context.h | 4 | ||||
-rw-r--r-- | ace/Remote_Name_Space.cpp | 3 | ||||
-rw-r--r-- | ace/Remote_Name_Space.h | 4 | ||||
-rw-r--r-- | ace/SString.cpp | 114 | ||||
-rw-r--r-- | ace/SString.h | 54 | ||||
-rw-r--r-- | ace/SString.i | 45 | ||||
-rw-r--r-- | ace/ace_wchar.h | 29 |
16 files changed, 222 insertions, 140 deletions
diff --git a/ChangeLog b/ChangeLog index 9c033bbaf65..1ebc1915920 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +Sun Apr 23 18:14:33 2000 Darrell Brunsch <brunsch@uci.edu> + + * ace/ace_wchar.h: + + Added compatibility for all the old ASYS_* macros by default. + But no part of ACE/TAO should still use them anymore. This + compatibility can be turned off by defining + ACE_ONLY_LATEST_AND_GREATEST. + + * ace/SString.cpp: + * ace/SString.h: + * ace/SString.i: + * ace/Local_Name_Space.cpp: + * ace/Local_Name_Space.h: + * ace/Local_Name_Space_T.h: + * ace/Name_Space.cpp: + * ace/Name_Space.h: + * ace/Naming_Context.cpp: + * ace/Naming_Context.h: + * ace/Remote_Name_Space.cpp: + * ace/Remote_Name_Space.h: + + Found a better way of support for the ACE_Name_Space classes when + there isn't a wchar_t. We now define the ACE_WString to internally + use a type called ACE_WSTRING_TYPE, which is defined to wchar_t + unless ACE_USES_WCHAR is not defined (in which case it is defined + to ACE_USHORT16). + Sun Apr 23 14:27:11 2000 Darrell Brunsch <brunsch@uci.edu> * ace/CLASSIX/CLASSIX_Port.cpp: diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a index 9c033bbaf65..1ebc1915920 100644 --- a/ChangeLogs/ChangeLog-02a +++ b/ChangeLogs/ChangeLog-02a @@ -1,3 +1,31 @@ +Sun Apr 23 18:14:33 2000 Darrell Brunsch <brunsch@uci.edu> + + * ace/ace_wchar.h: + + Added compatibility for all the old ASYS_* macros by default. + But no part of ACE/TAO should still use them anymore. This + compatibility can be turned off by defining + ACE_ONLY_LATEST_AND_GREATEST. + + * ace/SString.cpp: + * ace/SString.h: + * ace/SString.i: + * ace/Local_Name_Space.cpp: + * ace/Local_Name_Space.h: + * ace/Local_Name_Space_T.h: + * ace/Name_Space.cpp: + * ace/Name_Space.h: + * ace/Naming_Context.cpp: + * ace/Naming_Context.h: + * ace/Remote_Name_Space.cpp: + * ace/Remote_Name_Space.h: + + Found a better way of support for the ACE_Name_Space classes when + there isn't a wchar_t. We now define the ACE_WString to internally + use a type called ACE_WSTRING_TYPE, which is defined to wchar_t + unless ACE_USES_WCHAR is not defined (in which case it is defined + to ACE_USHORT16). + Sun Apr 23 14:27:11 2000 Darrell Brunsch <brunsch@uci.edu> * ace/CLASSIX/CLASSIX_Port.cpp: diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a index 9c033bbaf65..1ebc1915920 100644 --- a/ChangeLogs/ChangeLog-03a +++ b/ChangeLogs/ChangeLog-03a @@ -1,3 +1,31 @@ +Sun Apr 23 18:14:33 2000 Darrell Brunsch <brunsch@uci.edu> + + * ace/ace_wchar.h: + + Added compatibility for all the old ASYS_* macros by default. + But no part of ACE/TAO should still use them anymore. This + compatibility can be turned off by defining + ACE_ONLY_LATEST_AND_GREATEST. + + * ace/SString.cpp: + * ace/SString.h: + * ace/SString.i: + * ace/Local_Name_Space.cpp: + * ace/Local_Name_Space.h: + * ace/Local_Name_Space_T.h: + * ace/Name_Space.cpp: + * ace/Name_Space.h: + * ace/Naming_Context.cpp: + * ace/Naming_Context.h: + * ace/Remote_Name_Space.cpp: + * ace/Remote_Name_Space.h: + + Found a better way of support for the ACE_Name_Space classes when + there isn't a wchar_t. We now define the ACE_WString to internally + use a type called ACE_WSTRING_TYPE, which is defined to wchar_t + unless ACE_USES_WCHAR is not defined (in which case it is defined + to ACE_USHORT16). + Sun Apr 23 14:27:11 2000 Darrell Brunsch <brunsch@uci.edu> * ace/CLASSIX/CLASSIX_Port.cpp: diff --git a/ace/Local_Name_Space.cpp b/ace/Local_Name_Space.cpp index 6c96d4afece..25d27578da7 100644 --- a/ace/Local_Name_Space.cpp +++ b/ace/Local_Name_Space.cpp @@ -7,8 +7,6 @@ #include "ace/ACE.h" #include "ace/Local_Name_Space.h" -#if defined (ACE_HAS_WCHAR) - ACE_RCSID(ace, Local_Name_Space, "$Id$") ACE_USHORT16 * @@ -118,7 +116,8 @@ ACE_NS_String::ACE_NS_String (ACE_USHORT16 *dst, size_t ACE_NS_String::hash (void) const { - return ACE::hash_pjw (this->rep_); + return ACE::hash_pjw (ACE_reinterpret_cast (char *, this->rep_), + this->len_ * sizeof (ACE_USHORT16)); } ACE_NS_Internal::ACE_NS_Internal (void) @@ -211,6 +210,4 @@ template class ACE_Write_Guard<ACE_RW_Process_Mutex>; #pragma instantiate ACE_Write_Guard<ACE_RW_Process_Mutex> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ -#endif /* ACE_HAS_WCHAR */ - #endif /* ACE_LOCAL_NAME_SPACE_C */ diff --git a/ace/Local_Name_Space.h b/ace/Local_Name_Space.h index a8e33d991fe..edf83a69771 100644 --- a/ace/Local_Name_Space.h +++ b/ace/Local_Name_Space.h @@ -26,8 +26,6 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#if defined (ACE_HAS_WCHAR) - #include "ace/Containers.h" #include "ace/Malloc_T.h" #include "ace/Synch.h" @@ -120,7 +118,5 @@ private: // Include the ACE_Local_Name_Space templates stuff at this point. #include "ace/Local_Name_Space_T.h" -#endif /* ACE_HAS_WCHAR */ - #include "ace/post.h" #endif /* ACE_LOCAL_NAME_SPACE_H */ diff --git a/ace/Local_Name_Space_T.h b/ace/Local_Name_Space_T.h index bbf6255c461..5fce9307b7a 100644 --- a/ace/Local_Name_Space_T.h +++ b/ace/Local_Name_Space_T.h @@ -26,8 +26,6 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#if defined (ACE_HAS_WCHAR) - #include "ace/Naming_Context.h" #include "ace/SString.h" #include "ace/Local_Name_Space.h" @@ -252,7 +250,5 @@ private: #pragma implementation ("Local_Name_Space_T.cpp") #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ -#endif /* ACE_HAS_WCHAR */ - #include "ace/post.h" #endif /* ACE_LOCAL_NAME_SPACE_T_H */ diff --git a/ace/Name_Space.cpp b/ace/Name_Space.cpp index 1531654ae2b..dbc3c392d6c 100644 --- a/ace/Name_Space.cpp +++ b/ace/Name_Space.cpp @@ -3,8 +3,6 @@ #include "ace/Name_Space.h" -#if defined (ACE_HAS_WCHAR) - ACE_RCSID(ace, Name_Space, "$Id$") ACE_Name_Binding::ACE_Name_Binding (void) @@ -62,4 +60,3 @@ ACE_Name_Space::~ACE_Name_Space (void) ACE_TRACE ("ACE_Name_Space::~ACE_Name_Space"); } -#endif /* ACE_HAS_WCHAR */ diff --git a/ace/Name_Space.h b/ace/Name_Space.h index a2efb5c4da1..97e7a7b954c 100644 --- a/ace/Name_Space.h +++ b/ace/Name_Space.h @@ -24,8 +24,6 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#if defined (ACE_HAS_WCHAR) - #include "ace/SString.h" #include "ace/Containers.h" #include "ace/Name_Proxy.h" @@ -149,7 +147,5 @@ public: // Dump the state of the object }; -#endif /* ACE_HAS_WCHAR */ - #include "ace/post.h" #endif /* ACE_NAME_SPACE_H */ diff --git a/ace/Naming_Context.cpp b/ace/Naming_Context.cpp index 931f7735f35..dade371b387 100644 --- a/ace/Naming_Context.cpp +++ b/ace/Naming_Context.cpp @@ -9,8 +9,6 @@ ACE_RCSID(ace, Naming_Context, "$Id$") -#if defined (ACE_HAS_WCHAR) - // Make life easier later on... typedef ACE_Local_Name_Space <ACE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> @@ -685,4 +683,3 @@ template class ACE_Name_Space_Map <ACE_Allocator_Adapter <ACE_Malloc <ACE_LITE_M #pragma instantiate ACE_Name_Space_Map <ACE_Allocator_Adapter <ACE_Malloc <ACE_LITE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> > > #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ -#endif /* ACE_HAS_WCHAR */ diff --git a/ace/Naming_Context.h b/ace/Naming_Context.h index 0cc4e78d157..da03a26c0bc 100644 --- a/ace/Naming_Context.h +++ b/ace/Naming_Context.h @@ -24,8 +24,6 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#if defined (ACE_HAS_WCHAR) - #include "ace/SString.h" #include "ace/Containers.h" #include "ace/Service_Object.h" @@ -333,7 +331,5 @@ private: ACE_FACTORY_DECLARE (ACE, ACE_Naming_Context) -#endif /* ACE_HAS_WCHAR */ - #include "ace/post.h" #endif /* ACE_NAMING_CONTEXT_H */ diff --git a/ace/Remote_Name_Space.cpp b/ace/Remote_Name_Space.cpp index 21d02dd53d2..1891f5ee010 100644 --- a/ace/Remote_Name_Space.cpp +++ b/ace/Remote_Name_Space.cpp @@ -3,8 +3,6 @@ #include "ace/Remote_Name_Space.h" -#if defined (ACE_HAS_WCHAR) - ACE_RCSID(ace, Remote_Name_Space, "$Id$") int @@ -332,4 +330,3 @@ ACE_Remote_Name_Space::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -#endif /* ACE_HAS_WCHAR */ diff --git a/ace/Remote_Name_Space.h b/ace/Remote_Name_Space.h index 8d5c81dd0b2..2e44e7dd9f9 100644 --- a/ace/Remote_Name_Space.h +++ b/ace/Remote_Name_Space.h @@ -24,8 +24,6 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#if defined (ACE_HAS_WCHAR) - #include "ace/SString.h" #include "ace/Containers.h" #include "ace/Name_Proxy.h" @@ -128,7 +126,5 @@ private: // Interface to Name server process for NET_LOCAL namespace. }; -#endif /* ACE_HAS_WCHAR */ - #include "ace/post.h" #endif /* ACE_REMOTE_NAME_SPACE_H */ diff --git a/ace/SString.cpp b/ace/SString.cpp index 677a1f38289..c3add1c80e9 100644 --- a/ace/SString.cpp +++ b/ace/SString.cpp @@ -217,10 +217,7 @@ ACE_ALLOC_HOOK_DEFINE(ACE_CString) char ACE_CString::NULL_CString_ = '\0'; const int ACE_CString::npos = -1; const int ACE_SString::npos = -1; - -#if defined (ACE_HAS_WCHAR) const int ACE_WString::npos = -1; -#endif /* ACE_HAS_WCHAR */ #if !defined (ACE_LACKS_IOSTREAM_TOTALLY) ostream & @@ -231,7 +228,6 @@ operator<< (ostream &os, const ACE_CString &cs) return os; } -#if defined (ACE_HAS_WCHAR) ostream & operator<< (ostream &os, const ACE_WString &ws) { @@ -242,7 +238,6 @@ operator<< (ostream &os, const ACE_WString &ws) } return os; } -#endif /* ACE_HAS_WCHAR */ ostream & operator<< (ostream &os, const ACE_SString &ss) @@ -256,8 +251,7 @@ operator<< (ostream &os, const ACE_SString &ss) // Constructor that copies <s> into dynamically allocated memory. // Probable loss of data. Please use with care. -#if defined (ACE_HAS_WCHAR) -ACE_CString::ACE_CString (const wchar_t *s, +ACE_CString::ACE_CString (const ACE_WSTRING_TYPE *s, ACE_Allocator *alloc) : allocator_ (alloc ? alloc : ACE_Allocator::instance ()), len_ (0), @@ -267,7 +261,7 @@ ACE_CString::ACE_CString (const wchar_t *s, { ACE_TRACE ("ACE_CString::ACE_CString"); - if (s == 0 || s[0] == (wchar_t) '\0') + if (s == 0 || s[0] == (ACE_WSTRING_TYPE) '\0') { this->release_ = 0; this->len_ = 0; @@ -283,7 +277,7 @@ ACE_CString::ACE_CString (const wchar_t *s, this->len_ = len; this->buf_len_ = len + 1; - // Copy the wchar_t * string byte-by-byte into the char * + // Copy the ACE_WSTRING_TYPE * string byte-by-byte into the char * // string. for (size_t i = 0; i < this->len_; i++) this->rep_[i] = char (s[i]); @@ -291,7 +285,6 @@ ACE_CString::ACE_CString (const wchar_t *s, this->rep_[this->len_] = '\0'; } } -#endif /* ACE_HAS_WCHAR */ // this method might benefit from a little restructuring. void @@ -605,7 +598,6 @@ ACE_SString::substring (size_t offset, return ACE_SString (&rep_[offset], count, this->allocator_); } -#if defined (ACE_HAS_WCHAR) ACE_ALLOC_HOOK_DEFINE(ACE_WString) void @@ -627,18 +619,27 @@ ACE_WString::ACE_WString (ACE_Allocator *alloc) this->allocator_ = ACE_Allocator::instance (); this->len_ = 0; - this->rep_ = (wchar_t *) this->allocator_->malloc - ((this->len_ + 1) * sizeof (wchar_t)); + this->rep_ = (ACE_WSTRING_TYPE *) this->allocator_->malloc + ((this->len_ + 1) * sizeof (ACE_WSTRING_TYPE)); this->rep_[this->len_] = 0; } /* static */ size_t -ACE_WString::strlen (const wchar_t *s) +ACE_WString::strlen (const ACE_WSTRING_TYPE *s) { ACE_TRACE ("ACE_WString::strlen"); +#if defined (ACE_HAS_WCHAR) return ACE_OS::strlen (s); +#else /* ACE_HAS_WCHAR */ + size_t len = 0; + + while (*s++ != 0) + ++len; + + return len; +#endif /* ACE_HAS_WCHAR */ } // Get the underlying pointer as an ASCII char. @@ -681,17 +682,17 @@ ACE_WString::ACE_WString (const char *s, if (s == 0) { this->len_ = 0; - this->rep_ = (wchar_t *) this->allocator_->malloc - ((this->len_ + 1) * sizeof (wchar_t)); + this->rep_ = (ACE_WSTRING_TYPE *) this->allocator_->malloc + ((this->len_ + 1) * sizeof (ACE_WSTRING_TYPE)); this->rep_[this->len_] = 0; } else { this->len_ = ACE_OS::strlen (s); - this->rep_ = (wchar_t *) this->allocator_->malloc - ((this->len_ + 1) * sizeof (wchar_t)); + this->rep_ = (ACE_WSTRING_TYPE *) this->allocator_->malloc + ((this->len_ + 1) * sizeof (ACE_WSTRING_TYPE)); - // Copy the char * string byte-by-byte into the wchar_t * + // Copy the char * string byte-by-byte into the ACE_WSTRING_TYPE * // string. for (size_t i = 0; i < this->len_; i++) this->rep_[i] = s[i]; @@ -703,7 +704,7 @@ ACE_WString::ACE_WString (const char *s, // Constructor that actually copies memory. -ACE_WString::ACE_WString (const wchar_t *s, +ACE_WString::ACE_WString (const ACE_WSTRING_TYPE *s, ACE_Allocator *alloc) : allocator_ (alloc) { @@ -715,26 +716,26 @@ ACE_WString::ACE_WString (const wchar_t *s, if (s == 0) { this->len_ = 0; - this->rep_ = (wchar_t *) this->allocator_->malloc - ((this->len_ + 1) * sizeof (wchar_t)); + this->rep_ = (ACE_WSTRING_TYPE *) this->allocator_->malloc + ((this->len_ + 1) * sizeof (ACE_WSTRING_TYPE)); this->rep_[this->len_] = 0; } else { this->len_ = ACE_WString::strlen (s); - this->rep_ = (wchar_t *) this->allocator_->malloc - ((this->len_ + 1) * sizeof (wchar_t)); + this->rep_ = (ACE_WSTRING_TYPE *) this->allocator_->malloc + ((this->len_ + 1) * sizeof (ACE_WSTRING_TYPE)); ACE_OS::memcpy (this->rep_, s, - this->len_ * sizeof (wchar_t)); + this->len_ * sizeof (ACE_WSTRING_TYPE)); // null terminate this->rep_[this->len_] = 0; } } -ACE_WString::ACE_WString (wchar_t c, +ACE_WString::ACE_WString (ACE_WSTRING_TYPE c, ACE_Allocator *alloc) : allocator_ (alloc) { @@ -744,15 +745,15 @@ ACE_WString::ACE_WString (wchar_t c, this->allocator_ = ACE_Allocator::instance (); this->len_ = 1; - this->rep_ = (wchar_t *) this->allocator_->malloc - ((this->len_ + 1) * sizeof (wchar_t)); + this->rep_ = (ACE_WSTRING_TYPE *) this->allocator_->malloc + ((this->len_ + 1) * sizeof (ACE_WSTRING_TYPE)); this->rep_[0] = c; this->rep_[this->len_] = 0; } // Constructor that actually copies memory. -ACE_WString::ACE_WString (const wchar_t *s, +ACE_WString::ACE_WString (const ACE_WSTRING_TYPE *s, size_t len, ACE_Allocator *alloc) : allocator_ (alloc) @@ -765,19 +766,19 @@ ACE_WString::ACE_WString (const wchar_t *s, if (s == 0) { this->len_ = 0; - this->rep_ = (wchar_t *) this->allocator_->malloc - ((this->len_ + 1) * sizeof (wchar_t)); + this->rep_ = (ACE_WSTRING_TYPE *) this->allocator_->malloc + ((this->len_ + 1) * sizeof (ACE_WSTRING_TYPE)); this->rep_[this->len_] = 0; } else { this->len_ = len; - this->rep_ = (wchar_t *) this->allocator_->malloc - ((this->len_ + 1) * sizeof (wchar_t)); + this->rep_ = (ACE_WSTRING_TYPE *) this->allocator_->malloc + ((this->len_ + 1) * sizeof (ACE_WSTRING_TYPE)); ACE_OS::memcpy (this->rep_, s, - len * sizeof (wchar_t)); + len * sizeof (ACE_WSTRING_TYPE)); // null terminate this->rep_[this->len_] = 0; @@ -796,12 +797,12 @@ ACE_WString::ACE_WString (size_t len, this->allocator_ = ACE_Allocator::instance (); this->len_ = len; - this->rep_ = (wchar_t *) this->allocator_->malloc - ((this->len_ + 1) * sizeof (wchar_t)); + this->rep_ = (ACE_WSTRING_TYPE *) this->allocator_->malloc + ((this->len_ + 1) * sizeof (ACE_WSTRING_TYPE)); ACE_OS::memset (this->rep_, 0, - len * sizeof (wchar_t)); + len * sizeof (ACE_WSTRING_TYPE)); // NUL terminate. this->rep_[this->len_] = 0; } @@ -817,11 +818,11 @@ ACE_WString::ACE_WString (const ACE_WString &s) if (this->allocator_ == 0) this->allocator_ = ACE_Allocator::instance (); - this->rep_ = (wchar_t *) this->allocator_->malloc - ((s.len_ + 1) * sizeof (wchar_t)); + this->rep_ = (ACE_WSTRING_TYPE *) this->allocator_->malloc + ((s.len_ + 1) * sizeof (ACE_WSTRING_TYPE)); ACE_OS::memcpy ((void *) this->rep_, (const void *) s.rep_, - this->len_ * sizeof (wchar_t)); + this->len_ * sizeof (ACE_WSTRING_TYPE)); this->rep_[this->len_] = 0; } @@ -840,26 +841,26 @@ ACE_WString::operator= (const ACE_WString &s) } void -ACE_WString::set (const wchar_t *s) +ACE_WString::set (const ACE_WSTRING_TYPE *s) { this->set (s, ACE_WString::strlen (s)); } void -ACE_WString::set (const wchar_t *s, size_t len) +ACE_WString::set (const ACE_WSTRING_TYPE *s, size_t len) { // Only reallocate if we don't have enough space... if (this->len_ < len) { this->allocator_->free (this->rep_); - this->rep_ = (wchar_t *) this->allocator_->malloc - ((len + 1) * sizeof (wchar_t)); + this->rep_ = (ACE_WSTRING_TYPE *) this->allocator_->malloc + ((len + 1) * sizeof (ACE_WSTRING_TYPE)); } this->len_ = len; ACE_OS::memcpy (this->rep_, s, - len * sizeof (wchar_t)); + len * sizeof (ACE_WSTRING_TYPE)); // NUL terminate. this->rep_[len] = 0; } @@ -898,14 +899,14 @@ ACE_WString::resize (size_t len) if (this->len_ < len) { this->allocator_->free (this->rep_); - this->rep_ = (wchar_t *) this->allocator_->malloc - ((len + 1) * sizeof (wchar_t)); + this->rep_ = (ACE_WSTRING_TYPE *) this->allocator_->malloc + ((len + 1) * sizeof (ACE_WSTRING_TYPE)); } this->len_ = len; ACE_OS::memset (this->rep_, 0, - this->len_ * sizeof (wchar_t)); + this->len_ * sizeof (ACE_WSTRING_TYPE)); this->rep_[this->len_] = 0; } @@ -915,15 +916,15 @@ ACE_WString & ACE_WString::operator+= (const ACE_WString &s) { ACE_TRACE ("ACE_WString::operator+="); - wchar_t *t = (wchar_t *) this->allocator_->malloc - ((this->len_ + s.len_ + 1) * sizeof (wchar_t)); + ACE_WSTRING_TYPE *t = (ACE_WSTRING_TYPE *) this->allocator_->malloc + ((this->len_ + s.len_ + 1) * sizeof (ACE_WSTRING_TYPE)); ACE_OS::memcpy ((void *) t, (const void *) this->rep_, - this->len_ * sizeof (wchar_t)); + this->len_ * sizeof (ACE_WSTRING_TYPE)); ACE_OS::memcpy ((void *) (t + this->len_), (const void *) s.rep_, - s.len_ * sizeof (wchar_t)); + s.len_ * sizeof (ACE_WSTRING_TYPE)); this->len_ += s.len_; // NUL terminate. @@ -942,9 +943,9 @@ ACE_WString::~ACE_WString (void) } /* static */ -const wchar_t * -ACE_WString::strstr (const wchar_t *s1, - const wchar_t *s2) +const ACE_WSTRING_TYPE * +ACE_WString::strstr (const ACE_WSTRING_TYPE *s1, + const ACE_WSTRING_TYPE *s2) { ACE_TRACE ("ACE_WString::strstr"); @@ -962,7 +963,7 @@ ACE_WString::strstr (const wchar_t *s1, for (size_t i = 0; i <= len; i++) { - if (ACE_OS::memcmp (s1 + i, s2, len2 * sizeof (wchar_t)) == 0) + if (ACE_OS::memcmp (s1 + i, s2, len2 * sizeof (ACE_WSTRING_TYPE)) == 0) // Found a match! Return the index. return s1 + i; } @@ -970,4 +971,3 @@ ACE_WString::strstr (const wchar_t *s1, return 0; } -#endif /* ACE_HAS_WCHAR */ diff --git a/ace/SString.h b/ace/SString.h index 3c88b0aa61c..bbdd013fe22 100644 --- a/ace/SString.h +++ b/ace/SString.h @@ -24,6 +24,12 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#if defined (ACE_HAS_WCHAR) +typedef wchar_t ACE_WSTRING_TYPE; +#else /* ACE_HAS_WCHAR */ +typedef ACE_USHORT16 ACE_WSTRING_TYPE; +#endif /* ACE_HAS_WCHAR */ + // Forward decl. class ACE_Allocator; @@ -75,12 +81,10 @@ public: ACE_CString (const ACE_CString &); // Copy constructor. -#if defined (ACE_HAS_WCHAR) - ACE_CString (const wchar_t *s, + ACE_CString (const ACE_WSTRING_TYPE *s, ACE_Allocator *alloc = 0); // Constructor that copies <s> into dynamically allocated memory. // Probable loss of data. Please use with care. -#endif /* ACE_HAS_WCHAR */ ACE_CString (char c, ACE_Allocator *alloc = 0); // Constructor that copies <c> into dynamically allocated memory. @@ -199,12 +203,12 @@ private: // Represents the "NULL" string to simplify the internal logic. }; -ACE_Export ACE_INLINE ACE_CString operator + (const ACE_CString &, const ACE_CString &); +ACE_Export ACE_INLINE ACE_CString operator + (const ACE_CString &, + const ACE_CString &); #if !defined (ACE_LACKS_IOSTREAM_TOTALLY) ACE_Export ostream &operator << (ostream &, const ACE_CString &); #endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */ -#if defined (ACE_HAS_WCHAR) class ACE_Export ACE_WString { // = TITLE @@ -227,44 +231,44 @@ public: ACE_Allocator *alloc = 0); // Constructor that copies <s> into dynamically allocated memory. - ACE_WString (const wchar_t *s, + ACE_WString (const ACE_WSTRING_TYPE *s, ACE_Allocator *alloc = 0); // Constructor that copies <s> into dynamically allocated memory. - ACE_WString (const wchar_t *s, + ACE_WString (const ACE_WSTRING_TYPE *s, size_t len, ACE_Allocator *alloc = 0); - // Constructor that copies <len> wchar_t's of <s> into dynamically + // Constructor that copies <len> ACE_WSTRING_TYPE's of <s> into dynamically // allocated memory (will NUL terminate the result). ACE_WString (size_t len, ACE_Allocator *alloc = 0); // Constructor that dynamically allocates memory for <len> + 1 - // wchar_t characters. The newly created memory is set memset to 0. + // ACE_WSTRING_TYPE characters. The newly created memory is set memset to 0. ACE_WString (const ACE_WString &s); // Copy constructor. - ACE_WString (wchar_t c, ACE_Allocator *alloc = 0); + ACE_WString (ACE_WSTRING_TYPE c, ACE_Allocator *alloc = 0); // Constructor that copies <c> into dynamically allocated memory. ~ACE_WString (void); // Deletes the memory... - wchar_t operator [] (size_t slot) const; + ACE_WSTRING_TYPE operator [] (size_t slot) const; // Return the <slot'th> character in the string (doesn't perform // bounds checking). - wchar_t &operator [] (size_t slot); + ACE_WSTRING_TYPE &operator [] (size_t slot); // Return the <slot'th> character by reference in the string // (doesn't perform bounds checking). ACE_WString &operator = (const ACE_WString &); // Assignment operator (does copy memory). - void set (const wchar_t *s); + void set (const ACE_WSTRING_TYPE *s); // Copy <s> - void set (const wchar_t *s, + void set (const ACE_WSTRING_TYPE *s, size_t len); // Copy <len> bytes of <s> (will NUL terminate the result) @@ -285,16 +289,16 @@ public: size_t length (void) const; // Return the length of the string. - wchar_t *rep (void) const; + ACE_WSTRING_TYPE *rep (void) const; // Gets a copy of the underlying pointer. char *char_rep (void) const; // Transform into a copy of the ASCII character representation. - const wchar_t *fast_rep (void) const; + const ACE_WSTRING_TYPE *fast_rep (void) const; // Get at the underlying representation directly! - const wchar_t *c_str (void) const; + const ACE_WSTRING_TYPE *c_str (void) const; // Same as STL String's <c_str> and <fast_rep>. int strstr (const ACE_WString &s) const; @@ -305,15 +309,15 @@ public: // Find <str> starting at pos. Returns the slot of the first // location that matches, else npos. - int find (const wchar_t *s, int pos = 0) const; + int find (const ACE_WSTRING_TYPE *s, int pos = 0) const; // Find <s> starting at pos. Returns the slot of the first // location that matches, else npos. - int find (wchar_t c, int pos = 0) const; + int find (ACE_WSTRING_TYPE c, int pos = 0) const; // Find <c> starting at pos. Returns the slot of the first // location that matches, else npos. - int rfind (wchar_t c, int pos = npos) const; + int rfind (ACE_WSTRING_TYPE c, int pos = npos) const; // Find <c> starting at pos (counting from the end). Returns the // slot of the first location that matches, else npos. @@ -338,10 +342,11 @@ public: ACE_ALLOC_HOOK_DECLARE; // Declare the dynamic allocation hooks. - static size_t strlen (const wchar_t *); - // Computes the length of a "0" terminated wchar_t *. + static size_t strlen (const ACE_WSTRING_TYPE *); + // Computes the length of a "0" terminated ACE_WSTRING_TYPE *. - static const wchar_t *strstr (const wchar_t *s1, const wchar_t *s2); + static const ACE_WSTRING_TYPE *strstr (const ACE_WSTRING_TYPE *s1, + const ACE_WSTRING_TYPE *s2); // Traditional style strstr void resize (size_t len); @@ -357,7 +362,7 @@ private: size_t len_; // Length of the ACE_WString. - wchar_t *rep_; + ACE_WSTRING_TYPE *rep_; // Pointer to data. }; @@ -366,7 +371,6 @@ ACE_Export ACE_INLINE ACE_WString operator+ (const ACE_WString &, #if !defined (ACE_LACKS_IOSTREAM_TOTALLY) ACE_Export ostream &operator << (ostream &, const ACE_WString &); #endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */ -#endif /* ACE_HAS_WCHAR */ class ACE_Export ACE_SString { diff --git a/ace/SString.i b/ace/SString.i index 93f7c4ec8f8..6815ee00e61 100644 --- a/ace/SString.i +++ b/ace/SString.i @@ -312,7 +312,6 @@ ACE_CString::hash (void) const return ACE::hash_pjw (this->rep_, this->len_); } -#if defined (ACE_HAS_WCHAR) ACE_INLINE ACE_WString operator+ (const ACE_WString &s, const ACE_WString &t) @@ -321,7 +320,6 @@ operator+ (const ACE_WString &s, temp += t; return temp; } -#endif /* ACE_HAS_WCHAR */ ACE_INLINE ACE_CString operator+ (const ACE_CString &s, const ACE_CString &t) @@ -503,7 +501,6 @@ ACE_SString::length (void) const } -#if defined (ACE_HAS_WCHAR) ACE_INLINE ACE_WString ACE_WString::substr (size_t offset, @@ -514,7 +511,7 @@ ACE_WString::substr (size_t offset, // Get a copy of the underlying representation. -ACE_INLINE wchar_t * +ACE_INLINE ACE_WSTRING_TYPE * ACE_WString::rep (void) const { ACE_TRACE ("ACE_WString::rep"); @@ -522,9 +519,9 @@ ACE_WString::rep (void) const return 0; else { - wchar_t *t; - ACE_NEW_RETURN (t, wchar_t[this->len_ + 1], 0); - ACE_OS::memcpy (t, this->rep_, this->len_ * sizeof (wchar_t)); + ACE_WSTRING_TYPE *t; + ACE_NEW_RETURN (t, ACE_WSTRING_TYPE[this->len_ + 1], 0); + ACE_OS::memcpy (t, this->rep_, this->len_ * sizeof (ACE_WSTRING_TYPE)); // 0 terminate t[this->len_] = 0; @@ -535,13 +532,13 @@ ACE_WString::rep (void) const // Get at the underlying representation directly! -ACE_INLINE const wchar_t * +ACE_INLINE const ACE_WSTRING_TYPE * ACE_WString::fast_rep (void) const { return this->rep_; } -ACE_INLINE const wchar_t * +ACE_INLINE const ACE_WSTRING_TYPE * ACE_WString::c_str (void) const { return this->rep_; @@ -556,7 +553,7 @@ ACE_WString::operator== (const ACE_WString &s) const return this->len_ == s.len_ && ACE_OS::memcmp ((const void *) this->rep_, (const void *) s.rep_, - this->len_ * sizeof (wchar_t)) == 0; + this->len_ * sizeof (ACE_WSTRING_TYPE)) == 0; } // Less than comparison operator. @@ -568,10 +565,10 @@ ACE_WString::operator < (const ACE_WString &s) const return (this->len_ < s.len_) ? (ACE_OS::memcmp ((const void *) this->rep_, (const void *) s.rep_, - this->len_ * sizeof (wchar_t)) <= 0) + this->len_ * sizeof (ACE_WSTRING_TYPE)) <= 0) : (ACE_OS::memcmp ((const void *) this->rep_, (const void *) s.rep_, - s.len_ * sizeof (wchar_t)) < 0); + s.len_ * sizeof (ACE_WSTRING_TYPE)) < 0); } // Greater than comparison operator. @@ -583,10 +580,10 @@ ACE_WString::operator > (const ACE_WString &s) const return (this->len_ <= s.len_) ? (ACE_OS::memcmp ((const void *) this->rep_, (const void *) s.rep_, - this->len_ * sizeof (wchar_t)) > 0) + this->len_ * sizeof (ACE_WSTRING_TYPE)) > 0) : (ACE_OS::memcmp ((const void *) this->rep_, (const void *) s.rep_, - s.len_ * sizeof (wchar_t)) >= 0); + s.len_ * sizeof (ACE_WSTRING_TYPE)) >= 0); } @@ -606,12 +603,12 @@ ACE_WString::compare (const ACE_WString &s) const return ACE_OS::memcmp ((const void *) this->rep_, (const void *) s.rep_, - this->len_ * sizeof (wchar_t)); + this->len_ * sizeof (ACE_WSTRING_TYPE)); } // Return the <slot'th> character in the string. -ACE_INLINE wchar_t +ACE_INLINE ACE_WSTRING_TYPE ACE_WString::operator[] (size_t slot) const { ACE_TRACE ("ACE_WString::operator[]"); @@ -620,7 +617,7 @@ ACE_WString::operator[] (size_t slot) const // Return the <slot'th> character in the string. -ACE_INLINE wchar_t & +ACE_INLINE ACE_WSTRING_TYPE & ACE_WString::operator[] (size_t slot) { ACE_TRACE ("ACE_WString::operator[]"); @@ -628,10 +625,10 @@ ACE_WString::operator[] (size_t slot) } ACE_INLINE int -ACE_WString::find (const wchar_t *s, int pos) const +ACE_WString::find (const ACE_WSTRING_TYPE *s, int pos) const { - wchar_t *substr = this->rep_ + pos; - const wchar_t *pointer = ACE_WString::strstr (substr, s); + ACE_WSTRING_TYPE *substr = this->rep_ + pos; + const ACE_WSTRING_TYPE *pointer = ACE_WString::strstr (substr, s); if (pointer == 0) return ACE_WString::npos; else @@ -639,7 +636,7 @@ ACE_WString::find (const wchar_t *s, int pos) const } ACE_INLINE int -ACE_WString::find (wchar_t c, int pos) const +ACE_WString::find (ACE_WSTRING_TYPE c, int pos) const { if (pos == ACE_WString::npos) pos = this->len_; @@ -666,7 +663,7 @@ ACE_WString::find (const ACE_WString &str, int pos) const } ACE_INLINE int -ACE_WString::rfind (wchar_t c, int pos) const +ACE_WString::rfind (ACE_WSTRING_TYPE c, int pos) const { if (pos == ACE_WString::npos) pos = this->len_; @@ -688,10 +685,10 @@ ACE_WString::length (void) const ACE_INLINE u_long ACE_WString::hash (void) const { - return ACE::hash_pjw (this->rep_); + return ACE::hash_pjw (ACE_reinterpret_cast (char *, this->rep_), + this->len_ * sizeof (ACE_WSTRING_TYPE)); } -#endif /* ACE_HAS_WCHAR */ ACE_INLINE ACE_Auto_String_Free::ACE_Auto_String_Free (char* p) diff --git a/ace/ace_wchar.h b/ace/ace_wchar.h index 2f38402e22a..7bfe65bce2e 100644 --- a/ace/ace_wchar.h +++ b/ace/ace_wchar.h @@ -21,6 +21,35 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +// These macros have been deprecated and should be replaced by their +// ACE_TEXT_* equivalents. +#if !defined (ACE_ONLY_LATEST_AND_GREATEST) +// Convert the old unicode indicators +# if defined (ACE_HAS_MOSTLY_UNICODE_APIS) +# define ACE_USES_WCHAR +# endif /* ACE_HAS_MOSTLY_UNICODE_APIS */ +# if defined (ACE_HAS_UNICODE) +# define ACE_HAS_WCHAR +# endif /* ACE_HAS_UNICODE */ + +// These are defined to get older stuff to compile +# define ASYS_TCHAR ACE_TCHAR +# define ASYS_TEXT ACE_TEXT +# define ASYS_ONLY_MULTIBYTE_STRING ACE_TEXT_ALWAYS_CHAR +# define ASYS_MULTIBYTE_STRING ACE_TEXT_CHAR_TO_TCHAR +# define ASYS_WIDE_STRING ACE_TEXT_CHAR_TO_TCHAR +# define ACE_WIDE_STRING ACE_TEXT_CHAR_TO_TCHAR +# define ACE_DIRECTORY_SEPARATOR_CHAR_A ACE_DIRECTORY_SEPARATOR_CHAR + +# if defined (ACE_USES_WCHAR) +# define ASYS_ONLY_WIDE_STRING(STRING) STRING +# else /* ACE_USES_WCHAR */ +# define ASYS_ONLY_WIDE_STRING(STRING) ACE_Ascii_To_Wide (STRING).wchar_rep () +# endif /* ACE_USES_WCHAR */ + +#endif /* ACE_ONLY_LATEST_AND_GREATEST */ + + #if defined (ACE_HAS_WCHAR) && defined (ACE_WIN32) # include /**/ <tchar.h> #endif /* ACE_HAS_WCHAR && ACE_WIN32 */ |