NCBI C++ ToolKit
tempstr.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef CORELIB___TEMPSTR__HPP
2 #define CORELIB___TEMPSTR__HPP
3 
4 /* $Id: tempstr.hpp 99233 2023-03-01 16:19:54Z ucko $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Mike DiCuccio, Eugene Vasilchenko, Aaron Ucko, Vladimir Ivanov
30  *
31  * File Description:
32  *
33  * CTempString -- Light-weight const string class that can wrap an std::string
34  * or C-style char array.
35  *
36  */
37 
38 #include <corelib/ncbiexpt.hpp>
39 #include <algorithm>
40 
41 #ifdef NCBI_HAVE_CXX17
42  #include <string_view>
43 #endif
44 
45 
47 
48 
49 /** @addtogroup String
50  *
51  * @{
52  */
53 
54 /////////////////////////////////////////////////////////////////////////////
55 ///
56 /// CTempString implements a light-weight string on top of a storage buffer
57 /// whose lifetime management is known and controlled. CTempString is designed
58 /// to perform no memory allocation but provide a string interaction interface
59 /// congruent with std::basic_string<char>. As such, CTempString provides a
60 /// const-only access interface to its underlying storage. Care has been taken
61 /// to avoid allocations and other expensive operations wherever possible.
62 ///
63 
65 {
66 public:
67  /// @name std::basic_string<> compatibility typedefs and enums
68  /// @{
69  typedef char value_type;
70  typedef size_t size_type;
71  typedef const char* const_iterator;
72  static const size_type npos = static_cast<size_type>(-1);
73  /// @}
74 
75  CTempString(void);
76  CTempString(const char* str);
77  CTempString(const char* str, size_type len);
78  /// Use CTempString(const char* str + pos, size_type len - pos) instead
80 
81  CTempString(const string& str);
82  /// Use CTempString(const string& str, 0, size_type len) instead
84  CTempString(const string& str, size_type pos, size_type len);
85 
86  CTempString(const CTempString& str);
87  CTempString(const CTempString& str, size_type pos);
89 
90  #ifdef NCBI_HAVE_CXX17
91  CTempString(const string_view& str_view);
92  #endif
93 
94  /// Copy a substring into a string
95  /// Somewhat similar to basic_string::assign()
96  void Copy(string& dst, size_type pos, size_type len) const;
97 
98  /// @name std::basic_string<> compatibility interface
99  /// @{
100 
101  /// Assign new values to the content of the a string
102  CTempString& assign(const char* src_str, size_type len);
103  CTempString& assign(const CTempString src_str);
104  CTempString& assign(const CTempString src_str, size_type pos, size_type len);
106 
107 
108  /// Return an iterator to the string's starting position
109  const_iterator begin() const;
110 
111  /// Return an iterator to the string's ending position (one past the end of
112  /// the represented sequence)
113  const_iterator end() const;
114 
115  /// Return a pointer to the array represented. As with
116  /// std::basic_string<>, this is not guaranteed to be NULL terminated.
117  const char* data(void) const;
118 
119  /// Return the length of the represented array.
120  size_type length(void) const;
121 
122  /// Return the length of the represented array.
123  size_type size(void) const;
124 
125  /// Return true if the represented string is empty (i.e., the length is
126  /// zero)
127  bool empty(void) const;
128 
129  /// Clears the string
130  void clear(void);
131 
132  /// Truncate the string at some specified position
133  /// Note: basic_string<> supports additional erase() options that we
134  /// do not provide here
135  void erase(size_type pos = 0);
136 
137  /// Find the first instance of the entire matching string within the
138  /// current string, beginning at an optional offset.
140  size_type pos = 0) const;
141 
142  /// Find the first instance of a given character string within the
143  /// current string in a forward direction, beginning at an optional offset.
144  size_type find(char match, size_type pos = 0) const;
145 
146  /// Find the first instance of the entire matching string within the
147  /// current string in a backward direction, beginning at an optional offset.
149  size_type pos = npos) const;
150 
151  /// Find the last instance of a given character string within the
152  /// current string, beginning at an optional offset.
153  size_type rfind(char match, size_type pos = npos) const;
154 
155  /// Find the first occurrence of any character in the matching string
156  /// within the current string, beginning at an optional offset.
158  size_type pos = 0) const;
159 
160  /// Find the first occurrence of any character not in the matching string
161  /// within the current string, beginning at an optional offset.
163  size_type pos = 0) const;
164 
165  /// Find the last occurrence of any character in the matching string
166  /// within the current string, beginning at an optional offset.
168  size_type pos = npos) const;
169 
170  /// Find the last occurrence of any character not in the matching string
171  /// within the current string, beginning at an optional offset.
173  size_type pos = npos) const;
174 
175  /// Obtain a substring from this string, beginning at a given offset
176  CTempString substr(size_type pos) const;
177  /// Obtain a substring from this string, beginning at a given offset
178  /// and extending a specified length
180 
181  /// Index into the current string and provide its character in a read-
182  /// only fashion. If the index is beyond the length of the string,
183  /// a NULL character is returned.
184  char operator[](size_type pos) const;
185 
186  /// Compare the current string with a given string.
187  int compare(const CTempString str) const;
188 
189  // Comparison operators, see compare().
190  bool operator==(const CTempString str) const;
191  bool operator!=(const CTempString str) const;
192  bool operator< (const CTempString str) const;
193  bool operator> (const CTempString str) const;
194 
195  /// @}
196 
197  operator string(void) const;
198 
199  #ifdef NCBI_HAVE_CXX17
200  operator string_view(void) const;
201  #endif
202 
203 private:
204  const char* m_String; ///< Stored pointer to string
205  size_type m_Length; ///< Length of string
206 
207 private:
208  // Initialize CTempString with bounds checks
209  void x_Init(const char* str, size_type str_len, size_type pos, size_type len);
210  void x_Init(const char* str, size_type str_len, size_type pos);
211 
212 #if defined(NCBI_TEMPSTR_USE_A_COPY)
213  /// @attention This (making copy of the string) is turned off by default!
214  void x_MakeCopy(void);
215  /// @attention This (making copy of the string) is turned off by default!
216  void x_DestroyCopy(void);
217 #endif
218 };
219 
220 
221 /////////////////////////////////////////////////////////////////////////////
222 
223 
224 // Operator +
225 
226 /// @internal
227 inline
228 string g_CTempString_plus(const char* str1, size_t len1,
229  const char* str2, size_t len2)
230 {
231  string tmp;
232  tmp.reserve(len1 + len2);
233  tmp.assign(str1, len1);
234  tmp.append(str2, len2);
235  return tmp;
236 }
237 
238 inline
239 string operator+(const char* str1, const CTempString str2)
240 {
241  return g_CTempString_plus(str1, strlen(str1),
242  str2.data(), str2.length());
243 }
244 
245 inline
246 string operator+(const CTempString str1, const char* str2)
247 {
248  return g_CTempString_plus(str1.data(), str1.length(),
249  str2, strlen(str2));
250 }
251 
252 inline
253 string operator+(const string& str1, const CTempString str2)
254 {
255  return g_CTempString_plus(str1.data(), str1.length(),
256  str2.data(), str2.length());
257 }
258 
259 inline
260 string operator+(const CTempString str1, const string& str2)
261 {
262  return g_CTempString_plus(str1.data(), str1.length(),
263  str2.data(), str2.length());
264 }
265 
266 inline
267 string operator+(const CTempString str1, const CTempString str2)
268 {
269  return g_CTempString_plus(str1.data(), str1.length(),
270  str2.data(), str2.length());
271 }
272 
273 
274 // Put CTempString to stream
275 inline
277 {
278  return out.write(str.data(), str.length());
279 }
280 
281 
282 
283 /////////////////////////////////////////////////////////////////////////////
284 
285 #if defined(NCBI_TEMPSTR_USE_A_COPY)
286 // This is NOT a default behavior.
287 // The NCBI_TEMPSTR_USE_A_COPY define has been introduced specifically for
288 // SWIG. Making copies in the CTempString allows using this class naturally in
289 // the generated Python wrappers.
290 # define NCBI_TEMPSTR_MAKE_COPY() x_MakeCopy()
291 # define NCBI_TEMPSTR_DESTROY_COPY() x_DestroyCopy()
292 #else
293 # define NCBI_TEMPSTR_MAKE_COPY()
294 # define NCBI_TEMPSTR_DESTROY_COPY()
295 #endif
296 
297 
298 inline
300 {
301  return m_String;
302 }
303 
304 
305 inline
307 {
308  return m_String + m_Length;
309 }
310 
311 
312 inline
313 const char* CTempString::data(void) const
314 {
315  return m_String;
316 }
317 
318 
319 inline
321 {
322  return m_Length;
323 }
324 
325 
326 inline
328 {
329  return m_Length;
330 }
331 
332 
333 inline
334 bool CTempString::empty(void) const
335 {
336  return m_Length == 0;
337 }
338 
339 
340 inline
342 {
343  if ( pos < m_Length ) {
344  return m_String[pos];
345  }
346  return '\0';
347 }
348 
349 
350 inline
352 {
354  // clear() assures that m_String points to a NULL-terminated c-style
355  // string as a fall-back.
356  m_String = "";
357  m_Length = 0;
359 }
360 
361 
362 inline
363 void CTempString::x_Init(const char* str, size_type str_len,
364  size_type pos)
365 {
366  if ( pos >= str_len ) {
367  clear();
368  }
369  else {
370  m_String = str + pos;
371  m_Length = str_len - pos;
372  }
373 }
374 
375 
376 inline
377 void CTempString::x_Init(const char* str, size_type str_len,
378  size_type pos, size_type len)
379 {
380  if ( pos >= str_len ) {
381  clear();
382  }
383  else {
384  m_String = str + pos;
385  m_Length = min(len, str_len - pos);
386  }
387 }
388 
389 
390 #if defined(NCBI_TEMPSTR_USE_A_COPY)
391 inline
392 void CTempString::x_MakeCopy()
393 {
394  // 1 extra byte is for last 0 unconditionally
395  char* copy = new char[m_Length+1];
396  memcpy(copy, m_String, m_Length);
397  copy[m_Length] = 0;
398  m_String = copy;
399 }
400 
401 inline
402 void CTempString::x_DestroyCopy(void)
403 {
404  delete [] m_String;
405  m_String = NULL;
406  m_Length = 0;
407 }
408 #endif
409 
410 
411 inline
413 #if defined(NCBI_TEMPSTR_USE_A_COPY)
414  : m_String(NULL)
415 #endif
416 {
417  clear();
418 }
419 
420 
421 inline
423 #if defined(NCBI_TEMPSTR_USE_A_COPY)
424  : m_String(NULL)
425 #endif
426 {
427  if ( !str ) {
428  clear();
429  return;
430  }
431  m_String = str;
432  m_Length = strlen(str);
434 }
435 
436 
437 /// Templatized initialization from a string literal. This version is
438 /// optimized to deal specifically with constant-sized built-in arrays.
439 template<size_t Size>
440 inline
441 CTempString literal(const char (&str)[Size])
442 {
443  return CTempString(str, Size-1);
444 }
445 
446 
447 inline
449  : m_String(str), m_Length(len)
450 {
452 }
453 
454 
455 inline
457  : m_String(str.data()), m_Length(str.size())
458 {
460 }
461 
462 
463 inline
465 #if defined(NCBI_TEMPSTR_USE_A_COPY)
466  : m_String(NULL)
467 #endif
468 {
469  x_Init(str.data(), str.size(), pos, len);
471 }
472 
473 
474 inline
476  : m_String(str.data()), m_Length(str.size())
477 {
479 }
480 
481 
482 inline
484 #if defined(NCBI_TEMPSTR_USE_A_COPY)
485  : m_String(NULL)
486 #endif
487 {
488  x_Init(str.data(), str.size(), pos);
490 }
491 
492 
493 inline
495 #if defined(NCBI_TEMPSTR_USE_A_COPY)
496  : m_String(NULL)
497 #endif
498 {
499  x_Init(str.data(), str.size(), pos, len);
501 }
502 
503 #ifdef NCBI_HAVE_CXX17
504 inline
505 CTempString::CTempString(const string_view& str_view)
506  : m_String(str_view.data()), m_Length(str_view.size())
507 {
509 }
510 #endif
511 
512 
513 inline
515 {
516  if (pos < m_Length) {
517  m_Length = pos;
518  }
519 }
520 
521 
522 /// Copy a substring into a string.
523 /// These are analogs of basic_string::assign().
524 inline
525 void CTempString::Copy(string& dst, size_type pos, size_type len) const
526 {
527  if (pos < length()) {
528  len = min(len, length()-pos);
529  dst.assign(begin() + pos, begin() + pos + len);
530  }
531  else {
532  dst.erase();
533  }
534 }
535 
536 
537 inline
539  size_type pos) const
540 {
541  if (match.length() && pos < length()) {
542  const_iterator it = std::find_first_of(begin() + pos, end(),
543  match.begin(), match.end());
544  if (it != end()) {
545  return it - begin();
546  }
547  }
548  return npos;
549 }
550 
551 
552 inline
554  size_type pos) const
555 {
556  if (match.length() && pos < length()) {
557  const_iterator it = begin() + pos;
558  const_iterator end_it = end();
559  const_iterator match_begin = match.begin();
560  const_iterator match_end = match.end();
561  for ( ; it != end_it; ++it) {
562  bool found = false;
563  for (const_iterator match_it = match_begin;
564  match_it != match_end; ++match_it) {
565  if (*it == *match_it) {
566  found = true;
567  break;
568  }
569  }
570  if ( !found ) {
571  return it - begin();
572  }
573  }
574  }
575  return npos;
576 }
577 
578 
579 inline
581  size_type pos) const
582 {
583  if (match.length()) {
584  if (pos >= length()) {
585  pos = length() - 1;
586  }
587  const_iterator it = begin() + pos;
588  const_iterator end_it = begin();
589  const_iterator match_begin = match.begin();
590  const_iterator match_end = match.end();
591  for ( ; it >= end_it; --it) {
592  bool found = false;
593  for (const_iterator match_it = match_begin;
594  match_it != match_end; ++match_it) {
595  if (*it == *match_it) {
596  found = true;
597  break;
598  }
599  }
600  if ( found ) {
601  return it - begin();
602  }
603  }
604  }
605  return npos;
606 }
607 
608 
609 inline
611  size_type pos) const
612 {
613  if (match.length()) {
614  if (pos >= length()) {
615  pos = length() - 1;
616  }
617  const_iterator it = begin() + pos;
618  const_iterator end_it = begin();
619  const_iterator match_begin = match.begin();
620  const_iterator match_end = match.end();
621  for ( ; it >= end_it; --it) {
622  bool found = false;
623  for (const_iterator match_it = match_begin;
624  match_it != match_end; ++match_it) {
625  if (*it == *match_it) {
626  found = true;
627  break;
628  }
629  }
630  if ( !found ) {
631  return it - begin();
632  }
633  }
634  }
635  return npos;
636 }
637 
638 
639 inline
641 {
642  if (pos + 1 > length()) {
643  return npos;
644  }
645  for (size_type i = pos; i < length(); ++i) {
646  if (m_String[i] == match) {
647  return i;
648  }
649  }
650  return npos;
651 }
652 
653 
654 inline
656  size_type pos) const
657 {
658  if (pos + match.length() > length()) {
659  return npos;
660  }
661  if (match.length() == 0) {
662  return pos;
663  }
664  size_type length_limit = length() - match.length();
665  while ( (pos = find_first_of(CTempString(match, 0, 1), pos)) !=
666  string::npos) {
667  if (pos > length_limit) {
668  return npos;
669  }
670  int res = memcmp(begin() + pos + 1,
671  match.begin() + 1,
672  match.length() - 1);
673  if (res == 0) {
674  return pos;
675  }
676  ++pos;
677  }
678  return npos;
679 }
680 
681 
682 inline
684 {
685  if (length() == 0) {
686  return npos;
687  }
688  if (pos >= length()) {
689  pos = length() - 1;
690  }
691  for (size_type i = pos;;) {
692  if (m_String[i] == match) {
693  return i;
694  }
695  if (!i) {
696  break;
697  }
698  --i;
699  }
700  return npos;
701 }
702 
703 
704 inline
706  size_type pos) const
707 {
708  if (match.length() > length()) {
709  return npos;
710  }
711  if (match.length() == 0) {
712  return length();
713  }
714  pos = min(pos, length() - match.length());
715  while ( (pos = find_last_of(CTempString(match, 0, 1), pos)) !=
716  string::npos) {
717  int res = memcmp(begin() + pos + 1,
718  match.begin() + 1,
719  match.length() - 1);
720  if (res == 0) {
721  return pos;
722  }
723  if (!pos) {
724  break;
725  }
726  --pos;
727  }
728  return npos;
729 }
730 
731 
732 inline
734 {
736  m_String = src;
737  m_Length = len;
739  return *this;
740 }
741 
742 
743 inline
745 {
746  if (this != &src_str) {
748  m_String = src_str.m_String;
749  m_Length = src_str.m_Length;
751  }
752  return *this;
753 }
754 
755 
756 inline
758  size_type pos,
759  size_type len)
760 {
762  x_Init(src_str.data(), src_str.size(), pos, len);
764  return *this;
765 }
766 
767 
768 inline
770 {
771  return assign(src_str);
772 }
773 
774 
775 inline
777 {
778  return CTempString(*this, pos);
779 }
780 
781 
782 inline
784 {
785  return CTempString(*this, pos, len);
786 }
787 
788 
789 inline
790 CTempString::operator string(void) const
791 {
792  return string(data(), length());
793 }
794 
795 
796 #ifdef NCBI_HAVE_CXX17
797 inline
798 CTempString::operator string_view(void) const
799 {
800  return string_view(data(), length());
801 }
802 #endif
803 
804 
805 inline
807 {
808  const int kLess = -1;
809  const int kEqual = 0;
810  const int kGreater = 1;
811 
812  size_type n1 = length();
813  size_type n2 = str.length();
814 
815  if ( !n1 ) {
816  return n2 ? kLess : kEqual;
817  }
818  if ( !n2 ) {
819  return kGreater;
820  }
821  int res = memcmp(data(), str.data(), min(n1, n2));
822  if ( res ) {
823  return res;
824  }
825  if (n1 < n2) {
826  return kLess;
827  }
828  if (n1 > n2) {
829  return kGreater;
830  }
831  return kEqual;
832 }
833 
834 
835 inline
837 {
838  return length() == str.length() && memcmp(data(), str.data(), length()) == 0;
839 }
840 
841 inline
843 {
844  return !(*this == str);
845 }
846 
847 inline
849 {
850  return compare(str) < 0;
851 }
852 
853 inline
855 {
856  return compare(str) > 0;
857 }
858 
859 // Global comparison operators (counterparts for CTempString::operator's).
860 
861 inline
862 bool operator==(const char* str1, const CTempString str2)
863 {
864  return str2 == CTempString(str1);
865 }
866 
867 inline
868 bool operator==(const string& str1, const CTempString str2)
869 {
870  return str2 == CTempString(str1);
871 }
872 
873 inline
874 bool operator!=(const char* str1, const CTempString str2)
875 {
876  return str2 != str1;
877 }
878 
879 inline
880 bool operator!=(const string& str1, const CTempString str2)
881 {
882  return str2 != str1;
883 }
884 
885 inline
886 bool operator<(const char* str1, const CTempString str2)
887 {
888  return str2 > str1;
889 }
890 
891 inline
892 bool operator<(const string& str1, const CTempString str2)
893 {
894  return str2 > str1;
895 }
896 
897 inline
898 bool operator>(const char* str1, const CTempString str2)
899 {
900  return str2 < str1;
901 }
902 
903 inline
904 bool operator>(const string& str1, const CTempString str2)
905 {
906  return str2 < str1;
907 }
908 
909 
911 {
912 public:
913  enum EZeroAtEnd { ///< For compatibility with older code
916  };
919  {
920  }
921  CTempStringEx(const char* str)
922  : CTempString(str),
924  {
925  }
927  : CTempString(str, len),
929  {
930  }
931  CTempStringEx(const char* str, size_type len, EZeroAtEnd zero_at_end)
932  : CTempString(str, len),
933  m_ZeroAtEnd(zero_at_end)
934  {
935  }
936  CTempStringEx(const string& str)
937  : CTempString(str.c_str(), str.size()),
939  {
940  }
941  CTempStringEx(const string& str, size_type pos, size_type len)
942  : CTempString(str, pos, len),
944  {
945  }
947  : CTempString(str),
949  {
950  }
951  #ifdef NCBI_HAVE_CXX17
952  CTempStringEx(const string_view& str_view)
953  : CTempString(str_view),
955  {
956  }
957  #endif
959  : CTempString(str, pos),
961  {
962  }
964  : CTempString(str, pos, len),
966  {
967  }
968 
969  /// Assign new values to the content of the a string
971  {
974  return *this;
975  }
977  EZeroAtEnd zero_at_end)
978  {
979  m_ZeroAtEnd = zero_at_end;
981  return *this;
982  }
984  {
987  return *this;
988  }
990  {
991  return *this = str;
992  }
994  size_type pos,
995  size_type count)
996  {
998  CTempString::assign(str, pos, count);
999  return *this;
1000  }
1001 
1002  /// Clear value to an empty string
1003  void clear(void)
1004  {
1007  }
1008 
1009  /// Obtain a substring from this string, beginning at a given offset
1011  {
1012  size_type max = size();
1013  if ( pos > max ) {
1014  pos = max;
1015  }
1016  size_type rem = max - pos;
1017  return CTempStringEx(data()+pos, rem, m_ZeroAtEnd);
1018  }
1019  /// Obtain a substring from this string, beginning at a given offset
1020  /// and extending a specified length
1022  {
1023  size_type max = size();
1024  if ( pos > max ) {
1025  pos = max;
1026  }
1027  size_type rem = max - pos;
1028  EZeroAtEnd zero_at_end = eNoZeroAtEnd;
1029  if ( len >= rem ) {
1030  len = rem;
1031  zero_at_end = m_ZeroAtEnd;
1032  }
1033  return CTempStringEx(data()+pos, len, zero_at_end);
1034  }
1035 
1036  bool HasZeroAtEnd(void) const
1037  {
1038  return m_ZeroAtEnd != eNoZeroAtEnd;
1039  }
1040 
1041 private:
1043 };
1044 
1045 
1046 /// Helper class to allocate memory for CTempString[Ex] on demand
1047 /// in the functions which need to modify the strings (e.g. NStr::Split).
1048 
1049 
1051 {
1052 public:
1054 
1055  CTempString_Storage(void);
1056  ~CTempString_Storage(void);
1057 
1058  char* Allocate(CTempString::size_type len);
1059 
1060 private:
1061  typedef char* TBuffer;
1062  typedef list<TBuffer> TData;
1063 
1065 };
1066 
1067 
1069 
1070 
1071 /* @} */
1072 
1073 #endif // CORELIB___TEMPSTR__HPP
Helper class to allocate memory for CTempString[Ex] on demand in the functions which need to modify t...
Definition: tempstr.hpp:1051
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
std::ofstream out("events_result.xml")
main entry point for tests
static const char * str(char *buf, int n)
Definition: stats.c:84
static char tmp[3200]
Definition: utf8.c:42
char data[12]
Definition: iconv.c:80
#define NCBI_DEPRECATED_CTOR(decl)
Macro used to mark a constructor as deprecated.
Definition: ncbimisc.hpp:1209
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
bool operator<(const CTempString str) const
Definition: tempstr.hpp:848
char value_type
Definition: tempstr.hpp:69
const_iterator end() const
Return an iterator to the string's ending position (one past the end of the represented sequence)
Definition: tempstr.hpp:306
EZeroAtEnd m_ZeroAtEnd
Definition: tempstr.hpp:1042
string operator+(const char *str1, const CTempString str2)
Definition: tempstr.hpp:239
CTempString literal(const char(&str)[Size])
Templatized initialization from a string literal.
Definition: tempstr.hpp:441
size_type rfind(const CTempString match, size_type pos=npos) const
Find the first instance of the entire matching string within the current string in a backward directi...
Definition: tempstr.hpp:705
CTempStringEx(void)
Definition: tempstr.hpp:917
bool operator!=(const CTempString str) const
Definition: tempstr.hpp:842
CTempStringEx substr(size_type pos, size_type len) const
Obtain a substring from this string, beginning at a given offset and extending a specified length.
Definition: tempstr.hpp:1021
CTempStringEx substr(size_type pos) const
Obtain a substring from this string, beginning at a given offset.
Definition: tempstr.hpp:1010
CTempStringEx & assign(const char *str, size_type len, EZeroAtEnd zero_at_end)
Definition: tempstr.hpp:976
CTempStringEx & assign(const CTempString &str)
Definition: tempstr.hpp:983
void x_Init(const char *str, size_type str_len, size_type pos, size_type len)
Definition: tempstr.hpp:377
CTempString & assign(const char *src_str, size_type len)
Assign new values to the content of the a string.
Definition: tempstr.hpp:733
CTempString::size_type size_type
Definition: tempstr.hpp:1053
CTempStringEx(const string &str)
Definition: tempstr.hpp:936
CTempStringEx(const CTempString &str)
Definition: tempstr.hpp:946
CTempStringEx(const char *str, size_type len)
Definition: tempstr.hpp:926
CTempStringEx(const char *str)
Definition: tempstr.hpp:921
bool operator==(const char *str1, const CTempString str2)
Definition: tempstr.hpp:862
CTempStringEx & assign(const CTempString str, size_type pos, size_type count)
Definition: tempstr.hpp:993
CTempStringEx(const CTempString &str, size_type pos)
Definition: tempstr.hpp:958
const char * m_String
Stored pointer to string.
Definition: tempstr.hpp:204
char operator[](size_type pos) const
Index into the current string and provide its character in a read- only fashion.
Definition: tempstr.hpp:341
CTempStringEx(const CTempString &str, size_type pos, size_type len)
Definition: tempstr.hpp:963
string g_CTempString_plus(const char *str1, size_t len1, const char *str2, size_t len2)
Definition: tempstr.hpp:228
const char * const_iterator
Definition: tempstr.hpp:71
CNcbiOstream & operator<<(CNcbiOstream &out, const CTempString str)
Definition: tempstr.hpp:276
const char * data(void) const
Return a pointer to the array represented.
Definition: tempstr.hpp:313
void erase(size_type pos=0)
Truncate the string at some specified position Note: basic_string<> supports additional erase() optio...
Definition: tempstr.hpp:514
bool empty(void) const
Return true if the represented string is empty (i.e., the length is zero)
Definition: tempstr.hpp:334
void clear(void)
Clear value to an empty string.
Definition: tempstr.hpp:1003
int compare(const CTempString str) const
Compare the current string with a given string.
Definition: tempstr.hpp:806
bool operator==(const CTempString str) const
Definition: tempstr.hpp:836
size_type find_last_of(const CTempString match, size_type pos=npos) const
Find the last occurrence of any character in the matching string within the current string,...
Definition: tempstr.hpp:580
void clear(void)
Clears the string.
Definition: tempstr.hpp:351
size_type m_Length
Length of string.
Definition: tempstr.hpp:205
size_t size_type
Definition: tempstr.hpp:70
CTempString(void)
Definition: tempstr.hpp:412
size_type find_last_not_of(const CTempString match, size_type pos=npos) const
Find the last occurrence of any character not in the matching string within the current string,...
Definition: tempstr.hpp:610
size_type length(void) const
Return the length of the represented array.
Definition: tempstr.hpp:320
CTempString & operator=(const CTempString str)
Definition: tempstr.hpp:769
bool operator!=(const char *str1, const CTempString str2)
Definition: tempstr.hpp:874
CTempString substr(size_type pos) const
Obtain a substring from this string, beginning at a given offset.
Definition: tempstr.hpp:776
#define NCBI_TEMPSTR_DESTROY_COPY()
Definition: tempstr.hpp:294
size_type find_first_not_of(const CTempString match, size_type pos=0) const
Find the first occurrence of any character not in the matching string within the current string,...
Definition: tempstr.hpp:553
bool HasZeroAtEnd(void) const
Definition: tempstr.hpp:1036
#define NCBI_TEMPSTR_MAKE_COPY()
Definition: tempstr.hpp:293
list< TBuffer > TData
Definition: tempstr.hpp:1062
size_type find_first_of(const CTempString match, size_type pos=0) const
Find the first occurrence of any character in the matching string within the current string,...
Definition: tempstr.hpp:538
size_type find(const CTempString match, size_type pos=0) const
Find the first instance of the entire matching string within the current string, beginning at an opti...
Definition: tempstr.hpp:655
CTempStringEx & assign(const char *str, size_type len)
Assign new values to the content of the a string.
Definition: tempstr.hpp:970
CTempStringEx(const string &str, size_type pos, size_type len)
Definition: tempstr.hpp:941
CTempStringEx & assign(const CTempStringEx &str)
Definition: tempstr.hpp:989
bool operator<(const char *str1, const CTempString str2)
Definition: tempstr.hpp:886
size_type size(void) const
Return the length of the represented array.
Definition: tempstr.hpp:327
bool operator>(const CTempString str) const
Definition: tempstr.hpp:854
void Copy(string &dst, size_type pos, size_type len) const
Copy a substring into a string Somewhat similar to basic_string::assign()
Definition: tempstr.hpp:525
static const size_type npos
Definition: tempstr.hpp:72
bool operator>(const char *str1, const CTempString str2)
Definition: tempstr.hpp:898
const_iterator begin() const
Return an iterator to the string's starting position.
Definition: tempstr.hpp:299
CTempStringEx(const char *str, size_type len, EZeroAtEnd zero_at_end)
Definition: tempstr.hpp:931
@ eNoZeroAtEnd
For compatibility with older code.
Definition: tempstr.hpp:914
#define NCBI_XNCBI_EXPORT
Definition: ncbi_export.h:1283
int i
int len
const struct ncbi::grid::netcache::search::fields::SIZE size
Defines NCBI C++ exception handling.
T max(T x_, T y_)
T min(T x_, T y_)
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
Definition: njn_matrix.hpp:613
static int match(register const pcre_uchar *eptr, register const pcre_uchar *ecode, const pcre_uchar *mstart, int offset_top, match_data *md, eptrblock *eptrb, unsigned int rdepth)
Definition: pcre_exec.c:513
Modified on Sun Apr 14 05:24:40 2024 by modify_doxy.py rev. 669887