casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | List of all members
casacore::String Class Reference

String: the storage and methods of handling collections of characters. More...

#include <String.h>

Inheritance diagram for casacore::String:

Public Types

typedef string::traits_type traits_type
 
typedef string::value_type value_type
 
typedef string::allocator_type allocator_type
 
typedef string::size_type size_type
 
typedef string::difference_type difference_type
 
typedef string::reference reference
 
typedef string::const_reference const_reference
 
typedef string::pointer pointer
 
typedef string::const_pointer const_pointer
 
typedef string::iterator iterator
 
typedef string::const_iterator const_iterator
 
typedef string::reverse_iterator reverse_iterator
 
typedef
string::const_reverse_iterator 
const_reverse_iterator
 

Public Member Functions

 String ()
 Default constructor. More...
 
 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. More...
 
 String (const Char *s, size_type n)
 Construct from char* with given length. More...
 
 String (const Char *s)
 Construct from char array. More...
 
 String (size_type n, Char c)
 Construct from a single char (repeated n times) More...
 
template<class InputIterator >
 String (InputIterator begin, InputIterator end)
 Construct from iterator. More...
 
 String (Char c)
 From single char (** Casacore addition). More...
 
 String (const SubString &str)
 Construct from a SubString. More...
 
 String (ostringstream &os)
 Construct from a stream. More...
 
 ~String ()
 Destructor. More...
 
Stringoperator= (const string &str)
 Assignments (they are all deep copies according to standard) More...
 
Stringoperator= (const SubString &str)
 
Stringoperator= (const Char *s)
 
Stringoperator= (Char c)
 
SubString operator() (size_type pos, size_type len)
 Casacore addition: synonym for at(pos, len) More...
 
Stringoperator+= (const string &str)
 Concatenate. More...
 
Stringoperator+= (const Char *s)
 
Stringoperator+= (Char c)
 
const_reference operator[] (size_type pos) const
 Indexing. More...
 
reference operator[] (size_type pos)
 
const_reference elem (size_type pos) const
 *** Casacore addition More...
 
Char firstchar () const
 
Char lastchar () const
 
iterator begin ()
 Iterators. More...
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
size_type size () const
 Capacity, size. More...
 
size_type length () const
 
size_type max_size () const
 
size_type capacity () const
 
Int allocation () const
 ** Casacore addition – works as a capacity(n) – Note Int More...
 
Stringresize (size_type n)
 
Resize by truncating or extending with copies of <tt>c</tt> (default 

Char()) More...

 
Stringresize (size_type n, Char c)
 
Stringreserve (size_type res_arg=0)
 
void alloc (size_type n)
 ** Casacore addition – works as a resize(n) More...
 
void clear ()
 Clear the string
Warning: clear() executed as erase() due to missing clear() in gcc
More...
 
Bool empty () const
 Test for empty. More...
 
const_reference at (size_type n) const
 Addressing. More...
 
reference at (size_type n)
 
Stringappend (const string &str)
 Append. More...
 
Stringappend (const string &str, size_type pos, size_type n)
 
Stringappend (const Char *s, size_type n)
 
Stringappend (const Char *s)
 
Stringappend (size_type n, Char c)
 
template<class InputIterator >
Stringappend (InputIterator first, InputIterator last)
 
Stringappend (Char c)
 ** Casacore addition More...
 
Stringassign (const string &str)
 Assign. More...
 
Stringassign (const string &str, size_type pos, size_type n)
 
Stringassign (const Char *s, size_type n)
 
Stringassign (const Char *s)
 
Stringassign (size_type n, Char c)
 
template<class InputIterator >
Stringassign (InputIterator first, InputIterator last)
 
Stringassign (Char c)
 ** Casacore addition More...
 
Stringinsert (size_type pos1, const string &str)
 Insert. More...
 
Stringinsert (size_type pos1, const string &str, size_type pos2, size_type n)
 
Stringinsert (size_type pos, const Char *s, size_type n)
 
Stringinsert (size_type pos, const Char *s)
 
Stringinsert (size_type pos, size_type n, Char c)
 
Stringinsert (size_type pos, Char c)
 ** Casacore addition More...
 
iterator insert (iterator p, Char c)
 
void insert (iterator p, size_type n, Char c)
 
template<class InputIterator >
void insert (iterator p, InputIterator first, InputIterator last)
 
Stringinsert (iterator p, const string &str)
 ** Casacore additions More...
 
Stringinsert (iterator p, const Char *s, size_type n)
 
Stringinsert (iterator p, const Char *s)
 
Int compare (const string &str) const
 Compare. More...
 
Int compare (size_type pos1, size_type n1, const string &str) const
 
Int compare (size_type pos1, size_type n1, const string &str, size_type pos2, size_type n2) const
 
Int compare (const Char *s) const
 
Int compare (size_type pos1, size_type n1, const Char *s, size_type n2=npos) const
 
Stringerase (size_type pos, size_type n=npos)
 Erase. More...
 
iterator erase (iterator position)
 
iterator erase (iterator first, iterator last)
 
Stringreplace (size_type pos1, size_type n1, const string &str)
 Replace. More...
 
Stringreplace (size_type pos1, size_type n1, const string &str, size_type pos2, size_type n2)
 
Stringreplace (size_type pos, size_type n1, const Char *s, size_type n2)
 
Stringreplace (size_type pos, size_type n1, const Char *s)
 
Stringreplace (size_type pos, size_type n1, size_type n2, Char c)
 
Stringreplace (size_type pos, size_type n1, Char c)
 ** Casacore addition More...
 
Stringreplace (iterator i1, iterator i2, const string &str)
 
Stringreplace (iterator i1, iterator i2, const Char *s, size_type n)
 
Stringreplace (iterator i1, iterator i2, const Char *s)
 
Stringreplace (iterator i1, iterator i2, size_type n, Char c)
 
Stringreplace (iterator i1, iterator i2, Char c)
 ** Casacore addition More...
 
template<class InputIterator >
Stringreplace (iterator i1, iterator i2, InputIterator j1, InputIterator j2)
 
size_type copy (Char *s, size_type n, size_type pos=0) const
 Copy. More...
 
void swap (string &s)
 Swap. More...
 
const Charc_str () const
 Get char array. More...
 
const Chardata () const
 As pointer to char array. More...
 
const Charchars () const
 ** Casacore synonym More...
 
allocator_type get_allocator () const
 Get allocator used
Warning: gcc has no get_allocator()
More...
 
String substr (size_type pos=0, size_type n=npos) const
 Get a sub string. More...
 
template<typename T >
Bool fromString (T &value, Bool chk=True) const
 Convert a String to a value. More...
 
template<typename T >
fromString () const
 
void trim ()
 Remove beginning and ending whitespace. More...
 
void trim (char c[], uInt n)
 Remove specified chars from beginning and end of string. More...
 
void ltrim (char c)
 Remove specified character from beginning of string. More...
 
void rtrim (char c)
 Remove specified character from end of string. More...
 
Bool startsWith (const string &beginString) const
 Does the string start with the specified string? More...
 
size_type find (const string &str, size_type pos=0) const
 Search functions. More...
 
size_type find (const Char *s, size_type pos=0) const
 
size_type find (const Char *s, size_type pos, size_type n) const
 
size_type find (Char c, size_type pos=0) const
 
size_type find (const RegexBase &r, size_type pos=0) const
 
size_type rfind (const string &str, size_type pos=npos) const
 
size_type rfind (const Char *s, size_type pos=npos) const
 
size_type rfind (const Char *s, size_type pos, size_type n) const
 
size_type rfind (Char c, size_type pos=npos) const
 
size_type rfind (const RegexBase &r, size_type pos=npos) const
 
size_type find_first_of (const string &str, size_type pos=0) const
 
size_type find_first_of (const Char *s, size_type pos=0) const
 
size_type find_first_of (const Char *s, size_type pos, size_type n) const
 
size_type find_first_of (Char c, size_type pos=0) const
 
size_type find_last_of (const string &str, size_type pos=npos) const
 
size_type find_last_of (const Char *s, size_type pos=npos) const
 
size_type find_last_of (const Char *s, size_type pos, size_type n) const
 
size_type find_last_of (Char c, size_type pos=npos) const
 
size_type find_first_not_of (const string &str, size_type pos=0) const
 
size_type find_first_not_of (const Char *s, size_type pos=0) const
 
size_type find_first_not_of (const Char *s, size_type pos, size_type n) const
 
size_type find_first_not_of (Char c, size_type pos=0) const
 
size_type find_last_not_of (const string &str, size_type pos=npos) const
 
size_type find_last_not_of (const Char *s, size_type pos=npos) const
 
size_type find_last_not_of (const Char *s, size_type pos, size_type n) const
 
size_type find_last_not_of (Char c, size_type pos=npos) const
 
void reverse ()
 Maybe forget some. More...
 
void capitalize ()
 internal transformation to capitalization of String. More...
 
void upcase ()
 internal transformation to uppercase of String More...
 
void downcase ()
 internal transformation to lowercase of String More...
 
void del (size_type pos, size_type len)
 Delete len chars starting at pos. More...
 
Bool contains (Char c) const
 Containment. More...
 
Bool contains (const string &str) const
 
Bool contains (const Char *s) const
 
Bool contains (const RegexBase &r) const
 
Bool contains (Char c, Int pos) const
 Does the string starting at the given position contain the given substring? If the position is negative, it is counted from the end. More...
 
Bool contains (const string &str, Int pos) const
 
Bool contains (const Char *s, Int pos) const
 
Bool contains (const RegexBase &r, Int pos) const
 
Bool matches (const string &str, Int pos=0) const
 Matches entire string from pos (or till pos if negative pos). More...
 
Bool matches (Char c, Int pos=0) const
 
Bool matches (const Char *s, Int pos=0) const
 
Bool matches (const RegexBase &r, Int pos=0) const
 
void prepend (const string &str)
 Concatenate by prepending the argument onto String. More...
 
void prepend (const Char *s)
 
void prepend (Char c)
 
size_type index (Char c, Int startpos=0) const
 Return the position of the target in the string or npos for failure. More...
 
size_type index (const string &str, Int startpos=0) const
 
size_type index (const Char *s, Int startpos=0) const
 
size_type index (const RegexBase &r, Int startpos=0) const
 
Int freq (Char c) const
 Return the number of occurences of target in String. More...
 
Int freq (const string &str) const
 
Int freq (const Char *s) const
 
SubString at (size_type pos, size_type len)
 Extract the string "at" the argument's position. More...
 
String at (size_type pos, size_type len) const
 
SubString at (const string &str, Int startpos=0)
 
String at (const string &str, Int startpos=0) const
 
SubString at (const Char *s, Int startpos=0)
 
String at (const Char *s, Int startpos=0) const
 
SubString at (Char c, Int startpos=0)
 
String at (Char c, Int startpos=0) const
 
SubString at (const RegexBase &r, Int startpos=0)
 
String at (const RegexBase &r, Int startpos=0) const
 
SubString at (Int pos, Int len)
 Next ones for overloading reasons. More...
 
String at (Int pos, Int len) const
 
SubString at (Int pos, size_type len)
 
String at (Int pos, size_type len) const
 
SubString before (size_type pos) const
 
Start at startpos and extract the string "before" the argument's 

position, exclusive. More...

 
SubString before (const string &str, size_type startpos=0) const
 
SubString before (const Char *s, size_type startpos=0) const
 
SubString before (Char c, size_type startpos=0) const
 
SubString before (const RegexBase &r, size_type startpos=0) const
 
SubString before (Int pos) const
 Next one for overloading reasons. More...
 
SubString through (size_type pos)
 Start at startpos and extract the SubString "through" to the argument's position, inclusive. More...
 
SubString through (const string &str, size_type startpos=0)
 
SubString through (const Char *s, size_type startpos=0)
 
SubString through (Char c, size_type startpos=0)
 
SubString through (const RegexBase &r, size_type startpos=0)
 
SubString through (Int pos)
 Next one for overloading reasons. More...
 
SubString from (size_type pos)
 Start at startpos and extract the SubString "from" the argument's position, inclusive, to the String's end. More...
 
SubString from (const string &str, size_type startpos=0)
 
SubString from (const Char *s, size_type startpos=0)
 
SubString from (Char c, size_type startpos=0)
 
SubString from (const RegexBase &r, size_type startpos=0)
 
SubString from (Int pos)
 Next one for overloading reasons. More...
 
SubString after (size_type pos)
 Start at startpos and extract the SubString "after" the argument's position, exclusive, to the String's end. More...
 
SubString after (const string &str, size_type startpos=0)
 
SubString after (const Char *s, size_type startpos=0)
 
SubString after (Char c, size_type startpos=0)
 
SubString after (const RegexBase &r, size_type startpos=0)
 
SubString after (Int pos)
 Next one for overloading reasons. More...
 
void del (const string &str, size_type startpos=0)
 Delete the first occurrence of target after startpos. More...
 
void del (const Char *s, size_type startpos=0)
 
void del (Char c, size_type startpos=0)
 
void del (const RegexBase &r, size_type startpos=0)
 
void del (Int pos, Int len)
 Overload problem. More...
 
Int gsub (const string &pat, const string &repl)
 Global substitution: substitute all occurrences of pat with repl, and return the number of replacements. More...
 
Int gsub (const Char *pat, const string &repl)
 
Int gsub (const Char *pat, const Char *repl)
 
Int gsub (const RegexBase &pat, const string &repl)
 

Static Public Member Functions

static String format (const char *picture,...)
 Create a formatted string using the given printf format string. More...
 
static Int toInt (const String &s, Bool chk=False)
 Convert a string to an Int, Float or Double. More...
 
static Float toFloat (const String &s, Bool chk=False)
 
static Double toDouble (const String &s, Bool chk=False)
 
template<typename T >
static String toString (const T &value)
 Convert a value to a String. More...
 

Static Public Attributes

static const size_type npos
 

Private Member Functions

SubString _substr (size_type first, size_type l) const
 Helper functions for at, before etc. More...
 
void throwFromStringError () const
 Helper function for fromString. More...
 

Detailed Description

String: the storage and methods of handling collections of characters.

Intended use:

Public interface

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Test programs:
tString

Prerequisite

Etymology

The String class name is a continuation of the "C" language custom of refering to collections of characters as "strings of characters".

Synopsis

The String class is the Casacore implementation of a string class. It is from the standard library string class, and all operations and behaviour of strings as defined in the standard are available for a String. The only difference is the extension with additional functions in the Casacore String class as compared to the standard string class.

The String class may be instantiated in many ways:

  1. A single character - String myChar('C');
  2. A Char* argument - String myWord("Yowza");
  3. The first n chararcters of a pre-existing string - String myFoo("fooey", 3);

As well as the copy and default constructors and iterator based ones.

A String may be concatinated with another object (String, or char*) with either prepending or postpending. A search for the position of a character within a String may return its position, a Bool that it is contained within or a Bool confirming your guess at the character's position is correct. A check of the frequency of occurance of a string within a String will return the number of occurances.

Strings may be extracted from Strings at, before, through, from and after a starting position within the String. Deletion of characters is possible after a given position within the String. Global substitution of characters within a String is provided, as well. Splitting of Strings into a carray of Strings is possible, based upon a given separator character, with a return value of the number of elements split. The joining together of the elements of an array of Strings into one String is possible.

Finally, transformations of case and conversions of type are provided.

The standard string class provides the following functionality:

  1. Construction from (part of) String, (part of) Char*, (repeating) Char, iterator pair.
  2. Assignment from String, Char*, Char
  3. Iterators: begin() and end(); rbegin() and rend() (Note: gcc reverse iterators still weak)
  4. Capacity: size, length, max_size, resize, capacity, reserve, clear, empty
  5. Special size: String::size_type, with indicator: String::npos
  6. Element access: [pos] and at(pos) (both const and non-const)
  7. Modifiers: += of String, Char*, Char; append of (part of) String, Char*, Char and iterator defined; assign() of (part of) String, Char* and (repeating) Char and iterator; insertion of same; replacing of same; erase of part of String; a copy and a swap.
  8. C-string: get Char* with c_str() or data() and get the relevant Allocator used (Note: not fully supported in gcc)
  9. Operations: find, rfind, find_first_of, find_last_of, find_first_not_of, find_last_not_of; substr (Note only readable substring); compare with (part of) String, Char*
  10. Globals: Addition operators for String, Char*, Char; all comparison operators for String and Char*; getline; input and output stream operators
  11. Typedef: All relevant typedefs for standard containers and iterator handling

The Casacore additions are:

  1. To standard: some Char function arguments where appropriate; RegexBase arguments in search like methods.
  2. Substring additions: at, before, after, from, through functions taking search String, Char* as arguments can give (hidden) substrings which can be assigned (as in at(1,2) = ";")
  3. Methods: prepend (in addition to standard append); del (as erase); global substitution of String and patterns; freq (count of occurance); split/join of strings at separator or pattern; upcase, downcase, reverse; common_suffix and _prefix; replicate; case insensitive compare; creation from stream

Example

// Let's start with a simple string.
String myString("the time");
// add some more on the end..\.
myString += " for all good men";
// prepend some on the front..\.
myString.prepend("Now is ");
// do some concatination..\.
String evenMore;
evenMore += myString + " to come to";
// do some three way concatination
String allKeys, finishIt(" their country.");
allKeys = evenMore + "the aid of" + finishIt;
// find the spot where we put something earlier
String::size_type position = allKeys.index(finishIt);
// find if the word is in the String..\.
Bool query = myString.contains("good men");
// ask if the position we think is true is correct..\.
Bool answer = allKeys.matches(finishIt, position);
// How many spaces are in our phrase?
Int spacesCount = allKeys.freq(" ");

Motivation

The String class eases the handling of characters within the Casacore environment.

To Do

Definition at line 223 of file String.h.

Member Typedef Documentation

typedef string::allocator_type casacore::String::allocator_type

Definition at line 230 of file String.h.

typedef string::const_iterator casacore::String::const_iterator

Definition at line 240 of file String.h.

typedef string::const_pointer casacore::String::const_pointer

Definition at line 237 of file String.h.

typedef string::const_reference casacore::String::const_reference

Definition at line 235 of file String.h.

typedef string::const_reverse_iterator casacore::String::const_reverse_iterator

Definition at line 242 of file String.h.

typedef string::difference_type casacore::String::difference_type

Definition at line 232 of file String.h.

typedef string::iterator casacore::String::iterator

Definition at line 239 of file String.h.

typedef string::pointer casacore::String::pointer

Definition at line 236 of file String.h.

typedef string::reference casacore::String::reference

Definition at line 234 of file String.h.

typedef string::reverse_iterator casacore::String::reverse_iterator

Definition at line 241 of file String.h.

typedef string::size_type casacore::String::size_type

Definition at line 231 of file String.h.

typedef string::traits_type casacore::String::traits_type

Definition at line 228 of file String.h.

typedef string::value_type casacore::String::value_type

Definition at line 229 of file String.h.

Constructor & Destructor Documentation

casacore::String::String ( )
inline

Default constructor.

Definition at line 248 of file String.h.

Referenced by compare(), matches(), operator=(), and substr().

casacore::String::String ( const string &  str,
size_type  pos = 0,
size_type  n = npos 
)
inline

Construct from std string Construct from (part of) other string: acts as copy constructor.

Thrown Exceptions

Definition at line 254 of file String.h.

casacore::String::String ( const Char s,
size_type  n 
)
inline

Construct from char* with given length.

Thrown Exceptions

  • length_error if n == npos

Definition at line 260 of file String.h.

casacore::String::String ( const Char s)
inline

Construct from char array.

Definition at line 262 of file String.h.

casacore::String::String ( size_type  n,
Char  c 
)
inline

Construct from a single char (repeated n times)

Thrown Exceptions

  • length_error if n == npos

Definition at line 267 of file String.h.

template<class InputIterator >
casacore::String::String ( InputIterator  begin,
InputIterator  end 
)
inline

Construct from iterator.

Definition at line 270 of file String.h.

casacore::String::String ( Char  c)
inlineexplicit

From single char (** Casacore addition).


Warning: Note that there is no automatic Char-to-String conversion available; This stops inadvertent conversions of integer to string;

Definition at line 275 of file String.h.

casacore::String::String ( const SubString str)
inline

Construct from a SubString.

Definition at line 277 of file String.h.

casacore::String::String ( ostringstream &  os)

Construct from a stream.

casacore::String::~String ( )
inline

Destructor.

Definition at line 283 of file String.h.

Member Function Documentation

SubString casacore::String::_substr ( size_type  first,
size_type  l 
) const
inlineprivate

Helper functions for at, before etc.

Definition at line 881 of file String.h.

SubString casacore::String::after ( size_type  pos)

Start at startpos and extract the SubString "after" the argument's position, exclusive, to the String's end.

** Casacore addition

Referenced by casa::VPManager::antTypeFromAntDesc().

SubString casacore::String::after ( const string &  str,
size_type  startpos = 0 
)
SubString casacore::String::after ( const Char s,
size_type  startpos = 0 
)
SubString casacore::String::after ( Char  c,
size_type  startpos = 0 
)
SubString casacore::String::after ( const RegexBase r,
size_type  startpos = 0 
)
SubString casacore::String::after ( Int  pos)
inline

Next one for overloading reasons.

Definition at line 838 of file String.h.

void casacore::String::alloc ( size_type  n)
inline

** Casacore addition – works as a resize(n)

Definition at line 366 of file String.h.

Int casacore::String::allocation ( ) const
inline

** Casacore addition – works as a capacity(n) – Note Int

Definition at line 347 of file String.h.

String& casacore::String::append ( const string &  str)
inline

Append.

Thrown Exceptions


Warning: The standard has a void push_back(const Char) which is completely undefined; It probably is a remnant of the full list of container functions pop/push back/front;

Definition at line 396 of file String.h.

String& casacore::String::append ( const string &  str,
size_type  pos,
size_type  n 
)
inline

Definition at line 398 of file String.h.

String& casacore::String::append ( const Char s,
size_type  n 
)
inline

Definition at line 400 of file String.h.

String& casacore::String::append ( const Char s)
inline

Definition at line 402 of file String.h.

String& casacore::String::append ( size_type  n,
Char  c 
)
inline

Definition at line 404 of file String.h.

template<class InputIterator >
String& casacore::String::append ( InputIterator  first,
InputIterator  last 
)
inline

Definition at line 407 of file String.h.

String& casacore::String::append ( Char  c)
inline

** Casacore addition

Definition at line 410 of file String.h.

String& casacore::String::assign ( const string &  str)
inline

Assign.

Thrown Exceptions

Definition at line 419 of file String.h.

Referenced by casa::sdfiller::DataAccumulator::accumulate().

String& casacore::String::assign ( const string &  str,
size_type  pos,
size_type  n 
)
inline

Definition at line 421 of file String.h.

String& casacore::String::assign ( const Char s,
size_type  n 
)
inline

Definition at line 423 of file String.h.

String& casacore::String::assign ( const Char s)
inline

Definition at line 425 of file String.h.

String& casacore::String::assign ( size_type  n,
Char  c 
)
inline

Definition at line 427 of file String.h.

template<class InputIterator >
String& casacore::String::assign ( InputIterator  first,
InputIterator  last 
)
inline

Definition at line 430 of file String.h.

String& casacore::String::assign ( Char  c)
inline

** Casacore addition

Definition at line 433 of file String.h.

const_reference casacore::String::at ( size_type  n) const
inline

Addressing.

Thrown Exceptions

  • out_of_range if pos >= size()

Definition at line 382 of file String.h.

Referenced by firstchar(), and lastchar().

reference casacore::String::at ( size_type  n)
inline

Definition at line 383 of file String.h.

SubString casacore::String::at ( size_type  pos,
size_type  len 
)

Extract the string "at" the argument's position.

** Casacore addition

String casacore::String::at ( size_type  pos,
size_type  len 
) const
inline

Definition at line 761 of file String.h.

SubString casacore::String::at ( const string &  str,
Int  startpos = 0 
)
String casacore::String::at ( const string &  str,
Int  startpos = 0 
) const
SubString casacore::String::at ( const Char s,
Int  startpos = 0 
)
String casacore::String::at ( const Char s,
Int  startpos = 0 
) const
SubString casacore::String::at ( Char  c,
Int  startpos = 0 
)
String casacore::String::at ( Char  c,
Int  startpos = 0 
) const
SubString casacore::String::at ( const RegexBase r,
Int  startpos = 0 
)
String casacore::String::at ( const RegexBase r,
Int  startpos = 0 
) const
SubString casacore::String::at ( Int  pos,
Int  len 
)
inline

Next ones for overloading reasons.


Tip: It is better to use the substr() method in stead;

Definition at line 774 of file String.h.

String casacore::String::at ( Int  pos,
Int  len 
) const
inline

Definition at line 777 of file String.h.

SubString casacore::String::at ( Int  pos,
size_type  len 
)
inline

Definition at line 780 of file String.h.

String casacore::String::at ( Int  pos,
size_type  len 
) const
inline

Definition at line 783 of file String.h.

SubString casacore::String::before ( size_type  pos) const

Start at startpos and extract the string "before" the argument's 

position, exclusive.

** Casacore addition

Referenced by casa::VPManager::telFromAntDesc().

SubString casacore::String::before ( const string &  str,
size_type  startpos = 0 
) const
SubString casacore::String::before ( const Char s,
size_type  startpos = 0 
) const
SubString casacore::String::before ( Char  c,
size_type  startpos = 0 
) const
SubString casacore::String::before ( const RegexBase r,
size_type  startpos = 0 
) const
SubString casacore::String::before ( Int  pos) const
inline

Next one for overloading reasons.

Definition at line 798 of file String.h.

iterator casacore::String::begin ( )
inline

Iterators.

Definition at line 330 of file String.h.

References casa::vi::begin().

Referenced by clear(), and insert().

const_iterator casacore::String::begin ( ) const
inline

Definition at line 331 of file String.h.

References casa::vi::begin().

const Char* casacore::String::c_str ( ) const
inline
size_type casacore::String::capacity ( ) const
inline

Definition at line 345 of file String.h.

void casacore::String::capitalize ( )

internal transformation to capitalization of String.

const Char* casacore::String::chars ( ) const
inline
void casacore::String::clear ( )
inline

Clear the string
Warning: clear() executed as erase() due to missing clear() in gcc

Definition at line 372 of file String.h.

References begin(), and end().

Referenced by casa::CubePartitionMixin< T >::concat_images().

Int casacore::String::compare ( const string &  str) const
inline

Compare.

Returns 0 if strings equal and of equal size; else positive if str larger or longer; else negative.
Warning: The gcc compiler does not have the proper standard compare functions; Hence they are locally implemented;

Definition at line 481 of file String.h.

Int casacore::String::compare ( size_type  pos1,
size_type  n1,
const string &  str 
) const
inline

Definition at line 483 of file String.h.

References String().

Int casacore::String::compare ( size_type  pos1,
size_type  n1,
const string &  str,
size_type  pos2,
size_type  n2 
) const
inline

Definition at line 485 of file String.h.

References String().

Int casacore::String::compare ( const Char s) const
inline

Definition at line 488 of file String.h.

Int casacore::String::compare ( size_type  pos1,
size_type  n1,
const Char s,
size_type  n2 = npos 
) const
inline

Definition at line 490 of file String.h.

References String().

Bool casacore::String::contains ( Char  c) const
inline

Containment.

** Casacore addition

Definition at line 699 of file String.h.

Referenced by casa::VPManager::antTypeFromAntDesc(), and casa::VPManager::telFromAntDesc().

Bool casacore::String::contains ( const string &  str) const
inline

Definition at line 701 of file String.h.

Bool casacore::String::contains ( const Char s) const
inline

Definition at line 703 of file String.h.

Bool casacore::String::contains ( const RegexBase r) const
Bool casacore::String::contains ( Char  c,
Int  pos 
) const
inline

Does the string starting at the given position contain the given substring? If the position is negative, it is counted from the end.

Casacore addition

Definition at line 1023 of file String.h.

Bool casacore::String::contains ( const string &  str,
Int  pos 
) const
inline

Definition at line 1025 of file String.h.

Bool casacore::String::contains ( const Char s,
Int  pos 
) const
inline

Definition at line 1027 of file String.h.

Bool casacore::String::contains ( const RegexBase r,
Int  pos 
) const
inline

Definition at line 1029 of file String.h.

size_type casacore::String::copy ( Char s,
size_type  n,
size_type  pos = 0 
) const
inline

Copy.

Thrown Exceptions

  • out_of_range if pos > size()

Definition at line 546 of file String.h.

References casacore::copy().

const Char* casacore::String::data ( ) const
inline

As pointer to char array.

Definition at line 557 of file String.h.

References casa::data.

void casacore::String::del ( size_type  pos,
size_type  len 
)

Delete len chars starting at pos.

** Casacore addition

void casacore::String::del ( const string &  str,
size_type  startpos = 0 
)

Delete the first occurrence of target after startpos.

** Casacore addition

void casacore::String::del ( const Char s,
size_type  startpos = 0 
)
void casacore::String::del ( Char  c,
size_type  startpos = 0 
)
void casacore::String::del ( const RegexBase r,
size_type  startpos = 0 
)
void casacore::String::del ( Int  pos,
Int  len 
)
inline

Overload problem.

Definition at line 865 of file String.h.

void casacore::String::downcase ( )

internal transformation to lowercase of String

Referenced by casa::vi::PolAverageVi2Factory::GetAverageModeFromConfig(), and casa::PlotKeyEvent::modifier().

const_reference casacore::String::elem ( size_type  pos) const
inline

*** Casacore addition

Definition at line 320 of file String.h.

Bool casacore::String::empty ( ) const
inline
iterator casacore::String::end ( )
inline

Definition at line 332 of file String.h.

References casa::vi::end().

Referenced by clear().

const_iterator casacore::String::end ( ) const
inline

Definition at line 333 of file String.h.

References casa::vi::end().

String& casacore::String::erase ( size_type  pos,
size_type  n = npos 
)
inline

Erase.

Definition at line 497 of file String.h.

iterator casacore::String::erase ( iterator  position)
inline

Definition at line 499 of file String.h.

iterator casacore::String::erase ( iterator  first,
iterator  last 
)
inline

Definition at line 501 of file String.h.

size_type casacore::String::find ( const string &  str,
size_type  pos = 0 
) const
inline

Search functions.

Returns either npos (if not found); else position.
Warning: The RegexBase ones are ** Casacore additions

Definition at line 644 of file String.h.

Referenced by casa::CubePartitionMixin< T >::get_params(), casa::ScantableFieldIterator::getEntry(), and startsWith().

size_type casacore::String::find ( const Char s,
size_type  pos = 0 
) const
inline

Definition at line 646 of file String.h.

size_type casacore::String::find ( const Char s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 648 of file String.h.

size_type casacore::String::find ( Char  c,
size_type  pos = 0 
) const
inline

Definition at line 650 of file String.h.

size_type casacore::String::find ( const RegexBase r,
size_type  pos = 0 
) const
size_type casacore::String::find_first_not_of ( const string &  str,
size_type  pos = 0 
) const
inline

Definition at line 678 of file String.h.

size_type casacore::String::find_first_not_of ( const Char s,
size_type  pos = 0 
) const
inline

Definition at line 680 of file String.h.

size_type casacore::String::find_first_not_of ( const Char s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 682 of file String.h.

size_type casacore::String::find_first_not_of ( Char  c,
size_type  pos = 0 
) const
inline

Definition at line 684 of file String.h.

size_type casacore::String::find_first_of ( const string &  str,
size_type  pos = 0 
) const
inline

Definition at line 662 of file String.h.

size_type casacore::String::find_first_of ( const Char s,
size_type  pos = 0 
) const
inline

Definition at line 664 of file String.h.

size_type casacore::String::find_first_of ( const Char s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 666 of file String.h.

size_type casacore::String::find_first_of ( Char  c,
size_type  pos = 0 
) const
inline

Definition at line 668 of file String.h.

size_type casacore::String::find_last_not_of ( const string &  str,
size_type  pos = npos 
) const
inline

Definition at line 686 of file String.h.

size_type casacore::String::find_last_not_of ( const Char s,
size_type  pos = npos 
) const
inline

Definition at line 688 of file String.h.

size_type casacore::String::find_last_not_of ( const Char s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 690 of file String.h.

size_type casacore::String::find_last_not_of ( Char  c,
size_type  pos = npos 
) const
inline

Definition at line 692 of file String.h.

size_type casacore::String::find_last_of ( const string &  str,
size_type  pos = npos 
) const
inline

Definition at line 670 of file String.h.

size_type casacore::String::find_last_of ( const Char s,
size_type  pos = npos 
) const
inline

Definition at line 672 of file String.h.

size_type casacore::String::find_last_of ( const Char s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 674 of file String.h.

size_type casacore::String::find_last_of ( Char  c,
size_type  pos = npos 
) const
inline

Definition at line 676 of file String.h.

Char casacore::String::firstchar ( ) const
inline

Definition at line 322 of file String.h.

References at().

static String casacore::String::format ( const char *  picture,
  ... 
)
static

Create a formatted string using the given printf format string.

Referenced by casa::vi::VbCacheItem< casacore::Int >::fill(), and casacore::ColumnSlicer::validateParameters().

Int casacore::String::freq ( Char  c) const

Return the number of occurences of target in String.

** Casacore addition

Int casacore::String::freq ( const string &  str) const
Int casacore::String::freq ( const Char s) const
SubString casacore::String::from ( size_type  pos)

Start at startpos and extract the SubString "from" the argument's position, inclusive, to the String's end.

** Casacore addition

SubString casacore::String::from ( const string &  str,
size_type  startpos = 0 
)
SubString casacore::String::from ( const Char s,
size_type  startpos = 0 
)
SubString casacore::String::from ( Char  c,
size_type  startpos = 0 
)
SubString casacore::String::from ( const RegexBase r,
size_type  startpos = 0 
)
SubString casacore::String::from ( Int  pos)
inline

Next one for overloading reasons.

Definition at line 824 of file String.h.

template<typename T >
Bool casacore::String::fromString ( T &  value,
Bool  chk = True 
) const
inline

Convert a String to a value.

All characters in the string must be used. It uses a shift from an ostringstream, so that operator must exist for the data type used.
In case of an error, an exception is thrown if chk is set. Otherwise it returns False and value contains the value read so far.

Definition at line 583 of file String.h.

References casacore::False, throwFromStringError(), casacore::True, and casacore::value().

template<typename T >
T casacore::String::fromString ( ) const
inline

Definition at line 593 of file String.h.

References casacore::value().

allocator_type casacore::String::get_allocator ( ) const
inline

Get allocator used
Warning: gcc has no get_allocator()

Definition at line 564 of file String.h.

Int casacore::String::gsub ( const string &  pat,
const string &  repl 
)

Global substitution: substitute all occurrences of pat with repl, and return the number of replacements.

Casacore addition

Int casacore::String::gsub ( const Char pat,
const string &  repl 
)
Int casacore::String::gsub ( const Char pat,
const Char repl 
)
Int casacore::String::gsub ( const RegexBase pat,
const string &  repl 
)
size_type casacore::String::index ( Char  c,
Int  startpos = 0 
) const
inline

Return the position of the target in the string or npos for failure.

Casacore addition

Definition at line 739 of file String.h.

size_type casacore::String::index ( const string &  str,
Int  startpos = 0 
) const
inline

Definition at line 742 of file String.h.

size_type casacore::String::index ( const Char s,
Int  startpos = 0 
) const
inline

Definition at line 745 of file String.h.

size_type casacore::String::index ( const RegexBase r,
Int  startpos = 0 
) const
String& casacore::String::insert ( size_type  pos1,
const string &  str 
)
inline

Insert.

Thrown Exceptions

Definition at line 443 of file String.h.

String& casacore::String::insert ( size_type  pos1,
const string &  str,
size_type  pos2,
size_type  n 
)
inline

Definition at line 445 of file String.h.

String& casacore::String::insert ( size_type  pos,
const Char s,
size_type  n 
)
inline

Definition at line 448 of file String.h.

String& casacore::String::insert ( size_type  pos,
const Char s 
)
inline

Definition at line 450 of file String.h.

String& casacore::String::insert ( size_type  pos,
size_type  n,
Char  c 
)
inline

Definition at line 452 of file String.h.

String& casacore::String::insert ( size_type  pos,
Char  c 
)
inline

** Casacore addition

Definition at line 455 of file String.h.

iterator casacore::String::insert ( iterator  p,
Char  c 
)
inline

Definition at line 458 of file String.h.

void casacore::String::insert ( iterator  p,
size_type  n,
Char  c 
)
inline

Definition at line 460 of file String.h.

template<class InputIterator >
void casacore::String::insert ( iterator  p,
InputIterator  first,
InputIterator  last 
)
inline

Definition at line 463 of file String.h.

String& casacore::String::insert ( iterator  p,
const string &  str 
)
inline

** Casacore additions

Definition at line 467 of file String.h.

References begin().

String& casacore::String::insert ( iterator  p,
const Char s,
size_type  n 
)
inline

Definition at line 469 of file String.h.

References begin().

String& casacore::String::insert ( iterator  p,
const Char s 
)
inline

Definition at line 471 of file String.h.

References begin().

Char casacore::String::lastchar ( ) const
inline

Definition at line 323 of file String.h.

References at(), and length().

size_type casacore::String::length ( ) const
inline
void casacore::String::ltrim ( char  c)

Remove specified character from beginning of string.

If the character is repeated more than once on the left, all instances will be removed; e.g. ltrim(',') results in ",,xy" becoming "xy".

Bool casacore::String::matches ( const string &  str,
Int  pos = 0 
) const

Matches entire string from pos (or till pos if negative pos).

** Casacore addition

Referenced by casacore::TaqlRegex::match(), and matches().

Bool casacore::String::matches ( Char  c,
Int  pos = 0 
) const
inline

Definition at line 722 of file String.h.

References matches(), and String().

Bool casacore::String::matches ( const Char s,
Int  pos = 0 
) const
inline

Definition at line 724 of file String.h.

Bool casacore::String::matches ( const RegexBase r,
Int  pos = 0 
) const
size_type casacore::String::max_size ( ) const
inline

Definition at line 344 of file String.h.

SubString casacore::String::operator() ( size_type  pos,
size_type  len 
)
inline

Casacore addition: synonym for at(pos, len)

Definition at line 1019 of file String.h.

References casacore::SubString::String.

String& casacore::String::operator+= ( const string &  str)
inline

Concatenate.

Definition at line 301 of file String.h.

String& casacore::String::operator+= ( const Char s)
inline

Definition at line 303 of file String.h.

String& casacore::String::operator+= ( Char  c)
inline

Definition at line 305 of file String.h.

String& casacore::String::operator= ( const string &  str)
inline

Assignments (they are all deep copies according to standard)

Definition at line 288 of file String.h.

References casacore::operator=().

String& casacore::String::operator= ( const SubString str)
inline

Definition at line 290 of file String.h.

References String().

String& casacore::String::operator= ( const Char s)
inline

Definition at line 292 of file String.h.

References casacore::operator=().

String& casacore::String::operator= ( Char  c)
inline

Definition at line 294 of file String.h.

References casacore::operator=().

const_reference casacore::String::operator[] ( size_type  pos) const
inline

Indexing.

The standard version is undefined if pos > size(), or pos >= size() for non-const version.
Warning: The const_reference version needs the at() version for the gcc compiler: no const [] exists;

Definition at line 314 of file String.h.

reference casacore::String::operator[] ( size_type  pos)
inline

Definition at line 316 of file String.h.

void casacore::String::prepend ( const string &  str)

Concatenate by prepending the argument onto String.

** Casacore addition

void casacore::String::prepend ( const Char s)
void casacore::String::prepend ( Char  c)
reverse_iterator casacore::String::rbegin ( )
inline

Definition at line 334 of file String.h.

const_reverse_iterator casacore::String::rbegin ( ) const
inline

Definition at line 335 of file String.h.

reverse_iterator casacore::String::rend ( )
inline

Definition at line 336 of file String.h.

const_reverse_iterator casacore::String::rend ( ) const
inline

Definition at line 337 of file String.h.

String& casacore::String::replace ( size_type  pos1,
size_type  n1,
const string &  str 
)
inline

Replace.

Thrown Exceptions

Definition at line 511 of file String.h.

References casacore::replace().

String& casacore::String::replace ( size_type  pos1,
size_type  n1,
const string &  str,
size_type  pos2,
size_type  n2 
)
inline

Definition at line 513 of file String.h.

References casacore::replace().

String& casacore::String::replace ( size_type  pos,
size_type  n1,
const Char s,
size_type  n2 
)
inline

Definition at line 516 of file String.h.

References casacore::replace().

String& casacore::String::replace ( size_type  pos,
size_type  n1,
const Char s 
)
inline

Definition at line 518 of file String.h.

References casacore::replace().

String& casacore::String::replace ( size_type  pos,
size_type  n1,
size_type  n2,
Char  c 
)
inline

Definition at line 520 of file String.h.

References casacore::replace().

String& casacore::String::replace ( size_type  pos,
size_type  n1,
Char  c 
)
inline

** Casacore addition

Definition at line 523 of file String.h.

References casacore::replace().

String& casacore::String::replace ( iterator  i1,
iterator  i2,
const string &  str 
)
inline

Definition at line 525 of file String.h.

References casacore::replace().

String& casacore::String::replace ( iterator  i1,
iterator  i2,
const Char s,
size_type  n 
)
inline

Definition at line 527 of file String.h.

References casacore::replace().

String& casacore::String::replace ( iterator  i1,
iterator  i2,
const Char s 
)
inline

Definition at line 529 of file String.h.

References casacore::replace().

String& casacore::String::replace ( iterator  i1,
iterator  i2,
size_type  n,
Char  c 
)
inline

Definition at line 531 of file String.h.

References casacore::replace().

String& casacore::String::replace ( iterator  i1,
iterator  i2,
Char  c 
)
inline

** Casacore addition

Definition at line 534 of file String.h.

References casacore::replace().

template<class InputIterator >
String& casacore::String::replace ( iterator  i1,
iterator  i2,
InputIterator  j1,
InputIterator  j2 
)
inline

Definition at line 537 of file String.h.

References casacore::replace().

String& casacore::String::reserve ( size_type  res_arg = 0)
inline

Definition at line 363 of file String.h.

String& casacore::String::resize ( size_type  n)
inline

Resize by truncating or extending with copies of <tt>c</tt> (default 

Char())

Thrown Exceptions


Tip: The reserve length given is non-binding on the implementation

Definition at line 359 of file String.h.

Referenced by casa::sdfiller::DataChunk::setPolType(), and casa::PMS_PP_Display::xConnect().

String& casacore::String::resize ( size_type  n,
Char  c 
)
inline

Definition at line 361 of file String.h.

void casacore::String::reverse ( )

Maybe forget some.

** Casacore addition

internal transformation to reverse order of String.

size_type casacore::String::rfind ( const string &  str,
size_type  pos = npos 
) const
inline

Definition at line 653 of file String.h.

size_type casacore::String::rfind ( const Char s,
size_type  pos = npos 
) const
inline

Definition at line 655 of file String.h.

size_type casacore::String::rfind ( const Char s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 657 of file String.h.

size_type casacore::String::rfind ( Char  c,
size_type  pos = npos 
) const
inline

Definition at line 659 of file String.h.

size_type casacore::String::rfind ( const RegexBase r,
size_type  pos = npos 
) const
void casacore::String::rtrim ( char  c)

Remove specified character from end of string.

If the character is repeated more than once on the right, all instances will be removed; e.g. rtrim(',') results in "xy,," becoming "xy".

size_type casacore::String::size ( ) const
inline
Bool casacore::String::startsWith ( const string &  beginString) const
inline

Does the string start with the specified string?

Definition at line 638 of file String.h.

References find().

String casacore::String::substr ( size_type  pos = 0,
size_type  n = npos 
) const
inline

Get a sub string.

Thrown Exceptions

  • out_of_range if pos > size()

Definition at line 570 of file String.h.

References String().

Referenced by casa::ScantableFieldIterator::getEntry().

void casacore::String::swap ( string &  s)
inline

Swap.

Definition at line 550 of file String.h.

SubString casacore::String::through ( size_type  pos)

Start at startpos and extract the SubString "through" to the argument's position, inclusive.

** Casacore addition

SubString casacore::String::through ( const string &  str,
size_type  startpos = 0 
)
SubString casacore::String::through ( const Char s,
size_type  startpos = 0 
)
SubString casacore::String::through ( Char  c,
size_type  startpos = 0 
)
SubString casacore::String::through ( const RegexBase r,
size_type  startpos = 0 
)
SubString casacore::String::through ( Int  pos)
inline

Next one for overloading reasons.

Definition at line 811 of file String.h.

void casacore::String::throwFromStringError ( ) const
private

Helper function for fromString.

Referenced by fromString().

static Double casacore::String::toDouble ( const String s,
Bool  chk = False 
)
static
static Float casacore::String::toFloat ( const String s,
Bool  chk = False 
)
static
static Int casacore::String::toInt ( const String s,
Bool  chk = False 
)
static

Convert a string to an Int, Float or Double.


In case of an error, an exception is thrown if chk is set. Otherwise the value read so far is returned (0 if nothing read).

Referenced by casa::ScantableFieldIterator::getEntry().

template<typename T >
static String casacore::String::toString ( const T &  value)
inlinestatic
void casacore::String::trim ( )

Remove beginning and ending whitespace.

void casacore::String::trim ( char  c[],
uInt  n 
)

Remove specified chars from beginning and end of string.

void casacore::String::upcase ( )

internal transformation to uppercase of String

Referenced by casa::ImageRotator< T >::setInterpolationMethod().

Member Data Documentation

const size_type casacore::String::npos
static

Definition at line 244 of file String.h.

Referenced by casa::ScantableFieldIterator::getEntry().


The documentation for this class was generated from the following file: