casacore
Loading...
Searching...
No Matches
casacore::String Class Reference

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

#include <String.h>

Public Member Functions

 String ()=default
 Default constructor.
 String (const std::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 (** Casacore addition).
 String (const SubString &str)
 Construct from a SubString.
 String (std::ostringstream &os)
 Construct from a stream.
 ~String ()=default
 Destructor.
String & operator= (const std::string &str)
 Assignments (they are all deep copies according to standard).
String & operator= (const SubString &str)
String & operator= (const char *s)
String & operator= (char c)
SubString operator() (size_type pos, size_type len)
 Casacore addition: synonym for at(pos, len).
const_reference elem (size_type pos) const
 *** Casacore addition
char firstchar () const
char lastchar () const
int allocation () const
 ** Casacore addition – works as a capacity(n) – Note Int
void alloc (size_type n)
 ** Casacore addition – works as a resize(n)
std::string & append (char c)
 ** Casacore addition
String & assign (char c)
 ** Casacore addition
String & insert (size_type pos, char c)
 ** Casacore addition
String & replace (size_type pos, size_type n1, char c)
 ** Casacore addition
String & replace (iterator i1, iterator i2, char c)
 ** Casacore addition
const char * chars () const
 ** Casacore synonym
 DEPRECATED ("Use std::format if possible, or FormatString() if the format string can't be changed (e.g. " "runtime determined)") static String format(const char *picture
 Create a formatted string using the given printf format string.
template<typename T>
bool fromString (T &value, bool throw_on_error=true) const
 Convert a String to a value.
template<typename T>
T fromString () const
void trim ()
 Remove beginning and ending whitespace.
void trim (char c[], unsigned int 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 std::string &beginString) const
 Does the string start with the specified string?
size_type find (const Regex &r, size_type pos=0) const
bool contains (char c) const
 Containment.
DEPRECATED("Use find(str) != npos or StringContains()") bool contains(const std DEPRECATED ("Use find(), rfind() or IndexString()") bool contains(char c
 Does the string starting at the given position contain the given substring?
DEPRECATED("Use find(), rfind(), IndexString() and/or StringContains()") bool contains(const std DEPRECATED ("Use substr(pos) == str if possible, consider ends_with() / starts_with() for " "positive/negative pos or use EqualStringsAndNotEmpty() if direct replacement is necessary") bool matches(char c
 Matches entire string from pos, or till pos if negative pos.
void prepend (const char *str)
void prepend (char c)
 DEPRECATED ("Use find() or rfind(), or IndexString() if the search direction is runtime-dependent") size_type index(char c
 Return the position of the target in the string or npos for failure.
int freq (char c) const
 Return the number of occurences of target in String.
int freq (const std::string &str) const
int freq (const char *s) const
SubString at (size_type pos, size_type len)
String at (size_type pos, size_type len) const
SubString at (const std::string &str, int startpos=0)
String at (const std::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 Regex &r, int startpos=0)
String at (const Regex &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
 DEPRECATED ("Use substr(0, pos) or create a view. Also consider if str.start_with() suffices.") SubString before(size_type pos)
 Start at startpos and extract the string "before" the argument's position, exclusive.
SubString before (const std::string &str, size_type startpos=0)
SubString before (const char *s, size_type startpos=0)
SubString before (char c, size_type startpos=0)
SubString before (const Regex &r, size_type 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 std::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 Regex &r, size_type 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 std::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 Regex &r, size_type 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 std::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 Regex &r, size_type startpos=0)
SubString after (int pos)
 Next one for overloading reasons.
 DEPRECATED ("Use std::reverse(str.begin(), str.end())") 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.
void del (const std::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 Regex &r, size_type startpos=0)
void del (int pos, int len)
 Overload problem.
int gsub (const std::string &pat, const std::string &repl)
 Global substitution: substitute all occurrences of pat with repl, and return the number of replacements.
int gsub (const char *pat, const std::string &repl)
int gsub (const char *pat, const char *repl)
int gsub (const Regex &pat, const std::string &repl)

Static Public Member Functions

static int toInt (const String &s, bool chk=false)
 Convert a string to an Int, Float or Double.
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.

Public Attributes

DEPRECATED("Use find(str) != npos or StringContains()") bool contains(const std int pos const
DEPRECATED("Use find(), rfind(), IndexString() and/or StringContains()") bool contains(const std int pos
int startpos

Private Member Functions

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

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

  • Regex - the regular expressions class
  • the std string class

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; Regex 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(" ");
String()=default
Default constructor.
bool contains(char c) const
Containment.
Definition String.h:554
int freq(char c) const
Return the number of occurences of target in String.

Motivation

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

To Do

  • if old string disappeared; remove the alloc() call.
  • add more tests (for string methods) when old String disappears

Definition at line 355 of file String.h.

Constructor & Destructor Documentation

◆ String() [1/9]

casacore::String::String ( )
default

◆ String() [2/9]

casacore::String::String ( const std::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 365 of file String.h.

References pos.

◆ String() [3/9]

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 371 of file String.h.

◆ String() [4/9]

casacore::String::String ( const char * s)
inline

Construct from char array.

Definition at line 373 of file String.h.

◆ String() [5/9]

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 378 of file String.h.

◆ String() [6/9]

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

Construct from iterator.

Definition at line 381 of file String.h.

References casacore::begin(), and casacore::end().

◆ String() [7/9]

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 387 of file String.h.

References String().

◆ String() [8/9]

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

Construct from a SubString.

Definition at line 389 of file String.h.

◆ String() [9/9]

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

Construct from a stream.

References String().

◆ ~String()

casacore::String::~String ( )
default

Destructor.

References String().

Member Function Documentation

◆ _substr()

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

Helper functions for at, before etc.

Definition at line 803 of file String.h.

References first.

◆ after() [1/6]

SubString casacore::String::after ( char c,
size_type startpos = 0 )

References after(), DEPRECATED(), and startpos.

◆ after() [2/6]

SubString casacore::String::after ( const char * s,
size_type startpos = 0 )

References after(), const, DEPRECATED(), and startpos.

◆ after() [3/6]

SubString casacore::String::after ( const Regex & r,
size_type startpos = 0 )

References after(), const, DEPRECATED(), and startpos.

◆ after() [4/6]

SubString casacore::String::after ( const std::string & str,
size_type startpos = 0 )

References after(), const, DEPRECATED(), and startpos.

◆ after() [5/6]

SubString casacore::String::after ( int pos)
inline

Next one for overloading reasons.

Definition at line 749 of file String.h.

References after(), after(), and pos.

Referenced by after().

◆ after() [6/6]

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

References after(), DEPRECATED(), and pos.

Referenced by after(), after(), after(), after(), after(), and after().

◆ alloc()

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

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

Definition at line 428 of file String.h.

References alloc().

Referenced by alloc().

◆ allocation()

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

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

Definition at line 424 of file String.h.

References allocation().

Referenced by allocation().

◆ append()

std::string & casacore::String::append ( char c)
inline

** Casacore addition

Definition at line 432 of file String.h.

References append().

Referenced by append(), casacore::operator+(), casacore::operator+(), casacore::operator+(), casacore::operator+(), and casacore::operator+().

◆ assign()

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

** Casacore addition

Definition at line 437 of file String.h.

References assign(), and String().

Referenced by assign().

◆ at() [1/14]

SubString casacore::String::at ( char c,
int startpos = 0 )

References at(), DEPRECATED(), and startpos.

◆ at() [2/14]

String casacore::String::at ( char c,
int startpos = 0 ) const

References at(), const, DEPRECATED(), startpos, and String().

◆ at() [3/14]

SubString casacore::String::at ( const char * s,
int startpos = 0 )

References at(), const, DEPRECATED(), and startpos.

◆ at() [4/14]

String casacore::String::at ( const char * s,
int startpos = 0 ) const

References at(), const, DEPRECATED(), startpos, and String().

◆ at() [5/14]

SubString casacore::String::at ( const Regex & r,
int startpos = 0 )

References at(), const, DEPRECATED(), and startpos.

◆ at() [6/14]

String casacore::String::at ( const Regex & r,
int startpos = 0 ) const

References at(), const, DEPRECATED(), startpos, and String().

◆ at() [7/14]

SubString casacore::String::at ( const std::string & str,
int startpos = 0 )

References at(), const, DEPRECATED(), and startpos.

◆ at() [8/14]

String casacore::String::at ( const std::string & str,
int startpos = 0 ) const

References at(), const, DEPRECATED(), startpos, and String().

◆ at() [9/14]

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 665 of file String.h.

References at(), and pos.

◆ at() [10/14]

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

Definition at line 669 of file String.h.

References at(), pos, and String().

◆ at() [11/14]

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

Definition at line 673 of file String.h.

References at(), at(), and pos.

Referenced by at().

◆ at() [12/14]

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

Definition at line 675 of file String.h.

References at(), at(), pos, and String().

Referenced by at().

◆ at() [13/14]

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

References at(), DEPRECATED(), and pos.

Referenced by at(), at(), at(), at(), at(), at(), at(), at(), at(), at(), at(), at(), at(), at(), firstchar(), lastchar(), and operator()().

◆ at() [14/14]

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

Definition at line 642 of file String.h.

References at(), pos, and String().

◆ before() [1/5]

SubString casacore::String::before ( char c,
size_type startpos = 0 )

References before(), DEPRECATED(), and startpos.

◆ before() [2/5]

SubString casacore::String::before ( const char * s,
size_type startpos = 0 )

References before(), const, DEPRECATED(), and startpos.

◆ before() [3/5]

SubString casacore::String::before ( const Regex & r,
size_type startpos = 0 )

References before(), const, DEPRECATED(), and startpos.

◆ before() [4/5]

SubString casacore::String::before ( const std::string & str,
size_type startpos = 0 )

◆ before() [5/5]

SubString casacore::String::before ( int pos)
inline

Next one for overloading reasons.

Definition at line 695 of file String.h.

References before(), before(), and pos.

Referenced by before().

◆ capitalize()

void casacore::String::capitalize ( )

internal transformation to capitalization of String.

References capitalize(), and DEPRECATED().

Referenced by capitalize().

◆ chars()

const char * casacore::String::chars ( ) const
inline

** Casacore synonym

Definition at line 460 of file String.h.

References chars(), and const.

Referenced by chars().

◆ contains()

bool casacore::String::contains ( char c) const
inline

Containment.

** Casacore addition

Definition at line 554 of file String.h.

References contains(), and find().

Referenced by contains().

◆ del() [1/6]

void casacore::String::del ( char c,
size_type startpos = 0 )

References del(), DEPRECATED(), and startpos.

◆ del() [2/6]

void casacore::String::del ( const char * s,
size_type startpos = 0 )

References const, del(), DEPRECATED(), and startpos.

◆ del() [3/6]

void casacore::String::del ( const Regex & r,
size_type startpos = 0 )

References const, del(), DEPRECATED(), and startpos.

◆ del() [4/6]

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

Delete the first occurrence of target after startpos.

** Casacore addition

References const, del(), DEPRECATED(), and startpos.

◆ del() [5/6]

void casacore::String::del ( int pos,
int len )
inline

Overload problem.

Definition at line 784 of file String.h.

References del(), del(), and pos.

Referenced by del().

◆ del() [6/6]

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

Delete len chars starting at pos.

** Casacore addition

References del(), DEPRECATED(), and pos.

Referenced by del(), del(), del(), del(), del(), and del().

◆ DEPRECATED() [1/6]

casacore::String::DEPRECATED ( "Use find) or rfind(,
or IndexString() if the search direction is runtime-dependent"  )

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

Searches the first index if the startpos >= 0, or the last index if startpos < 0. Casacore addition

References DEPRECATED().

◆ DEPRECATED() [2/6]

DEPRECATED("Use find(str) != npos or StringContains()") bool contains(const std casacore::String::DEPRECATED ( "Use find(),
rfind() or IndexString()"  )

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

References DEPRECATED().

◆ DEPRECATED() [3/6]

casacore::String::DEPRECATED ( "Use std::format if possible,
or FormatString() if the format string can 't be changed(e.g. " "runtime determined)"  ) const

◆ DEPRECATED() [4/6]

casacore::String::DEPRECATED ( "Use std::reverse(str.begin(), str.end())" )

Maybe forget some.

** Casacore addition

internal transformation to reverse order of String.

References DEPRECATED(), and casacore::reverse().

◆ DEPRECATED() [5/6]

casacore::String::DEPRECATED ( "Use substr(0, pos) or create a view. Also consider if str.start_with() suffices." )

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

** Casacore addition

References before(), DEPRECATED(), and pos.

◆ DEPRECATED() [6/6]

DEPRECATED("Use find(), rfind(), IndexString() and/or StringContains()") bool contains(const std casacore::String::DEPRECATED ( "Use substr(pos) = = str if possible,
consider ends_with()/starts_with() for " "positive/negative pos or use EqualStringsAndNotEmpty() if direct replacement is necessary"  )

Matches entire string from pos, or till pos if negative pos.

** Casacore addition Returns false if either is empty and pos >= 0. The original implementation has multiple bugs and awkward behaviour. BUG: Returns false for two empty strings (except if pos < 0). BUG: Returns false when pattern is empty, whereas normally an empty pattern matches everything. BUG: When pos < 0, it does not behave as advertised; e.g. "xyxy" does not match with "x" when

References DEPRECATED().

◆ downcase()

void casacore::String::downcase ( )

internal transformation to lowercase of String

References DEPRECATED(), and downcase().

Referenced by downcase().

◆ elem()

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

*** Casacore addition

Definition at line 415 of file String.h.

References elem(), and pos.

Referenced by elem().

◆ find()

size_type casacore::String::find ( const Regex & r,
size_type pos = 0 ) const

References const, DEPRECATED(), find(), and pos.

Referenced by contains(), and find().

◆ firstchar()

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

Definition at line 418 of file String.h.

References at(), and firstchar().

Referenced by firstchar().

◆ freq() [1/3]

int casacore::String::freq ( char c) const

Return the number of occurences of target in String.

** Casacore addition

References const, DEPRECATED(), and freq().

Referenced by freq(), freq(), and freq().

◆ freq() [2/3]

int casacore::String::freq ( const char * s) const

References const, DEPRECATED(), and freq().

◆ freq() [3/3]

int casacore::String::freq ( const std::string & str) const

References const, DEPRECATED(), and freq().

◆ from() [1/6]

SubString casacore::String::from ( char c,
size_type startpos = 0 )

References DEPRECATED(), from(), and startpos.

◆ from() [2/6]

SubString casacore::String::from ( const char * s,
size_type startpos = 0 )

References const, DEPRECATED(), from(), and startpos.

◆ from() [3/6]

SubString casacore::String::from ( const Regex & r,
size_type startpos = 0 )

References const, DEPRECATED(), from(), and startpos.

◆ from() [4/6]

SubString casacore::String::from ( const std::string & str,
size_type startpos = 0 )

References const, DEPRECATED(), from(), and startpos.

◆ from() [5/6]

SubString casacore::String::from ( int pos)
inline

Next one for overloading reasons.

Definition at line 731 of file String.h.

References from(), from(), and pos.

Referenced by from().

◆ from() [6/6]

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

References DEPRECATED(), from(), and pos.

Referenced by from(), from(), from(), from(), from(), and from().

◆ fromString() [1/2]

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

Definition at line 482 of file String.h.

References fromString(), fromString(), and casacore::NewDelAllocator< T >::value.

Referenced by fromString().

◆ fromString() [2/2]

template<typename T>
bool casacore::String::fromString ( T & value,
bool throw_on_error = 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 477 of file String.h.

References fromString(), casacore::NewDelAllocator< T >::value, and casacore::StringToValue().

Referenced by fromString(), and fromString().

◆ gsub() [1/4]

int casacore::String::gsub ( const char * pat,
const char * repl )

References const, DEPRECATED(), and gsub().

◆ gsub() [2/4]

int casacore::String::gsub ( const char * pat,
const std::string & repl )

References const, DEPRECATED(), and gsub().

◆ gsub() [3/4]

int casacore::String::gsub ( const Regex & pat,
const std::string & repl )
inline

Definition at line 798 of file String.h.

References const, gsub(), and casacore::RegexReplaceAll().

◆ gsub() [4/4]

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

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

Casacore addition

References const, DEPRECATED(), and gsub().

Referenced by gsub(), gsub(), gsub(), and gsub().

◆ insert()

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

** Casacore addition

Definition at line 441 of file String.h.

References insert(), pos, and String().

Referenced by insert().

◆ lastchar()

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

Definition at line 420 of file String.h.

References at(), lastchar(), and casacore::length().

Referenced by lastchar().

◆ ltrim()

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".

References DEPRECATED(), and ltrim().

Referenced by ltrim().

◆ operator()()

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

Casacore addition: synonym for at(pos, len).

Definition at line 929 of file String.h.

References at(), and pos.

◆ operator=() [1/4]

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

Definition at line 406 of file String.h.

References String().

◆ operator=() [2/4]

String & casacore::String::operator= ( const char * s)
inline

Definition at line 405 of file String.h.

References String().

◆ operator=() [3/4]

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

Assignments (they are all deep copies according to standard).

Definition at line 401 of file String.h.

References const, and String().

◆ operator=() [4/4]

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

Definition at line 404 of file String.h.

References String().

◆ prepend() [1/2]

void casacore::String::prepend ( char c)

References prepend().

◆ prepend() [2/2]

void casacore::String::prepend ( const char * str)

References const, DEPRECATED(), and prepend().

Referenced by prepend(), and prepend().

◆ replace() [1/2]

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

** Casacore addition

Definition at line 453 of file String.h.

References replace(), and String().

◆ replace() [2/2]

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

** Casacore addition

Definition at line 448 of file String.h.

References pos, replace(), and String().

Referenced by replace(), and replace().

◆ rtrim()

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".

References DEPRECATED(), and rtrim().

Referenced by rtrim().

◆ startsWith()

bool casacore::String::startsWith ( const std::string & beginString) const
inline

Does the string start with the specified string?

Definition at line 544 of file String.h.

References const, and startsWith().

Referenced by startsWith().

◆ through() [1/6]

SubString casacore::String::through ( char c,
size_type startpos = 0 )

References DEPRECATED(), startpos, and through().

◆ through() [2/6]

SubString casacore::String::through ( const char * s,
size_type startpos = 0 )

References const, DEPRECATED(), startpos, and through().

◆ through() [3/6]

SubString casacore::String::through ( const Regex & r,
size_type startpos = 0 )

References const, DEPRECATED(), startpos, and through().

◆ through() [4/6]

SubString casacore::String::through ( const std::string & str,
size_type startpos = 0 )

References const, DEPRECATED(), startpos, and through().

◆ through() [5/6]

SubString casacore::String::through ( int pos)
inline

Next one for overloading reasons.

Definition at line 713 of file String.h.

References pos, through(), and through().

Referenced by through().

◆ through() [6/6]

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

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

** Casacore addition

References DEPRECATED(), pos, and through().

Referenced by through(), through(), through(), through(), through(), and through().

◆ throwFromStringError()

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

Helper function for fromString.

◆ toDouble()

double casacore::String::toDouble ( const String & s,
bool chk = false )
inlinestatic

Definition at line 506 of file String.h.

References const, String(), casacore::StringToValue(), and toDouble().

Referenced by toDouble().

◆ toFloat()

float casacore::String::toFloat ( const String & s,
bool chk = false )
inlinestatic

Definition at line 500 of file String.h.

References const, String(), casacore::StringToValue(), and toFloat().

Referenced by toFloat().

◆ toInt()

int casacore::String::toInt ( const String & s,
bool chk = false )
inlinestatic

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).

Definition at line 494 of file String.h.

References const, String(), casacore::StringToValue(), and toInt().

Referenced by toInt().

◆ toString()

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

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 518 of file String.h.

References const, casacore::NewDelAllocator< T >::value, String(), toString(), and casacore::ValueToString().

Referenced by toString().

◆ trim() [1/2]

void casacore::String::trim ( )

Remove beginning and ending whitespace.

References DEPRECATED(), and trim().

Referenced by trim(), and trim().

◆ trim() [2/2]

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

Remove specified chars from beginning and end of string.

References DEPRECATED(), and trim().

◆ upcase()

void casacore::String::upcase ( )

internal transformation to uppercase of String

References DEPRECATED(), and upcase().

Referenced by upcase().

Member Data Documentation

◆ const

◆ pos

DEPRECATED("Use find(), rfind(), IndexString() and/or StringContains()") bool contains(const std int casacore::String::pos

◆ startpos

int casacore::String::startpos

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