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_WSTRING_TYPE *s, size_type len, ACE_Allocator *alloc=0)
 ACE_NS_WString (size_type 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.

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

References ACE_ALLOCATOR, ACE_String_Base< CHAR >::buf_len_, ACE_String_Base< CHAR >::len_, ACE_String_Base< CHAR >::release_, and ACE_OS::strlen().

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

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.

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

ACE_INLINE ACE_NS_WString::ACE_NS_WString ( const ACE_WSTRING_TYPE s,
size_type  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.

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

ACE_INLINE ACE_NS_WString::ACE_NS_WString ( size_type  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.

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.

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.

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

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

Referenced by ACE_NS_String::char_rep(), ACE_Local_Name_Space<, ACE_LOCK >::dump_i(), ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), ACE_Local_Name_Space<, ACE_LOCK >::list_types_i(), and ACE_Naming_Context::resolve().

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

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

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

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


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:24 2010 for ACE by  doxygen 1.4.7