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);
244 static const size_type npos =
static_cast<size_type
>(-1);
254 String(
const string& str, size_type pos=0, size_type n=npos) :
255 string(str, pos, n) {}
269 template<
class InputIterator>
270 String(InputIterator begin, InputIterator end) : string(begin, end) {}
279 String(ostringstream &os);
291 return (*
this =
String(str)); }
298 SubString operator()(size_type pos, size_type len);
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); }
320 const_reference
elem(size_type pos)
const {
321 return string::at(pos); }
330 iterator
begin() {
return string::begin(); }
331 const_iterator
begin()
const {
return string::begin(); }
332 iterator
end() {
return string::end(); }
333 const_iterator
end()
const {
return string::end(); }
334 reverse_iterator
rbegin() {
return string::rbegin(); }
335 const_reverse_iterator
rbegin()
const {
return string::rbegin(); }
336 reverse_iterator
rend() {
return string::rend(); }
337 const_reverse_iterator
rend()
const {
return string::rend(); }
342 size_type
size()
const {
return string::size(); }
344 size_type
max_size()
const {
return string::max_size(); }
345 size_type
capacity()
const {
return string::capacity(); }
360 string::resize(n);
return *
this; }
362 string::resize(n, c);
return *
this; }
364 string::reserve(res_arg);
return *
this; }
366 void alloc(size_type n) { string::resize(n); }
372 void clear() { string::erase(begin(), end()); }
382 const_reference
at(size_type n)
const {
return string::at(n); }
383 reference
at(size_type n) {
return string::at(n); }
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)); }
446 size_type pos2, size_type n) {
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>
463 void insert(iterator p, InputIterator
first, InputIterator last) {
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); }
483 Int compare(size_type pos1, size_type n1,
const string& str)
const {
484 return String(*
this, pos1, n1).compare(str); }
486 size_type pos2, size_type n2)
const {
487 return String(*
this, pos1, n1).compare(
String(str, pos2, n2)); }
489 return string::compare(s); }
491 size_type n2=npos)
const {
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); }
514 size_type pos2, size_type n2) {
536 template<
class InputIterator>
546 size_type
copy(
Char* s, size_type n, size_type pos = 0)
const {
550 void swap(
string& s) { string::swap(s); }
557 const Char *
data()
const {
return string::data(); }
571 return String(*
this, pos, n); }
574 static String format (
const char* picture, ...);
585 std::istringstream os(*
this);
587 if (os.fail() || !os.eof()) {
588 if (chk) throwFromStringError();
616 std::ostringstream os;
639 {
return find(beginString) == 0; }
644 size_type
find(
const string &str, size_type pos=0)
const {
645 return string::find(str, pos); }
646 size_type
find(
const Char *s, size_type pos=0)
const {
647 return string::find(s, pos); }
648 size_type
find(
const Char *s, size_type pos, size_type n)
const {
649 return string::find(s, pos, n); }
651 return string::find(c, pos); }
652 size_type find(
const RegexBase &r, size_type pos=0)
const;
653 size_type
rfind(
const string &str, size_type pos=npos)
const {
654 return string::rfind(str, pos); }
655 size_type
rfind(
const Char *s, size_type pos=npos)
const {
656 return string::rfind(s, pos); }
657 size_type
rfind(
const Char *s, size_type pos, size_type n)
const {
658 return string::rfind(s, pos, n); }
660 return string::rfind(c, pos); }
661 size_type rfind(
const RegexBase &r, size_type pos=npos)
const;
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); }
699 return (find(c) != npos); }
700 Bool contains(
const string &str)
const {
701 return (find(str) != npos); }
702 Bool contains(
const Char *s)
const {
703 return (find(s) != npos); }
711 Bool contains(
const string &str,
Int pos)
const;
719 Bool matches(
const string &str,
Int pos = 0)
const;
721 return matches(
String(c), pos); };
723 return matches(
String(s), pos); };
729 void prepend(
const string &str);
730 void prepend(
const Char *s);
731 void prepend(
Char c);
737 size_type index(
Char c,
Int startpos = 0)
const {
738 return ((startpos >= 0) ? find(c, startpos) :
740 size_type index(
const string &str,
Int startpos = 0)
const {
741 return ((startpos >= 0) ? find(str, startpos) :
742 rfind(str,
length() + startpos - str.length())); }
743 size_type index(
const Char *s,
Int startpos = 0)
const {
744 return ((startpos >= 0) ? find(s, startpos) :
746 size_type index(
const RegexBase &r,
Int startpos = 0)
const;
752 Int freq(
const string &str)
const;
758 SubString at(size_type pos, size_type len);
759 String at(size_type pos, size_type len)
const {
760 return String(*
this, pos, len); }
762 String at(
const string &str,
Int startpos = 0)
const;
774 return at(static_cast<size_type>(pos), static_cast<size_type>(len));
777 return at(static_cast<size_type>(pos), static_cast<size_type>(len));
780 return at(static_cast<size_type>(pos), len);
782 String at(
Int pos, size_type len)
const {
783 return at(static_cast<size_type>(pos), len);
792 SubString before(
const string &str, size_type startpos = 0)
const;
793 SubString before(
const Char *s, size_type startpos = 0)
const;
798 return before(static_cast<size_type>(pos)); };
805 SubString through(
const string &str, size_type startpos = 0);
811 return through(static_cast<size_type>(pos)); }
818 SubString from(
const string &str, size_type startpos = 0);
824 return from(static_cast<size_type>(pos));
832 SubString after(
const string &str, size_type startpos = 0);
838 return after(static_cast<size_type>(pos));
855 void del(size_type pos, size_type len);
859 void del(
const string &str, size_type startpos = 0);
860 void del(
const Char *s, size_type startpos = 0);
861 void del(
Char c, size_type startpos = 0);
862 void del(
const RegexBase &r, size_type startpos = 0);
864 void del(
Int pos,
Int len) {
865 del(static_cast<size_type>(pos), static_cast<size_type>(len)); }
872 Int gsub(
const string &pat,
const string &repl);
873 Int gsub(
const Char *pat,
const string &repl);
886 void throwFromStringError()
const;
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,
970 Int split(
const string &str,
string res[],
Int maxn,
972 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) :
1018 return at(pos, len); }
1020 return String(*this).c_str(); }
1023 return (index(c, pos) != npos); }
1025 return (index(str, pos) != npos); }
1027 return (index(s, pos) != npos); }
1029 return (index(r, pos) != npos); }
1032 s << x.
c_str();
return s; }
String & assign(size_type n, Char c)
Int compare(const string &x, const string &y)
** Casacore additions of global compares.
String & resize(size_type n, Char c)
size_type find_last_not_of(const Char *s, size_type pos, size_type n) const
String & insert(size_type pos, size_type n, Char c)
size_type max_size() const
String & replace(size_type pos, size_type n1, const Char *s)
size_type find_last_of(const Char *s, size_type pos=npos) const
String & insert(iterator p, const Char *s, size_type n)
size_type find_first_not_of(const Char *s, size_type pos, size_type n) const
size_type find_last_of(const string &str, size_type pos=npos) const
String & replace(iterator i1, iterator i2, const Char *s, size_type n)
String & replace(iterator i1, iterator i2, size_type n, Char c)
TableExprNode downcase(const TableExprNode &node)
StatsData< AccumType > copy(const StatsData< AccumType > &stats)
Int compare(const string &str) const
Compare.
SubString before(Int pos) const
Next one for overloading reasons.
iterator erase(iterator position)
size_type find_first_not_of(Char c, size_type pos=0) const
void swap(string &s)
Swap.
bool operator==(const std11_allocator< T > &, const std11_allocator< T > &)
size_type capacity() const
size_type find(Char c, size_type pos=0) const
String & replace(iterator i1, iterator i2, InputIterator j1, InputIterator j2)
String & append(const Char *s, size_type n)
size_type rfind(const Char *s, size_type pos=npos) const
String & operator=(Char c)
bool operator!=(const std11_allocator< T > &, const std11_allocator< T > &)
size_type rfind(const Char *s, size_type pos, size_type n) const
String & reserve(size_type res_arg=0)
String & append(const Char *s)
size_type find_first_of(const Char *s, size_type pos=0) const
String & insert(size_type pos, const Char *s)
string::value_type value_type
TableExprNode ltrim(const TableExprNode &node)
reverse_iterator rbegin()
string::size_type pos_p
Start of sub-string.
PtrHolder< T > & operator=(const PtrHolder< T > &other)
String & resize(size_type n)
Resize by truncating or extending with copies of c (default Char())
reference at(size_type n)
String & assign(InputIterator first, InputIterator last)
String & operator=(const SubString &str)
ostream & operator<<(ostream &os, const IComplex &)
Show on ostream.
Bool startsWith(const string &beginString) const
Does the string start with the specified string?
size_type find_first_not_of(const Char *s, size_type pos=0) const
LatticeExprNode toFloat(const LatticeExprNode &expr)
Functions to convert to the given data type.
const Char * c_str() const
Get char array.
String & replace(iterator i1, iterator i2, const Char *s)
const_reference elem(size_type pos) const
*** Casacore addition
String & assign(Char c)
** Casacore addition
SubString at(Int pos, Int len)
Next ones for overloading reasons.
Bool empty() const
Test for empty.
const_reference operator[](size_type pos) const
Indexing.
String & replace(size_type pos, size_type n1, size_type n2, Char c)
String & assign(const string &str, size_type pos, size_type n)
const Char * chars() const
Get as (const) C array.
string::reference reference
String & insert(iterator p, const string &str)
** Casacore additions
String & replace(iterator i1, iterator i2, Char c)
** Casacore addition
iterator begin()
Iterators.
String & assign(const Char *s, size_type n)
string::iterator iterator
SubString through(Int pos)
Next one for overloading reasons.
TableExprNode rtrim(const TableExprNode &node)
size_type size() const
Capacity, size.
Int compare(size_type pos1, size_type n1, const string &str, size_type pos2, size_type n2) const
LatticeExprNode operator>=(const LatticeExprNode &left, const LatticeExprNode &right)
allocator_type get_allocator() const
Get allocator used Warning: gcc has no get_allocator()
iterator erase(iterator first, iterator last)
string::allocator_type allocator_type
size_type find_first_of(const string &str, size_type pos=0) const
String & assign(const Char *s)
String & replace(size_type pos1, size_type n1, const string &str, size_type pos2, size_type n2)
const string & ref_p
Referenced string.
Bool fromString(T &value, Bool chk=True) const
Convert a String to a value.
Bool matches(const Char *s, Int pos=0) const
Vector< String > & split(const String &s, char delim, Vector< String > &elems)
String & insert(size_type pos1, const string &str, size_type pos2, size_type n)
size_type find_last_of(Char c, size_type pos=npos) const
size_type find_last_not_of(Char c, size_type pos=npos) const
string::const_pointer const_pointer
SubString operator()(size_type pos, size_type len)
Casacore addition: synonym for at(pos, len)
void clear()
Clear the string Warning: clear() executed as erase() due to missing clear() in gcc ...
LatticeExprNode replace(const LatticeExprNode &arg1, const LatticeExprNode &arg2)
This function replaces every masked-off element in the first argument with the corresponding element ...
string::difference_type difference_type
SubString help class to be used in at, before, ...
const_iterator end() const
string::size_type size_type
String & insert(size_type pos, Char c)
** Casacore addition
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
String & erase(size_type pos, size_type n=npos)
Erase.
TableExprNode trim(const TableExprNode &node)
String & assign(const string &str)
Assign.
LatticeExprNode operator<=(const LatticeExprNode &left, const LatticeExprNode &right)
Bool contains(Char c) const
Containment.
String & insert(size_type pos1, const string &str)
Insert.
LatticeExprNode toDouble(const LatticeExprNode &expr)
void insert(iterator p, InputIterator first, InputIterator last)
Int compare(const Char *s) const
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 & operator+=(const string &str)
Concatenate.
SubString & operator=(const SubString &str)
Assignment.
bool Bool
Define the standard types used by Casacore.
TableExprNode upcase(const TableExprNode &node)
size_type find(const string &str, size_type pos=0) const
Search functions.
String()
Default constructor.
reference operator[](size_type pos)
size_type find_first_not_of(const string &str, size_type pos=0) const
string::size_type length() const
Obtain length.
size_type find_last_of(const Char *s, size_type pos, size_type n) const
String & operator+=(const Char *s)
void insert(iterator p, size_type n, Char c)
string::const_iterator const_iterator
Int compare(const string &x, const Char y)
SubString at(Int pos, size_type len)
string::const_reference const_reference
const Char * data() const
As pointer to char array.
const_reverse_iterator rbegin() const
const Char * chars() const
** Casacore synonym
void alloc(size_type n)
** Casacore addition – works as a resize(n)
LatticeExprNode operator>(const LatticeExprNode &left, const LatticeExprNode &right)
String at(Int pos, size_type len) const
String at(size_type pos, size_type len) const
String & replace(size_type pos1, size_type n1, const string &str)
Replace.
String & insert(size_type pos, const Char *s, size_type n)
string::size_type len_p
Length of sub-string.
String(size_type n, Char c)
Construct from a single char (repeated n times)
Int compare(size_type pos1, size_type n1, const Char *s, size_type n2=npos) const
Int compare(const string &x, const Char *y)
String(const Char *s)
Construct from char array.
size_type rfind(Char c, size_type pos=npos) const
string::reverse_iterator reverse_iterator
String(const SubString &str)
Construct from a SubString.
LatticeExprNode operator+(const LatticeExprNode &expr)
Global functions operating on a LatticeExprNode.
size_type find_last_not_of(const Char *s, size_type pos=npos) const
String & append(InputIterator first, InputIterator last)
String & operator=(const string &str)
Assignments (they are all deep copies according to standard)
size_type rfind(const string &str, size_type pos=npos) const
void del(Int pos, Int len)
Overload problem.
String & insert(iterator p, const Char *s)
String substr(size_type pos=0, size_type n=npos) const
Get a sub string.
String & operator+=(Char c)
iterator insert(iterator p, Char c)
String & replace(size_type pos, size_type n1, Char c)
** Casacore addition
Abstract interface class to regular expressions for String.
string::traits_type traits_type
const Double c
Fundamental physical constants (SI units):
const_reference at(size_type n) const
Addressing.
const_reverse_iterator rend() const
String & append(size_type n, Char c)
Int compare(size_type pos1, size_type n1, const string &str) const
TableExprNode capitalize(const TableExprNode &node)
String: the storage and methods of handling collections of characters.
const_iterator begin() const
String & append(Char c)
** Casacore addition
LatticeExprNode operator<(const LatticeExprNode &left, const LatticeExprNode &right)
size_type find(const Char *s, size_type pos, size_type n) const
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)
size_type find_last_not_of(const string &str, size_type pos=npos) const
String(InputIterator begin, InputIterator end)
Construct from iterator.
string::const_reverse_iterator const_reverse_iterator
String(Char c)
From single char (** Casacore addition).
size_type find(const Char *s, size_type pos=0) const
size_type copy(Char *s, size_type n, size_type pos=0) const
Copy.
Bool matches(Char c, Int pos=0) const
this file contains all the compiler specific defines
String & append(const string &str)
Append.
String at(Int pos, Int len) const
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
String & operator=(const Char *s)
String(const Char *s, size_type n)
Construct from char* with given length.
String & replace(iterator i1, iterator i2, const string &str)
String & replace(size_type pos, size_type n1, const Char *s, size_type n2)
String & append(const string &str, size_type pos, size_type n)
SubString _substr(size_type first, size_type l) const
Helper functions for at, before etc.
static String toString(const T &value)
Convert a value to a String.
SubString after(Int pos)
Next one for overloading reasons.
SubString from(Int pos)
Next one for overloading reasons.
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