Use override/default for RTPortableServer
[ACE_TAO.git] / ACE / ace / Local_Name_Space.cpp
blobce5f345b39d968c08964e39858cd38327e21687b
1 #include "ace/Local_Name_Space.h"
2 #include "ace/ACE.h"
3 #include "ace/RW_Process_Mutex.h"
4 #include "ace/SString.h"
5 #include "ace/OS_NS_string.h"
6 #include "ace/Truncate.h"
8 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
10 ACE_NS_String::~ACE_NS_String ()
12 if (this->delete_rep_)
13 #if defined (ACE_HAS_ALLOC_HOOKS)
14 ACE_Allocator::instance()->free(this->rep_);
15 #else
16 delete [] this->rep_;
17 #endif /* ACE_HAS_ALLOC_HOOKS */
20 ACE_WCHAR_T *
21 ACE_NS_String::fast_rep () const
23 ACE_TRACE ("ACE_NS_String::fast_rep");
24 return this->rep_;
27 ACE_NS_String::operator ACE_NS_WString () const
29 ACE_TRACE ("ACE_NS_String::operator ACE_NS_WString");
30 return ACE_NS_WString (this->rep_,
31 (this->len_ / sizeof (ACE_WCHAR_T)) - 1);
34 size_t
35 ACE_NS_String::len () const
37 ACE_TRACE ("ACE_NS_String::len");
38 return this->len_;
41 char *
42 ACE_NS_String::char_rep () const
44 ACE_TRACE ("ACE_NS_String::char_rep");
45 ACE_NS_WString w_string (this->rep_,
46 (this->len_ / sizeof (ACE_WCHAR_T)) - 1);
47 return w_string.char_rep ();
50 ACE_NS_String::ACE_NS_String ()
51 : len_ (0),
52 rep_ (0),
53 delete_rep_ (false)
55 ACE_TRACE ("ACE_NS_String::ACE_NS_String");
58 ACE_NS_String::ACE_NS_String (const ACE_NS_WString &s)
59 : len_ ((s.length () + 1) * sizeof (ACE_WCHAR_T)),
60 rep_ (s.rep ()),
61 delete_rep_ (true)
63 ACE_TRACE ("ACE_NS_String::ACE_NS_String");
66 int
67 ACE_NS_String::strstr (const ACE_NS_String &s) const
69 ACE_TRACE ("ACE_NS_String::strstr");
71 if (this->len_ < s.len_)
72 // If they're larger than we are they can't be a substring of us!
73 return -1;
74 else if (this->len_ == s.len_)
75 // Check if we're equal.
76 return *this == s ? 0 : -1;
77 else
79 // They're smaller than we are...
80 const size_t len = (this->len_ - s.len_) / sizeof (ACE_WCHAR_T);
81 const size_t pat_len = s.len_ / sizeof (ACE_WCHAR_T) - 1;
83 for (size_t i = 0; i <= len; ++i)
85 size_t j;
87 for (j = 0; j < pat_len; ++j)
88 if (this->rep_[i + j] != s.rep_[j])
89 break;
91 if (j == pat_len)
92 // Found a match! Return the index.
93 return ACE_Utils::truncate_cast<int> (i);
96 return -1;
100 bool
101 ACE_NS_String::operator == (const ACE_NS_String &s) const
103 ACE_TRACE ("ACE_NS_String::operator ==");
104 return this->len_ == s.len_
105 && ACE_OS::memcmp ((void *) this->rep_,
106 (void *) s.rep_, this->len_) == 0;
109 bool
110 ACE_NS_String::operator != (const ACE_NS_String &s) const
112 ACE_TRACE ("ACE_NS_String::operator !=");
113 return !this->operator == (s);
116 ACE_NS_String::ACE_NS_String (ACE_WCHAR_T *dst,
117 const ACE_WCHAR_T *src,
118 size_t bytes)
119 : len_ (bytes),
120 rep_ (dst),
121 delete_rep_ (false)
123 ACE_TRACE ("ACE_NS_String::ACE_NS_String");
124 ACE_OS::memcpy (this->rep_, src, bytes);
127 u_long
128 ACE_NS_String::hash () const
130 return ACE::hash_pjw
131 (reinterpret_cast<char *> (const_cast<ACE_WCHAR_T *> (this->rep_)),
132 this->len_);
135 ACE_NS_Internal::ACE_NS_Internal ()
136 : value_ (),
137 type_ ()
141 ACE_NS_Internal::ACE_NS_Internal (ACE_NS_String &value, const char *type)
142 : value_ (value),
143 type_ (type)
145 ACE_TRACE ("ACE_NS_Internal::ACE_NS_Internal");
148 bool
149 ACE_NS_Internal::operator == (const ACE_NS_Internal &s) const
151 ACE_TRACE ("ACE_NS_Internal::operator ==");
152 return this->value_ == s.value_;
155 ACE_NS_String
156 ACE_NS_Internal::value ()
158 ACE_TRACE ("ACE_NS_Internal::value");
159 return this->value_;
162 const char *
163 ACE_NS_Internal::type ()
165 ACE_TRACE ("ACE_NS_Internal::type");
166 return this->type_;
169 ACE_END_VERSIONED_NAMESPACE_DECL