Public Member Functions

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 58 of file SString.h.


Constructor & Destructor Documentation

ACE_NS_WString::ACE_NS_WString ( ACE_Allocator alloc = 0  ) 

Default constructor.

Definition at line 17 of file SString.inl.

  : ACE_WString (alloc)
{
}

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

Constructor that copies s into dynamically allocated memory.

Definition at line 111 of file SString.cpp.

  : ACE_WString (alloc)
{
  if (s == 0)
    return;

  this->len_ = this->buf_len_ = ACE_OS::strlen (s);

  if (this->buf_len_ == 0)
    return;

  ACE_ALLOCATOR (this->rep_,
                 (ACE_WSTRING_TYPE *)
                 this->allocator_->malloc ((this->buf_len_ + 1) *
                                           sizeof (ACE_WSTRING_TYPE)));
  this->release_ = 1;
  for (size_type i = 0; i <= this->buf_len_; ++i)
    this->rep_[i] = s[i];
}

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.

  : ACE_WString (s, alloc)
{
}

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.

  : ACE_WString (s, len, alloc)
{
}

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.

  : ACE_WString (len, 0, alloc)
{
}

ACE_NS_WString::ACE_NS_WString ( const ACE_NS_WString s  ) 

Copy constructor.

Definition at line 44 of file SString.inl.

  : ACE_WString (s)
{
}

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.

  : ACE_WString (c, alloc)
{
}


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

{
  ACE_TRACE ("ACE_NS_WString::char_rep");
  if (this->len_ == 0)
    return 0;
  else
    {
      char *t = 0;

      ACE_NEW_RETURN (t,
                      char[this->len_ + 1],
                      0);

      for (size_type i = 0; i < this->len_; ++i)
        // Note that this cast may lose data if wide chars are
        // actually used!
        t[i] = char (this->rep_[i]);

      t[this->len_] = '\0';
      return t;
    }
}

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

{
  ACE_TRACE ("ACE_NS_WString::ushort_rep");
  if (this->len_ <= 0)
    return 0;
  else
    {
      ACE_USHORT16 *t = 0;

      ACE_NEW_RETURN (t,
                      ACE_USHORT16[this->len_ + 1],
                      0);

      for (size_type i = 0; i < this->len_; ++i)
        // Note that this cast may lose data if wide chars are
        // actually used!
        t[i] = (ACE_USHORT16)this->rep_[i];

      t[this->len_] = 0;
      return t;
    }
}


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines