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