2 #include "ace/Malloc_Base.h"
3 #include "ace/Min_Max.h"
4 #include "ace/OS_NS_string.h"
5 #include "ace/OS_Memory.h"
7 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
9 template <class ACE_CHAR_T> ACE_INLINE void
10 ACE_String_Base<ACE_CHAR_T>::dump () const
12 #if defined (ACE_HAS_DUMP)
13 ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::dump");
14 #endif /* ACE_HAS_DUMP */
17 // Assignment method (does not copy memory)
18 template <class ACE_CHAR_T> ACE_INLINE ACE_String_Base<ACE_CHAR_T> &
19 ACE_String_Base<ACE_CHAR_T>::assign_nocopy (const ACE_String_Base<ACE_CHAR_T> &s)
21 ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::assign_nocopy");
22 this->set (s.rep_, s.len_, false);
26 template <class ACE_CHAR_T> ACE_INLINE typename ACE_String_Base<ACE_CHAR_T>::size_type
27 ACE_String_Base<ACE_CHAR_T>::length () const
29 ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::length");
33 template <class ACE_CHAR_T> ACE_INLINE size_t
34 ACE_String_Base<ACE_CHAR_T>::capacity () const
36 ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::capacity");
37 return this->buf_len_;
40 template <class ACE_CHAR_T> ACE_INLINE bool
41 ACE_String_Base<ACE_CHAR_T>::is_empty () const
43 return this->len_ == 0;
46 template <class ACE_CHAR_T> ACE_INLINE bool
47 ACE_String_Base<ACE_CHAR_T>::empty () const
49 return this->is_empty ();
52 template <class ACE_CHAR_T> ACE_INLINE ACE_String_Base<ACE_CHAR_T>
53 ACE_String_Base<ACE_CHAR_T>::substr (
54 typename ACE_String_Base<ACE_CHAR_T>::size_type offset,
55 typename ACE_String_Base<ACE_CHAR_T>::size_type length) const
57 ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::substr");
58 return this->substring (offset, length);
61 // Return the <slot'th> character in the string.
63 template <class ACE_CHAR_T> ACE_INLINE const ACE_CHAR_T &
64 ACE_String_Base<ACE_CHAR_T>::operator[] (
65 typename ACE_String_Base<ACE_CHAR_T>::size_type slot) const
67 ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::operator[]");
68 return this->rep_[slot];
71 // Return the <slot'th> character in the string by reference.
73 template <class ACE_CHAR_T> ACE_INLINE ACE_CHAR_T &
74 ACE_String_Base<ACE_CHAR_T>::operator[] (
75 typename ACE_String_Base<ACE_CHAR_T>::size_type slot)
77 ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::operator[]");
78 return this->rep_[slot];
81 template <class ACE_CHAR_T> ACE_INLINE const ACE_CHAR_T *
82 ACE_String_Base<ACE_CHAR_T>::fast_rep () const
87 template <class ACE_CHAR_T> ACE_INLINE const ACE_CHAR_T *
88 ACE_String_Base<ACE_CHAR_T>::c_str () const
93 // Less than comparison operator.
95 template <class ACE_CHAR_T> ACE_INLINE bool
96 ACE_String_Base<ACE_CHAR_T>::operator < (const ACE_String_Base<ACE_CHAR_T> &s) const
98 ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::operator <");
99 return compare (s) < 0;
102 // Greater than comparison operator.
104 template <class ACE_CHAR_T> ACE_INLINE bool
105 ACE_String_Base<ACE_CHAR_T>::operator > (const ACE_String_Base &s) const
107 ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::operator >");
108 return compare (s) > 0;
112 // Comparison operator.
114 template <class ACE_CHAR_T> ACE_INLINE bool
115 ACE_String_Base<ACE_CHAR_T>::operator!= (const ACE_String_Base<ACE_CHAR_T> &s) const
117 ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::operator!=");
118 return !(*this == s);
121 template <class ACE_CHAR_T> ACE_INLINE bool
122 ACE_String_Base<ACE_CHAR_T>::operator!= (const ACE_CHAR_T *s) const
124 return !(*this == s);
127 template <class ACE_CHAR_T> ACE_INLINE typename ACE_String_Base<ACE_CHAR_T>::size_type
128 ACE_String_Base<ACE_CHAR_T>::find (const ACE_String_Base<ACE_CHAR_T>&str,
129 typename ACE_String_Base<ACE_CHAR_T>::size_type pos) const
131 ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::find");
132 return this->find (str.rep_, pos);
135 template <class ACE_CHAR_T> ACE_INLINE typename ACE_String_Base<ACE_CHAR_T>::size_type
136 ACE_String_Base<ACE_CHAR_T>::strstr (const ACE_String_Base<ACE_CHAR_T> &s) const
138 ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::strstr");
139 return this->find (s.rep_);
142 template <class ACE_CHAR_T> ACE_INLINE typename ACE_String_Base<ACE_CHAR_T>::iterator
143 ACE_String_Base<ACE_CHAR_T>::begin ()
145 ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::begin");
146 return iterator (*this);
149 template <class ACE_CHAR_T> ACE_INLINE typename ACE_String_Base<ACE_CHAR_T>::const_iterator
150 ACE_String_Base<ACE_CHAR_T>::begin () const
152 ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::begin");
153 return const_iterator (*this);
156 template <class ACE_CHAR_T> ACE_INLINE typename ACE_String_Base<ACE_CHAR_T>::iterator
157 ACE_String_Base<ACE_CHAR_T>::end ()
159 ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::end");
160 return iterator (*this, 1);
163 template <class ACE_CHAR_T> ACE_INLINE typename ACE_String_Base<ACE_CHAR_T>::const_iterator
164 ACE_String_Base<ACE_CHAR_T>::end () const
166 ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::end");
167 return const_iterator (*this, 1);
170 // ----------------------------------------------
172 template <class ACE_CHAR_T> ACE_INLINE
173 ACE_String_Base_Iterator <ACE_CHAR_T>::
174 ACE_String_Base_Iterator (ACE_String_Base <ACE_CHAR_T> & str, int end)
176 index_ (0 == end ? 0 : str.length ())
178 ACE_TRACE ("ACE_String_Base_Iterator<ACE_CHAR_T>::ACE_String_Base_Iterator");
181 template <class ACE_CHAR_T> ACE_INLINE
182 ACE_String_Base_Iterator <ACE_CHAR_T>::
183 ACE_String_Base_Iterator (const ACE_String_Base_Iterator <ACE_CHAR_T> & iter)
187 ACE_TRACE ("ACE_String_Base_Iterator<ACE_CHAR_T>::ACE_String_Base_Iterator");
190 template <class ACE_CHAR_T> ACE_INLINE
191 ACE_String_Base_Iterator <ACE_CHAR_T>::~ACE_String_Base_Iterator ()
193 ACE_TRACE ("ACE_String_Base_Iterator<ACE_CHAR_T>::~ACE_String_Base_Iterator");
196 template <class ACE_CHAR_T> ACE_INLINE
197 int ACE_String_Base_Iterator <ACE_CHAR_T>::done () const
199 ACE_TRACE ("ACE_String_Base_Iterator<ACE_CHAR_T>::done");
201 return this->index_ >= this->str_->length () ? 1 : 0;
204 template <class ACE_CHAR_T> ACE_INLINE
205 ACE_CHAR_T & ACE_String_Base_Iterator <ACE_CHAR_T>::operator * ()
207 ACE_TRACE ("ACE_String_Base_Iterator<ACE_CHAR_T>::operator *");
209 return this->str_->rep_[this->index_];
212 template <class ACE_CHAR_T> ACE_INLINE
213 ACE_String_Base_Iterator <ACE_CHAR_T> &
214 ACE_String_Base_Iterator <ACE_CHAR_T>::operator ++ ()
216 ACE_TRACE ("ACE_String_Base_Iterator<ACE_CHAR_T>::operator ++");
218 if (0 == this->done ())
224 template <class ACE_CHAR_T> ACE_INLINE
225 ACE_String_Base_Iterator <ACE_CHAR_T>
226 ACE_String_Base_Iterator <ACE_CHAR_T>::operator ++ (int)
228 ACE_TRACE ("ACE_String_Base_Iterator<ACE_CHAR_T>::operator ++ (int)");
230 ACE_String_Base_Iterator <ACE_CHAR_T> temp (*this);
232 if (0 == this->done ())
238 template <class ACE_CHAR_T> ACE_INLINE
239 ACE_String_Base_Iterator <ACE_CHAR_T> &
240 ACE_String_Base_Iterator <ACE_CHAR_T>::operator -- ()
242 ACE_TRACE ("ACE_String_Base_Iterator<ACE_CHAR_T>::operator --");
244 if (0 < this->index_)
250 template <class ACE_CHAR_T> ACE_INLINE
251 ACE_String_Base_Iterator <ACE_CHAR_T>
252 ACE_String_Base_Iterator <ACE_CHAR_T>::operator -- (int)
254 ACE_TRACE ("ACE_String_Base_Iterator<ACE_CHAR_T>::operator -- (int)");
256 ACE_String_Base_Iterator <ACE_CHAR_T> temp (*this);
258 if (0 < this->index_)
264 template <class ACE_CHAR_T> ACE_INLINE bool
265 ACE_String_Base_Iterator <ACE_CHAR_T>::
266 operator == (const ACE_String_Base_Iterator <ACE_CHAR_T> & rhs) const
268 return this->index_ == rhs.index_;
271 template <class ACE_CHAR_T> ACE_INLINE bool
272 ACE_String_Base_Iterator <ACE_CHAR_T>::
273 operator != (const ACE_String_Base_Iterator <ACE_CHAR_T> & rhs) const
275 return this->index_ != rhs.index_;
278 template <class ACE_CHAR_T> ACE_INLINE bool
279 ACE_String_Base_Iterator <ACE_CHAR_T>::
280 operator < (const ACE_String_Base_Iterator <ACE_CHAR_T> & rhs) const
282 return this->index_ < rhs.index_;
285 template <class ACE_CHAR_T> ACE_INLINE bool
286 ACE_String_Base_Iterator <ACE_CHAR_T>::
287 operator > (const ACE_String_Base_Iterator <ACE_CHAR_T> & rhs) const
289 return this->index_ > rhs.index_;
292 template <class ACE_CHAR_T> ACE_INLINE bool
293 ACE_String_Base_Iterator <ACE_CHAR_T>::
294 operator >= (const ACE_String_Base_Iterator <ACE_CHAR_T> & rhs) const
296 return this->index_ >= rhs.index_;
299 template <class ACE_CHAR_T> ACE_INLINE bool
300 ACE_String_Base_Iterator <ACE_CHAR_T>::
301 operator <= (const ACE_String_Base_Iterator <ACE_CHAR_T> & rhs) const
303 return this->index_ <= rhs.index_;
306 // ----------------------------------------------
308 template <class ACE_CHAR_T> ACE_INLINE
309 ACE_String_Base_Const_Iterator <ACE_CHAR_T>::
310 ACE_String_Base_Const_Iterator (const ACE_String_Base <ACE_CHAR_T> & str, int end)
312 index_ (0 == end ? 0 : str.length ())
314 ACE_TRACE ("ACE_String_Base_Const_Iterator<ACE_CHAR_T>::ACE_String_Base_Const_Iterator");
317 template <class ACE_CHAR_T> ACE_INLINE
318 ACE_String_Base_Const_Iterator <ACE_CHAR_T>::
319 ACE_String_Base_Const_Iterator (const ACE_String_Base_Const_Iterator <ACE_CHAR_T> & iter)
323 ACE_TRACE ("ACE_String_Base_Const_Iterator<ACE_CHAR_T>::ACE_String_Base_Const_Iterator");
326 template <class ACE_CHAR_T> ACE_INLINE
327 ACE_String_Base_Const_Iterator <ACE_CHAR_T>::~ACE_String_Base_Const_Iterator ()
329 ACE_TRACE ("ACE_String_Base_Const_Iterator<ACE_CHAR_T>::~ACE_String_Base_Const_Iterator");
332 template <class ACE_CHAR_T> ACE_INLINE
333 int ACE_String_Base_Const_Iterator <ACE_CHAR_T>::done () const
335 ACE_TRACE ("ACE_String_Base_Const_Iterator<ACE_CHAR_T>::done");
337 return this->index_ >= this->str_->length () ? 1 : 0;
340 template <class ACE_CHAR_T> ACE_INLINE
341 const ACE_CHAR_T & ACE_String_Base_Const_Iterator <ACE_CHAR_T>::operator * ()
343 ACE_TRACE ("ACE_String_Base_Const_Iterator<ACE_CHAR_T>::operator *");
345 return this->str_->rep_[this->index_];
348 template <class ACE_CHAR_T> ACE_INLINE
349 ACE_String_Base_Const_Iterator <ACE_CHAR_T> &
350 ACE_String_Base_Const_Iterator <ACE_CHAR_T>::operator ++ ()
352 ACE_TRACE ("ACE_String_Base_Const_Iterator<ACE_CHAR_T>::operator ++");
354 if (0 == this->done ())
360 template <class ACE_CHAR_T> ACE_INLINE
361 ACE_String_Base_Const_Iterator <ACE_CHAR_T>
362 ACE_String_Base_Const_Iterator <ACE_CHAR_T>::operator ++ (int)
364 ACE_TRACE ("ACE_String_Base_Const_Iterator<ACE_CHAR_T>::operator ++ (int)");
366 ACE_String_Base_Const_Iterator <ACE_CHAR_T> temp (*this);
368 if (0 == this->done ())
374 template <class ACE_CHAR_T> ACE_INLINE
375 ACE_String_Base_Const_Iterator <ACE_CHAR_T> &
376 ACE_String_Base_Const_Iterator <ACE_CHAR_T>::operator -- ()
378 ACE_TRACE ("ACE_String_Base_Const_Iterator<ACE_CHAR_T>::operator --");
380 if (0 < this->index_)
386 template <class ACE_CHAR_T> ACE_INLINE
387 ACE_String_Base_Const_Iterator <ACE_CHAR_T>
388 ACE_String_Base_Const_Iterator <ACE_CHAR_T>::operator -- (int)
390 ACE_TRACE ("ACE_String_Base_Const_Iterator<ACE_CHAR_T>::operator -- (int)");
392 ACE_String_Base_Const_Iterator <ACE_CHAR_T> temp (*this);
394 if (0 < this->index_)
400 template <class ACE_CHAR_T> ACE_INLINE bool
401 ACE_String_Base_Const_Iterator <ACE_CHAR_T>::
402 operator == (const ACE_String_Base_Const_Iterator <ACE_CHAR_T> & rhs) const
404 return this->index_ == rhs.index_;
407 template <class ACE_CHAR_T> ACE_INLINE bool
408 ACE_String_Base_Const_Iterator <ACE_CHAR_T>::
409 operator != (const ACE_String_Base_Const_Iterator <ACE_CHAR_T> & rhs) const
411 return this->index_ != rhs.index_;
414 template <class ACE_CHAR_T> ACE_INLINE bool
415 ACE_String_Base_Const_Iterator <ACE_CHAR_T>::
416 operator < (const ACE_String_Base_Const_Iterator <ACE_CHAR_T> & rhs) const
418 return this->index_ < rhs.index_;
421 template <class ACE_CHAR_T> ACE_INLINE bool
422 ACE_String_Base_Const_Iterator <ACE_CHAR_T>::
423 operator > (const ACE_String_Base_Const_Iterator <ACE_CHAR_T> & rhs) const
425 return this->index_ > rhs.index_;
428 template <class ACE_CHAR_T> ACE_INLINE bool
429 ACE_String_Base_Const_Iterator <ACE_CHAR_T>::
430 operator >= (const ACE_String_Base_Const_Iterator <ACE_CHAR_T> & rhs) const
432 return this->index_ >= rhs.index_;
435 template <class ACE_CHAR_T> ACE_INLINE bool
436 ACE_String_Base_Const_Iterator <ACE_CHAR_T>::
437 operator <= (const ACE_String_Base_Const_Iterator <ACE_CHAR_T> & rhs) const
439 return this->index_ <= rhs.index_;
442 // ----------------------------------------------
444 template <class ACE_CHAR_T> ACE_INLINE bool
445 operator== (const ACE_CHAR_T *s, const ACE_String_Base<ACE_CHAR_T> &t)
450 template <class ACE_CHAR_T> ACE_INLINE bool
451 operator!= (const ACE_CHAR_T *s, const ACE_String_Base<ACE_CHAR_T> &t)
456 ACE_END_VERSIONED_NAMESPACE_DECL