ACE_NS_WString Class Reference

This class retain the backward compatibility for ACE_Naming_Context 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 Member Functions

 ACE_NS_WString (ACE_Allocator *alloc=0)
 Default constructor.

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

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

 ACE_NS_WString (const ACE_USHORT16 *s, size_t len, ACE_Allocator *alloc=0)
 ACE_NS_WString (const ACE_WSTRING_TYPE *s, size_t len, ACE_Allocator *alloc=0)
 ACE_NS_WString (size_t len, ACE_Allocator *alloc=0)
 ACE_NS_WString (const ACE_NS_WString &s)
 Copy constructor.

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

char * char_rep (void) const
ACE_USHORT16ushort_rep (void) const

Detailed Description

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

Definition at line 52 of file SString.h.


Constructor & Destructor Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_NS_WString::ACE_NS_WString ACE_Allocator alloc = 0  ) 
 

Default constructor.

Definition at line 17 of file SString.inl.

References ACE_WString.

00018   : ACE_WString (alloc)
00019 {
00020 }

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

Constructor that copies s into dynamically allocated memory.

Definition at line 112 of file SString.cpp.

References ACE_ALLOCATOR, ACE_WString, ACE_WSTRING_TYPE, and ACE_OS::strlen().

00114   : ACE_WString (alloc)
00115 {
00116   if (s == 0)
00117     return;
00118 
00119   this->len_ = this->buf_len_ = ACE_OS::strlen (s);
00120 
00121   if (this->buf_len_ == 0)
00122     return;
00123 
00124   ACE_ALLOCATOR (this->rep_,
00125                  (ACE_WSTRING_TYPE *)
00126                  this->allocator_->malloc ((this->buf_len_ + 1) *
00127                                            sizeof (ACE_WSTRING_TYPE)));
00128   this->release_ = 1;
00129   for (size_t i = 0; i <= this->buf_len_; i++)
00130     this->rep_[i] = s[i];
00131 }

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 31 of file SString.inl.

References ACE_WString, and ACE_WSTRING_TYPE.

00033   : ACE_WString (s, alloc)
00034 {
00035 }

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 134 of file SString.cpp.

References ACE_ALLOCATOR, ACE_USHORT16, ACE_WString, and ACE_WSTRING_TYPE.

00137   : ACE_WString (alloc)
00138 {
00139   if (s == 0)
00140     return;
00141 
00142   this->buf_len_ = len;
00143 
00144   if (this->buf_len_ == 0)
00145     return;
00146 
00147   ACE_ALLOCATOR (this->rep_,
00148                  (ACE_WSTRING_TYPE *)
00149                  this->allocator_->malloc ((this->buf_len_) *
00150                                            sizeof (ACE_WSTRING_TYPE)));
00151   this->release_ = 1;
00152   for (size_t i = 0; i < this->buf_len_; i++)
00153     this->rep_[i] = s[i];
00154 }

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 23 of file SString.inl.

References ACE_WString, and ACE_WSTRING_TYPE.

00026   : ACE_WString (s, len, alloc)
00027 {
00028 }

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 38 of file SString.inl.

References ACE_WString.

00039   : ACE_WString (len, 0, alloc)
00040 {
00041 }

ACE_INLINE ACE_NS_WString::ACE_NS_WString const ACE_NS_WString s  ) 
 

Copy constructor.

Definition at line 44 of file SString.inl.

References ACE_WString.

00045   : ACE_WString (s)
00046 {
00047 }

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 50 of file SString.inl.

References ACE_WString, and ACE_WSTRING_TYPE.

00051   : ACE_WString (c, alloc)
00052 {
00053 }


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 65 of file SString.cpp.

References ACE_NEW_RETURN, and ACE_TRACE.

Referenced by ACE_Registry_Name_Space::bind(), ACE_NS_String::char_rep(), ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), ACE_Local_Name_Space<, ACE_LOCK >::list_types_i(), ACE_Registry_Name_Space::rebind(), ACE_Registry_Name_Space::resolve(), ACE_Naming_Context::resolve(), and ACE_Registry_Name_Space::unbind().

00066 {
00067   ACE_TRACE ("ACE_NS_WString::char_rep");
00068   if (this->len_ <= 0)
00069     return 0;
00070   else
00071     {
00072       char *t = 0;
00073 
00074       ACE_NEW_RETURN (t,
00075                       char[this->len_ + 1],
00076                       0);
00077 
00078       for (size_t i = 0; i < this->len_; i++)
00079         // Note that this cast may lose data if wide chars are
00080         // actually used!
00081         t[i] = char (this->rep_[i]);
00082 
00083       t[this->len_] = '\0';
00084       return t;
00085     }
00086 }

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 89 of file SString.cpp.

References ACE_NEW_RETURN, ACE_TRACE, and ACE_USHORT16.

00090 {
00091   ACE_TRACE ("ACE_NS_WString::ushort_rep");
00092   if (this->len_ <= 0)
00093     return 0;
00094   else
00095     {
00096       ACE_USHORT16 *t = 0;
00097 
00098       ACE_NEW_RETURN (t,
00099                       ACE_USHORT16[this->len_ + 1],
00100                       0);
00101 
00102       for (size_t i = 0; i < this->len_; i++)
00103         // Note that this cast may lose data if wide chars are
00104         // actually used!
00105         t[i] = (ACE_USHORT16)this->rep_[i];
00106 
00107       t[this->len_] = 0;
00108       return t;
00109     }
00110 }


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:25:54 2006 for ACE by doxygen 1.3.6