casacore
Loading...
Searching...
No Matches
String.h File Reference
#include <algorithm>
#include <cassert>
#include <cctype>
#include <sstream>
#include <string>
#include <string_view>

Go to the source code of this file.

Classes

class  casacore::SubString
  More...
class  casacore::String
 String: the storage and methods of handling collections of characters. More...
struct  std::hash< casacore::String >

Namespaces

namespace  casacore
 For temporary backward namespace compatibility, use casa as alias for casacore.
namespace  std
 Define real & complex conjugation for non-complex types and put comparisons into std namespace.

Macros

#define CASACORE_DEPRECATE_STRING
 Comment this out to suppress warnings for use of non-std::string functions.
#define DEPRECATED(X)
 Some of the (deprecated) code calls deprecated functions, so disable this.

Functions

std::string::size_type casacore::IndexString (std::string_view str, char c, int startpos=0)
 Return the position of the character in the string or npos if not found.
std::string::size_type casacore::IndexString (std::string_view str, std::string_view pattern, int startpos=0)
 Return the position of the substring in the string or npos if not found.
bool casacore::EqualStringsAndNotEmpty (std::string_view str1, std::string_view str2, int position=0)
 Replacement of old member function "matches", which has somewhat confusing semantics: two empty strings do not match, and an empty pattern does also not match.
template<typename T>
bool casacore::StringToValue (const std::string &str, T &value, bool throw_on_error=true)
 Convert a String to a value.
template<typename T>
T casacore::StringToValue (const std::string &str, bool throw_on_error=true)
 Same as other StringToValue() overload, but returns the parsed value.
int casacore::StringToInt (const std::string &str, bool throw_on_error=false)
 Same as StringToValue<int>.
float casacore::StringToFloat (const std::string &str, bool throw_on_error=false)
 Same as StringToValue<float>.
double casacore::StringToDouble (const std::string &str, bool throw_on_error=false)
 Same as StringToValue<double>.
template<typename T>
std::string casacore::ValueToString (T &&value)
int casacore::RegexReplaceAll (std::string &str, const Regex &pat, const std::string &repl)
 Replace all matches of the string str with the regex @pat by @repl.
bool casacore::RegexMatches (const std::string &str, const Regex &r, int pos=0)
 Checks if the regex @r matches with the string @str.
std::string casacore::RegexSubStr (const std::string &str, const Regex &r, size_t startpos=0)
 Matches the regex and returns the matching part.
size_t casacore::RegexIndex (const std::string &str, const Regex &r, size_t startpos=0)
 Matches the regex and returns at what index in the string.
String casacore::operator+ (const String &lhs, const String &rhs)
 Global concatenation operators.
String casacore::operator+ (const char *lhs, const String &rhs)
String casacore::operator+ (char lhs, const String &rhs)
String casacore::operator+ (const String &lhs, const char *rhs)
String casacore::operator+ (const String &lhs, char rhs)
bool casacore::operator== (const String &x, const String &y)
 Global comparison operators.
bool casacore::operator!= (const String &x, const String &y)
bool casacore::operator> (const String &x, const String &y)
bool casacore::operator>= (const String &x, const String &y)
bool casacore::operator< (const String &x, const String &y)
bool casacore::operator<= (const String &x, const String &y)
bool casacore::operator== (const String &x, const char *t)
bool casacore::operator!= (const String &x, const char *t)
bool casacore::operator> (const String &x, const char *t)
bool casacore::operator>= (const String &x, const char *t)
bool casacore::operator< (const String &x, const char *t)
bool casacore::operator<= (const String &x, const char *t)
bool casacore::operator== (const String &x, const char t)
bool casacore::operator!= (const String &x, const char t)
bool casacore::operator> (const String &x, const char t)
bool casacore::operator>= (const String &x, const char t)
bool casacore::operator< (const String &x, const char t)
bool casacore::operator<= (const String &x, const char t)
int casacore::compare (const std::string &x, const std::string &y)
 ** Casacore additions of global compares.
int casacore::compare (const std::string &x, const char *y)
int casacore::compare (const std::string &x, const char y)
int casacore::fcompare (const String &x, const String &y)
 this version ignores case.
int casacore::split (const std::string &str, std::string res[], int maxn, const std::string &sep)
 Splitting Global function which splits the String into string array res at separator and returns the number of elements.
int casacore::split (const std::string &str, std::string res[], int maxn, const char sep)
int casacore::split (const std::string &str, std::string res[], int maxn, const Regex &sep)
String casacore::common_prefix (const std::string &x, const std::string &y, int startpos=0)
 Some general functions Functions to find special patterns, join and replicate .
String casacore::common_suffix (const std::string &x, const std::string &y, int startpos=-1)
String casacore::replicate (char c, String::size_type n)
String casacore::replicate (const std::string &str, String::size_type n)
String casacore::join (std::string src[], int n, const std::string &sep)
String casacore::reverse (const std::string &str)
 Casing and related functions Case conversion and rearrangement functions .
String casacore::upcase (const std::string &str)
 Global function which returns a transformation to uppercase of String.
String casacore::downcase (const std::string &str)
 Global function which returns a transformation to lowercase of String.
String casacore::capitalize (const std::string &str)
 Global function which returns a transformation to capitalization of String.
String casacore::trim (const std::string &str)
 Global function which removes leading and trailing whitespace.
std::ostream & casacore::operator<< (std::ostream &s, const String &x)
 IO .
void casacore::LTrimInPlace (std::string &str, char character)
 Remove specified character from beginning of string.
void casacore::LTrimInPlace (std::string &str, std::string_view characters)
 Remove specified characters from beginning of string.
void casacore::RTrimInPlace (std::string &str, char character)
 Remove specified character from end of string.
void casacore::RTrimInPlace (std::string &str, std::string_view characters)
 Remove specified characters from end of string.
void casacore::TrimInPlace (std::string &str, char single_character)
 Remove specified char from beginning and end of string.
void casacore::TrimInPlace (std::string &str, std::string_view characters=kWhiteSpaceCharacters)
 Remove specified chars from beginning and end of string.
std::string casacore::FormatString (const char *format_string,...)
 Like sprintf.
std::size_t casacore::SubStringCount (std::string_view str, std::string_view pattern)
 Returns the number of times a given pattern occurs in a string.
std::string_view casacore::GetStringUpToExcluding (std::string_view input, std::string_view pattern, size_t start_position=0)
 Gets a part of a string up to and excluding a specified pattern.
std::string_view casacore::GetStringUpToIncluding (std::string_view input, std::string_view pattern, size_t start_position=0)
 Rather specific function – this is a replacement for String:through() with string argument, but maybe String::through() is rarely used, in which case this function should be removed.
std::string_view casacore::GetStringFrom (std::string_view input, std::string_view pattern, size_t start_position=0)
 Get a string starting at a specific pattern that is found in the string.
std::string_view casacore::GetStringAfter (std::string_view input, std::string_view pattern, size_t start_position=0)
 Rather specific function – this is a replacement for String:after(), but maybe String::after() is rarely used, in which case this function should be removed.
void casacore::ToUpperCaseInPlace (std::string &str)
 Converts the specified string to upper case, in place.
void casacore::ToLowerCaseInPlace (std::string &str)
 Converts the specified string to lower case, in place.
void casacore::CapitalizeStringInPlace (std::string &str)
 Changes the casing such that every separate word starts with an uppercase character and continues lowercase.
void casacore::EraseStringFrom (std::string &str, std::string_view pattern, size_t start_position=0)
 Remove the end of a string, starting from a specified pattern.
size_t casacore::ReplaceAllInPlace (std::string &str, std::string_view pattern, std::string_view replacement)
 Replace every occurence of pattern in str by replacement.
constexpr bool casacore::StringContains (std::string_view str, std::string_view pattern)
 Determines if a given string contains another given string.

Variables

const std::string_view casacore::kWhiteSpaceCharacters
 Standard white space characters: space, new line, tab and carriage return.
const std::string_view casacore::kExtendedWhiteSpaceCharacters
 All the characters of kWhiteSpaceCharacters, extended with vertical tab (\v) and form feed (\f).

Macro Definition Documentation

◆ CASACORE_DEPRECATE_STRING

#define CASACORE_DEPRECATE_STRING

Comment this out to suppress warnings for use of non-std::string functions.

String.h: String class

Definition at line 30 of file String.h.

◆ DEPRECATED

#define DEPRECATED ( X)

Some of the (deprecated) code calls deprecated functions, so disable this.

Definition at line 36 of file String.h.

Referenced by casacore::SubString::operator=(), casacore::SubString::operator=(), casacore::SubString::operator=(), and casacore::SubString::operator=().