2 // Include ACE.h only if it hasn't already been included
5 #endif /* !ACE_ACE_H */
7 #include "ace/OS_NS_stdlib.h"
9 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
12 ACE_NS_WString::ACE_NS_WString (ACE_Allocator *alloc)
18 ACE_NS_WString::ACE_NS_WString (const ACE_WSTRING_TYPE *s,
21 : ACE_WString (s, len, alloc)
26 ACE_NS_WString::ACE_NS_WString (const ACE_WSTRING_TYPE *s,
28 : ACE_WString (s, alloc)
33 ACE_NS_WString::ACE_NS_WString (size_type len, ACE_Allocator *alloc)
34 : ACE_WString (len, 0, alloc)
39 ACE_NS_WString::ACE_NS_WString (ACE_WSTRING_TYPE c, ACE_Allocator *alloc)
40 : ACE_WString (c, alloc)
44 ACE_INLINE ACE_NS_WString
45 operator+ (const ACE_NS_WString &s, const ACE_NS_WString &t)
47 ACE_NS_WString temp (s);
52 // -------------------------------------------------------
55 ACE_SString::~ACE_SString ()
59 ACE_INLINE ACE_SString
60 ACE_SString::substr (size_type offset,
61 size_type length) const
63 return this->substring (offset, length);
66 // Return the <slot'th> character in the string.
69 ACE_SString::operator[] (size_type slot) const
71 ACE_TRACE ("ACE_SString::operator[]");
72 return this->rep_[slot];
75 // Return the <slot'th> character in the string by reference.
78 ACE_SString::operator[] (size_type slot)
80 ACE_TRACE ("ACE_SString::operator[]");
81 return this->rep_[slot];
84 // Get the underlying pointer (does not make a copy, so beware!).
86 ACE_INLINE const char *
87 ACE_SString::rep () const
89 ACE_TRACE ("ACE_SString::rep");
93 // Get the underlying pointer (does not make a copy, so beware!).
95 ACE_INLINE const char *
96 ACE_SString::fast_rep () const
98 ACE_TRACE ("ACE_SString::fast_rep");
102 // Get the underlying pointer (does not make a copy, so beware!).
104 ACE_INLINE const char *
105 ACE_SString::c_str () const
107 ACE_TRACE ("ACE_SString::c_str");
111 // Comparison operator.
114 ACE_SString::operator== (const ACE_SString &s) const
116 ACE_TRACE ("ACE_SString::operator==");
117 return this->len_ == s.len_
118 && ACE_OS::strcmp (this->rep_, s.rep_) == 0;
121 // Less than comparison operator.
123 ACE_SString::operator < (const ACE_SString &s) const
125 ACE_TRACE ("ACE_SString::operator <");
127 return (this->rep_ && s.rep_)
128 ? ACE_OS::strcmp (this->rep_, s.rep_) < 0
129 : ((s.rep_) ? true : false);
132 // Greater than comparison operator.
135 ACE_SString::operator > (const ACE_SString &s) const
137 ACE_TRACE ("ACE_SString::operator >");
139 return (this->rep_ && s.rep_)
140 ? ACE_OS::strcmp (this->rep_, s.rep_) > 0
141 : ((this->rep_) ? true : false );
144 // Comparison operator.
147 ACE_SString::operator!= (const ACE_SString &s) const
149 ACE_TRACE ("ACE_SString::operator!=");
150 return !(*this == s);
154 ACE_SString::compare (const ACE_SString &s) const
156 ACE_TRACE ("ACE_SString::compare");
157 return ACE_OS::strcmp (this->rep_, s.rep_);
160 ACE_INLINE ACE_SString::size_type
161 ACE_SString::find (const char *s, size_type pos) const
163 char *substr = this->rep_ + pos;
164 char *pointer = ACE_OS::strstr (substr, s);
166 return ACE_SString::npos;
168 return pointer - this->rep_;
171 ACE_INLINE ACE_SString::size_type
172 ACE_SString::find (char c, size_type pos) const
174 char *substr = this->rep_ + pos;
175 char *pointer = ACE_OS::strchr (substr, c);
177 return ACE_SString::npos;
179 return pointer - this->rep_;
182 ACE_INLINE ACE_SString::size_type
183 ACE_SString::strstr (const ACE_SString &s) const
185 ACE_TRACE ("ACE_SString::strstr");
187 return this->find (s.rep_);
190 ACE_INLINE ACE_SString::size_type
191 ACE_SString::find (const ACE_SString &str, size_type pos) const
193 return this->find (str.rep_, pos);
196 ACE_INLINE ACE_SString::size_type
197 ACE_SString::rfind (char c, size_type pos) const
199 if (pos == ACE_SString::npos)
202 // Do not change to prefix operator! Proper operation of this loop
203 // depends on postfix decrement behavior.
204 for (size_type i = pos; i-- != 0; )
205 if (this->rep_[i] == c)
208 return ACE_SString::npos;
212 ACE_SString::hash () const
214 return ACE::hash_pjw (this->rep_);
217 ACE_INLINE ACE_SString::size_type
218 ACE_SString::length () const
220 ACE_TRACE ("ACE_SString::length");
225 ACE_Auto_String_Free::ACE_Auto_String_Free (char* p)
231 ACE_Auto_String_Free::ACE_Auto_String_Free (ACE_Auto_String_Free& rhs)
238 ACE_Auto_String_Free::reset (char* p)
240 #if defined (ACE_HAS_ALLOC_HOOKS)
241 ACE_Allocator::instance()->free (this->p_);
243 ACE_OS::free (this->p_);
244 #endif /* ACE_HAS_ALLOC_HOOKS */
248 ACE_INLINE ACE_Auto_String_Free&
249 ACE_Auto_String_Free::operator= (ACE_Auto_String_Free& rhs)
253 this->reset (rhs.p_);
260 ACE_Auto_String_Free::~ACE_Auto_String_Free ()
266 ACE_Auto_String_Free::operator* () const
272 ACE_Auto_String_Free::operator[] (size_t i) const
278 ACE_Auto_String_Free::get () const
284 ACE_Auto_String_Free::release ()
291 ACE_END_VERSIONED_NAMESPACE_DECL