Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_NS_WString Class Reference

This class retain the backward compatibility for Naming_Conext and related classes. The only addition to ACE_WString is a very naive "wchar" to "char" conversion function. More...

#include <SString.h>

Inheritance diagram for ACE_NS_WString:

Inheritance graph
[legend]
Collaboration diagram for ACE_NS_WString:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_NS_WString (ACE_Allocator *alloc=0)
 Default constructor. More...

 ACE_NS_WString (const char *s, ACE_Allocator *alloc=0)
 Constructor that copies s into dynamically allocated memory. More...

 ACE_NS_WString (const ACE_WSTRING_TYPE *s, ACE_Allocator *alloc=0)
 Constructor that copies s into dynamically allocated memory. More...

 ACE_NS_WString (const ACE_USHORT16 *s, size_t len, ACE_Allocator *alloc=0)
 Constructor that takes in a ushort16 string (mainly used by the ACE Name_Space classes). More...

 ACE_NS_WString (const ACE_WSTRING_TYPE *s, size_t len, ACE_Allocator *alloc=0)
 Constructor that copies len ACE_WSTRING_TYPE's of s into dynamically allocated memory (will NUL terminate the result). More...

 ACE_NS_WString (size_t len, ACE_Allocator *alloc=0)
 Constructor that dynamically allocates memory for len + 1 ACE_WSTRING_TYPE characters. The newly created memory is set memset to 0. More...

 ACE_NS_WString (const ACE_NS_WString &s)
 Copy constructor. More...

 ACE_NS_WString (ACE_WSTRING_TYPE c, ACE_Allocator *alloc=0)
 Constructor that copies c into dynamically allocated memory. More...

char * char_rep (void) const
 Transform into a copy of the ASCII character representation. (caller must delete). More...

ACE_USHORT16ushort_rep (void) const
 Transform into a copy of a USHORT16 representation (caller must delete). Note, behavior is undefined when sizeof (wchar_t) != 2. More...


Detailed Description

This class retain the backward compatibility for Naming_Conext and related classes. The only addition to ACE_WString is a very naive "wchar" to "char" conversion function.

Definition at line 48 of file SString.h.


Constructor & Destructor Documentation

ACE_INLINE ACE_NS_WString::ACE_NS_WString ACE_Allocator   alloc = 0
 

Default constructor.

Definition at line 7 of file SString.i.

00008   : ACE_WString (alloc)
00009 {
00010 }

ACE_NS_WString::ACE_NS_WString const char *    s,
ACE_Allocator   alloc = 0
 

Constructor that copies s into dynamically allocated memory.

Definition at line 311 of file SString.cpp.

References ACE_ALLOCATOR, ACE_WSTRING_TYPE, ACE_String_Base< ACE_WSTRING_TYPE >::buf_len_, ACE_String_Base< ACE_WSTRING_TYPE >::len_, ACE_String_Base< ACE_WSTRING_TYPE >::release_, ACE_String_Base< ACE_WSTRING_TYPE >::rep_, and ACE_OS_String::strlen.

00313   : ACE_WString (alloc)
00314 {
00315   if (s == 0)
00316     return;
00317 
00318   this->len_ = this->buf_len_ = ACE_OS_String::strlen (s);
00319 
00320   if (this->buf_len_ == 0)
00321     return;
00322 
00323   ACE_ALLOCATOR (this->rep_,
00324                  (ACE_WSTRING_TYPE *)
00325                  this->allocator_->malloc ((this->buf_len_ + 1) *
00326                                            sizeof (ACE_WSTRING_TYPE)));
00327   this->release_ = 1;
00328   for (size_t i = 0; i <= this->buf_len_; i++)
00329     this->rep_[i] = s[i];
00330 }

ACE_INLINE ACE_NS_WString::ACE_NS_WString const ACE_WSTRING_TYPE   s,
ACE_Allocator   alloc = 0
 

Constructor that copies s into dynamically allocated memory.

Definition at line 21 of file SString.i.

References ACE_WSTRING_TYPE.

00023   : ACE_WString (s, alloc)
00024 {
00025 }

ACE_NS_WString::ACE_NS_WString const ACE_USHORT16   s,
size_t    len,
ACE_Allocator   alloc = 0
 

Constructor that takes in a ushort16 string (mainly used by the ACE Name_Space classes).

Definition at line 333 of file SString.cpp.

References ACE_ALLOCATOR, ACE_USHORT16, ACE_WSTRING_TYPE, ACE_String_Base< ACE_WSTRING_TYPE >::buf_len_, ACE_String_Base< ACE_WSTRING_TYPE >::release_, and ACE_String_Base< ACE_WSTRING_TYPE >::rep_.

00336   : ACE_WString (alloc)
00337 {
00338   if (s == 0)
00339     return;
00340 
00341   this->buf_len_ = len;
00342 
00343   if (this->buf_len_ == 0)
00344     return;
00345 
00346   ACE_ALLOCATOR (this->rep_,
00347                  (ACE_WSTRING_TYPE *)
00348                  this->allocator_->malloc ((this->buf_len_) *
00349                                            sizeof (ACE_WSTRING_TYPE)));
00350   this->release_ = 1;
00351   for (size_t i = 0; i < this->buf_len_; i++)
00352     this->rep_[i] = s[i];
00353 }

ACE_INLINE ACE_NS_WString::ACE_NS_WString const ACE_WSTRING_TYPE   s,
size_t    len,
ACE_Allocator   alloc = 0
 

Constructor that copies len ACE_WSTRING_TYPE's of s into dynamically allocated memory (will NUL terminate the result).

Definition at line 13 of file SString.i.

References ACE_WSTRING_TYPE.

00016   : ACE_WString (s, len, alloc)
00017 {
00018 }

ACE_INLINE ACE_NS_WString::ACE_NS_WString size_t    len,
ACE_Allocator   alloc = 0
 

Constructor that dynamically allocates memory for len + 1 ACE_WSTRING_TYPE characters. The newly created memory is set memset to 0.

Definition at line 28 of file SString.i.

00029   : ACE_WString (len, 0, alloc)
00030 {
00031 }

ACE_INLINE ACE_NS_WString::ACE_NS_WString const ACE_NS_WString &    s
 

Copy constructor.

Definition at line 34 of file SString.i.

00035   : ACE_WString (s)
00036 {
00037 }

ACE_INLINE ACE_NS_WString::ACE_NS_WString ACE_WSTRING_TYPE    c,
ACE_Allocator   alloc = 0
 

Constructor that copies c into dynamically allocated memory.

Definition at line 40 of file SString.i.

References ACE_WSTRING_TYPE.

00041   : ACE_WString (c, alloc)
00042 {
00043 }


Member Function Documentation

char * ACE_NS_WString::char_rep void    const
 

Transform into a copy of the ASCII character representation. (caller must delete).

Definition at line 260 of file SString.cpp.

References ACE_NEW_RETURN, ACE_TRACE, and ACE_String_Base< ACE_WSTRING_TYPE >::len_.

Referenced by ACE_Registry_Name_Space::bind, ACE_NS_String::char_rep, ACE_Local_Name_Space::list_type_entries_i, ACE_Local_Name_Space::list_types_i, ACE_Registry_Name_Space::rebind, ACE_Registry_Name_Space::resolve, ACE_Naming_Context::resolve, and ACE_Registry_Name_Space::unbind.

00261 {
00262   ACE_TRACE ("ACE_NS_WString::char_rep");
00263   if (this->len_ <= 0)
00264     return 0;
00265   else
00266     {
00267       char *t;
00268 
00269       ACE_NEW_RETURN (t,
00270                       char[this->len_ + 1],
00271                       0);
00272 
00273       for (size_t i = 0; i < this->len_; i++)
00274         // Note that this cast may lose data if wide chars are
00275         // actually used!
00276         t[i] = char (this->rep_[i]);
00277 
00278       t[this->len_] = '\0';
00279       return t;
00280     }
00281 }

ACE_USHORT16 * ACE_NS_WString::ushort_rep void    const
 

Transform into a copy of a USHORT16 representation (caller must delete). Note, behavior is undefined when sizeof (wchar_t) != 2.

Definition at line 284 of file SString.cpp.

References ACE_NEW_RETURN, ACE_TRACE, ACE_USHORT16, ACE_String_Base< ACE_WSTRING_TYPE >::len_, and ACE_String_Base< ACE_WSTRING_TYPE >::rep_.

Referenced by ACE_Remote_Name_Space::bind, ACE_Remote_Name_Space::list_name_entries, ACE_Remote_Name_Space::list_names, ACE_Remote_Name_Space::list_type_entries, ACE_Remote_Name_Space::list_types, ACE_Remote_Name_Space::list_value_entries, ACE_Remote_Name_Space::list_values, ACE_Remote_Name_Space::rebind, ACE_Remote_Name_Space::resolve, ACE_Local_Name_Space::shared_bind_i, and ACE_Remote_Name_Space::unbind.

00285 {
00286   ACE_TRACE ("ACE_NS_WString::ushort_rep");
00287   if (this->len_ <= 0)
00288     return 0;
00289   else
00290     {
00291       ACE_USHORT16 *t;
00292 
00293       ACE_NEW_RETURN (t,
00294                       ACE_USHORT16[this->len_ + 1],
00295                       0);
00296 
00297       for (size_t i = 0; i < this->len_; i++)
00298         // Note that this cast may lose data if wide chars are
00299         // actually used!
00300         t[i] = (ACE_USHORT16)this->rep_[i];
00301 
00302       t[this->len_] = 0;
00303       return t;
00304     }
00305 }


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:51:07 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002