casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions
casa::String Class Reference

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

#include <String.h>

Inherits string.

List of all members.

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.
 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.
 String (const Char *s, size_type n)
 Construct from char* with given length.
 String (const Char *s)
 Construct from char array.
 String (size_type n, Char c)
 Construct from a single char (repeated n times)
template<class InputIterator >
 String (InputIterator begin, InputIterator end)
 Construct from iterator.
 String (Char c)
 From single char (** aips++ addition).
 String (const SubString &str)
 Construct from a SubString.
 String (ostringstream &os)
 Construct from a stream.
 ~String ()
 Destructor.
Stringoperator= (const string &str)
 Assignments (they are all deep copies according to standard)
Stringoperator= (const SubString &str)
Stringoperator= (const Char *s)
Stringoperator= (Char c)
SubString operator() (size_type pos, size_type len)
 aips++ addition: synonym for at(pos, len)
Stringoperator+= (const string &str)
 Concatenate.
Stringoperator+= (const Char *s)
Stringoperator+= (Char c)
const_reference operator[] (size_type pos) const
 Indexing.
reference operator[] (size_type pos)
const_reference elem (size_type pos) const
 *** aips++ addition
Char firstchar () const
Char lastchar () const
iterator begin ()
 Iterators.
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.
size_type length () const
size_type max_size () const
size_type capacity () const
Int allocation () const
 ** aips++ addition -- works as a capacity(n) -- Note Int
Stringresize (size_type n)
 Resize by truncating or extending with copies of c (default Char())
Stringresize (size_type n, Char c)
Stringreserve (size_type res_arg=0)
void alloc (size_type n)
 ** aips++ addition -- works as a resize(n)
void clear ()
 Clear the string
Warning: clear() executed as erase() due to missing clear() in gcc

Bool empty () const
 Test for empty.
const_reference at (size_type n) const
 Addressing.
reference at (size_type n)
Stringappend (const string &str)
 Append.
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)
 ** aips++ addition
Stringassign (const string &str)
 Assign.
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)
 ** aips++ addition
Stringinsert (size_type pos1, const string &str)
 Insert.
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)
 ** aips++ addition
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)
 ** aips++ additions
Stringinsert (iterator p, const Char *s, size_type n)
Stringinsert (iterator p, const Char *s)
Int compare (const string &str) const
 Compare.
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.
iterator erase (iterator position)
iterator erase (iterator first, iterator last)
Stringreplace (size_type pos1, size_type n1, const string &str)
 Replace.
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)
 ** aips++ addition
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)
 ** aips++ addition
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.
void swap (string &s)
 Swap.
const Charc_str () const
 Get char array.
const Chardata () const
 As pointer to char array.
const Charchars () const
 ** aips++ synonym
allocator_type get_allocator () const
 Get allocator used
Warning: gcc has no get_allocator()

String substr (size_type pos=0, size_type n=npos) const
 Get a sub string.
void trim ()
 Remove beginning and ending whitespace.
void trim (char c[], uInt n)
 Remove specified chars from beginning and end of string.
void ltrim (char c)
 Remove specified character from beginning of string.
void rtrim (char c)
 Remove specified character from end of string.
Bool startsWith (const string &beginString) const
 Does the string start with the specified string?
size_type find (const string &str, size_type pos=0) const
 Search functions.
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=0) const
size_type rfind (const Char *s, size_type pos=0) const
size_type rfind (const Char *s, size_type pos, size_type n) const
size_type rfind (Char c, size_type pos=0) const
size_type rfind (const RegexBase &r, size_type pos=0) 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.
void capitalize ()
 internal transformation to capitalization of String.
void upcase ()
 internal transformation to uppercase of String
void downcase ()
 internal transformation to lowercase of String
void del (size_type pos, size_type len)
 Delete len chars starting at pos.
Bool contains (Char c) const
 Containment.
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
 Containment after (or before if pos negative) pos.
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).
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.
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.
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.
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.
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.
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)
 Start at startpos and extract the string "before" the argument's position, exclusive.
SubString before (const string &str, Int startpos=0)
SubString before (const Char *s, Int startpos=0)
SubString before (Char c, Int startpos=0)
SubString before (const RegexBase &r, Int startpos=0)
SubString before (Int pos)
 Next one for overloading reasons.
SubString through (size_type pos)
 Start at startpos and extract the SubString "through" to the argument's position, inclusive.
SubString through (const string &str, Int startpos=0)
SubString through (const Char *s, Int startpos=0)
SubString through (Char c, Int startpos=0)
SubString through (const RegexBase &r, Int startpos=0)
SubString through (Int pos)
 Next one for overloading reasons.
SubString from (size_type pos)
 Start at startpos and extract the SubString "from" the argument's position, inclusive, to the String's end.
SubString from (const string &str, Int startpos=0)
SubString from (const Char *s, Int startpos=0)
SubString from (Char c, Int startpos=0)
SubString from (const RegexBase &r, Int startpos=0)
SubString from (Int pos)
 Next one for overloading reasons.
SubString after (size_type pos)
 Start at startpos and extract the SubString "after" the argument's position, exclusive, to the String's end.
SubString after (const string &str, Int startpos=0)
SubString after (const Char *s, Int startpos=0)
SubString after (Char c, Int startpos=0)
SubString after (const RegexBase &r, Int startpos=0)
SubString after (Int pos)
 Next one for overloading reasons.
void del (const string &str, size_type startpos=0)
 Delete the first occurrence of target after startpos.
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.
Int gsub (const string &pat, const string &repl)
 Global substitution: substitute all occurrences of pat with repl, and return the number of replacements.
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 Double toDouble (const String &string)
 Convert a string to a Double.
static Float toFloat (const String &string)
 Convert a string to a Float.
static Int toInt (const String &string)
 Convert a string to an Int.
static String format (const char *picture,...)
 Create a formatted string using the given printf format string.
template<typename T >
static String toString (const T &value)
 Convert a value to a String.

Static Public Attributes

static const size_type npos

Private Member Functions

SubString _substr (size_type first, size_type l)
 Helper functions for at, before etc.

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 aips++ implementation of a string class. It is closely based on 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 aips++ 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 aips++ addition 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 AIPS++ environment.

To Do

Definition at line 223 of file String.h.


Member Typedef Documentation

typedef string::allocator_type casa::String::allocator_type

Definition at line 230 of file String.h.

typedef string::const_iterator casa::String::const_iterator

Definition at line 240 of file String.h.

typedef string::const_pointer casa::String::const_pointer

Definition at line 237 of file String.h.

typedef string::const_reference casa::String::const_reference

Definition at line 235 of file String.h.

typedef string::const_reverse_iterator casa::String::const_reverse_iterator

Definition at line 242 of file String.h.

typedef string::difference_type casa::String::difference_type

Definition at line 232 of file String.h.

typedef string::iterator casa::String::iterator

Definition at line 239 of file String.h.

typedef string::pointer casa::String::pointer

Definition at line 236 of file String.h.

typedef string::reference casa::String::reference

Definition at line 234 of file String.h.

typedef string::reverse_iterator casa::String::reverse_iterator

Definition at line 241 of file String.h.

typedef string::size_type casa::String::size_type

Definition at line 231 of file String.h.

typedef string::traits_type casa::String::traits_type

Definition at line 228 of file String.h.

typedef string::value_type casa::String::value_type

Definition at line 229 of file String.h.


Constructor & Destructor Documentation

casa::String::String ( ) [inline]

Default constructor.

Definition at line 248 of file String.h.

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

casa::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

  • out_of_range if pos > str.size()

Definition at line 254 of file String.h.

casa::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.

casa::String::String ( const Char s) [inline]

Construct from char array.

Definition at line 262 of file String.h.

casa::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 >
casa::String::String ( InputIterator  begin,
InputIterator  end 
) [inline]

Construct from iterator.

Definition at line 270 of file String.h.

casa::String::String ( Char  c) [inline, explicit]

From single char (** aips++ 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.

casa::String::String ( const SubString str) [inline]

Construct from a SubString.

Definition at line 277 of file String.h.

casa::String::String ( ostringstream &  os)

Construct from a stream.

casa::String::~String ( ) [inline]

Destructor.

Definition at line 283 of file String.h.


Member Function Documentation

SubString casa::String::_substr ( size_type  first,
size_type  l 
) [inline, private]

Helper functions for at, before etc.

Definition at line 858 of file String.h.

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

** aips++ addition

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

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

Next one for overloading reasons.

Definition at line 804 of file String.h.

void casa::String::alloc ( size_type  n) [inline]

** aips++ addition -- works as a resize(n)

Definition at line 366 of file String.h.

References resize().

Int casa::String::allocation ( ) const [inline]

** aips++ addition -- works as a capacity(n) -- Note Int

Definition at line 347 of file String.h.

References capacity().

String& casa::String::append ( const string &  str) [inline]

Append.

Thrown Exceptions

  • out_of_range if pos > str.size()
  • length_error if new size() >= npos


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.

Referenced by append().

String& casa::String::append ( const string &  str,
size_type  pos,
size_type  n 
) [inline]

Definition at line 398 of file String.h.

References append().

String& casa::String::append ( const Char s,
size_type  n 
) [inline]

Definition at line 400 of file String.h.

References append().

String& casa::String::append ( const Char s) [inline]

Definition at line 402 of file String.h.

References append().

String& casa::String::append ( size_type  n,
Char  c 
) [inline]

Definition at line 404 of file String.h.

References append().

template<class InputIterator >
String& casa::String::append ( InputIterator  first,
InputIterator  last 
) [inline]

Definition at line 407 of file String.h.

References append().

String& casa::String::append ( Char  c) [inline]

** aips++ addition

Definition at line 410 of file String.h.

References append().

String& casa::String::assign ( const string &  str) [inline]

Assign.

Thrown Exceptions

  • out_of_range if pos > str.size()

Definition at line 419 of file String.h.

Referenced by assign().

String& casa::String::assign ( const string &  str,
size_type  pos,
size_type  n 
) [inline]

Definition at line 421 of file String.h.

References assign().

String& casa::String::assign ( const Char s,
size_type  n 
) [inline]

Definition at line 423 of file String.h.

References assign().

String& casa::String::assign ( const Char s) [inline]

Definition at line 425 of file String.h.

References assign().

String& casa::String::assign ( size_type  n,
Char  c 
) [inline]

Definition at line 427 of file String.h.

References assign().

template<class InputIterator >
String& casa::String::assign ( InputIterator  first,
InputIterator  last 
) [inline]

Definition at line 430 of file String.h.

References assign().

String& casa::String::assign ( Char  c) [inline]

** aips++ addition

Definition at line 433 of file String.h.

References assign().

Addressing.

Thrown Exceptions

  • out_of_range if pos >= size()

Definition at line 382 of file String.h.

Referenced by at(), elem(), firstchar(), lastchar(), and operator[]().

Definition at line 383 of file String.h.

References at().

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

** aips++ addition

String casa::String::at ( size_type  pos,
size_type  len 
) const [inline]

Definition at line 727 of file String.h.

SubString casa::String::at ( const string &  str,
Int  startpos = 0 
)
String casa::String::at ( const string &  str,
Int  startpos = 0 
) const
SubString casa::String::at ( const Char s,
Int  startpos = 0 
)
String casa::String::at ( const Char s,
Int  startpos = 0 
) const
SubString casa::String::at ( Char  c,
Int  startpos = 0 
)
String casa::String::at ( Char  c,
Int  startpos = 0 
) const
SubString casa::String::at ( const RegexBase r,
Int  startpos = 0 
)
String casa::String::at ( const RegexBase r,
Int  startpos = 0 
) const
SubString casa::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 740 of file String.h.

String casa::String::at ( Int  pos,
Int  len 
) const [inline]

Definition at line 743 of file String.h.

SubString casa::String::at ( Int  pos,
size_type  len 
) [inline]

Definition at line 746 of file String.h.

String casa::String::at ( Int  pos,
size_type  len 
) const [inline]

Definition at line 749 of file String.h.

Start at startpos and extract the string "before" the argument's position, exclusive.

** aips++ addition

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

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

Next one for overloading reasons.

Definition at line 764 of file String.h.

Iterators.

Definition at line 330 of file String.h.

Referenced by begin(), clear(), and insert().

const_iterator casa::String::begin ( ) const [inline]

Definition at line 331 of file String.h.

References begin().

const Char* casa::String::c_str ( ) const [inline]
size_type casa::String::capacity ( ) const [inline]

Definition at line 345 of file String.h.

Referenced by allocation().

internal transformation to capitalization of String.

const Char* casa::String::chars ( ) const [inline]

** aips++ synonym

Definition at line 559 of file String.h.

References c_str().

Referenced by casa::VariableArrayFITSFieldCopier< recordType, fitsType >::copyToFITS(), and casa::GLPCDisplayListElement::name().

void casa::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(), end(), and erase().

Int casa::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.

Referenced by compare().

Int casa::String::compare ( size_type  pos1,
size_type  n1,
const string &  str 
) const [inline]

Definition at line 483 of file String.h.

References String().

Int casa::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 casa::String::compare ( const Char s) const [inline]

Definition at line 488 of file String.h.

References compare().

Int casa::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 casa::String::contains ( Char  c) const [inline]

Containment.

** aips++ addition

Definition at line 667 of file String.h.

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

Bool casa::String::contains ( const string &  str) const [inline]

Definition at line 669 of file String.h.

Bool casa::String::contains ( const Char s) const [inline]

Definition at line 671 of file String.h.

Bool casa::String::contains ( const RegexBase r) const
Bool casa::String::contains ( Char  c,
Int  pos 
) const [inline]

Containment after (or before if pos negative) pos.

** aips++ addition

Definition at line 995 of file String.h.

Bool casa::String::contains ( const string &  str,
Int  pos 
) const [inline]

Definition at line 997 of file String.h.

Bool casa::String::contains ( const Char s,
Int  pos 
) const [inline]

Definition at line 999 of file String.h.

Bool casa::String::contains ( const RegexBase r,
Int  pos 
) const [inline]

Definition at line 1001 of file String.h.

size_type casa::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.

const Char* casa::String::data ( ) const [inline]

As pointer to char array.

Definition at line 557 of file String.h.

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

Delete len chars starting at pos.

** aips++ addition

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

Delete the first occurrence of target after startpos.

** aips++ addition

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

Overload problem.

Definition at line 831 of file String.h.

internal transformation to lowercase of String

Referenced by casa::PlotKeyEvent::modifier().

const_reference casa::String::elem ( size_type  pos) const [inline]

*** aips++ addition

Definition at line 320 of file String.h.

References at().

Bool casa::String::empty ( ) const [inline]

Definition at line 332 of file String.h.

Referenced by clear(), and end().

const_iterator casa::String::end ( ) const [inline]

Definition at line 333 of file String.h.

References end().

String& casa::String::erase ( size_type  pos,
size_type  n = npos 
) [inline]

Erase.

Definition at line 497 of file String.h.

Referenced by clear(), and erase().

iterator casa::String::erase ( iterator  position) [inline]

Definition at line 499 of file String.h.

References erase().

iterator casa::String::erase ( iterator  first,
iterator  last 
) [inline]

Definition at line 501 of file String.h.

References erase().

size_type casa::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 ** aips++ additions

Definition at line 612 of file String.h.

Referenced by find(), rfind(), and startsWith().

size_type casa::String::find ( const Char s,
size_type  pos = 0 
) const [inline]

Definition at line 614 of file String.h.

References find().

size_type casa::String::find ( const Char s,
size_type  pos,
size_type  n 
) const [inline]

Definition at line 616 of file String.h.

References find().

size_type casa::String::find ( Char  c,
size_type  pos = 0 
) const [inline]

Definition at line 618 of file String.h.

References find().

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

Definition at line 646 of file String.h.

Referenced by find_first_not_of().

size_type casa::String::find_first_not_of ( const Char s,
size_type  pos = 0 
) const [inline]

Definition at line 648 of file String.h.

References find_first_not_of().

size_type casa::String::find_first_not_of ( const Char s,
size_type  pos,
size_type  n 
) const [inline]

Definition at line 650 of file String.h.

References find_first_not_of().

size_type casa::String::find_first_not_of ( Char  c,
size_type  pos = 0 
) const [inline]

Definition at line 652 of file String.h.

References find_first_not_of().

size_type casa::String::find_first_of ( const string &  str,
size_type  pos = 0 
) const [inline]

Definition at line 630 of file String.h.

Referenced by find_first_of().

size_type casa::String::find_first_of ( const Char s,
size_type  pos = 0 
) const [inline]

Definition at line 632 of file String.h.

References find_first_of().

size_type casa::String::find_first_of ( const Char s,
size_type  pos,
size_type  n 
) const [inline]

Definition at line 634 of file String.h.

References find_first_of().

size_type casa::String::find_first_of ( Char  c,
size_type  pos = 0 
) const [inline]

Definition at line 636 of file String.h.

References find_first_of().

size_type casa::String::find_last_not_of ( const string &  str,
size_type  pos = npos 
) const [inline]

Definition at line 654 of file String.h.

Referenced by find_last_not_of().

size_type casa::String::find_last_not_of ( const Char s,
size_type  pos = npos 
) const [inline]

Definition at line 656 of file String.h.

References find_last_not_of().

size_type casa::String::find_last_not_of ( const Char s,
size_type  pos,
size_type  n 
) const [inline]

Definition at line 658 of file String.h.

References find_last_not_of().

size_type casa::String::find_last_not_of ( Char  c,
size_type  pos = npos 
) const [inline]

Definition at line 660 of file String.h.

References find_last_not_of().

size_type casa::String::find_last_of ( const string &  str,
size_type  pos = npos 
) const [inline]

Definition at line 638 of file String.h.

Referenced by find_last_of().

size_type casa::String::find_last_of ( const Char s,
size_type  pos = npos 
) const [inline]

Definition at line 640 of file String.h.

References find_last_of().

size_type casa::String::find_last_of ( const Char s,
size_type  pos,
size_type  n 
) const [inline]

Definition at line 642 of file String.h.

References find_last_of().

size_type casa::String::find_last_of ( Char  c,
size_type  pos = npos 
) const [inline]

Definition at line 644 of file String.h.

References find_last_of().

Char casa::String::firstchar ( ) const [inline]

Definition at line 322 of file String.h.

References at().

static String casa::String::format ( const char *  picture,
  ... 
) [static]

Create a formatted string using the given printf format string.

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

Return the number of occurences of target in String.

** aips++ addition

Int casa::String::freq ( const string &  str) const
Int casa::String::freq ( const Char s) const

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

** aips++ addition

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

Next one for overloading reasons.

Definition at line 790 of file String.h.

Get allocator used
Warning: gcc has no get_allocator()

Definition at line 564 of file String.h.

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

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

aips++ addition

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

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

aips++ addition

Definition at line 705 of file String.h.

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

Definition at line 708 of file String.h.

size_type casa::String::index ( const Char s,
Int  startpos = 0 
) const [inline]

Definition at line 711 of file String.h.

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

Insert.

Thrown Exceptions

  • out_of_range if pos1 > str.size() or pos2 > str.size()
  • length_error if new size() >= npos

Definition at line 443 of file String.h.

Referenced by insert().

String& casa::String::insert ( size_type  pos1,
const string &  str,
size_type  pos2,
size_type  n 
) [inline]

Definition at line 445 of file String.h.

References insert().

String& casa::String::insert ( size_type  pos,
const Char s,
size_type  n 
) [inline]

Definition at line 448 of file String.h.

References insert().

String& casa::String::insert ( size_type  pos,
const Char s 
) [inline]

Definition at line 450 of file String.h.

References insert().

String& casa::String::insert ( size_type  pos,
size_type  n,
Char  c 
) [inline]

Definition at line 452 of file String.h.

References insert().

String& casa::String::insert ( size_type  pos,
Char  c 
) [inline]

** aips++ addition

Definition at line 455 of file String.h.

References insert().

iterator casa::String::insert ( iterator  p,
Char  c 
) [inline]

Definition at line 458 of file String.h.

References insert().

void casa::String::insert ( iterator  p,
size_type  n,
Char  c 
) [inline]

Definition at line 460 of file String.h.

References insert().

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

Definition at line 463 of file String.h.

References insert().

String& casa::String::insert ( iterator  p,
const string &  str 
) [inline]

** aips++ additions

Definition at line 467 of file String.h.

References begin(), and insert().

String& casa::String::insert ( iterator  p,
const Char s,
size_type  n 
) [inline]

Definition at line 469 of file String.h.

References begin(), and insert().

String& casa::String::insert ( iterator  p,
const Char s 
) [inline]

Definition at line 471 of file String.h.

References begin(), and insert().

Char casa::String::lastchar ( ) const [inline]

Definition at line 323 of file String.h.

References at(), and length().

size_type casa::String::length ( ) const [inline]
void casa::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 casa::String::matches ( const string &  str,
Int  pos = 0 
) const

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

** aips++ addition

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

Bool casa::String::matches ( Char  c,
Int  pos = 0 
) const [inline]

Definition at line 688 of file String.h.

References matches(), and String().

Bool casa::String::matches ( const Char s,
Int  pos = 0 
) const [inline]

Definition at line 690 of file String.h.

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

Definition at line 344 of file String.h.

SubString casa::String::operator() ( size_type  pos,
size_type  len 
) [inline]

aips++ addition: synonym for at(pos, len)

Definition at line 991 of file String.h.

References casa::SubString::String.

String& casa::String::operator+= ( const string &  str) [inline]

Concatenate.

Definition at line 301 of file String.h.

Referenced by operator+=().

String& casa::String::operator+= ( const Char s) [inline]

Definition at line 303 of file String.h.

References operator+=().

String& casa::String::operator+= ( Char  c) [inline]

Definition at line 305 of file String.h.

References operator+=().

String& casa::String::operator= ( const string &  str) [inline]

Assignments (they are all deep copies according to standard)

Definition at line 288 of file String.h.

Referenced by operator=().

String& casa::String::operator= ( const SubString str) [inline]

Definition at line 290 of file String.h.

References String().

String& casa::String::operator= ( const Char s) [inline]

Definition at line 292 of file String.h.

References operator=().

String& casa::String::operator= ( Char  c) [inline]

Definition at line 294 of file String.h.

References operator=().

const_reference casa::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.

References at().

Referenced by operator[]().

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

Definition at line 316 of file String.h.

References operator[]().

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

Concatenate by prepending the argument onto String.

** aips++ addition

void casa::String::prepend ( const Char s)

Definition at line 334 of file String.h.

Referenced by rbegin().

Definition at line 335 of file String.h.

References rbegin().

Definition at line 336 of file String.h.

Referenced by rend().

Definition at line 337 of file String.h.

References rend().

String& casa::String::replace ( size_type  pos1,
size_type  n1,
const string &  str 
) [inline]

Replace.

Thrown Exceptions

  • out_of_range if pos1 > str.size() or pos2 > str.size()
  • length_error if new size() > npos

Definition at line 511 of file String.h.

Referenced by replace().

String& casa::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 replace().

String& casa::String::replace ( size_type  pos,
size_type  n1,
const Char s,
size_type  n2 
) [inline]

Definition at line 516 of file String.h.

References replace().

String& casa::String::replace ( size_type  pos,
size_type  n1,
const Char s 
) [inline]

Definition at line 518 of file String.h.

References replace().

String& casa::String::replace ( size_type  pos,
size_type  n1,
size_type  n2,
Char  c 
) [inline]

Definition at line 520 of file String.h.

References replace().

String& casa::String::replace ( size_type  pos,
size_type  n1,
Char  c 
) [inline]

** aips++ addition

Definition at line 523 of file String.h.

References replace().

String& casa::String::replace ( iterator  i1,
iterator  i2,
const string &  str 
) [inline]

Definition at line 525 of file String.h.

References replace().

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

Definition at line 527 of file String.h.

References replace().

String& casa::String::replace ( iterator  i1,
iterator  i2,
const Char s 
) [inline]

Definition at line 529 of file String.h.

References replace().

String& casa::String::replace ( iterator  i1,
iterator  i2,
size_type  n,
Char  c 
) [inline]

Definition at line 531 of file String.h.

References replace().

String& casa::String::replace ( iterator  i1,
iterator  i2,
Char  c 
) [inline]

** aips++ addition

Definition at line 534 of file String.h.

References replace().

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

Definition at line 537 of file String.h.

References replace().

String& casa::String::reserve ( size_type  res_arg = 0) [inline]

Definition at line 363 of file String.h.

Resize by truncating or extending with copies of c (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 alloc(), and resize().

String& casa::String::resize ( size_type  n,
Char  c 
) [inline]

Definition at line 361 of file String.h.

References resize().

Maybe forget some.

** aips++ addition

 internal transformation to reverse order of String.  
size_type casa::String::rfind ( const string &  str,
size_type  pos = 0 
) const [inline]

Definition at line 621 of file String.h.

References find().

Referenced by rfind().

size_type casa::String::rfind ( const Char s,
size_type  pos = 0 
) const [inline]

Definition at line 623 of file String.h.

References rfind().

size_type casa::String::rfind ( const Char s,
size_type  pos,
size_type  n 
) const [inline]

Definition at line 625 of file String.h.

References rfind().

size_type casa::String::rfind ( Char  c,
size_type  pos = 0 
) const [inline]

Definition at line 627 of file String.h.

References rfind().

size_type casa::String::rfind ( const RegexBase r,
size_type  pos = 0 
) const
void casa::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 casa::String::size ( ) const [inline]

Capacity, size.

Definition at line 342 of file String.h.

Referenced by casa::RSLine::arrowType().

Bool casa::String::startsWith ( const string &  beginString) const [inline]

Does the string start with the specified string?

Definition at line 606 of file String.h.

References find().

String casa::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().

void casa::String::swap ( string &  s) [inline]

Swap.

Definition at line 550 of file String.h.

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

** aips++ addition

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

Next one for overloading reasons.

Definition at line 777 of file String.h.

static Double casa::String::toDouble ( const String string) [static]

Convert a string to a Double.

If the specified string does not represent a Double, 0 is returned.

static Float casa::String::toFloat ( const String string) [static]

Convert a string to a Float.

If the specified string does not represent a Float, 0 is returned.

static Int casa::String::toInt ( const String string) [static]

Convert a string to an Int.

If the specified string does not represent an Int, 0 is returned.

template<typename T >
static String casa::String::toString ( const T &  value) [inline, static]

Convert a value to a String.

It uses a shift into an ostringstream, so that operator must be defined for the data type used.

Definition at line 848 of file String.h.

References casa::value().

Remove beginning and ending whitespace.

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

Remove specified chars from beginning and end of string.

internal transformation to uppercase of String


Member Data Documentation

const size_type casa::String::npos [static]

Definition at line 244 of file String.h.


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