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

ACE_NS_String Class Reference

This class and ACE_NS_Internal are used as Adapters to work with the Map_Manager. More...

#include <Local_Name_Space.h>

List of all members.

Public Methods

 ACE_NS_String (void)
 Default "no-op" constructor. More...

 ACE_NS_String (ACE_USHORT16 *dst, const ACE_USHORT16 *src, size_t len)
 Initialization method. More...

 ACE_NS_String (const ACE_NS_WString &)
 Converts an ACE_NS_WString to an ACE_NS_String;. More...

 ~ACE_NS_String (void)
 Destructor. More...

 operator ACE_NS_WString () const
 Converts an ACE_NS_String to fresh copy of an ACE_NS_WString;. More...

char * char_rep (void) const
 Return the ASCII character representation. More...

int strstr (const ACE_NS_String &) const
 Matches on substrings. More...

int operator== (const ACE_NS_String &) const
 Compare an ACE_NS_String. More...

int operator!= (const ACE_NS_String &) const
 Compare an ACE_NS_String. More...

size_t len (void) const
 Returns length of the string. More...

ACE_USHORT16fast_rep (void) const
 Returns the underlying representation. More...

u_long hash (void) const
 Returns a hash value for this string. More...


Private Attributes

size_t len_
 Length of the string. More...

ACE_USHORT16rep_
 This actually points into shared/persistent memory. More...

int delete_rep_
 Should rep_ be deleted when destructed (only used for WString conversions). More...


Detailed Description

This class and ACE_NS_Internal are used as Adapters to work with the Map_Manager.

In order to work correctly, this class must be able to convert back and forth with <ACE_NS_WStrings>.

Definition at line 37 of file Local_Name_Space.h.


Constructor & Destructor Documentation

ACE_NS_String::ACE_NS_String void   
 

Default "no-op" constructor.

Definition at line 50 of file Local_Name_Space.cpp.

References ACE_TRACE.

00051   : len_ (0),
00052     rep_ (0),
00053     delete_rep_ (0)
00054 {
00055   ACE_TRACE ("ACE_NS_String::ACE_NS_String");
00056 }

ACE_NS_String::ACE_NS_String ACE_USHORT16   dst,
const ACE_USHORT16   src,
size_t    len
 

Initialization method.

Definition at line 116 of file Local_Name_Space.cpp.

References ACE_TRACE, ACE_USHORT16, and ACE_OS_String::memcpy.

00119   : len_ (bytes),
00120     rep_ (dst),
00121     delete_rep_ (0)
00122 {
00123   ACE_TRACE ("ACE_NS_String::ACE_NS_String");
00124   ACE_OS::memcpy (this->rep_, src, bytes);
00125 }

ACE_NS_String::ACE_NS_String const ACE_NS_WString  
 

Converts an ACE_NS_WString to an ACE_NS_String;.

Definition at line 58 of file Local_Name_Space.cpp.

References ACE_TRACE, and ACE_USHORT16.

00059   : len_ ((s.length () + 1) * sizeof (ACE_USHORT16)),
00060     rep_ (s.ushort_rep ()),
00061     delete_rep_ (1)
00062 {
00063   ACE_TRACE ("ACE_NS_String::ACE_NS_String");
00064 }

ACE_NS_String::~ACE_NS_String void   
 

Destructor.

Definition at line 14 of file Local_Name_Space.cpp.

References delete_rep_, and rep_.

00015 {
00016   if (this->delete_rep_)
00017     delete [] this->rep_;
00018 }


Member Function Documentation

char * ACE_NS_String::char_rep void    const
 

Return the ASCII character representation.

Definition at line 42 of file Local_Name_Space.cpp.

References ACE_TRACE, ACE_USHORT16, and ACE_NS_WString::char_rep.

Referenced by ACE_Local_Name_Space::dump_i.

00043 {
00044   ACE_TRACE ("ACE_NS_String::char_rep");
00045   ACE_NS_WString w_string (this->rep_,
00046                            (this->len_ / sizeof (ACE_USHORT16)) - 1);
00047   return w_string.char_rep ();
00048 }

ACE_USHORT16 * ACE_NS_String::fast_rep void    const
 

Returns the underlying representation.

Definition at line 21 of file Local_Name_Space.cpp.

References ACE_TRACE, and rep_.

00022 {
00023   ACE_TRACE ("ACE_NS_String::fast_rep");
00024   return this->rep_;
00025 }

u_long ACE_NS_String::hash void    const
 

Returns a hash value for this string.

Definition at line 128 of file Local_Name_Space.cpp.

References ACE_USHORT16, ACE::hash_pjw, and len_.

00129 {
00130   return ACE::hash_pjw
00131     (ACE_reinterpret_cast (char *, ACE_const_cast (ACE_USHORT16 *,
00132                                                    this->rep_)),
00133      this->len_);
00134 }

size_t ACE_NS_String::len void    const
 

Returns length of the string.

Definition at line 35 of file Local_Name_Space.cpp.

References ACE_TRACE, and len_.

Referenced by strstr.

00036 {
00037   ACE_TRACE ("ACE_NS_String::len");
00038   return this->len_;
00039 }

ACE_NS_String::operator ACE_NS_WString   const
 

Converts an ACE_NS_String to fresh copy of an ACE_NS_WString;.

Definition at line 27 of file Local_Name_Space.cpp.

References ACE_TRACE, and ACE_USHORT16.

00028 {
00029   ACE_TRACE ("ACE_NS_String::operator ACE_NS_WString");
00030   return ACE_NS_WString (this->rep_,
00031                          (this->len_ / sizeof (ACE_USHORT16)) - 1);
00032 }

int ACE_NS_String::operator!= const ACE_NS_String &    const
 

Compare an ACE_NS_String.

Definition at line 110 of file Local_Name_Space.cpp.

References ACE_TRACE, and operator==.

00111 {
00112   ACE_TRACE ("ACE_NS_String::operator !=");
00113   return !this->operator == (s);
00114 }

int ACE_NS_String::operator== const ACE_NS_String &    const
 

Compare an ACE_NS_String.

Definition at line 101 of file Local_Name_Space.cpp.

References ACE_TRACE, len_, ACE_OS_String::memcmp, and rep_.

Referenced by operator!=.

00102 {
00103   ACE_TRACE ("ACE_NS_String::operator ==");
00104   return this->len_ == s.len_
00105     && ACE_OS::memcmp ((void *) this->rep_,
00106                        (void *) s.rep_, this->len_) == 0;
00107 }

int ACE_NS_String::strstr const ACE_NS_String &    const
 

Matches on substrings.

Definition at line 67 of file Local_Name_Space.cpp.

References ACE_TRACE, len, len_, and rep_.

Referenced by ACE_Local_Name_Space::list_name_entries_i, ACE_Local_Name_Space::list_names_i, ACE_Local_Name_Space::list_value_entries_i, and ACE_Local_Name_Space::list_values_i.

00068 {
00069   ACE_TRACE ("ACE_NS_String::strstr");
00070 
00071   if (this->len_ < s.len_)
00072     // If they're larger than we are they can't be a substring of us!
00073     return -1;
00074   else if (this->len_ == s.len_)
00075     // Check if we're equal.
00076     return *this == s ? 0 : -1;
00077   else
00078     {
00079       // They're smaller than we are...
00080       size_t len = (this->len_ - s.len_) / sizeof (ACE_USHORT16);
00081       size_t pat_len = s.len_ / sizeof (ACE_USHORT16) - 1;
00082 
00083       for (size_t i = 0; i <= len; i++)
00084         {
00085           size_t j;
00086 
00087           for (j = 0; j < pat_len; j++)
00088             if (this->rep_[i + j] != s.rep_[j])
00089               break;
00090 
00091           if (j == pat_len)
00092             // Found a match!  Return the index.
00093             return ACE_static_cast (int, i);
00094         }
00095 
00096       return -1;
00097     }
00098 }


Member Data Documentation

int ACE_NS_String::delete_rep_ [private]
 

Should rep_ be deleted when destructed (only used for WString conversions).

Definition at line 88 of file Local_Name_Space.h.

Referenced by ~ACE_NS_String.

size_t ACE_NS_String::len_ [private]
 

Length of the string.

Definition at line 81 of file Local_Name_Space.h.

Referenced by hash, len, operator==, and strstr.

ACE_USHORT16* ACE_NS_String::rep_ [private]
 

This actually points into shared/persistent memory.

Definition at line 84 of file Local_Name_Space.h.

Referenced by fast_rep, operator==, strstr, and ~ACE_NS_String.


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