2 // Include ACE.h only if it hasn't already been included, e.g., if
3 // ACE_TEMPLATES_REQUIRE_SOURCE, ACE.h won't have been pulled in by
7 #endif /* !ACE_ACE_H */
9 #include "ace/OS_NS_stdlib.h"
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
14 ACE_NS_WString::ACE_NS_WString (ACE_Allocator *alloc)
20 ACE_NS_WString::ACE_NS_WString (const ACE_WSTRING_TYPE *s,
23 : ACE_WString (s, len, alloc)
28 ACE_NS_WString::ACE_NS_WString (const ACE_WSTRING_TYPE *s,
30 : ACE_WString (s, alloc)
35 ACE_NS_WString::ACE_NS_WString (size_type len, ACE_Allocator *alloc)
36 : ACE_WString (len, 0, alloc)
41 ACE_NS_WString::ACE_NS_WString (const ACE_NS_WString &s)
47 ACE_NS_WString::ACE_NS_WString (ACE_WSTRING_TYPE c, ACE_Allocator *alloc)
48 : ACE_WString (c, alloc)
52 ACE_INLINE ACE_NS_WString
53 operator+ (const ACE_NS_WString &s, const ACE_NS_WString &t)
55 ACE_NS_WString temp (s);
60 // -------------------------------------------------------
63 ACE_SString::~ACE_SString (void)
67 ACE_INLINE ACE_SString
68 ACE_SString::substr (size_type offset,
69 size_type length) const
71 return this->substring (offset, length);
74 // Return the <slot'th> character in the string.
77 ACE_SString::operator[] (size_type slot) const
79 ACE_TRACE ("ACE_SString::operator[]");
80 return this->rep_[slot];
83 // Return the <slot'th> character in the string by reference.
86 ACE_SString::operator[] (size_type slot)
88 ACE_TRACE ("ACE_SString::operator[]");
89 return this->rep_[slot];
92 // Get the underlying pointer (does not make a copy, so beware!).
94 ACE_INLINE const char *
95 ACE_SString::rep (void) const
97 ACE_TRACE ("ACE_SString::rep");
101 // Get the underlying pointer (does not make a copy, so beware!).
103 ACE_INLINE const char *
104 ACE_SString::fast_rep (void) const
106 ACE_TRACE ("ACE_SString::fast_rep");
110 // Get the underlying pointer (does not make a copy, so beware!).
112 ACE_INLINE const char *
113 ACE_SString::c_str (void) const
115 ACE_TRACE ("ACE_SString::c_str");
119 // Comparison operator.
122 ACE_SString::operator== (const ACE_SString &s) const
124 ACE_TRACE ("ACE_SString::operator==");
125 return this->len_ == s.len_
126 && ACE_OS::strcmp (this->rep_, s.rep_) == 0;
129 // Less than comparison operator.
132 ACE_SString::operator < (const ACE_SString &s) const
134 ACE_TRACE ("ACE_SString::operator <");
136 return (this->rep_ && s.rep_)
137 ? ACE_OS::strcmp (this->rep_, s.rep_) < 0
138 : ((s.rep_) ? true : false);
141 // Greater than comparison operator.
144 ACE_SString::operator > (const ACE_SString &s) const
146 ACE_TRACE ("ACE_SString::operator >");
148 return (this->rep_ && s.rep_)
149 ? ACE_OS::strcmp (this->rep_, s.rep_) > 0
150 : ((this->rep_) ? true : false );
153 // Comparison operator.
156 ACE_SString::operator!= (const ACE_SString &s) const
158 ACE_TRACE ("ACE_SString::operator!=");
159 return !(*this == s);
163 ACE_SString::compare (const ACE_SString &s) const
165 ACE_TRACE ("ACE_SString::compare");
166 return ACE_OS::strcmp (this->rep_, s.rep_);
169 ACE_INLINE ACE_SString::size_type
170 ACE_SString::find (const char *s, size_type pos) const
172 char *substr = this->rep_ + pos;
173 char *pointer = ACE_OS::strstr (substr, s);
175 return ACE_SString::npos;
177 return pointer - this->rep_;
180 ACE_INLINE ACE_SString::size_type
181 ACE_SString::find (char c, size_type pos) const
183 char *substr = this->rep_ + pos;
184 char *pointer = ACE_OS::strchr (substr, c);
186 return ACE_SString::npos;
188 return pointer - this->rep_;
191 ACE_INLINE ACE_SString::size_type
192 ACE_SString::strstr (const ACE_SString &s) const
194 ACE_TRACE ("ACE_SString::strstr");
196 return this->find (s.rep_);
199 ACE_INLINE ACE_SString::size_type
200 ACE_SString::find (const ACE_SString &str, size_type pos) const
202 return this->find (str.rep_, pos);
205 ACE_INLINE ACE_SString::size_type
206 ACE_SString::rfind (char c, size_type pos) const
208 if (pos == ACE_SString::npos)
211 // Do not change to prefix operator! Proper operation of this loop
212 // depends on postfix decrement behavior.
213 for (size_type i = pos; i-- != 0; )
214 if (this->rep_[i] == c)
217 return ACE_SString::npos;
221 ACE_SString::hash (void) const
223 return ACE::hash_pjw (this->rep_);
226 ACE_INLINE ACE_SString::size_type
227 ACE_SString::length (void) const
229 ACE_TRACE ("ACE_SString::length");
234 ACE_Auto_String_Free::ACE_Auto_String_Free (char* p)
240 ACE_Auto_String_Free::ACE_Auto_String_Free (ACE_Auto_String_Free& rhs)
247 ACE_Auto_String_Free::reset (char* p)
249 #if defined (ACE_HAS_ALLOC_HOOKS)
250 ACE_Allocator::instance()->free (this->p_);
252 ACE_OS::free (this->p_);
253 #endif /* ACE_HAS_ALLOC_HOOKS */
257 ACE_INLINE ACE_Auto_String_Free&
258 ACE_Auto_String_Free::operator= (ACE_Auto_String_Free& rhs)
262 this->reset (rhs.p_);
269 ACE_Auto_String_Free::~ACE_Auto_String_Free (void)
275 ACE_Auto_String_Free::operator* (void) const
281 ACE_Auto_String_Free::operator[] (size_t i) const
287 ACE_Auto_String_Free::get (void) const
293 ACE_Auto_String_Free::release (void)
300 ACE_END_VERSIONED_NAMESPACE_DECL