casacore
String.h
Go to the documentation of this file.
1 //# String.h: String class
2 //# Copyright (C) 2001,2002,2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef CASA_STRING_H
29 #define CASA_STRING_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 
34 //# Includes
35 #include <string>
36 
37 using std::string;
38 
39 #include <casacore/casa/iosstrfwd.h>
40 #include <casacore/casa/sstream.h>
41 
42 namespace casacore { //# NAMESPACE CASACORE - BEGIN
43 
44 //# Forward Declarations
45 class String;
46 class Regex;
47 
48 // <summary> SubString help class to be used in at, before, ... </summary>
49 // <synopsis>
50 // The SubString class can only be used by the String class to be able to
51 // operate the Casacore defined replacement operators at, before, after,
52 // through, from. The class is used transparently in operations like:
53 // <srcblock>
54 // string.at(2,3) = "five";
55 // </srcblock>
56 // If the SubString starts at a position outside the length of the
57 // original string (like e.g. in after(1000000)), a zero length string is
58 // created (not an exception thrown like in standard string operations).
59 // </synopsis>
60 
61 class SubString {
62 public:
63  //# Friends
64  friend class String;
65  // Make a string
66  operator const string() const { return string(ref_p, pos_p, len_p); }
67  // Default copy constructor.
68  SubString (const SubString&) = default;
69  // Assignment
70  // <group>
72  SubString &operator=(const String &str);
73  SubString &operator=(const Char *s);
75  // </group>
76  // Get as (const) C array
77  const Char *chars() const;
78  // Obtain length
79  string::size_type length() const { return len_p; }
80 
81 private:
82  //# Constructors
83  // Constructor (there are no public constructors)
84  SubString(const string &str, string::size_type pos,
85  string::size_type len);
86  //# Data
87  // Referenced string
88  const string &ref_p;
89  // Start of sub-string
90  string::size_type pos_p;
91  // Length of sub-string
92  string::size_type len_p;
93 };
94 
95 // <summary>
96 // String: the storage and methods of handling collections of characters.
97 // </summary>
98 
99 // <use visibility=export>
100 
101 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tString.cc" demos="">
102 // </reviewed>
103 
104 // <prerequisite>
105 // <li> Regex - the regular expressions class
106 // <li> the std string class
107 // </prerequisite>
108 //
109 // <etymology>
110 // The String class name is a continuation of the "C" language custom of
111 // refering to collections of characters as "strings of characters".
112 // </etymology>
113 //
114 // <synopsis>
115 // The String class is the Casacore implementation of a string class. It is
116 // from the standard library string class, and all operations
117 // and behaviour of strings as defined in the standard are available for
118 // a String. The only difference is the extension with additional functions
119 // in the Casacore String class as compared to the standard string class.
120 //
121 // The String class may be instantiated in many ways:
122 // <ol>
123 // <li> A single character - <src>String myChar('C');</src>
124 // <li> A Char* argument - <src>String myWord("Yowza");</src>
125 // <li> The first n chararcters of a pre-existing string -
126 // <src>String myFoo("fooey", 3);</src>
127 // </ol> As well as the copy and default constructors and iterator based ones.
128 //
129 // A String may be concatinated with another object (String, or
130 // char*) with either prepending or postpending. A search for the position
131 // of a character within a String may return its position, a Bool that it
132 // is contained within or a Bool confirming your guess at the character's
133 // position is correct. A check of the frequency of occurance of a string
134 // within a String will return the number of occurances.
135 //
136 // Strings may be extracted from Strings at, before, through, from and
137 // after a starting position within the String. Deletion of characters is
138 // possible after a given position within the String. Global substitution
139 // of characters within a String is provided, as well. Splitting of Strings
140 // into a carray of Strings is possible, based upon a given separator
141 // character, with a return value of the number of elements split. The joining
142 // together of the elements of an array of Strings into one String is possible.
143 //
144 // Finally, transformations of case and conversions of type are provided.
145 //
146 // The standard string class provides the following functionality:
147 // <ol>
148 // <li> Construction from (part of) String, (part of) Char*,
149 // (repeating) Char, iterator pair.
150 // <li> Assignment from String, Char*, Char
151 // <li> Iterators: begin() and end(); rbegin() and rend() (Note: gcc reverse
152 // iterators still weak)
153 // <li> Capacity: size, length, max_size, resize, capacity, reserve, clear,
154 // empty
155 // <li> Special size: String::size_type, with indicator: String::npos
156 // <li> Element access: [pos] and at(pos) (both const and non-const)
157 // <li> Modifiers: += of String, Char*, Char; append of (part of) String,
158 // Char*, Char and iterator defined; assign() of (part of)
159 // String, Char* and (repeating) Char and iterator;
160 // insertion of same; replacing of same; erase of part of
161 // String; a copy and a swap.
162 // <li> C-string: get Char* with c_str() or data() and get the relevant
163 // Allocator used (Note: not fully supported in gcc)
164 // <li> Operations: find, rfind, find_first_of, find_last_of, find_first_not_of,
165 // find_last_not_of; substr (Note only readable substring);
166 // compare with (part of) String, Char*
167 // <li> Globals: Addition operators for String, Char*, Char; all comparison
168 // operators for String and Char*; getline; input and output
169 // stream operators
170 // <li> Typedef: All relevant typedefs for standard containers and iterator
171 // handling
172 // </ol>
173 // The Casacore additions are:
174 // <ol>
175 // <li> To standard: some Char function arguments where appropriate; Regex
176 // arguments in search like methods.
177 // <li> Substring additions: at, before, after, from, through functions taking
178 // search String, Char* as arguments can give (hidden) substrings
179 // which can be assigned (as in <src> at(1,2) = ";"</src>)
180 // <li> Methods: prepend (in addition to standard append); del (as erase);
181 // global substitution of String and patterns;
182 // freq (count of occurance); split/join of strings at separator
183 // or pattern; upcase, downcase, reverse;
184 // common_suffix and _prefix; replicate; case insensitive
185 // compare; creation from stream
186 // </ol>
187 
188 // </synopsis>
189 //
190 // <example>
191 // <srcblock>
192 // // Let's start with a simple string.
193 // String myString("the time");
194 // // add some more on the end...
195 // myString += " for all good men";
196 // // prepend some on the front...
197 // myString.prepend("Now is ");
198 // // do some concatination...
199 // String evenMore;
200 // evenMore += myString + " to come to";
201 // // do some three way concatination
202 // String allKeys, finishIt(" their country.");
203 // allKeys = evenMore + "the aid of" + finishIt;
204 // // find the spot where we put something earlier
205 // String::size_type position = allKeys.index(finishIt);
206 // // find if the word is in the String...
207 // Bool query = myString.contains("good men");
208 // // ask if the position we think is true is correct...
209 // Bool answer = allKeys.matches(finishIt, position);
210 // // How many spaces are in our phrase?
211 // Int spacesCount = allKeys.freq(" ");
212 // </srcblock>
213 // </example>
214 //
215 // <motivation>
216 // The String class eases the handling of characters within the Casacore
217 // environment.
218 // </motivation>
219 //
220 // <todo asof=2000/12/05">
221 // <li> if old string disappeared; remove the alloc() call.
222 // <li> add more tests (for string methods) when old String disappears
223 // </todo>
224 
225 class String : public string {
226 
227  public:
228 
229  //# Basic container typedefs
230  typedef string::traits_type traits_type;
231  typedef string::value_type value_type;
232  typedef string::allocator_type allocator_type;
233  typedef string::size_type size_type;
234  typedef string::difference_type difference_type;
235 
236  typedef string::reference reference;
237  typedef string::const_reference const_reference;
238  typedef string::pointer pointer;
239  typedef string::const_pointer const_pointer;
240 
241  typedef string::iterator iterator;
242  typedef string::const_iterator const_iterator;
243  typedef string::reverse_iterator reverse_iterator;
244  typedef string::const_reverse_iterator const_reverse_iterator;
245  //# Next cast necessary to stop warning in gcc
246  static const size_type npos = static_cast<size_type>(-1);
247 
248  //# Constructors
249  // Default constructor
250  String() : string("") {}
251  // Construct from std string
252  // Construct from (part of) other string: acts as copy constructor
253  // <thrown>
254  // <li> out_of_range if pos > str.size()
255  // </thrown>
256  String(const string& str, size_type pos=0, size_type n=npos) :
257  string(str, pos, n) {}
258  // Construct from char* with given length
259  // <thrown>
260  // <li> length_error if n == npos
261  // </thrown>
262  String(const Char* s, size_type n) : string(s, n) {}
263  // Construct from char array
264  String(const Char* s) : string(s) {}
265  // Construct from a single char (repeated n times)
266  // <thrown>
267  // <li> length_error if n == npos
268  // </thrown>
269  String(size_type n, Char c) : string(n, c) {}
270  // Construct from iterator
271  template<class InputIterator>
272  String(InputIterator begin, InputIterator end) : string(begin, end) {}
273  // From single char (** Casacore addition).
274  // <note role=warning> Note that there is no automatic Char-to-String
275  // conversion available. This stops inadvertent conversions of
276  // integer to string. </note>
277  explicit String(Char c) : string(1, c) {}
278  // Construct from a SubString
279  String(const SubString &str) : string(str.ref_p, str.pos_p, str.len_p) {}
280  // Construct from a stream.
281  String(ostringstream &os);
282 
283  //# Destructor
284  // Destructor
285  ~String() {}
286 
287  //# Operators
288  // Assignments (they are all deep copies according to standard)
289  // <group>
290  String& operator=(const string& str) {
291  return static_cast<String&>(string::operator=(str)); }
292  String& operator=(const SubString &str) {
293  return (*this = String(str)); }
294  String& operator=(const Char* s) {
295  return static_cast<String&>(string::operator=(s)); }
297  return static_cast<String&>(string::operator=(c)); }
298  // </group>
299  // ** Casacore addition: synonym for at(pos, len)
301  // Concatenate
302  // <group>
303  String& operator+=(const string& str) {
304  return static_cast<String&>(string::operator+=(str)); }
305  String& operator+=(const Char* s) {
306  return static_cast<String&>(string::operator+=(s)); }
308  return static_cast<String&>(string::operator+=(c)); }
309  // </group>
310 
311  // Indexing. The standard version is undefined if <src>pos > size()</src>, or
312  // <src>pos >= size()</src> for non-const version.
313  // <note role=warning> The const_reference version needs the at() version
314  // for the gcc compiler: no const [] exists. </note>
315  // <group>
317  return string::at(pos); }
319  return string::operator[](pos); }
320  // *** Casacore addition
321  // <group>
323  return string::at(pos); }
324  Char firstchar() const { return at(static_cast<size_type>(0)); }
325  Char lastchar() const { return at(length()-1); }
326  // </group>
327  // </group>
328 
329  //# Member functions
330  // Iterators
331  // <group>
332  iterator begin() { return string::begin(); }
333  const_iterator begin() const { return string::begin(); }
334  iterator end() { return string::end(); }
335  const_iterator end() const { return string::end(); }
336  reverse_iterator rbegin() { return string::rbegin(); }
337  const_reverse_iterator rbegin() const { return string::rbegin(); }
338  reverse_iterator rend() { return string::rend(); }
339  const_reverse_iterator rend() const { return string::rend(); }
340  // </group>
341 
342  // Capacity, size
343  // <group>
344  size_type size() const { return string::size(); }
345  size_type length() const { return string::length(); }
346  size_type max_size() const { return string::max_size(); }
347  size_type capacity() const { return string::capacity(); }
348  // ** Casacore addition -- works as a capacity(n) -- Note Int
349  Int allocation() const { return string::capacity(); }
350  // </group>
351 
352  // Resize by truncating or extending with copies of <src>c</src> (default
353  // Char())
354  // <thrown>
355  // <li> length_error if n > max_size()
356  // <li> length_error if res_arg > max_size()
357  // </thrown>
358  // <group>
359  // <note role=tip> The reserve length given is non-binding on the
360  // implementation </note>
362  string::resize(n); return *this; }
364  string::resize(n, c); return *this; }
365  String& reserve(size_type res_arg = 0) {
366  string::reserve(res_arg); return *this; }
367  // ** Casacore addition -- works as a resize(n)
368  void alloc(size_type n) { string::resize(n); }
369  // </group>
370 
371  // Clear the string
372  // <note role=warning> clear() executed as erase() due to missing clear() in
373  // gcc </note>
374  void clear() { string::erase(begin(), end()); }
375 
376  // Test for empty
377  Bool empty() const { return string::empty(); }
378 
379  // Addressing
380  // <thrown>
381  // <li> out_of_range if pos >= size()
382  // </thrown>
383  // <group>
384  const_reference at(size_type n) const { return string::at(n); }
385  reference at(size_type n) { return string::at(n); }
386  // </group>
387 
388  // Append
389  // <thrown>
390  // <li> out_of_range if pos > str.size()
391  // <li> length_error if new size() >= npos
392  // </thrown>
393  // <note role=warning> The standard has a
394  // <src>void push_back(const Char) </src> which is completely undefined. It
395  // probably is a remnant of the full list of container functions pop/push
396  // back/front. </note>
397  // <group>
398  String& append(const string& str) {
399  return static_cast<String&>(string::append(str)); }
400  String& append(const string& str, size_type pos, size_type n) {
401  return static_cast<String&>(string::append(str, pos, n)); }
402  String& append(const Char* s, size_type n) {
403  return static_cast<String&>(string::append(s, n)); }
404  String& append(const Char* s) {
405  return static_cast<String&>(string::append(s)); }
407  return static_cast<String&>(string::append(n, c)); }
408  template<class InputIterator>
409  String& append(InputIterator first, InputIterator last) {
410  return static_cast<String&>(string::append(first, last)); }
411  // ** Casacore addition
413  return static_cast<String&>(string::append(1, c)); }
414  // </group>
415 
416  // Assign
417  // <thrown>
418  // <li> out_of_range if pos > str.size()
419  // </thrown>
420  // <group>
421  String& assign(const string& str) {
422  return static_cast<String&>(string::assign(str)); }
423  String& assign(const string& str, size_type pos, size_type n) {
424  return static_cast<String&>(string::assign(str, pos, n)); }
425  String& assign(const Char* s, size_type n) {
426  return static_cast<String&>(string::assign(s, n)); }
427  String& assign(const Char* s) {
428  return static_cast<String&>(string::assign(s)); }
430  return static_cast<String&>(string::assign(n, c)); }
431  template<class InputIterator>
432  String& assign(InputIterator first, InputIterator last) {
433  return static_cast<String&>(string::assign(first, last)); }
434  // ** Casacore addition
436  return static_cast<String&>(string::assign(1, c)); }
437  // </group>
438 
439  // Insert
440  // <thrown>
441  // <li> out_of_range if pos1 > str.size() or pos2 > str.size()
442  // <li> length_error if new size() >= npos
443  // </thrown>
444  // <group>
445  String& insert(size_type pos1, const string& str) {
446  return static_cast<String&>(string::insert(pos1, str)); }
447  String& insert(size_type pos1, const string& str,
448  size_type pos2, size_type n) {
449  return static_cast<String&>(string::insert(pos1, str, pos2, n)); }
450  String& insert(size_type pos, const Char* s, size_type n) {
451  return static_cast<String&>(string::insert(pos, s, n)); }
452  String& insert(size_type pos, const Char* s) {
453  return static_cast<String&>(string::insert(pos, s)); }
455  return static_cast<String&>(string::insert(pos, n, c)); }
456  // ** Casacore addition
458  return static_cast<String&>(string::insert(pos, 1, c)); }
459 
461  return string::insert(p, c); }
463  string::insert(p, n, c); }
464  template<class InputIterator>
465  void insert(iterator p, InputIterator first, InputIterator last) {
466  string::insert(p, first, last); }
467  // ** Casacore additions
468  // <group>
469  String& insert(iterator p, const string& str) {
470  return static_cast<String&>(string::insert(p-begin(), str)); }
471  String& insert(iterator p, const Char* s, size_type n) {
472  return static_cast<String&>(string::insert(p-begin(), s, n)); }
473  String& insert(iterator p, const Char* s) {
474  return static_cast<String&>(string::insert(p-begin(), s)); }
475  // </group>
476  // </group>
477 
478  // Compare. Returns 0 if strings equal and of equal size; else positive if
479  // str larger or longer; else negative.
480  // <note role=warning> The gcc compiler does not have the proper standard
481  // compare functions. Hence they are locally implemented. </note>
482  // <group>
483  Int compare(const string& str) const {
484  return string::compare(str); }
485  Int compare(size_type pos1, size_type n1, const string& str) const {
486  return String(*this, pos1, n1).compare(str); }
487  Int compare(size_type pos1, size_type n1, const string& str,
488  size_type pos2, size_type n2) const {
489  return String(*this, pos1, n1).compare(String(str, pos2, n2)); }
490  Int compare(const Char* s) const {
491  return string::compare(s); }
492  Int compare(size_type pos1, size_type n1, const Char* s,
493  size_type n2=npos) const {
494  return String(*this, pos1, n1).compare(String(s, n2)); }
495  // </group>
496 
497  // Erase
498  // <group>
500  return static_cast<String&>(string::erase(pos, n)); }
501  iterator erase(iterator position) {
502  return string::erase(position); }
504  return string::erase(first, last); }
505  // </group>
506 
507  // Replace
508  // <thrown>
509  // <li> out_of_range if pos1 > str.size() or pos2 > str.size()
510  // <li> length_error if new size() > npos
511  // </thrown>
512  // <group>
513  String& replace(size_type pos1, size_type n1, const string& str) {
514  return static_cast<String&>(string::replace(pos1, n1, str)); }
515  String& replace(size_type pos1, size_type n1, const string& str,
516  size_type pos2, size_type n2) {
517  return static_cast<String&>(string::replace(pos1, n1, str, pos2, n2)); }
518  String& replace(size_type pos, size_type n1, const Char* s, size_type n2) {
519  return static_cast<String&>(string::replace(pos, n1, s, n2)); }
520  String& replace(size_type pos, size_type n1, const Char* s) {
521  return static_cast<String&>(string::replace(pos, n1, s)); }
523  return static_cast<String&>(string::replace(pos, n1, n2, c)); }
524  // ** Casacore addition
526  return static_cast<String&>(string::replace(pos, n1, 1, c)); }
527  String& replace(iterator i1, iterator i2, const string& str) {
528  return static_cast<String&>(string::replace(i1, i2, str)); }
529  String& replace(iterator i1, iterator i2, const Char* s, size_type n) {
530  return static_cast<String&>(string::replace(i1, i2, s, n)); }
531  String& replace(iterator i1, iterator i2, const Char* s) {
532  return static_cast<String&>(string::replace(i1, i2, s)); }
534  return static_cast<String&>(string::replace(i1, i2, n, c)); }
535  // ** Casacore addition
537  return static_cast<String&>(string::replace(i1, i2, 1, c)); }
538  template<class InputIterator>
539  String& replace(iterator i1, iterator i2, InputIterator j1,
540  InputIterator j2) {
541  return static_cast<String&>(string::replace(i1, i2, j1, j2)); }
542  // </group>
543 
544  // Copy
545  // <thrown>
546  // <li> out_of_range if pos > size()
547  // </thrown>
548  size_type copy(Char* s, size_type n, size_type pos = 0) const {
549  return string::copy(s, n, pos); }
550 
551  // Swap
552  void swap(string& s) { string::swap(s); }
553 
554  // Get char array
555  // <group>
556  // As a proper null terminated C-string
557  const Char *c_str() const { return string::c_str(); }
558  // As pointer to char array
559  const Char *data() const { return string::data(); }
560  // ** Casacore synonym
561  const Char *chars() const { return string::c_str(); }
562  // </group>
563 
564  // Get allocator used
565  // <note role=warning> gcc has no get_allocator() </note>
566  allocator_type get_allocator() const { return string::allocator_type(); }
567 
568  // Get a sub string
569  // <thrown>
570  // <li> out_of_range if pos > size()
571  // </thrown>
573  return String(*this, pos, n); }
574 
575  // Create a formatted string using the given printf format string.
576  static String format (const char* picture, ...);
577 
578  // Convert a String to a value. All characters in the string must be used.
579  // It uses a shift from an ostringstream, so that operator must exist
580  // for the data type used.
581  // <br>In case of an error, an exception is thrown if <src>chk</src> is set.
582  // Otherwise it returns False and <src>value</src> contains the value read
583  // so far.
584  // <group>
585  template<typename T> inline Bool fromString (T& value, Bool chk=True) const
586  {
587  std::istringstream os(*this);
588  os >> value;
589  if (os.fail() || !os.eof()) {
590  if (chk) throwFromStringError();
591  return False;
592  }
593  return True;
594  }
595  template<typename T> inline T fromString() const
596  {
597  T value;
598  fromString(value);
599  return value;
600  }
601  // </group>
602 
603  // Convert a string to an Int, Float or Double.
604  // <br>In case of an error, an exception is thrown if <src>chk</src> is set.
605  // Otherwise the value read so far is returned (0 if nothing read).
606  // <group>
607  static Int toInt (const String& s, Bool chk=False);
608  static Float toFloat (const String& s, Bool chk=False);
609  static Double toDouble (const String& s, Bool chk=False);
610  // </group>
611 
612  // Convert a value to a String.
613  // It uses a shift into an ostringstream, so that operator must be
614  // defined for the data type used.
615  template<typename T>
616  static String toString(const T& value)
617  {
618  std::ostringstream os;
619  os << value;
620  return os.str();
621  }
622 
623  // Remove beginning and ending whitespace.
624  void trim();
625 
626  // Remove specified chars from beginning and end of string.
627  void trim(char c[], uInt n);
628 
629  // Remove specified character from beginning of string.
630  // If the character is repeated more than once on the left, all instances
631  // will be removed; e.g. ltrim(',') results in ",,xy" becoming "xy".
632  void ltrim(char c);
633 
634  // Remove specified character from end of string.
635  // If the character is repeated more than once on the right, all instances
636  // will be removed; e.g. rtrim(',') results in "xy,," becoming "xy".
637  void rtrim(char c);
638 
639  // Does the string start with the specified string?
640  Bool startsWith(const string& beginString) const
641  { return find(beginString) == 0; }
642 
643  // Search functions. Returns either npos (if not found); else position.
644  // <note role=warning> The Regex ones are ** Casacore additions</note>
645  // <group>
646  size_type find(const string &str, size_type pos=0) const {
647  return string::find(str, pos); }
648  size_type find(const Char *s, size_type pos=0) const {
649  return string::find(s, pos); }
650  size_type find(const Char *s, size_type pos, size_type n) const {
651  return string::find(s, pos, n); }
652  size_type find(Char c, size_type pos=0) const {
653  return string::find(c, pos); }
654  size_type find(const Regex &r, size_type pos=0) const;
655  size_type rfind(const string &str, size_type pos=npos) const {
656  return string::rfind(str, pos); }
657  size_type rfind(const Char *s, size_type pos=npos) const {
658  return string::rfind(s, pos); }
659  size_type rfind(const Char *s, size_type pos, size_type n) const {
660  return string::rfind(s, pos, n); }
662  return string::rfind(c, pos); }
663  size_type find_first_of(const string &str, size_type pos=0) const {
664  return string::find_first_of(str, pos); }
665  size_type find_first_of(const Char *s, size_type pos=0) const {
666  return string::find_first_of(s, pos); }
667  size_type find_first_of(const Char *s, size_type pos, size_type n) const {
668  return string::find_first_of(s, pos, n); }
670  return string::find_first_of(c, pos); }
671  size_type find_last_of(const string &str, size_type pos=npos) const {
672  return string::find_last_of(str, pos); }
673  size_type find_last_of(const Char *s, size_type pos=npos) const {
674  return string::find_last_of(s, pos); }
675  size_type find_last_of(const Char *s, size_type pos, size_type n) const {
676  return string::find_last_of(s, pos, n); }
678  return string::find_last_of(c, pos); }
679  size_type find_first_not_of(const string &str, size_type pos=0) const {
680  return string::find_first_not_of(str, pos); }
681  size_type find_first_not_of(const Char *s, size_type pos=0) const {
682  return string::find_first_not_of(s, pos); }
684  return string::find_first_not_of(s, pos, n); }
686  return string::find_first_not_of(c, pos); }
687  size_type find_last_not_of(const string &str, size_type pos=npos) const {
688  return string::find_last_not_of(str, pos); }
690  return string::find_last_not_of(s, pos); }
692  return string::find_last_not_of(s, pos, n); }
694  return string::find_last_not_of(c, pos); }
695  // </group>
696 
697  // Containment. ** Casacore addition
698  // <group name=contains>
699  Bool contains(Char c) const {
700  return (find(c) != npos); }
701  Bool contains(const string &str) const {
702  return (find(str) != npos); }
703  Bool contains(const Char *s) const {
704  return (find(s) != npos); }
705  Bool contains(const Regex &r) const;
706  // </group>
707  // Does the string starting at the given position contain the given substring?
708  // If the position is negative, it is counted from the end.
709  // ** Casacore addition
710  // <group name=contains_pos>
711  Bool contains(Char c, Int pos) const;
712  Bool contains(const string &str, Int pos) const;
713  Bool contains(const Char *s, Int pos) const;
714  Bool contains(const Regex &r, Int pos) const;
715  // </group>
716 
717  // Matches entire string from pos
718  // (or till pos if negative pos). ** Casacore addition
719  // <group name=matches>
720  Bool matches(const string &str, Int pos = 0) const;
721  Bool matches(Char c, Int pos = 0) const {
722  return matches(String(c), pos); };
723  Bool matches(const Char *s, Int pos = 0) const {
724  return matches(String(s), pos); };
725  Bool matches(const Regex &r, Int pos = 0) const;
726  // </group>
727 
728  // Concatenate by prepending the argument onto String. ** Casacore addition
729  // <group name=concatenation_method>
730  void prepend(const string &str);
731  void prepend(const Char *s);
732  void prepend(Char c);
733  // </group>
734 
735  // Return the position of the target in the string or npos for failure.
736  // ** Casacore addition
737  // <group name=index>
738  size_type index(Char c, Int startpos = 0) const {
739  return ((startpos >= 0) ? find(c, startpos) :
740  rfind(c, length() + startpos - 1)); }
741  size_type index(const string &str, Int startpos = 0) const {
742  return ((startpos >= 0) ? find(str, startpos) :
743  rfind(str, length() + startpos - str.length())); }
744  size_type index(const Char *s, Int startpos = 0) const {
745  return ((startpos >= 0) ? find(s, startpos) :
746  rfind(s, length() + startpos - traits_type::length(s))); }
747  size_type index(const Regex &r, Int startpos = 0) const;
748  // </group>
749 
750  // Return the number of occurences of target in String. ** Casacore addition
751  // <group name=freq>
752  Int freq(Char c) const;
753  Int freq(const string &str) const;
754  Int freq(const Char *s) const;
755  // </group>
756 
757  // Extract the string "at" the argument's position. ** Casacore addition
758  // <group name=at>
759  SubString at(size_type pos, size_type len);
760  String at(size_type pos, size_type len) const {
761  return String(*this, pos, len); }
762  SubString at(const string &str, Int startpos = 0);
763  String at(const string &str, Int startpos = 0) const;
764  SubString at(const Char *s, Int startpos = 0);
765  String at(const Char *s, Int startpos = 0) const;
766  SubString at(Char c, Int startpos = 0);
767  String at(Char c, Int startpos = 0) const;
768  SubString at(const Regex &r, Int startpos = 0);
769  String at(const Regex &r, Int startpos = 0) const;
770  // Next ones for overloading reasons.
771  // <note role=tip> It is better to use the <src>substr()</src> method
772  // in stead. </note>
773  // <group>
774  SubString at(Int pos, Int len) {
775  return at(static_cast<size_type>(pos), static_cast<size_type>(len));
776  };
777  String at(Int pos, Int len) const {
778  return at(static_cast<size_type>(pos), static_cast<size_type>(len));
779  };
780  SubString at(Int pos, size_type len) {
781  return at(static_cast<size_type>(pos), len);
782  };
783  String at(Int pos, size_type len) const {
784  return at(static_cast<size_type>(pos), len);
785  };
786  // </group>
787  // </group>
788 
789  // Start at startpos and extract the string "before" the argument's
790  // position, exclusive. ** Casacore addition
791  // <group name=before>
792  SubString before(size_type pos) const;
793  SubString before(const string &str, size_type startpos = 0) const;
794  SubString before(const Char *s, size_type startpos = 0) const;
795  SubString before(Char c, size_type startpos = 0) const;
796  SubString before(const Regex &r, size_type startpos = 0) const;
797  // Next one for overloading reasons
798  SubString before(Int pos) const {
799  return before(static_cast<size_type>(pos)); };
800  // </group>
801 
802  // Start at startpos and extract the SubString "through" to the argument's
803  // position, inclusive. ** Casacore addition
804  // <group name=through>
806  SubString through(const string &str, size_type startpos = 0);
807  SubString through(const Char *s, size_type startpos = 0);
808  SubString through(Char c, size_type startpos = 0);
809  SubString through(const Regex &r, size_type startpos = 0);
810  // Next one for overloading reasons
811  SubString through(Int pos) {
812  return through(static_cast<size_type>(pos)); }
813  // </group>
814 
815  // Start at startpos and extract the SubString "from" the argument's
816  // position, inclusive, to the String's end. ** Casacore addition
817  // <group name=from>
818  SubString from(size_type pos);
819  SubString from(const string &str, size_type startpos = 0);
820  SubString from(const Char *s, size_type startpos = 0);
821  SubString from(Char c, size_type startpos = 0);
822  SubString from(const Regex &r, size_type startpos = 0);
823  // Next one for overloading reasons
824  SubString from(Int pos) {
825  return from(static_cast<size_type>(pos));
826  };
827  // </group>
828 
829  // Start at startpos and extract the SubString "after" the argument's
830  // position, exclusive, to the String's end. ** Casacore addition
831  // <group name=after>
833  SubString after(const string &str, size_type startpos = 0);
834  SubString after(const Char *s, size_type startpos = 0);
835  SubString after(Char c, size_type startpos = 0);
836  SubString after(const Regex &r, size_type startpos = 0);
837  // Next one for overloading reasons
838  SubString after(Int pos) {
839  return after(static_cast<size_type>(pos));
840  };
841  // </group>
842 
843  // Maybe forget some. ** Casacore addition
844  // <group>
845  // internal transformation to reverse order of String.
846  void reverse();
847  // internal transformation to capitalization of String.
848  void capitalize();
849  // internal transformation to uppercase of String
850  void upcase();
851  // internal transformation to lowercase of String
852  void downcase();
853  // </group>
854 
855  // Delete len chars starting at pos. ** Casacore addition
856  void del(size_type pos, size_type len);
857 
858  // Delete the first occurrence of target after startpos. ** Casacore addition
859  //<group name=del_after>
860  void del(const string &str, size_type startpos = 0);
861  void del(const Char *s, size_type startpos = 0);
862  void del(Char c, size_type startpos = 0);
863  void del(const Regex &r, size_type startpos = 0);
864  // Overload problem
865  void del(Int pos, Int len) {
866  del(static_cast<size_type>(pos), static_cast<size_type>(len)); }
867  //</group>
868 
869  // Global substitution: substitute all occurrences of pat with repl, and
870  // return the number of replacements.
871  // ** Casacore addition
872  //<group name=gsub>
873  Int gsub(const string &pat, const string &repl);
874  Int gsub(const Char *pat, const string &repl);
875  Int gsub(const Char *pat, const Char *repl);
876  Int gsub(const Regex &pat, const string &repl);
877  //</group>
878 
879 private:
880  // Helper functions for at, before etc
881  // <group>
883  return SubString(*this, first, l); }
884  // </group>
885 
886  // Helper function for fromString.
887  void throwFromStringError() const;
888 };
889 
890 // <summary>
891 // Global concatenation operators
892 // </summary>
893 
894 // The global concatenation operators
895 // <group name=concatenator>
896 inline String operator+(const String &lhs, const String &rhs) {
897  String str(lhs); str.append(rhs); return str; }
898 inline String operator+(const Char *lhs, const String &rhs) {
899  String str(lhs); str.append(rhs); return str; }
900 inline String operator+(Char lhs, const String &rhs) {
901  String str(lhs); str.append(rhs); return str; }
902 inline String operator+(const String &lhs, const Char *rhs) {
903  String str(lhs); str.append(rhs); return str; }
904 inline String operator+(const String &lhs, Char rhs) {
905  String str(lhs); str.append(rhs); return str; }
906 // </group>
907 
908 // <summary>
909 // Global comparison operators
910 // </summary>
911 
912 // The global comparison operators
913 // <group name=comparitor>
914 inline Bool operator==(const String &x, const String &y) {
915  return x.compare(y) == 0; }
916 inline Bool operator!=(const String &x, const String &y) {
917  return x.compare(y) != 0; }
918 inline Bool operator>(const String &x, const String &y) {
919  return x.compare(y) > 0; }
920 inline Bool operator>=(const String &x, const String &y) {
921  return x.compare(y) >= 0; }
922 inline Bool operator<(const String &x, const String &y) {
923  return x.compare(y) < 0; }
924 inline Bool operator<=(const String &x, const String &y) {
925  return x.compare(y) <= 0; }
926 inline Bool operator==(const String &x, const Char *t) {
927  return x.compare(t) == 0; }
928 inline Bool operator!=(const String &x, const Char *t) {
929  return x.compare(t) != 0; }
930 inline Bool operator>(const String &x, const Char *t) {
931  return x.compare(t) > 0; }
932 inline Bool operator>=(const String &x, const Char *t) {
933  return x.compare(t) >= 0; }
934 inline Bool operator<(const String &x, const Char *t) {
935  return x.compare(t) < 0; }
936 inline Bool operator<=(const String &x, const Char *t) {
937  return x.compare(t) <= 0; }
938 inline Bool operator==(const String &x, const Char t) {
939  return x.compare(String(t)) == 0; }
940 inline Bool operator!=(const String &x, const Char t) {
941  return x.compare(String(t)) != 0; }
942 inline Bool operator>(const String &x, const Char t) {
943  return x.compare(String(t)) > 0; }
944 inline Bool operator>=(const String &x, const Char t) {
945  return x.compare(String(t)) >= 0; }
946 inline Bool operator<(const String &x, const Char t) {
947  return x.compare(String(t)) < 0; }
948 inline Bool operator<=(const String &x, const Char t) {
949  return x.compare(String(t)) <= 0; }
950 // ** Casacore additions of global compares. Returns 0 if equal; lt or gt 0 if
951 // strings unequal or of unequal lengths.
952 // <group>
953 inline Int compare(const string &x, const string &y) {
954  return x.compare(y); }
955 inline Int compare(const string &x, const Char *y) {
956  return x.compare(y); }
957 inline Int compare(const string &x, const Char y) {
958  return x.compare(String(y)); }
959 // this version ignores case. ** Casacore addition. Result is 0 if equal
960 // strings of equal lengths; else lt or gt 0 to indicate differences.
961 Int fcompare(const String& x, const String& y);
962 // </group>
963 // </group>
964 
965 // <summary> Splitting </summary>
966 // Global function which splits the String into string array res at separator
967 // and returns the number of elements. ** Casacore addition
968 // <group name=split>
969 Int split(const string &str, string res[], Int maxn,
970  const string &sep);
971 Int split(const string &str, string res[], Int maxn,
972  const Char sep);
973 Int split(const string &str, string res[], Int maxn,
974  const Regex &sep);
975 //</group>
976 
977 // <summary> Some general functions </summary>
978 // Functions to find special patterns, join and replicate
979 // <group name=common>
980 String common_prefix(const string &x, const string &y,
981  Int startpos = 0);
982 String common_suffix(const string &x, const string &y,
983  Int startpos = -1);
984 String replicate(Char c, String::size_type n);
985 String replicate(const string &str, String::size_type n);
986 String join(string src[], Int n, const string &sep);
987 // </group>
988 
989 // <summary> Casing and related functions </summary>
990 // Case conversion and rearrangement functions
991 // <group name=case>
992 // Global function which returns a transformation to reverse order of String.
993 String reverse(const string& str);
994 // Global function which returns a transformation to uppercase of String.
995 String upcase(const string& str);
996 // Global function which returns a transformation to lowercase of String.
997 String downcase(const string& str);
998 // Global function which returns a transformation to capitalization of
999 // String.
1000 String capitalize(const string& str);
1001 // Global function which removes leading and trailing whitespace.
1002 String trim(const string& str);
1003 // </group>
1005 // <summary> IO </summary>
1006 // <group name=io>
1007 // Output
1008 ostream &operator<<(ostream &s, const String &x);
1009 // </group>
1010 
1011 //# Inlines
1012 inline SubString::SubString(const string &str, string::size_type pos,
1013  string::size_type len) :
1014  ref_p(str), pos_p((pos > str.length()) ? str.length() : pos),
1015  len_p((len == string::npos || pos_p+len > str.length()) ?
1016  str.length()-pos_p : len) {}
1017 
1018 inline SubString String::operator()(size_type pos, size_type len) {
1019  return at(pos, len); }
1020 inline const Char *SubString::chars() const {
1021  return String(*this).c_str(); }
1023 inline Bool String::contains(Char c, Int pos) const {
1024  return (index(c, pos) != npos); }
1025 inline Bool String::contains(const string &str, Int pos) const {
1026  return (index(str, pos) != npos); }
1027 inline Bool String::contains(const Char *s, Int pos) const {
1028  return (index(s, pos) != npos); }
1029 inline Bool String::contains(const Regex &r, Int pos) const {
1030  return (index(r, pos) != npos); }
1031 
1032 inline ostream &operator<<(ostream &s, const String &x) {
1033  s << x.c_str(); return s; }
1034 
1035 
1036 } //# NAMESPACE CASACORE - END
1037 
1038 #endif
String: the storage and methods of handling collections of characters.
Definition: String.h:225
static String format(const char *picture,...)
Create a formatted string using the given printf format string.
iterator end()
Definition: String.h:334
String & operator+=(Char c)
Definition: String.h:307
size_type max_size() const
Definition: String.h:346
Bool matches(const string &str, Int pos=0) const
Matches entire string from pos (or till pos if negative pos).
void del(const Char *s, size_type startpos=0)
Int compare(size_type pos1, size_type n1, const string &str, size_type pos2, size_type n2) const
Definition: String.h:487
SubString at(Int pos, Int len)
Next ones for overloading reasons.
Definition: String.h:775
static Float toFloat(const String &s, Bool chk=False)
iterator begin()
Iterators.
Definition: String.h:332
SubString from(Int pos)
Next one for overloading reasons.
Definition: String.h:825
Char firstchar() const
Definition: String.h:324
SubString from(const string &str, size_type startpos=0)
Char lastchar() const
Definition: String.h:325
void swap(string &s)
Swap.
Definition: String.h:552
iterator erase(iterator first, iterator last)
Definition: String.h:503
String & append(const Char *s)
Definition: String.h:404
String & replace(size_type pos, size_type n1, const Char *s)
Definition: String.h:520
String & insert(size_type pos1, const string &str)
Insert.
Definition: String.h:445
String(const Char *s, size_type n)
Construct from char* with given length.
Definition: String.h:262
String & assign(const string &str)
Assign.
Definition: String.h:421
size_type find_first_of(const Char *s, size_type pos=0) const
Definition: String.h:665
void downcase()
internal transformation to lowercase of String
String & insert(size_type pos, Char c)
** Casacore addition
Definition: String.h:457
string::const_reverse_iterator const_reverse_iterator
Definition: String.h:244
size_type rfind(const Char *s, size_type pos, size_type n) const
Definition: String.h:659
String & assign(const string &str, size_type pos, size_type n)
Definition: String.h:423
String & replace(iterator i1, iterator i2, size_type n, Char c)
Definition: String.h:533
size_type find_last_of(Char c, size_type pos=npos) const
Definition: String.h:677
static String toString(const T &value)
Convert a value to a String.
Definition: String.h:616
size_type find(const Regex &r, size_type pos=0) const
size_type find(const string &str, size_type pos=0) const
Search functions.
Definition: String.h:646
size_type find_last_not_of(Char c, size_type pos=npos) const
Definition: String.h:693
SubString through(Int pos)
Next one for overloading reasons.
Definition: String.h:812
String & append(size_type n, Char c)
Definition: String.h:406
static const size_type npos
Definition: String.h:246
size_type find_first_of(const string &str, size_type pos=0) const
Definition: String.h:663
string::const_reference const_reference
Definition: String.h:237
SubString before(const Char *s, size_type startpos=0) const
size_type find_last_of(const Char *s, size_type pos=npos) const
Definition: String.h:673
const Char * c_str() const
Get char array.
Definition: String.h:557
String at(const string &str, Int startpos=0) const
SubString after(Int pos)
Next one for overloading reasons.
Definition: String.h:839
string::allocator_type allocator_type
Definition: String.h:232
String(const Char *s)
Construct from char array.
Definition: String.h:264
String & replace(size_type pos1, size_type n1, const string &str, size_type pos2, size_type n2)
Definition: String.h:515
Int freq(Char c) const
Return the number of occurences of target in String.
string::difference_type difference_type
Definition: String.h:234
size_type find_last_not_of(const Char *s, size_type pos=npos) const
Definition: String.h:689
const_reverse_iterator rbegin() const
Definition: String.h:337
void rtrim(char c)
Remove specified character from end of string.
const_reference operator[](size_type pos) const
Indexing.
Definition: String.h:316
Bool matches(const Char *s, Int pos=0) const
Definition: String.h:725
String & replace(size_type pos1, size_type n1, const string &str)
Replace.
Definition: String.h:513
String & insert(size_type pos, const Char *s)
Definition: String.h:452
string::value_type value_type
Definition: String.h:231
void trim(char c[], uInt n)
Remove specified chars from beginning and end of string.
SubString from(const Char *s, size_type startpos=0)
String & append(const string &str, size_type pos, size_type n)
Definition: String.h:400
String & replace(size_type pos, size_type n1, const Char *s, size_type n2)
Definition: String.h:518
reference at(size_type n)
Definition: String.h:385
SubString after(const string &str, size_type startpos=0)
void capitalize()
internal transformation to capitalization of String.
reverse_iterator rbegin()
Definition: String.h:336
string::reference reference
Definition: String.h:236
const_reference elem(size_type pos) const
*** Casacore addition
Definition: String.h:322
~String()
Destructor.
Definition: String.h:285
SubString through(Char c, size_type startpos=0)
Bool fromString(T &value, Bool chk=True) const
Convert a String to a value.
Definition: String.h:585
String substr(size_type pos=0, size_type n=npos) const
Get a sub string.
Definition: String.h:572
Int compare(size_type pos1, size_type n1, const string &str) const
Definition: String.h:485
size_type find_first_not_of(const Char *s, size_type pos=0) const
Definition: String.h:681
String & insert(iterator p, const Char *s, size_type n)
Definition: String.h:471
SubString before(Char c, size_type startpos=0) const
size_type capacity() const
Definition: String.h:347
String & assign(size_type n, Char c)
Definition: String.h:429
String(Char c)
From single char (** Casacore addition).
Definition: String.h:277
SubString through(const Char *s, size_type startpos=0)
allocator_type get_allocator() const
Get allocator used Warning: gcc has no get_allocator()
Definition: String.h:566
void ltrim(char c)
Remove specified character from beginning of string.
String & replace(iterator i1, iterator i2, const Char *s)
Definition: String.h:531
string::const_iterator const_iterator
Definition: String.h:242
String & operator=(const Char *s)
Definition: String.h:294
Int gsub(const Char *pat, const string &repl)
size_type find_first_not_of(const string &str, size_type pos=0) const
Definition: String.h:679
void insert(iterator p, InputIterator first, InputIterator last)
Definition: String.h:465
void clear()
Clear the string Warning: clear() executed as erase() due to missing clear() in gcc
Definition: String.h:374
Int allocation() const
** Casacore addition – works as a capacity(n) – Note Int
Definition: String.h:349
String & assign(const Char *s)
Definition: String.h:427
String & insert(size_type pos, size_type n, Char c)
Definition: String.h:454
iterator erase(iterator position)
Definition: String.h:501
size_type find_last_not_of(const Char *s, size_type pos, size_type n) const
Definition: String.h:691
size_type find_last_not_of(const string &str, size_type pos=npos) const
Definition: String.h:687
void del(Char c, size_type startpos=0)
String & operator=(Char c)
Definition: String.h:296
string::const_pointer const_pointer
Definition: String.h:239
String(ostringstream &os)
Construct from a stream.
String(const SubString &str)
Construct from a SubString.
Definition: String.h:279
string::reverse_iterator reverse_iterator
Definition: String.h:243
size_type copy(Char *s, size_type n, size_type pos=0) const
Copy.
Definition: String.h:548
SubString at(Int pos, size_type len)
Definition: String.h:781
void del(const string &str, size_type startpos=0)
Delete the first occurrence of target after startpos.
SubString through(size_type pos)
Start at startpos and extract the SubString "through" to the argument's position, inclusive.
const_iterator begin() const
Definition: String.h:333
String(size_type n, Char c)
Construct from a single char (repeated n times)
Definition: String.h:269
size_type find_last_of(const string &str, size_type pos=npos) const
Definition: String.h:671
String & reserve(size_type res_arg=0)
Definition: String.h:365
String & operator+=(const string &str)
Concatenate.
Definition: String.h:303
String & append(const string &str)
Append.
Definition: String.h:398
size_type find(Char c, size_type pos=0) const
Definition: String.h:652
void del(Int pos, Int len)
Overload problem.
Definition: String.h:866
String at(Int pos, size_type len) const
Definition: String.h:784
void insert(iterator p, size_type n, Char c)
Definition: String.h:462
const_reverse_iterator rend() const
Definition: String.h:339
SubString operator()(size_type pos, size_type len)
Casacore addition: synonym for at(pos, len)
Definition: String.h:1020
size_type length() const
Definition: String.h:345
String & assign(Char c)
** Casacore addition
Definition: String.h:435
String(const string &str, size_type pos=0, size_type n=npos)
Construct from std string Construct from (part of) other string: acts as copy constructor.
Definition: String.h:256
const Char * data() const
As pointer to char array
Definition: String.h:559
String at(Int pos, Int len) const
Definition: String.h:778
Bool startsWith(const string &beginString) const
Does the string start with the specified string?
Definition: String.h:640
void trim()
Remove beginning and ending whitespace.
SubString at(const Char *s, Int startpos=0)
size_type rfind(const string &str, size_type pos=npos) const
Definition: String.h:655
SubString after(const Char *s, size_type startpos=0)
size_type find(const Char *s, size_type pos, size_type n) const
Definition: String.h:650
String & replace(iterator i1, iterator i2, const string &str)
Definition: String.h:527
const Char * chars() const
** Casacore synonym
Definition: String.h:561
SubString at(Char c, Int startpos=0)
SubString from(size_type pos)
Start at startpos and extract the SubString "from" the argument's position, inclusive,...
String & insert(iterator p, const Char *s)
Definition: String.h:473
String & append(const Char *s, size_type n)
Definition: String.h:402
SubString before(Int pos) const
Next one for overloading reasons.
Definition: String.h:799
void del(size_type pos, size_type len)
Delete len chars starting at pos.
Bool empty() const
Test for empty.
Definition: String.h:377
String & operator+=(const Char *s)
Definition: String.h:305
Bool contains(Char c) const
Containment.
Definition: String.h:700
string::size_type size_type
Definition: String.h:233
size_type index(Char c, Int startpos=0) const
Return the position of the target in the string or npos for failure.
Definition: String.h:740
void alloc(size_type n)
** Casacore addition – works as a resize(n)
Definition: String.h:368
static Int toInt(const String &s, Bool chk=False)
Convert a string to an Int, Float or Double.
String & replace(size_type pos, size_type n1, Char c)
** Casacore addition
Definition: String.h:525
size_type find_first_not_of(Char c, size_type pos=0) const
Definition: String.h:685
String at(size_type pos, size_type len) const
Definition: String.h:762
SubString before(size_type pos) const
Start at startpos and extract the string "before" the argument's position, exclusive.
String & insert(size_type pos, const Char *s, size_type n)
Definition: String.h:450
void reverse()
Maybe forget some.
string::pointer pointer
Definition: String.h:238
SubString at(const string &str, Int startpos=0)
SubString _substr(size_type first, size_type l) const
Helper functions for at, before etc.
Definition: String.h:882
size_type find_first_of(const Char *s, size_type pos, size_type n) const
Definition: String.h:667
size_type rfind(const Char *s, size_type pos=npos) const
Definition: String.h:657
String & assign(const Char *s, size_type n)
Definition: String.h:425
Int compare(const string &str) const
Compare.
Definition: String.h:483
size_type find_first_not_of(const Char *s, size_type pos, size_type n) const
Definition: String.h:683
String & assign(InputIterator first, InputIterator last)
Definition: String.h:432
void throwFromStringError() const
Helper function for fromString.
String & operator=(const SubString &str)
Definition: String.h:292
Int compare(const Char *s) const
Definition: String.h:490
SubString after(Char c, size_type startpos=0)
string::traits_type traits_type
Definition: String.h:230
size_type size() const
Capacity, size.
Definition: String.h:344
size_type find(const Char *s, size_type pos=0) const
Definition: String.h:648
String & resize(size_type n, Char c)
Definition: String.h:363
String & replace(iterator i1, iterator i2, const Char *s, size_type n)
Definition: String.h:529
String & operator=(const string &str)
Assignments (they are all deep copies according to standard)
Definition: String.h:290
String & append(Char c)
** Casacore addition
Definition: String.h:412
String at(const Char *s, Int startpos=0) const
string::iterator iterator
Definition: String.h:241
size_type rfind(Char c, size_type pos=npos) const
Definition: String.h:661
reference operator[](size_type pos)
Definition: String.h:318
size_type find_first_of(Char c, size_type pos=0) const
Definition: String.h:669
Int compare(size_type pos1, size_type n1, const Char *s, size_type n2=npos) const
Definition: String.h:492
void prepend(const string &str)
Concatenate by prepending the argument onto String.
reverse_iterator rend()
Definition: String.h:338
static Double toDouble(const String &s, Bool chk=False)
String(InputIterator begin, InputIterator end)
Construct from iterator.
Definition: String.h:272
String & insert(size_type pos1, const string &str, size_type pos2, size_type n)
Definition: String.h:447
Int gsub(const string &pat, const string &repl)
Global substitution: substitute all occurrences of pat with repl, and return the number of replacemen...
String()
Default constructor.
Definition: String.h:250
size_type find_last_of(const Char *s, size_type pos, size_type n) const
Definition: String.h:675
String & append(InputIterator first, InputIterator last)
Definition: String.h:409
const_reference at(size_type n) const
Addressing.
Definition: String.h:384
SubString through(const string &str, size_type startpos=0)
SubString before(const string &str, size_type startpos=0) const
String & replace(iterator i1, iterator i2, Char c)
** Casacore addition
Definition: String.h:536
String & replace(size_type pos, size_type n1, size_type n2, Char c)
Definition: String.h:522
String & erase(size_type pos, size_type n=npos)
Erase.
Definition: String.h:499
Bool matches(Char c, Int pos=0) const
Definition: String.h:723
iterator insert(iterator p, Char c)
Definition: String.h:460
String & replace(iterator i1, iterator i2, InputIterator j1, InputIterator j2)
Definition: String.h:539
SubString from(Char c, size_type startpos=0)
SubString after(size_type pos)
Start at startpos and extract the SubString "after" the argument's position, exclusive,...
String & resize(size_type n)
Resize by truncating or extending with copies of c (default Char())
Definition: String.h:361
void upcase()
internal transformation to uppercase of String
Int gsub(const Char *pat, const Char *repl)
String & insert(iterator p, const string &str)
** Casacore additions
Definition: String.h:469
T fromString() const
Definition: String.h:595
const_iterator end() const
Definition: String.h:335
String at(Char c, Int startpos=0) const
const string & ref_p
Referenced string.
Definition: String.h:88
SubString & operator=(const String &str)
SubString(const SubString &)=default
Default copy constructor.
friend class String
Definition: String.h:64
string::size_type length() const
Obtain length.
Definition: String.h:79
SubString & operator=(const SubString &str)
Assignment.
string::size_type pos_p
Start of sub-string.
Definition: String.h:90
SubString & operator=(const Char *s)
const Char * chars() const
Get as (const) C array.
Definition: String.h:1022
string::size_type len_p
Length of sub-string.
Definition: String.h:92
SubString & operator=(const Char c)
struct Node * first
Definition: malloc.h:330
const Double c
Fundamental physical constants (SI units):
this file contains all the compiler specific defines
Definition: mainpage.dox:28
Vector< String > & split(const String &s, char delim, Vector< String > &elems)
const Bool False
Definition: aipstype.h:44
StatsData< AccumType > copy(const StatsData< AccumType > &stats)
LatticeExprNode operator>(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode replace(const LatticeExprNode &arg1, const LatticeExprNode &arg2)
This function replaces every masked-off element in the first argument with the corresponding element ...
TableExprNode upcase(const TableExprNode &node)
Definition: ExprNode.h:1468
LatticeExprNode operator+(const LatticeExprNode &expr)
Global functions operating on a LatticeExprNode.
unsigned int uInt
Definition: aipstype.h:51
PtrHolder< T > & operator=(const PtrHolder< T > &other)
bool operator==(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
Definition: Allocator.h:129
bool operator!=(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
Definition: Allocator.h:135
TableExprNode capitalize(const TableExprNode &node)
Definition: ExprNode.h:1478
TableExprNode downcase(const TableExprNode &node)
Definition: ExprNode.h:1473
float Float
Definition: aipstype.h:54
LatticeExprNode operator<(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
LatticeExprNode operator>=(const LatticeExprNode &left, const LatticeExprNode &right)
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
ostream & operator<<(ostream &os, const IComplex &)
Show on ostream.
TableExprNode trim(const TableExprNode &node)
Definition: ExprNode.h:1584
const Bool True
Definition: aipstype.h:43
double Double
Definition: aipstype.h:55
void swap(Array< T, Alloc > &first, Array< T, Alloc > &second)
Swap the first array with the second.
Definition: Array.h:1005
LatticeExprNode operator<=(const LatticeExprNode &left, const LatticeExprNode &right)
char Char
Definition: aipstype.h:46
Int compare(const string &x, const string &y)
** Casacore additions of global compares.
Definition: String.h:953
Int fcompare(const String &x, const String &y)
this version ignores case.
Int compare(const string &x, const Char y)
Definition: String.h:957
Int compare(const string &x, const Char *y)
Definition: String.h:955
Int split(const string &str, string res[], Int maxn, const string &sep)
Int split(const string &str, string res[], Int maxn, const Char sep)