Go to the documentation of this file.
32 #include <casacore/casa/aips.h>
39 #include <casacore/casa/iosstrfwd.h>
40 #include <casacore/casa/sstream.h>
82 SubString(
const string &str, string::size_type pos,
83 string::size_type len);
255 string(str, pos, n) {}
269 template<
class InputIterator>
291 return (*
this =
String(str)); }
302 return static_cast<String&
>(string::operator+=(str)); }
304 return static_cast<String&
>(string::operator+=(s)); }
306 return static_cast<String&
>(string::operator+=(
c)); }
315 return string::at(pos); }
317 return string::operator[](pos); }
321 return string::at(pos); }
360 string::resize(n);
return *
this; }
362 string::resize(n,
c);
return *
this; }
364 string::reserve(res_arg);
return *
this; }
397 return static_cast<String&
>(string::append(str)); }
399 return static_cast<String&
>(string::append(str, pos, n)); }
401 return static_cast<String&
>(string::append(s, n)); }
403 return static_cast<String&
>(string::append(s)); }
405 return static_cast<String&
>(string::append(n,
c)); }
406 template<
class InputIterator>
408 return static_cast<String&
>(string::append(
first, last)); }
411 return static_cast<String&
>(string::append(1,
c)); }
420 return static_cast<String&
>(string::assign(str)); }
422 return static_cast<String&
>(string::assign(str, pos, n)); }
424 return static_cast<String&
>(string::assign(s, n)); }
426 return static_cast<String&
>(string::assign(s)); }
428 return static_cast<String&
>(string::assign(n,
c)); }
429 template<
class InputIterator>
431 return static_cast<String&
>(string::assign(
first, last)); }
434 return static_cast<String&
>(string::assign(1,
c)); }
444 return static_cast<String&
>(string::insert(pos1, str)); }
447 return static_cast<String&
>(string::insert(pos1, str, pos2, n)); }
449 return static_cast<String&
>(string::insert(pos, s, n)); }
451 return static_cast<String&
>(string::insert(pos, s)); }
453 return static_cast<String&
>(string::insert(pos, n,
c)); }
456 return static_cast<String&
>(string::insert(pos, 1,
c)); }
459 return string::insert(p,
c); }
461 string::insert(p, n,
c); }
462 template<
class InputIterator>
464 string::insert(p,
first, last); }
468 return static_cast<String&
>(string::insert(p-
begin(), str)); }
470 return static_cast<String&
>(string::insert(p-
begin(), s, n)); }
472 return static_cast<String&
>(string::insert(p-
begin(), s)); }
482 return string::compare(str); }
484 return String(*
this, pos1, n1).compare(str); }
487 return String(*
this, pos1, n1).compare(
String(str, pos2, n2)); }
489 return string::compare(s); }
492 return String(*
this, pos1, n1).compare(
String(s, n2)); }
498 return static_cast<String&
>(string::erase(pos, n)); }
500 return string::erase(position); }
502 return string::erase(
first, last); }
536 template<
class InputIterator>
550 void swap(
string& s) { string::swap(s); }
557 const Char *
data()
const {
return string::data(); }
571 return String(*
this, pos, n); }
585 std::istringstream os(*
this);
587 if (os.fail() || !os.eof()) {
616 std::ostringstream os;
639 {
return find(beginString) == 0; }
645 return string::find(str, pos); }
647 return string::find(s, pos); }
649 return string::find(s, pos, n); }
651 return string::find(
c, pos); }
654 return string::rfind(str, pos); }
656 return string::rfind(s, pos); }
658 return string::rfind(s, pos, n); }
660 return string::rfind(
c, pos); }
663 return string::find_first_of(str, pos); }
665 return string::find_first_of(s, pos); }
667 return string::find_first_of(s, pos, n); }
669 return string::find_first_of(
c, pos); }
671 return string::find_last_of(str, pos); }
673 return string::find_last_of(s, pos); }
675 return string::find_last_of(s, pos, n); }
677 return string::find_last_of(
c, pos); }
679 return string::find_first_not_of(str, pos); }
681 return string::find_first_not_of(s, pos); }
683 return string::find_first_not_of(s, pos, n); }
685 return string::find_first_not_of(
c, pos); }
687 return string::find_last_not_of(str, pos); }
689 return string::find_last_not_of(s, pos); }
691 return string::find_last_not_of(s, pos, n); }
693 return string::find_last_not_of(
c, pos); }
729 void prepend(
const string &str);
738 return ((startpos >= 0) ?
find(
c, startpos) :
741 return ((startpos >= 0) ?
find(str, startpos) :
744 return ((startpos >= 0) ?
find(s, startpos) :
752 Int freq(
const string &str)
const;
762 String at(
const string &str,
Int startpos = 0)
const;
872 Int gsub(
const string &pat,
const string &repl);
896 String str(lhs); str.append(rhs);
return str; }
898 String str(lhs); str.append(rhs);
return str; }
900 String str(lhs); str.append(rhs);
return str; }
902 String str(lhs); str.append(rhs);
return str; }
904 String str(lhs); str.append(rhs);
return str; }
953 return x.compare(y); }
955 return x.compare(y); }
957 return x.compare(
String(y)); }
968 Int split(
const string &str,
string res[],
Int maxn,
979 String common_prefix(
const string &x,
const string &y,
981 String common_suffix(
const string &x,
const string &y,
985 String join(
string src[],
Int n,
const string &sep);
992 String reverse(
const string& str);
1012 string::size_type len) :
1013 ref_p(str), pos_p((pos > str.
length()) ? str.
length() : pos),
1014 len_p((len == string::npos || pos_p+len > str.
length()) ?
1015 str.
length()-pos_p : len) {}
1018 return at(pos, len); }
1020 return String(*this).c_str(); }
1032 s << x.
c_str();
return s; }
String & operator=(Char c)
String(ostringstream &os)
Construct from a stream.
const_reference at(size_type n) const
Addressing.
reverse_iterator rbegin()
String & append(size_type n, Char c)
Int allocation() const
** Casacore addition – works as a capacity(n) – Note Int
SubString(const string &str, string::size_type pos, string::size_type len)
Constructor (there are no public constructors)
Int gsub(const string &pat, const string &repl)
Global substitution: substitute all occurrences of pat with repl, and return the number of replacemen...
Bool operator!=(const String &x, const Char *t)
String & reserve(size_type res_arg=0)
size_type find_last_not_of(const string &str, size_type pos=npos) const
String & append(const Char *s)
String(InputIterator begin, InputIterator end)
Construct from iterator.
SubString at(const string &str, Int startpos=0)
String & operator=(const SubString &str)
SubString before(const Char *s, size_type startpos=0) const
SubString after(const Char *s, size_type startpos=0)
LatticeExprNode operator+(const LatticeExprNode &expr)
Global functions operating on a LatticeExprNode.
size_type find(const Char *s, size_type pos, size_type n) const
SubString & operator=(const Char *s)
PtrHolder< T > & operator=(const PtrHolder< T > &other)
SubString from(const Char *s, size_type startpos=0)
size_type copy(Char *s, size_type n, size_type pos=0) const
Copy.
SubString before(Char c, size_type startpos=0) const
SubString before(size_type pos) const
Start at startpos and extract the string "before" the argument's position, exclusive.
size_type find_first_not_of(const Char *s, size_type pos=0) const
void prepend(const string &str)
Concatenate by prepending the argument onto String.
Bool startsWith(const string &beginString) const
Does the string start with the specified string?
String at(const string &str, Int startpos=0) const
Int compare(const string &x, const Char y)
Bool empty() const
Test for empty.
String(const Char *s, size_type n)
Construct from char* with given length.
bool operator!=(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
String join(string src[], Int n, const string &sep)
void del(size_type pos, size_type len)
Delete len chars starting at pos.
Bool matches(Char c, Int pos=0) const
Global comparison operators.
iterator begin()
Iterators.
const Char * c_str() const
Get char array.
size_type find_first_of(const Char *s, size_type pos, size_type n) const
void downcase()
internal transformation to lowercase of String
string::iterator iterator
String & replace(iterator i1, iterator i2, const Char *s)
size_type find_first_of(Char c, size_type pos=0) const
const_reference elem(size_type pos) const
*** Casacore addition
Bool operator>(const String &x, const Char t)
Bool operator<=(const String &x, const Char t)
size_type size() const
Capacity, size.
LatticeExprNode replace(const LatticeExprNode &arg1, const LatticeExprNode &arg2)
This function replaces every masked-off element in the first argument with the corresponding element ...
size_type index(const Char *s, Int startpos=0) const
String & insert(size_type pos, size_type n, Char c)
iterator erase(iterator first, iterator last)
String & replace(iterator i1, iterator i2, const string &str)
String & replace(size_type pos, size_type n1, const Char *s, size_type n2)
string::reference reference
SubString after(const RegexBase &r, size_type startpos=0)
Bool operator==(const String &x, const String &y)
String & insert(iterator p, const string &str)
** Casacore additions
String & append(const string &str, size_type pos, size_type n)
void capitalize()
internal transformation to capitalization of String.
SubString after(Int pos)
Next one for overloading reasons.
SubString from(Int pos)
Next one for overloading reasons.
Casing and related functions Case conversion and rearrangement functions.
String & replace(size_type pos, size_type n1, const Char *s)
string::allocator_type allocator_type
size_type find_first_of(const string &str, size_type pos=0) const
String & assign(size_type n, Char c)
SubString through(Int pos)
Next one for overloading reasons.
String common_prefix(const string &x, const string &y, Int startpos=0)
Int compare(size_type pos1, size_type n1, const string &str, size_type pos2, size_type n2) const
String & replace(iterator i1, iterator i2, size_type n, Char c)
LatticeExprNode operator>=(const LatticeExprNode &left, const LatticeExprNode &right)
static Float toFloat(const String &s, Bool chk=False)
String & insert(size_type pos1, const string &str, size_type pos2, size_type n)
void rtrim(char c)
Remove specified character from end of string.
size_type find_last_of(const Char *s, size_type pos=npos) const
size_type find_last_of(Char c, size_type pos=npos) const
String & insert(iterator p, const Char *s, size_type n)
LatticeExprNode operator<(const LatticeExprNode &left, const LatticeExprNode &right)
size_type find_last_of(const string &str, size_type pos=npos) const
void reverse()
Maybe forget some.
Bool fromString(T &value, Bool chk=True) const
Convert a String to a value.
String & replace(iterator i1, iterator i2, const Char *s, size_type n)
SubString operator()(size_type pos, size_type len)
Casacore addition: synonym for at(pos, len)
Bool contains(const string &str) const
String & append(const Char *s, size_type n)
Int gsub(const RegexBase &pat, const string &repl)
size_type rfind(const Char *s, size_type pos=npos) const
String capitalize(const string &str)
Global function which returns a transformation to capitalization of String.
String replicate(Char c, String::size_type n)
string::size_type len_p
Length of sub-string.
SubString through(const RegexBase &r, size_type startpos=0)
size_type rfind(const Char *s, size_type pos, size_type n) const
Bool operator!=(const String &x, const Char t)
size_type find_first_of(const Char *s, size_type pos=0) const
String & assign(const string &str)
Assign.
Bool operator<(const String &x, const String &y)
String & insert(size_type pos, const Char *s)
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.
SubString through(const string &str, size_type startpos=0)
const_iterator end() const
String operator+(const String &lhs, const String &rhs)
void del(Char c, size_type startpos=0)
String & operator+=(const string &str)
Concatenate.
String common_suffix(const string &x, const string &y, Int startpos=-1)
const Char * chars() const
Get as (const) C array.
String & insert(size_type pos1, const string &str)
Insert.
String & resize(size_type n)
Resize by truncating or extending with copies of c (default Char())
reference at(size_type n)
Bool operator==(const String &x, const Char t)
void trim()
Remove beginning and ending whitespace.
SubString after(size_type pos)
Start at startpos and extract the SubString "after" the argument's position, exclusive,...
void del(const RegexBase &r, size_type startpos=0)
String & assign(InputIterator first, InputIterator last)
bool operator==(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
Int compare(const string &x, const Char *y)
SubString after(const string &str, size_type startpos=0)
SubString at(Char c, Int startpos=0)
string::value_type value_type
String upcase(const string &str)
Global function which returns a transformation to uppercase of String.
Bool operator>=(const String &x, const Char t)
Int gsub(const Char *pat, const string &repl)
String & operator+=(const Char *s)
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
Vector< String > & split(const String &s, char delim, Vector< String > &elems)
string::const_iterator const_iterator
void upcase()
internal transformation to uppercase of String
TableExprNode upcase(const TableExprNode &node)
void throwFromStringError() const
Helper function for fromString.
Bool operator<=(const String &x, const Char *t)
size_type find(const string &str, size_type pos=0) const
Search functions.
size_type find(const RegexBase &r, size_type pos=0) const
String & assign(Char c)
** Casacore addition
String()
Default constructor.
reference operator[](size_type pos)
SubString through(const Char *s, size_type startpos=0)
const_reference operator[](size_type pos) const
Indexing.
static Double toDouble(const String &s, Bool chk=False)
String & replace(size_type pos, size_type n1, size_type n2, Char c)
void insert(iterator p, size_type n, Char c)
Int freq(const string &str) const
Bool matches(const RegexBase &r, Int pos=0) const
String(size_type n, Char c)
Construct from a single char (repeated n times)
SubString at(Int pos, Int len)
Next ones for overloading reasons.
SubString & operator=(const String &str)
Bool contains(const RegexBase &r) const
ostream & operator<<(ostream &s, const String &x)
Output.
String at(size_type pos, size_type len) const
String(const SubString &str)
Construct from a SubString.
String & assign(const string &str, size_type pos, size_type n)
String & operator=(const string &str)
Assignments (they are all deep copies according to standard)
Bool operator>(const String &x, const String &y)
String & replace(iterator i1, iterator i2, Char c)
** Casacore addition
String & assign(const Char *s, size_type n)
void del(Int pos, Int len)
Overload problem.
SubString help class to be used in at, before,...
allocator_type get_allocator() const
Get allocator used Warning: gcc has no get_allocator()
Int compare(size_type pos1, size_type n1, const string &str) const
this file contains all the compiler specific defines
String at(const RegexBase &r, Int startpos=0) const
SubString from(size_type pos)
Start at startpos and extract the SubString "from" the argument's position, inclusive,...
size_type index(const RegexBase &r, Int startpos=0) const
String & assign(const Char *s)
String & replace(size_type pos1, size_type n1, const string &str, size_type pos2, size_type n2)
Bool operator!=(const String &x, const String &y)
String & append(Char c)
** Casacore addition
void prepend(const Char *s)
String substr(size_type pos=0, size_type n=npos) const
Get a sub string.
size_type find_last_not_of(Char c, size_type pos=npos) const
Bool matches(const Char *s, Int pos=0) const
SubString at(const RegexBase &r, Int startpos=0)
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
const Double c
Fundamental physical constants (SI units):
void clear()
Clear the string Warning: clear() executed as erase() due to missing clear() in gcc
SubString from(Char c, size_type startpos=0)
TableExprNode capitalize(const TableExprNode &node)
string::difference_type difference_type
Int split(const string &str, string res[], Int maxn, const Char sep)
string::size_type length() const
Obtain length.
SubString before(const string &str, size_type startpos=0) const
size_type rfind(const RegexBase &r, size_type pos=npos) const
String & insert(size_type pos, Char c)
** Casacore addition
SubString through(size_type pos)
Start at startpos and extract the SubString "through" to the argument's position, inclusive.
Int split(const string &str, string res[], Int maxn, const RegexBase &sep)
String operator+(Char lhs, const String &rhs)
string::const_pointer const_pointer
Bool contains(Char c) const
Containment.
void insert(iterator p, InputIterator first, InputIterator last)
Int compare(const Char *s) const
Int split(const string &str, string res[], Int maxn, const string &sep)
string::size_type size_type
String downcase(const string &str)
Global function which returns a transformation to lowercase of String.
string::const_reverse_iterator const_reverse_iterator
SubString at(size_type pos, size_type len)
Extract the string "at" the argument's position.
Bool operator<(const String &x, const Char t)
String & erase(size_type pos, size_type n=npos)
Erase.
String(Char c)
From single char (** Casacore addition).
void trim(char c[], uInt n)
Remove specified chars from beginning and end of string.
String reverse(const string &str)
Global function which returns a transformation to reverse order of String.
String & operator=(const Char *s)
static const size_type npos
String operator+(const String &lhs, Char rhs)
TableExprNode downcase(const TableExprNode &node)
Bool operator<=(const String &x, const String &y)
String operator+(const Char *lhs, const String &rhs)
Bool contains(const Char *s) const
size_type find(const Char *s, size_type pos=0) const
StatsData< AccumType > copy(const StatsData< AccumType > &stats)
Splitting Global function which splits the String into string array res at separator and returns the ...
Bool operator==(const String &x, const Char *t)
static String toString(const T &value)
Convert a value to a String.
size_type find_first_not_of(const string &str, size_type pos=0) const
Int compare(const string &x, const string &y)
** Casacore additions of global compares.
String & append(const string &str)
Append.
String at(Char c, Int startpos=0) const
String & resize(size_type n, Char c)
String at(Int pos, Int len) const
LatticeExprNode operator<=(const LatticeExprNode &left, const LatticeExprNode &right)
Some general functions Functions to find special patterns, join and replicate.
String: the storage and methods of handling collections of characters.
string::const_reference const_reference
Int fcompare(const String &x, const String &y)
this version ignores case.
size_type max_size() const
bool Bool
Define the standard types used by Casacore.
SubString _substr(size_type first, size_type l) const
Helper functions for at, before etc.
string::size_type pos_p
Start of sub-string.
const Char * chars() const
** Casacore synonym
void alloc(size_type n)
** Casacore addition – works as a resize(n)
const string & ref_p
Referenced string.
ostream & operator<<(ostream &os, const IComplex &)
Show on ostream.
Bool operator>=(const String &x, const String &y)
size_type index(const string &str, Int startpos=0) const
size_type find_last_of(const Char *s, size_type pos, size_type n) const
static Int toInt(const String &s, Bool chk=False)
Convert a string to an Int, Float or Double.
SubString at(const Char *s, Int startpos=0)
String & replace(size_type pos1, size_type n1, const string &str)
Replace.
TableExprNode trim(const TableExprNode &node)
Global concatenation operators.
Abstract interface class to regular expressions for String.
String & insert(size_type pos, const Char *s, size_type n)
static String format(const char *picture,...)
Create a formatted string using the given printf format string.
SubString at(Int pos, size_type len)
void del(const Char *s, size_type startpos=0)
size_type find_last_not_of(const Char *s, size_type pos, size_type n) const
Bool operator<(const String &x, const Char *t)
const Char * data() const
As pointer to char array
SubString before(const RegexBase &r, size_type startpos=0) const
const_reverse_iterator rbegin() const
Int compare(size_type pos1, size_type n1, const Char *s, size_type n2=npos) const
SubString from(const string &str, size_type startpos=0)
SubString & operator=(const Char c)
String trim(const string &str)
Global function which removes leading and trailing whitespace.
Int freq(const Char *s) const
SubString from(const RegexBase &r, size_type startpos=0)
String(const Char *s)
Construct from char array.
String operator+(const String &lhs, const Char *rhs)
String at(Int pos, size_type len) const
size_type find_first_not_of(const Char *s, size_type pos, size_type n) const
LatticeExprNode operator>(const LatticeExprNode &left, const LatticeExprNode &right)
size_type find_last_not_of(const Char *s, size_type pos=npos) const
String & append(InputIterator first, InputIterator last)
Int gsub(const Char *pat, const Char *repl)
size_type capacity() const
String replicate(const string &str, String::size_type n)
Int freq(Char c) const
Return the number of occurences of target in String.
size_type find(Char c, size_type pos=0) const
size_type rfind(const string &str, size_type pos=npos) const
String & replace(iterator i1, iterator i2, InputIterator j1, InputIterator j2)
SubString after(Char c, size_type startpos=0)
Int compare(const string &str) const
Compare.
Bool matches(const string &str, Int pos=0) const
Matches entire string from pos (or till pos if negative pos).
SubString before(Int pos) const
Next one for overloading reasons.
iterator erase(iterator position)
String & operator+=(Char c)
size_type rfind(Char c, size_type pos=npos) const
String & replace(size_type pos, size_type n1, Char c)
** Casacore addition
string::reverse_iterator reverse_iterator
void ltrim(char c)
Remove specified character from beginning of string.
size_type find_first_not_of(Char c, size_type pos=0) const
SubString through(Char c, size_type startpos=0)
void swap(string &s)
Swap.
string::traits_type traits_type
const_reverse_iterator rend() const
size_type index(Char c, Int startpos=0) const
Return the position of the target in the string or npos for failure.
Bool operator>=(const String &x, const Char *t)
void del(const string &str, size_type startpos=0)
Delete the first occurrence of target after startpos.
SubString & operator=(const SubString &str)
Assignment.
String at(const Char *s, Int startpos=0) const
const_iterator begin() const
Bool operator>(const String &x, const Char *t)
String & insert(iterator p, const Char *s)
iterator insert(iterator p, Char c)