This class and ACE_NS_Internal are used as Adapters to work with the Map_Manager. More...
#include <Local_Name_Space.h>
Public Member Functions | |
ACE_NS_String (void) | |
Default "no-op" constructor. | |
ACE_NS_String (ACE_WCHAR_T *dst, const ACE_WCHAR_T *src, size_t len) | |
Initialization method. | |
ACE_NS_String (const ACE_NS_WString &) | |
Converts an ACE_NS_WString to an ACE_NS_String;. | |
~ACE_NS_String (void) | |
Destructor. | |
operator ACE_NS_WString () const | |
Converts an ACE_NS_String to fresh copy of an ACE_NS_WString;. | |
char * | char_rep (void) const |
Return the ASCII character representation. | |
int | strstr (const ACE_NS_String &) const |
Matches on substrings. | |
bool | operator== (const ACE_NS_String &) const |
Compare an ACE_NS_String. | |
bool | operator!= (const ACE_NS_String &) const |
Compare an ACE_NS_String. | |
size_t | len (void) const |
Returns length of the string. | |
ACE_WCHAR_T * | fast_rep (void) const |
Returns the underlying representation. | |
u_long | hash (void) const |
Returns a hash value for this string. | |
Private Attributes | |
size_t | len_ |
Length of the string. | |
ACE_WCHAR_T * | rep_ |
This actually points into shared/persistent memory. | |
bool | delete_rep_ |
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 39 of file Local_Name_Space.h.
ACE_NS_String::ACE_NS_String | ( | void | ) |
Default "no-op" constructor.
Definition at line 50 of file Local_Name_Space.cpp.
: len_ (0), rep_ (0), delete_rep_ (false) { ACE_TRACE ("ACE_NS_String::ACE_NS_String"); }
ACE_NS_String::ACE_NS_String | ( | ACE_WCHAR_T * | dst, | |
const ACE_WCHAR_T * | src, | |||
size_t | len | |||
) |
Initialization method.
Definition at line 116 of file Local_Name_Space.cpp.
: len_ (bytes), rep_ (dst), delete_rep_ (false) { ACE_TRACE ("ACE_NS_String::ACE_NS_String"); ACE_OS::memcpy (this->rep_, src, bytes); }
ACE_NS_String::ACE_NS_String | ( | const ACE_NS_WString & | s | ) |
Converts an ACE_NS_WString to an ACE_NS_String;.
Definition at line 58 of file Local_Name_Space.cpp.
: len_ ((s.length () + 1) * sizeof (ACE_WCHAR_T)), rep_ (s.rep ()), delete_rep_ (true) { ACE_TRACE ("ACE_NS_String::ACE_NS_String"); }
ACE_NS_String::~ACE_NS_String | ( | void | ) |
Destructor.
char * ACE_NS_String::char_rep | ( | void | ) | const |
Return the ASCII character representation.
Definition at line 42 of file Local_Name_Space.cpp.
{ ACE_TRACE ("ACE_NS_String::char_rep"); ACE_NS_WString w_string (this->rep_, (this->len_ / sizeof (ACE_WCHAR_T)) - 1); return w_string.char_rep (); }
ACE_WCHAR_T * ACE_NS_String::fast_rep | ( | void | ) | const |
Returns the underlying representation.
Definition at line 21 of file Local_Name_Space.cpp.
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.
{ return ACE::hash_pjw (reinterpret_cast<char *> (const_cast<ACE_WCHAR_T *> (this->rep_)), this->len_); }
size_t ACE_NS_String::len | ( | void | ) | const |
Returns length of the string.
Definition at line 35 of file Local_Name_Space.cpp.
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.
{ ACE_TRACE ("ACE_NS_String::operator ACE_NS_WString"); return ACE_NS_WString (this->rep_, (this->len_ / sizeof (ACE_WCHAR_T)) - 1); }
bool ACE_NS_String::operator!= | ( | const ACE_NS_String & | s | ) | const |
Compare an ACE_NS_String.
Definition at line 110 of file Local_Name_Space.cpp.
{ ACE_TRACE ("ACE_NS_String::operator !="); return !this->operator == (s); }
bool ACE_NS_String::operator== | ( | const ACE_NS_String & | s | ) | const |
Compare an ACE_NS_String.
Definition at line 101 of file Local_Name_Space.cpp.
int ACE_NS_String::strstr | ( | const ACE_NS_String & | s | ) | const |
Matches on substrings.
Definition at line 67 of file Local_Name_Space.cpp.
{ ACE_TRACE ("ACE_NS_String::strstr"); if (this->len_ < s.len_) // If they're larger than we are they can't be a substring of us! return -1; else if (this->len_ == s.len_) // Check if we're equal. return *this == s ? 0 : -1; else { // They're smaller than we are... const size_t len = (this->len_ - s.len_) / sizeof (ACE_WCHAR_T); const size_t pat_len = s.len_ / sizeof (ACE_WCHAR_T) - 1; for (size_t i = 0; i <= len; ++i) { size_t j; for (j = 0; j < pat_len; ++j) if (this->rep_[i + j] != s.rep_[j]) break; if (j == pat_len) // Found a match! Return the index. return ACE_Utils::truncate_cast<int> (i); } return -1; } }
bool ACE_NS_String::delete_rep_ [private] |
Should rep_ be deleted when destructed (only used for WString conversions)
Definition at line 90 of file Local_Name_Space.h.
size_t ACE_NS_String::len_ [private] |
Length of the string.
Definition at line 83 of file Local_Name_Space.h.
ACE_WCHAR_T* ACE_NS_String::rep_ [private] |
This actually points into shared/persistent memory.
Definition at line 86 of file Local_Name_Space.h.