Skip to content

datatypes::utils::StringProcessing

Helper class with string processing related functions. These emulate methods found in other languages such as C#, R, etc.

#include <common.h>

Public Functions

Name
vector< string > Split(const string & s, const string & separators)
string TrimAny(const string & s, const string & charactersToTrim)
vector< string > SplitOnSpaces(const string & s, bool removeEmptyEntries)
vector< string > RemoveEmpty(const vector< string > & s)
vector< string > Concatenate(const vector< vector< string >> & vars)
void Concatenate(vector< string > & a, const vector< string > & b)
bool Contains(const string & toTest, const string & toMatch, bool caseSensitive =true)
bool StartsWith(const string & toTest, const string & toMatch, bool caseSensitive =true)
bool Equals(const string & toTest, const string & toMatch, bool caseSensitive =true)
bool EqualsAny(const string & toTest, const vector< string > & toMatch, bool caseSensitive =true)
bool StringPredicate(const string & toTest, const string & toMatch, boost::function< bool(const string &, const string &)> predicate, bool caseSensitive =true)
string Paste(const vector< string > & items, const string & sep ="")
vector< string > VPaste(const vector< string > & prefixes, const string & postfix, const string & sep ="")
vector< string > VPaste(const string & prefix, const vector< string > & postfixes, const string & sep ="")
bool ContainsAll(const vector< string > & toTest, const vector< string > & toMatch, bool caseSensitive =true)
bool SetEquals(const vector< string > & toTest, const vector< string > & toMatch, bool caseSensitive =true)
vector< string > SetDiff(const vector< string > & toTest, const vector< string > & toRemove, bool caseSensitive =true)
vector< string > Unique(const vector< string > & set)
string BuildIdentifier(vector< string > & tokens, int fromIndex, int toIndex =-1, const string & sep =StringProcessing::kElementSeparatorToken)
string BuildIdentifier(const string & a, const string & b, const string & sep =StringProcessing::kElementSeparatorToken)

Public Attributes

Name
const string kElementSeparatorToken

Public Functions Documentation

function Split

static vector< string > Split(
    const string & s,
    const string & separators
)

function TrimAny

static string TrimAny(
    const string & s,
    const string & charactersToTrim
)

function SplitOnSpaces

static vector< string > SplitOnSpaces(
    const string & s,
    bool removeEmptyEntries
)

function RemoveEmpty

static vector< string > RemoveEmpty(
    const vector< string > & s
)

function Concatenate

static vector< string > Concatenate(
    const vector< vector< string >> & vars
)

function Concatenate

static void Concatenate(
    vector< string > & a,
    const vector< string > & b
)

function Contains

static bool Contains(
    const string & toTest,
    const string & toMatch,
    bool caseSensitive =true
)

function StartsWith

static bool StartsWith(
    const string & toTest,
    const string & toMatch,
    bool caseSensitive =true
)

function Equals

static bool Equals(
    const string & toTest,
    const string & toMatch,
    bool caseSensitive =true
)

function EqualsAny

static bool EqualsAny(
    const string & toTest,
    const vector< string > & toMatch,
    bool caseSensitive =true
)

function StringPredicate

static bool StringPredicate(
    const string & toTest,
    const string & toMatch,
    boost::function< bool(const string &, const string &)> predicate,
    bool caseSensitive =true
)

function Paste

static string Paste(
    const vector< string > & items,
    const string & sep =""
)

function VPaste

static vector< string > VPaste(
    const vector< string > & prefixes,
    const string & postfix,
    const string & sep =""
)

function VPaste

static vector< string > VPaste(
    const string & prefix,
    const vector< string > & postfixes,
    const string & sep =""
)

function ContainsAll

static bool ContainsAll(
    const vector< string > & toTest,
    const vector< string > & toMatch,
    bool caseSensitive =true
)

function SetEquals

static bool SetEquals(
    const vector< string > & toTest,
    const vector< string > & toMatch,
    bool caseSensitive =true
)

function SetDiff

static vector< string > SetDiff(
    const vector< string > & toTest,
    const vector< string > & toRemove,
    bool caseSensitive =true
)

function Unique

static vector< string > Unique(
    const vector< string > & set
)

function BuildIdentifier

static string BuildIdentifier(
    vector< string > & tokens,
    int fromIndex,
    int toIndex =-1,
    const string & sep =StringProcessing::kElementSeparatorToken
)

function BuildIdentifier

static string BuildIdentifier(
    const string & a,
    const string & b,
    const string & sep =StringProcessing::kElementSeparatorToken
)

Public Attributes Documentation

variable kElementSeparatorToken

static const string kElementSeparatorToken;

Updated on 2022-08-21 at 18:10:33 +1000