32 #include <casacore/casa/aips.h>
39 #include <casacore/casa/iosstrfwd.h>
40 #include <casacore/casa/sstream.h>
84 SubString(
const string &str, string::size_type pos,
85 string::size_type len);
257 string(str, pos, n) {}
271 template<
class InputIterator>
293 return (*
this =
String(str)); }
304 return static_cast<String&
>(string::operator+=(str)); }
306 return static_cast<String&
>(string::operator+=(s)); }
308 return static_cast<String&
>(string::operator+=(
c)); }
317 return string::at(pos); }
319 return string::operator[](pos); }
323 return string::at(pos); }
362 string::resize(n);
return *
this; }
364 string::resize(n,
c);
return *
this; }
366 string::reserve(res_arg);
return *
this; }
399 return static_cast<String&
>(string::append(str)); }
401 return static_cast<String&
>(string::append(str, pos, n)); }
403 return static_cast<String&
>(string::append(s, n)); }
405 return static_cast<String&
>(string::append(s)); }
407 return static_cast<String&
>(string::append(n,
c)); }
408 template<
class InputIterator>
410 return static_cast<String&
>(string::append(
first, last)); }
413 return static_cast<String&
>(string::append(1,
c)); }
422 return static_cast<String&
>(string::assign(str)); }
424 return static_cast<String&
>(string::assign(str, pos, n)); }
426 return static_cast<String&
>(string::assign(s, n)); }
428 return static_cast<String&
>(string::assign(s)); }
430 return static_cast<String&
>(string::assign(n,
c)); }
431 template<
class InputIterator>
433 return static_cast<String&
>(string::assign(
first, last)); }
436 return static_cast<String&
>(string::assign(1,
c)); }
446 return static_cast<String&
>(string::insert(pos1, str)); }
449 return static_cast<String&
>(string::insert(pos1, str, pos2, n)); }
451 return static_cast<String&
>(string::insert(pos, s, n)); }
453 return static_cast<String&
>(string::insert(pos, s)); }
455 return static_cast<String&
>(string::insert(pos, n,
c)); }
458 return static_cast<String&
>(string::insert(pos, 1,
c)); }
461 return string::insert(p,
c); }
463 string::insert(p, n,
c); }
464 template<
class InputIterator>
466 string::insert(p,
first, last); }
470 return static_cast<String&
>(string::insert(p-
begin(), str)); }
472 return static_cast<String&
>(string::insert(p-
begin(), s, n)); }
474 return static_cast<String&
>(string::insert(p-
begin(), s)); }
484 return string::compare(str); }
486 return String(*
this, pos1, n1).compare(str); }
489 return String(*
this, pos1, n1).compare(
String(str, pos2, n2)); }
491 return string::compare(s); }
494 return String(*
this, pos1, n1).compare(
String(s, n2)); }
500 return static_cast<String&
>(string::erase(pos, n)); }
502 return string::erase(position); }
504 return string::erase(
first, last); }
538 template<
class InputIterator>
559 const Char *
data()
const {
return string::data(); }
573 return String(*
this, pos, n); }
587 std::istringstream os(*
this);
589 if (os.fail() || !os.eof()) {
618 std::ostringstream os;
641 {
return find(beginString) == 0; }
647 return string::find(str, pos); }
649 return string::find(s, pos); }
651 return string::find(s, pos, n); }
653 return string::find(
c, pos); }
656 return string::rfind(str, pos); }
658 return string::rfind(s, pos); }
660 return string::rfind(s, pos, n); }
662 return string::rfind(
c, pos); }
664 return string::find_first_of(str, pos); }
666 return string::find_first_of(s, pos); }
668 return string::find_first_of(s, pos, n); }
670 return string::find_first_of(
c, pos); }
672 return string::find_last_of(str, pos); }
674 return string::find_last_of(s, pos); }
676 return string::find_last_of(s, pos, n); }
678 return string::find_last_of(
c, pos); }
680 return string::find_first_not_of(str, pos); }
682 return string::find_first_not_of(s, pos); }
684 return string::find_first_not_of(s, pos, n); }
686 return string::find_first_not_of(
c, pos); }
688 return string::find_last_not_of(str, pos); }
690 return string::find_last_not_of(s, pos); }
692 return string::find_last_not_of(s, pos, n); }
694 return string::find_last_not_of(
c, pos); }
730 void prepend(
const string &str);
739 return ((startpos >= 0) ?
find(
c, startpos) :
742 return ((startpos >= 0) ?
find(str, startpos) :
745 return ((startpos >= 0) ?
find(s, startpos) :
753 Int freq(
const string &str)
const;
763 String at(
const string &str,
Int startpos = 0)
const;
873 Int gsub(
const string &pat,
const string &repl);
897 String str(lhs); str.append(rhs);
return str; }
899 String str(lhs); str.append(rhs);
return str; }
901 String str(lhs); str.append(rhs);
return str; }
903 String str(lhs); str.append(rhs);
return str; }
905 String str(lhs); str.append(rhs);
return str; }
954 return x.compare(y); }
956 return x.compare(y); }
958 return x.compare(
String(y)); }
969 Int split(
const string &str,
string res[],
Int maxn,
980 String common_prefix(
const string &x,
const string &y,
982 String common_suffix(
const string &x,
const string &y,
986 String join(
string src[],
Int n,
const string &sep);
993 String reverse(
const string& str);
1013 string::size_type len) :
1014 ref_p(str), pos_p((pos > str.
length()) ? str.
length() : pos),
1015 len_p((len == string::npos || pos_p+len > str.
length()) ?
1016 str.
length()-pos_p : len) {}
1019 return at(pos, len); }
1021 return String(*this).c_str(); }
1033 s << x.
c_str();
return s; }
String: the storage and methods of handling collections of characters.
static String format(const char *picture,...)
Create a formatted string using the given printf format string.
String & operator+=(Char c)
size_type max_size() const
Bool matches(const string &str, Int pos=0) const
Matches entire string from pos (or till pos if negative pos).
void del(const Char *s, size_type startpos=0)
Int compare(size_type pos1, size_type n1, const string &str, size_type pos2, size_type n2) const
SubString at(Int pos, Int len)
Next ones for overloading reasons.
static Float toFloat(const String &s, Bool chk=False)
iterator begin()
Iterators.
SubString from(Int pos)
Next one for overloading reasons.
SubString from(const string &str, size_type startpos=0)
void swap(string &s)
Swap.
iterator erase(iterator first, iterator last)
String & append(const Char *s)
String & replace(size_type pos, size_type n1, const Char *s)
String & insert(size_type pos1, const string &str)
Insert.
String(const Char *s, size_type n)
Construct from char* with given length.
String & assign(const string &str)
Assign.
size_type find_first_of(const Char *s, size_type pos=0) const
void downcase()
internal transformation to lowercase of String
String & insert(size_type pos, Char c)
** Casacore addition
string::const_reverse_iterator const_reverse_iterator
size_type rfind(const Char *s, size_type pos, size_type n) const
String & assign(const string &str, size_type pos, size_type n)
String & replace(iterator i1, iterator i2, size_type n, Char c)
size_type find_last_of(Char c, size_type pos=npos) const
static String toString(const T &value)
Convert a value to a String.
size_type find(const Regex &r, size_type pos=0) const
size_type find(const string &str, size_type pos=0) const
Search functions.
size_type find_last_not_of(Char c, size_type pos=npos) const
SubString through(Int pos)
Next one for overloading reasons.
String & append(size_type n, Char c)
static const size_type npos
size_type find_first_of(const string &str, size_type pos=0) const
string::const_reference const_reference
SubString before(const Char *s, size_type startpos=0) const
size_type find_last_of(const Char *s, size_type pos=npos) const
const Char * c_str() const
Get char array.
String at(const string &str, Int startpos=0) const
SubString after(Int pos)
Next one for overloading reasons.
string::allocator_type allocator_type
String(const Char *s)
Construct from char array.
String & replace(size_type pos1, size_type n1, const string &str, size_type pos2, size_type n2)
Int freq(Char c) const
Return the number of occurences of target in String.
string::difference_type difference_type
size_type find_last_not_of(const Char *s, size_type pos=npos) const
const_reverse_iterator rbegin() const
void rtrim(char c)
Remove specified character from end of string.
const_reference operator[](size_type pos) const
Indexing.
Bool matches(const Char *s, Int pos=0) const
String & replace(size_type pos1, size_type n1, const string &str)
Replace.
String & insert(size_type pos, const Char *s)
string::value_type value_type
void trim(char c[], uInt n)
Remove specified chars from beginning and end of string.
SubString from(const Char *s, size_type startpos=0)
String & append(const string &str, size_type pos, size_type n)
String & replace(size_type pos, size_type n1, const Char *s, size_type n2)
reference at(size_type n)
SubString after(const string &str, size_type startpos=0)
void capitalize()
internal transformation to capitalization of String.
reverse_iterator rbegin()
string::reference reference
const_reference elem(size_type pos) const
*** Casacore addition
SubString through(Char c, size_type startpos=0)
Bool fromString(T &value, Bool chk=True) const
Convert a String to a value.
String substr(size_type pos=0, size_type n=npos) const
Get a sub string.
Int compare(size_type pos1, size_type n1, const string &str) const
size_type find_first_not_of(const Char *s, size_type pos=0) const
String & insert(iterator p, const Char *s, size_type n)
SubString before(Char c, size_type startpos=0) const
size_type capacity() const
String & assign(size_type n, Char c)
String(Char c)
From single char (** Casacore addition).
SubString through(const Char *s, size_type startpos=0)
allocator_type get_allocator() const
Get allocator used Warning: gcc has no get_allocator()
void ltrim(char c)
Remove specified character from beginning of string.
String & replace(iterator i1, iterator i2, const Char *s)
string::const_iterator const_iterator
String & operator=(const Char *s)
Int gsub(const Char *pat, const string &repl)
size_type find_first_not_of(const string &str, size_type pos=0) const
void insert(iterator p, InputIterator first, InputIterator last)
void clear()
Clear the string Warning: clear() executed as erase() due to missing clear() in gcc
Int allocation() const
** Casacore addition – works as a capacity(n) – Note Int
String & assign(const Char *s)
String & insert(size_type pos, size_type n, Char c)
iterator erase(iterator position)
size_type find_last_not_of(const Char *s, size_type pos, size_type n) const
size_type find_last_not_of(const string &str, size_type pos=npos) const
void del(Char c, size_type startpos=0)
String & operator=(Char c)
string::const_pointer const_pointer
String(ostringstream &os)
Construct from a stream.
String(const SubString &str)
Construct from a SubString.
string::reverse_iterator reverse_iterator
size_type copy(Char *s, size_type n, size_type pos=0) const
Copy.
SubString at(Int pos, size_type len)
void del(const string &str, size_type startpos=0)
Delete the first occurrence of target after startpos.
SubString through(size_type pos)
Start at startpos and extract the SubString "through" to the argument's position, inclusive.
const_iterator begin() const
String(size_type n, Char c)
Construct from a single char (repeated n times)
size_type find_last_of(const string &str, size_type pos=npos) const
String & reserve(size_type res_arg=0)
String & operator+=(const string &str)
Concatenate.
String & append(const string &str)
Append.
size_type find(Char c, size_type pos=0) const
void del(Int pos, Int len)
Overload problem.
String at(Int pos, size_type len) const
void insert(iterator p, size_type n, Char c)
const_reverse_iterator rend() const
SubString operator()(size_type pos, size_type len)
Casacore addition: synonym for at(pos, len)
String & assign(Char c)
** Casacore addition
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.
const Char * data() const
As pointer to char array
String at(Int pos, Int len) const
Bool startsWith(const string &beginString) const
Does the string start with the specified string?
void trim()
Remove beginning and ending whitespace.
SubString at(const Char *s, Int startpos=0)
size_type rfind(const string &str, size_type pos=npos) const
SubString after(const Char *s, size_type startpos=0)
size_type find(const Char *s, size_type pos, size_type n) const
String & replace(iterator i1, iterator i2, const string &str)
const Char * chars() const
** Casacore synonym
SubString at(Char c, Int startpos=0)
SubString from(size_type pos)
Start at startpos and extract the SubString "from" the argument's position, inclusive,...
String & insert(iterator p, const Char *s)
String & append(const Char *s, size_type n)
SubString before(Int pos) const
Next one for overloading reasons.
void del(size_type pos, size_type len)
Delete len chars starting at pos.
Bool empty() const
Test for empty.
String & operator+=(const Char *s)
Bool contains(Char c) const
Containment.
string::size_type size_type
size_type index(Char c, Int startpos=0) const
Return the position of the target in the string or npos for failure.
void alloc(size_type n)
** Casacore addition – works as a resize(n)
static Int toInt(const String &s, Bool chk=False)
Convert a string to an Int, Float or Double.
String & replace(size_type pos, size_type n1, Char c)
** Casacore addition
size_type find_first_not_of(Char c, size_type pos=0) const
String at(size_type pos, size_type len) const
SubString before(size_type pos) const
Start at startpos and extract the string "before" the argument's position, exclusive.
String & insert(size_type pos, const Char *s, size_type n)
void reverse()
Maybe forget some.
SubString at(const string &str, Int startpos=0)
SubString _substr(size_type first, size_type l) const
Helper functions for at, before etc.
size_type find_first_of(const Char *s, size_type pos, size_type n) const
size_type rfind(const Char *s, size_type pos=npos) const
String & assign(const Char *s, size_type n)
Int compare(const string &str) const
Compare.
size_type find_first_not_of(const Char *s, size_type pos, size_type n) const
String & assign(InputIterator first, InputIterator last)
void throwFromStringError() const
Helper function for fromString.
String & operator=(const SubString &str)
Int compare(const Char *s) const
SubString after(Char c, size_type startpos=0)
string::traits_type traits_type
size_type size() const
Capacity, size.
size_type find(const Char *s, size_type pos=0) const
String & resize(size_type n, Char c)
String & replace(iterator i1, iterator i2, const Char *s, size_type n)
String & operator=(const string &str)
Assignments (they are all deep copies according to standard)
String & append(Char c)
** Casacore addition
String at(const Char *s, Int startpos=0) const
string::iterator iterator
size_type rfind(Char c, size_type pos=npos) const
reference operator[](size_type pos)
size_type find_first_of(Char c, size_type pos=0) const
Int compare(size_type pos1, size_type n1, const Char *s, size_type n2=npos) const
void prepend(const string &str)
Concatenate by prepending the argument onto String.
static Double toDouble(const String &s, Bool chk=False)
String(InputIterator begin, InputIterator end)
Construct from iterator.
String & insert(size_type pos1, const string &str, size_type pos2, size_type n)
Int gsub(const string &pat, const string &repl)
Global substitution: substitute all occurrences of pat with repl, and return the number of replacemen...
String()
Default constructor.
size_type find_last_of(const Char *s, size_type pos, size_type n) const
String & append(InputIterator first, InputIterator last)
const_reference at(size_type n) const
Addressing.
SubString through(const string &str, size_type startpos=0)
SubString before(const string &str, size_type startpos=0) const
String & replace(iterator i1, iterator i2, Char c)
** Casacore addition
String & replace(size_type pos, size_type n1, size_type n2, Char c)
String & erase(size_type pos, size_type n=npos)
Erase.
Bool matches(Char c, Int pos=0) const
iterator insert(iterator p, Char c)
String & replace(iterator i1, iterator i2, InputIterator j1, InputIterator j2)
SubString from(Char c, size_type startpos=0)
SubString after(size_type pos)
Start at startpos and extract the SubString "after" the argument's position, exclusive,...
String & resize(size_type n)
Resize by truncating or extending with copies of c (default Char())
void upcase()
internal transformation to uppercase of String
Int gsub(const Char *pat, const Char *repl)
String & insert(iterator p, const string &str)
** Casacore additions
const_iterator end() const
String at(Char c, Int startpos=0) const
const string & ref_p
Referenced string.
SubString & operator=(const String &str)
SubString(const SubString &)=default
Default copy constructor.
string::size_type length() const
Obtain length.
SubString & operator=(const SubString &str)
Assignment.
string::size_type pos_p
Start of sub-string.
SubString & operator=(const Char *s)
const Char * chars() const
Get as (const) C array.
string::size_type len_p
Length of sub-string.
SubString & operator=(const Char c)
const Double c
Fundamental physical constants (SI units):
this file contains all the compiler specific defines
Vector< String > & split(const String &s, char delim, Vector< String > &elems)
StatsData< AccumType > copy(const StatsData< AccumType > &stats)
LatticeExprNode operator>(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode replace(const LatticeExprNode &arg1, const LatticeExprNode &arg2)
This function replaces every masked-off element in the first argument with the corresponding element ...
TableExprNode upcase(const TableExprNode &node)
LatticeExprNode operator+(const LatticeExprNode &expr)
Global functions operating on a LatticeExprNode.
PtrHolder< T > & operator=(const PtrHolder< T > &other)
bool operator==(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
bool operator!=(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
TableExprNode capitalize(const TableExprNode &node)
TableExprNode downcase(const TableExprNode &node)
LatticeExprNode operator<(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
LatticeExprNode operator>=(const LatticeExprNode &left, const LatticeExprNode &right)
bool Bool
Define the standard types used by Casacore.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
ostream & operator<<(ostream &os, const IComplex &)
Show on ostream.
TableExprNode trim(const TableExprNode &node)
void swap(Array< T, Alloc > &first, Array< T, Alloc > &second)
Swap the first array with the second.
LatticeExprNode operator<=(const LatticeExprNode &left, const LatticeExprNode &right)
Int compare(const string &x, const string &y)
** Casacore additions of global compares.
Int fcompare(const String &x, const String &y)
this version ignores case.
Int compare(const string &x, const Char y)
Int compare(const string &x, const Char *y)
Int split(const string &str, string res[], Int maxn, const string &sep)
Int split(const string &str, string res[], Int maxn, const Char sep)