casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
40 #include <casacore/casa/sstream.h>
41 
42 namespace casacore { //# NAMESPACE CASACORE - BEGIN
43 
44 //# Forward Declarations
45 class String;
46 class RegexBase;
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>
69  SubString &operator=(const SubString &str);
70  SubString &operator=(const String &str);
71  SubString &operator=(const Char *s);
72  SubString &operator=(const Char c);
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> RegexBase - 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; RegexBase
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 
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;
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 RegexBase 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 RegexBase &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 rfind(const RegexBase &r, size_type pos=npos) const;
662  size_type find_first_of(const string &str, size_type pos=0) const {
663  return string::find_first_of(str, pos); }
664  size_type find_first_of(const Char *s, size_type pos=0) const {
665  return string::find_first_of(s, pos); }
666  size_type find_first_of(const Char *s, size_type pos, size_type n) const {
667  return string::find_first_of(s, pos, n); }
669  return string::find_first_of(c, pos); }
670  size_type find_last_of(const string &str, size_type pos=npos) const {
671  return string::find_last_of(str, pos); }
672  size_type find_last_of(const Char *s, size_type pos=npos) const {
673  return string::find_last_of(s, pos); }
674  size_type find_last_of(const Char *s, size_type pos, size_type n) const {
675  return string::find_last_of(s, pos, n); }
677  return string::find_last_of(c, pos); }
678  size_type find_first_not_of(const string &str, size_type pos=0) const {
679  return string::find_first_not_of(str, pos); }
680  size_type find_first_not_of(const Char *s, size_type pos=0) const {
681  return string::find_first_not_of(s, pos); }
683  return string::find_first_not_of(s, pos, n); }
685  return string::find_first_not_of(c, pos); }
686  size_type find_last_not_of(const string &str, size_type pos=npos) const {
687  return string::find_last_not_of(str, pos); }
689  return string::find_last_not_of(s, pos); }
691  return string::find_last_not_of(s, pos, n); }
693  return string::find_last_not_of(c, pos); }
694  // </group>
695 
696  // Containment. ** Casacore addition
697  // <group name=contains>
698  Bool contains(Char c) const {
699  return (find(c) != npos); }
700  Bool contains(const string &str) const {
701  return (find(str) != npos); }
702  Bool contains(const Char *s) const {
703  return (find(s) != npos); }
704  Bool contains(const RegexBase &r) const;
705  // </group>
706  // Does the string starting at the given position contain the given substring?
707  // If the position is negative, it is counted from the end.
708  // ** Casacore addition
709  // <group name=contains_pos>
710  Bool contains(Char c, Int pos) const;
711  Bool contains(const string &str, Int pos) const;
712  Bool contains(const Char *s, Int pos) const;
713  Bool contains(const RegexBase &r, Int pos) const;
714  // </group>
715 
716  // Matches entire string from pos
717  // (or till pos if negative pos). ** Casacore addition
718  // <group name=matches>
719  Bool matches(const string &str, Int pos = 0) const;
720  Bool matches(Char c, Int pos = 0) const {
721  return matches(String(c), pos); };
722  Bool matches(const Char *s, Int pos = 0) const {
723  return matches(String(s), pos); };
724  Bool matches(const RegexBase &r, Int pos = 0) const;
725  // </group>
726 
727  // Concatenate by prepending the argument onto String. ** Casacore addition
728  // <group name=concatenation_method>
729  void prepend(const string &str);
730  void prepend(const Char *s);
731  void prepend(Char c);
732  // </group>
733 
734  // Return the position of the target in the string or npos for failure.
735  // ** Casacore addition
736  // <group name=index>
737  size_type index(Char c, Int startpos = 0) const {
738  return ((startpos >= 0) ? find(c, startpos) :
739  rfind(c, length() + startpos - 1)); }
740  size_type index(const string &str, Int startpos = 0) const {
741  return ((startpos >= 0) ? find(str, startpos) :
742  rfind(str, length() + startpos - str.length())); }
743  size_type index(const Char *s, Int startpos = 0) const {
744  return ((startpos >= 0) ? find(s, startpos) :
745  rfind(s, length() + startpos - traits_type::length(s))); }
746  size_type index(const RegexBase &r, Int startpos = 0) const;
747  // </group>
748 
749  // Return the number of occurences of target in String. ** Casacore addition
750  // <group name=freq>
751  Int freq(Char c) const;
752  Int freq(const string &str) const;
753  Int freq(const Char *s) const;
754  // </group>
755 
756  // Extract the string "at" the argument's position. ** Casacore addition
757  // <group name=at>
758  SubString at(size_type pos, size_type len);
759  String at(size_type pos, size_type len) const {
760  return String(*this, pos, len); }
761  SubString at(const string &str, Int startpos = 0);
762  String at(const string &str, Int startpos = 0) const;
763  SubString at(const Char *s, Int startpos = 0);
764  String at(const Char *s, Int startpos = 0) const;
765  SubString at(Char c, Int startpos = 0);
766  String at(Char c, Int startpos = 0) const;
767  SubString at(const RegexBase &r, Int startpos = 0);
768  String at(const RegexBase &r, Int startpos = 0) const;
769  // Next ones for overloading reasons.
770  // <note role=tip> It is better to use the <src>substr()</src> method
771  // in stead. </note>
772  // <group>
773  SubString at(Int pos, Int len) {
774  return at(static_cast<size_type>(pos), static_cast<size_type>(len));
775  };
776  String at(Int pos, Int len) const {
777  return at(static_cast<size_type>(pos), static_cast<size_type>(len));
778  };
779  SubString at(Int pos, size_type len) {
780  return at(static_cast<size_type>(pos), len);
781  };
782  String at(Int pos, size_type len) const {
783  return at(static_cast<size_type>(pos), len);
784  };
785  // </group>
786  // </group>
787 
788  // Start at startpos and extract the string "before" the argument's
789  // position, exclusive. ** Casacore addition
790  // <group name=before>
791  SubString before(size_type pos) const;
792  SubString before(const string &str, size_type startpos = 0) const;
793  SubString before(const Char *s, size_type startpos = 0) const;
794  SubString before(Char c, size_type startpos = 0) const;
795  SubString before(const RegexBase &r, size_type startpos = 0) const;
796  // Next one for overloading reasons
797  SubString before(Int pos) const {
798  return before(static_cast<size_type>(pos)); };
799  // </group>
800 
801  // Start at startpos and extract the SubString "through" to the argument's
802  // position, inclusive. ** Casacore addition
803  // <group name=through>
805  SubString through(const string &str, size_type startpos = 0);
806  SubString through(const Char *s, size_type startpos = 0);
807  SubString through(Char c, size_type startpos = 0);
808  SubString through(const RegexBase &r, size_type startpos = 0);
809  // Next one for overloading reasons
810  SubString through(Int pos) {
811  return through(static_cast<size_type>(pos)); }
812  // </group>
813 
814  // Start at startpos and extract the SubString "from" the argument's
815  // position, inclusive, to the String's end. ** Casacore addition
816  // <group name=from>
817  SubString from(size_type pos);
818  SubString from(const string &str, size_type startpos = 0);
819  SubString from(const Char *s, size_type startpos = 0);
820  SubString from(Char c, size_type startpos = 0);
821  SubString from(const RegexBase &r, size_type startpos = 0);
822  // Next one for overloading reasons
823  SubString from(Int pos) {
824  return from(static_cast<size_type>(pos));
825  };
826  // </group>
827 
828  // Start at startpos and extract the SubString "after" the argument's
829  // position, exclusive, to the String's end. ** Casacore addition
830  // <group name=after>
832  SubString after(const string &str, size_type startpos = 0);
833  SubString after(const Char *s, size_type startpos = 0);
834  SubString after(Char c, size_type startpos = 0);
835  SubString after(const RegexBase &r, size_type startpos = 0);
836  // Next one for overloading reasons
837  SubString after(Int pos) {
838  return after(static_cast<size_type>(pos));
839  };
840  // </group>
841 
842  // Maybe forget some. ** Casacore addition
843  // <group>
844  // internal transformation to reverse order of String.
845  void reverse();
846  // internal transformation to capitalization of String.
847  void capitalize();
848  // internal transformation to uppercase of String
849  void upcase();
850  // internal transformation to lowercase of String
851  void downcase();
852  // </group>
853 
854  // Delete len chars starting at pos. ** Casacore addition
855  void del(size_type pos, size_type len);
856 
857  // Delete the first occurrence of target after startpos. ** Casacore addition
858  //<group name=del_after>
859  void del(const string &str, size_type startpos = 0);
860  void del(const Char *s, size_type startpos = 0);
861  void del(Char c, size_type startpos = 0);
862  void del(const RegexBase &r, size_type startpos = 0);
863  // Overload problem
864  void del(Int pos, Int len) {
865  del(static_cast<size_type>(pos), static_cast<size_type>(len)); }
866  //</group>
867 
868  // Global substitution: substitute all occurrences of pat with repl, and
869  // return the number of replacements.
870  // ** Casacore addition
871  //<group name=gsub>
872  Int gsub(const string &pat, const string &repl);
873  Int gsub(const Char *pat, const string &repl);
874  Int gsub(const Char *pat, const Char *repl);
875  Int gsub(const RegexBase &pat, const string &repl);
876  //</group>
877 
878 private:
879  // Helper functions for at, before etc
880  // <group>
882  return SubString(*this, first, l); }
883  // </group>
884 
885  // Helper function for fromString.
886  void throwFromStringError() const;
887 };
888 
889 // <summary>
890 // Global concatenation operators
891 // </summary>
892 
893 // The global concatenation operators
894 // <group name=concatenator>
895 inline String operator+(const String &lhs, const String &rhs) {
896  String str(lhs); str.append(rhs); return str; }
897 inline String operator+(const Char *lhs, const String &rhs) {
898  String str(lhs); str.append(rhs); return str; }
899 inline String operator+(Char lhs, const String &rhs) {
900  String str(lhs); str.append(rhs); return str; }
901 inline String operator+(const String &lhs, const Char *rhs) {
902  String str(lhs); str.append(rhs); return str; }
903 inline String operator+(const String &lhs, Char rhs) {
904  String str(lhs); str.append(rhs); return str; }
905 // </group>
906 
907 // <summary>
908 // Global comparison operators
909 // </summary>
910 
911 // The global comparison operators
912 // <group name=comparitor>
913 inline Bool operator==(const String &x, const String &y) {
914  return x.compare(y) == 0; }
915 inline Bool operator!=(const String &x, const String &y) {
916  return x.compare(y) != 0; }
917 inline Bool operator>(const String &x, const String &y) {
918  return x.compare(y) > 0; }
919 inline Bool operator>=(const String &x, const String &y) {
920  return x.compare(y) >= 0; }
921 inline Bool operator<(const String &x, const String &y) {
922  return x.compare(y) < 0; }
923 inline Bool operator<=(const String &x, const String &y) {
924  return x.compare(y) <= 0; }
925 inline Bool operator==(const String &x, const Char *t) {
926  return x.compare(t) == 0; }
927 inline Bool operator!=(const String &x, const Char *t) {
928  return x.compare(t) != 0; }
929 inline Bool operator>(const String &x, const Char *t) {
930  return x.compare(t) > 0; }
931 inline Bool operator>=(const String &x, const Char *t) {
932  return x.compare(t) >= 0; }
933 inline Bool operator<(const String &x, const Char *t) {
934  return x.compare(t) < 0; }
935 inline Bool operator<=(const String &x, const Char *t) {
936  return x.compare(t) <= 0; }
937 inline Bool operator==(const String &x, const Char t) {
938  return x.compare(String(t)) == 0; }
939 inline Bool operator!=(const String &x, const Char t) {
940  return x.compare(String(t)) != 0; }
941 inline Bool operator>(const String &x, const Char t) {
942  return x.compare(String(t)) > 0; }
943 inline Bool operator>=(const String &x, const Char t) {
944  return x.compare(String(t)) >= 0; }
945 inline Bool operator<(const String &x, const Char t) {
946  return x.compare(String(t)) < 0; }
947 inline Bool operator<=(const String &x, const Char t) {
948  return x.compare(String(t)) <= 0; }
949 // ** Casacore additions of global compares. Returns 0 if equal; lt or gt 0 if
950 // strings unequal or of unequal lengths.
951 // <group>
952 inline Int compare(const string &x, const string &y) {
953  return x.compare(y); }
954 inline Int compare(const string &x, const Char *y) {
955  return x.compare(y); }
956 inline Int compare(const string &x, const Char y) {
957  return x.compare(String(y)); }
958 // this version ignores case. ** Casacore addition. Result is 0 if equal
959 // strings of equal lengths; else lt or gt 0 to indicate differences.
960 Int fcompare(const String& x, const String& y);
961 // </group>
962 // </group>
963 
964 // <summary> Splitting </summary>
965 // Global function which splits the String into string array res at separator
966 // and returns the number of elements. ** Casacore addition
967 // <group name=split>
968 Int split(const string &str, string res[], Int maxn,
969  const string &sep);
970 Int split(const string &str, string res[], Int maxn,
971  const Char sep);
972 Int split(const string &str, string res[], Int maxn,
973  const RegexBase &sep);
974 //</group>
975 
976 // <summary> Some general functions </summary>
977 // Functions to find special patterns, join and replicate
978 // <group name=common>
979 String common_prefix(const string &x, const string &y,
980  Int startpos = 0);
981 String common_suffix(const string &x, const string &y,
982  Int startpos = -1);
983 String replicate(Char c, String::size_type n);
984 String replicate(const string &str, String::size_type n);
985 String join(string src[], Int n, const string &sep);
986 // </group>
987 
988 // <summary> Casing and related functions </summary>
989 // Case conversion and rearrangement functions
990 // <group name=case>
991 // Global function which returns a transformation to reverse order of String.
992 String reverse(const string& str);
993 // Global function which returns a transformation to uppercase of String.
994 String upcase(const string& str);
995 // Global function which returns a transformation to lowercase of String.
996 String downcase(const string& str);
997 // Global function which returns a transformation to capitalization of
998 // String.
999 String capitalize(const string& str);
1000 // Global function which removes leading and trailing whitespace.
1001 String trim(const string& str);
1002 // </group>
1003 
1004 // <summary> IO </summary>
1005 // <group name=io>
1006 // Output
1007 ostream &operator<<(ostream &s, const String &x);
1008 // </group>
1009 
1010 //# Inlines
1011 inline SubString::SubString(const string &str, string::size_type pos,
1012  string::size_type len) :
1013  ref_p(str), pos_p((pos > str.length()) ? str.length() : pos),
1014  len_p((len == string::npos || pos_p+len > str.length()) ?
1015  str.length()-pos_p : len) {}
1016 
1017 inline SubString String::operator()(size_type pos, size_type len) {
1018  return at(pos, len); }
1019 inline const Char *SubString::chars() const {
1020  return String(*this).c_str(); }
1022 inline Bool String::contains(Char c, Int pos) const {
1023  return (index(c, pos) != npos); }
1024 inline Bool String::contains(const string &str, Int pos) const {
1025  return (index(str, pos) != npos); }
1026 inline Bool String::contains(const Char *s, Int pos) const {
1027  return (index(s, pos) != npos); }
1028 inline Bool String::contains(const RegexBase &r, Int pos) const {
1029  return (index(r, pos) != npos); }
1030 
1031 inline ostream &operator<<(ostream &s, const String &x) {
1032  s << x.c_str(); return s; }
1033 
1034 
1035 } //# NAMESPACE CASACORE - END
1036 
1037 #endif
allocator_type get_allocator() const
Get allocator used Warning: gcc has no get_allocator()
Definition: String.h:564
String & assign(size_type n, Char c)
Definition: String.h:427
Int compare(const string &x, const string &y)
** Casacore additions of global compares.
Definition: String.h:952
String & resize(size_type n, Char c)
Definition: String.h:361
String & insert(size_type pos, size_type n, Char c)
Definition: String.h:452
String & replace(size_type pos, size_type n1, const Char *s)
Definition: String.h:518
int Int
Definition: aipstype.h:50
void rtrim(char c)
Remove specified character from end of string.
Int compare(const Char *s) const
Definition: String.h:488
reverse_iterator rend()
Definition: String.h:336
String & insert(iterator p, const Char *s, size_type n)
Definition: String.h:469
static Int toInt(const String &s, Bool chk=False)
Convert a string to an Int, Float or Double.
void reverse()
Maybe forget some.
Elements::const_iterator const_iterator
String & replace(iterator i1, iterator i2, const Char *s, size_type n)
Definition: String.h:527
String & replace(iterator i1, iterator i2, size_type n, Char c)
Definition: String.h:531
TableExprNode downcase(const TableExprNode &node)
Definition: ExprNode.h:1430
StatsData< AccumType > copy(const StatsData< AccumType > &stats)
size_type rfind(Char c, size_type pos=npos) const
Definition: String.h:659
iterator erase(iterator position)
Definition: String.h:499
size_type capacity() const
Definition: String.h:345
void ltrim(char c)
Remove specified character from beginning of string.
void swap(string &s)
Swap.
Definition: String.h:550
size_type rfind(const Char *s, size_type pos, size_type n) const
Definition: String.h:657
size_type find_last_of(const string &str, size_type pos=npos) const
Definition: String.h:670
String & replace(iterator i1, iterator i2, InputIterator j1, InputIterator j2)
Definition: String.h:537
String & append(const Char *s, size_type n)
Definition: String.h:400
size_type find_last_not_of(Char c, size_type pos=npos) const
Definition: String.h:692
size_type find_first_not_of(const Char *s, size_type pos=0) const
Definition: String.h:680
String & operator=(Char c)
Definition: String.h:294
const Char * chars() const
Get as (const) C array.
Definition: String.h:1021
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:739
Char firstchar() const
Definition: String.h:322
struct Node * first
Definition: malloc.h:330
size_type rfind(const Char *s, size_type pos=npos) const
Definition: String.h:655
Int gsub(const string &pat, const string &repl)
Global substitution: substitute all occurrences of pat with repl, and return the number of replacemen...
String & reserve(size_type res_arg=0)
Definition: String.h:363
String & append(const Char *s)
Definition: String.h:402
String & insert(size_type pos, const Char *s)
Definition: String.h:450
size_type find(Char c, size_type pos=0) const
Definition: String.h:650
size_type copy(Char *s, size_type n, size_type pos=0) const
Copy.
Definition: String.h:546
Bool matches(Char c, Int pos=0) const
Definition: String.h:722
string::value_type value_type
Definition: String.h:229
each selection effectively specify the desired channel data in a specified spectral window If the user uses the FrequencySelectionChannel class then the selection simply selects a range of channels The other derived class is FrequencySelectionReferential which specifies a range of frequencies in a specified frame of reference(e.g., LSRK).Unlike the other first method
reverse_iterator rbegin()
Definition: String.h:334
string::size_type pos_p
Start of sub-string.
Definition: String.h:88
size_type find_last_of(const Char *s, size_type pos, size_type n) const
Definition: String.h:674
PtrHolder< T > & operator=(const PtrHolder< T > &other)
size_type size() const
Capacity, size.
Definition: String.h:342
String & resize(size_type n)
Resize by truncating or extending with copies of &lt;tt&gt;c&lt;/tt&gt; (default Char())
Definition: String.h:359
reference at(size_type n)
Definition: String.h:383
Int compare(const string &str) const
Compare.
Definition: String.h:481
SubString after(size_type pos)
Start at startpos and extract the SubString &quot;after&quot; the argument&#39;s position, exclusive, to the String&#39;s end.
String & assign(InputIterator first, InputIterator last)
Definition: String.h:430
String & operator=(const SubString &str)
Definition: String.h:290
LatticeExprNode operator!=(const LatticeExprNode &left, const LatticeExprNode &right)
void prepend(const string &str)
Concatenate by prepending the argument onto String.
casacore::String join(Itr begin, Itr end, const casacore::String &delimiter)
Definition: UtilJ.h:177
Int allocation() const
** Casacore addition – works as a capacity(n) – Note Int
Definition: String.h:347
char Char
Definition: aipstype.h:46
const_reverse_iterator rbegin() const
Definition: String.h:335
void upcase()
internal transformation to uppercase of String
String & replace(iterator i1, iterator i2, const Char *s)
Definition: String.h:529
String & assign(Char c)
** Casacore addition
Definition: String.h:433
SubString at(Int pos, Int len)
Next ones for overloading reasons.
Definition: String.h:774
size_type find_first_of(const string &str, size_type pos=0) const
Definition: String.h:662
string::size_type length() const
Obtain length.
Definition: String.h:77
String & replace(size_type pos, size_type n1, size_type n2, Char c)
Definition: String.h:520
ostream & operator<<(ostream &os, const std::pair< T, U > &p)
String at(Int pos, size_type len) const
Definition: String.h:783
String & assign(const string &str, size_type pos, size_type n)
Definition: String.h:421
const_iterator end() const
string::reference reference
Definition: String.h:234
String & insert(iterator p, const string &str)
** Casacore additions
Definition: String.h:467
size_t size() const
String & replace(iterator i1, iterator i2, Char c)
** Casacore addition
Definition: String.h:534
iterator begin()
Iterators.
Definition: String.h:330
String & assign(const Char *s, size_type n)
Definition: String.h:423
Int freq(Char c) const
Return the number of occurences of target in String.
string::iterator iterator
Definition: String.h:239
Char lastchar() const
Definition: String.h:323
SubString through(Int pos)
Next one for overloading reasons.
Definition: String.h:811
size_type find_first_not_of(const string &str, size_type pos=0) const
Definition: String.h:678
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
LatticeExprNode operator>=(const LatticeExprNode &left, const LatticeExprNode &right)
iterator erase(iterator first, iterator last)
Definition: String.h:501
SubString before(Int pos) const
Next one for overloading reasons.
Definition: String.h:798
string::allocator_type allocator_type
Definition: String.h:230
String & assign(const Char *s)
Definition: String.h:425
String & replace(size_type pos1, size_type n1, const string &str, size_type pos2, size_type n2)
Definition: String.h:513
const string & ref_p
Referenced string.
Definition: String.h:86
size_type find(const Char *s, size_type pos=0) const
Definition: String.h:646
const_reference at(size_type n) const
Addressing.
Definition: String.h:382
Vector< String > & split(const String &s, char delim, Vector< String > &elems)
SubString _substr(size_type first, size_type l) const
Helper functions for at, before etc.
Definition: String.h:881
const_iterator begin() const
static Float toFloat(const String &s, Bool chk=False)
String & insert(size_type pos1, const string &str, size_type pos2, size_type n)
Definition: String.h:445
size_type find_first_not_of(Char c, size_type pos=0) const
Definition: String.h:684
void throwFromStringError() const
Helper function for fromString.
size_type find_last_of(Char c, size_type pos=npos) const
Definition: String.h:676
string::const_pointer const_pointer
Definition: String.h:237
SubString operator()(size_type pos, size_type len)
Casacore addition: synonym for at(pos, len)
Definition: String.h:1019
iterator end()
Definition: String.h:332
~String()
Destructor.
Definition: String.h:283
void clear()
Clear the string Warning: clear() executed as erase() due to missing clear() in gcc ...
Definition: String.h:372
LatticeExprNode replace(const LatticeExprNode &arg1, const LatticeExprNode &arg2)
This function replaces every masked-off element in the first argument with the corresponding element ...
string::difference_type difference_type
Definition: String.h:232
SubString help class to be used in at, before,...
Definition: String.h:61
friend class String
Definition: String.h:64
double Double
Definition: aipstype.h:55
size_type find_first_not_of(const Char *s, size_type pos, size_type n) const
Definition: String.h:682
string::size_type size_type
Definition: String.h:231
String & insert(size_type pos, Char c)
** Casacore addition
Definition: String.h:455
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
size_type rfind(const string &str, size_type pos=npos) const
Definition: String.h:653
String & erase(size_type pos, size_type n=npos)
Erase.
Definition: String.h:497
TableExprNode trim(const TableExprNode &node)
Definition: ExprNode.h:1541
String & assign(const string &str)
Assign.
Definition: String.h:419
Bool startsWith(const string &beginString) const
Does the string start with the specified string?
Definition: String.h:638
LatticeExprNode operator<=(const LatticeExprNode &left, const LatticeExprNode &right)
const Char * chars() const
** Casacore synonym
Definition: String.h:559
String & insert(size_type pos1, const string &str)
Insert.
Definition: String.h:443
const Char * c_str() const
Get char array.
Definition: String.h:555
size_type find_last_of(const Char *s, size_type pos=npos) const
Definition: String.h:672
size_type length() const
Definition: String.h:343
void insert(iterator p, InputIterator first, InputIterator last)
Definition: String.h:463
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
String substr(size_type pos=0, size_type n=npos) const
Get a sub string.
Definition: String.h:570
String & operator+=(const string &str)
Concatenate.
Definition: String.h:301
SubString & operator=(const SubString &str)
Assignment.
size_type find_first_of(Char c, size_type pos=0) const
Definition: String.h:668
const_reverse_iterator rend() const
Definition: String.h:337
size_type find_last_not_of(const string &str, size_type pos=npos) const
Definition: String.h:686
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
size_type find_first_of(const Char *s, size_type pos=0) const
Definition: String.h:664
void trim()
Remove beginning and ending whitespace.
TableExprNode upcase(const TableExprNode &node)
Definition: ExprNode.h:1425
String()
Default constructor.
Definition: String.h:248
reference operator[](size_type pos)
Definition: String.h:316
static Double toDouble(const String &s, Bool chk=False)
String & operator+=(const Char *s)
Definition: String.h:303
float Float
Definition: aipstype.h:54
void insert(iterator p, size_type n, Char c)
Definition: String.h:460
casacore::Bool empty() const
static String format(const char *picture,...)
Create a formatted string using the given printf format string.
string::const_iterator const_iterator
Definition: String.h:240
Int compare(const string &x, const Char y)
Definition: String.h:956
SubString at(Int pos, size_type len)
Definition: String.h:780
const Bool False
Definition: aipstype.h:44
string::const_reference const_reference
Definition: String.h:235
const_reference operator[](size_type pos) const
Indexing.
Definition: String.h:314
void alloc(size_type n)
** Casacore addition – works as a resize(n)
Definition: String.h:366
LatticeExprNode operator>(const LatticeExprNode &left, const LatticeExprNode &right)
SubString before(size_type pos) const
Start at startpos and extract the string &quot;before&quot; the argument&#39;s position, exclusive.
String & replace(size_type pos1, size_type n1, const string &str)
Replace.
Definition: String.h:511
String & insert(size_type pos, const Char *s, size_type n)
Definition: String.h:448
string::size_type len_p
Length of sub-string.
Definition: String.h:90
Int compare(size_type pos1, size_type n1, const string &str, size_type pos2, size_type n2) const
Definition: String.h:485
const_reference elem(size_type pos) const
*** Casacore addition
Definition: String.h:320
String at(Int pos, Int len) const
Definition: String.h:777
String(size_type n, Char c)
Construct from a single char (repeated n times)
Definition: String.h:267
Int compare(const string &x, const Char *y)
Definition: String.h:954
String(const Char *s)
Construct from char array.
Definition: String.h:262
size_type find(const string &str, size_type pos=0) const
Search functions.
Definition: String.h:644
string::reverse_iterator reverse_iterator
Definition: String.h:241
String(const SubString &str)
Construct from a SubString.
Definition: String.h:277
LatticeExprNode operator+(const LatticeExprNode &expr)
Global functions operating on a LatticeExprNode.
String & append(InputIterator first, InputIterator last)
Definition: String.h:407
String & operator=(const string &str)
Assignments (they are all deep copies according to standard)
Definition: String.h:288
SubString from(size_type pos)
Start at startpos and extract the SubString &quot;from&quot; the argument&#39;s position, inclusive, to the String&#39;s end.
void del(Int pos, Int len)
Overload problem.
Definition: String.h:865
Bool fromString(T &value, Bool chk=True) const
Convert a String to a value.
Definition: String.h:583
String & insert(iterator p, const Char *s)
Definition: String.h:471
size_type max_size() const
Definition: String.h:344
String & operator+=(Char c)
Definition: String.h:305
iterator insert(iterator p, Char c)
Definition: String.h:458
String & replace(size_type pos, size_type n1, Char c)
** Casacore addition
Definition: String.h:523
Abstract interface class to regular expressions for String.
Definition: RegexBase.h:132
string::traits_type traits_type
Definition: String.h:228
const Double c
Fundamental physical constants (SI units):
String & append(size_type n, Char c)
Definition: String.h:404
T fromString() const
Definition: String.h:593
size_type find_last_not_of(const Char *s, size_type pos, size_type n) const
Definition: String.h:690
TableExprNode capitalize(const TableExprNode &node)
Definition: ExprNode.h:1435
Bool matches(const string &str, Int pos=0) const
Matches entire string from pos (or till pos if negative pos).
String: the storage and methods of handling collections of characters.
Definition: String.h:223
String & append(Char c)
** Casacore addition
Definition: String.h:410
Bool operator==(const MVTime &lh, const MVTime &rh)
is equal operator, uses operator Double which returns days
Definition: MVTime.h:465
size_type find_last_not_of(const Char *s, size_type pos=npos) const
Definition: String.h:688
LatticeExprNode operator<(const LatticeExprNode &left, const LatticeExprNode &right)
SubString(const string &str, string::size_type pos, string::size_type len)
Constructor (there are no public constructors)
Definition: String.h:1014
Int compare(size_type pos1, size_type n1, const string &str) const
Definition: String.h:483
String(InputIterator begin, InputIterator end)
Construct from iterator.
Definition: String.h:270
Bool contains(Char c) const
Containment.
Definition: String.h:699
const_iterator begin() const
Definition: String.h:331
SubString through(size_type pos)
Start at startpos and extract the SubString &quot;through&quot; to the argument&#39;s position, inclusive.
string::const_reverse_iterator const_reverse_iterator
Definition: String.h:242
String(Char c)
From single char (** Casacore addition).
Definition: String.h:275
static const size_type npos
Definition: String.h:244
size_type find_first_of(const Char *s, size_type pos, size_type n) const
Definition: String.h:666
const_iterator end() const
Definition: String.h:333
const Bool True
Definition: aipstype.h:43
const Char * data() const
As pointer to char array.
Definition: String.h:557
void downcase()
internal transformation to lowercase of String
size_type find(const Char *s, size_type pos, size_type n) const
Definition: String.h:648
String & append(const string &str)
Append.
Definition: String.h:396
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
String & operator=(const Char *s)
Definition: String.h:292
String at(size_type pos, size_type len) const
Definition: String.h:761
String(const Char *s, size_type n)
Construct from char* with given length.
Definition: String.h:260
string::pointer pointer
Definition: String.h:236
unsigned int uInt
Definition: aipstype.h:51
Int compare(size_type pos1, size_type n1, const Char *s, size_type n2=npos) const
Definition: String.h:490
void del(size_type pos, size_type len)
Delete len chars starting at pos.
String & replace(iterator i1, iterator i2, const string &str)
Definition: String.h:525
String & replace(size_type pos, size_type n1, const Char *s, size_type n2)
Definition: String.h:516
String & append(const string &str, size_type pos, size_type n)
Definition: String.h:398
void capitalize()
internal transformation to capitalization of String.
static String toString(const T &value)
Convert a value to a String.
Definition: String.h:614
SubString after(Int pos)
Next one for overloading reasons.
Definition: String.h:838
SubString from(Int pos)
Next one for overloading reasons.
Definition: String.h:824
Bool empty() const
Test for empty.
Definition: String.h:375
Bool matches(const Char *s, Int pos=0) const
Definition: String.h:724
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42