NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
StringVector Class Reference

This class is an extension to the std::vector<std::string> to provide the vector-like functionalities as requested by the string parser. It also provides the functionality to distinguish between a string and a numerical value. More...

#include <stringdatastructures.hpp>

Inheritance diagram for StringVector:
Collaboration diagram for StringVector:

Public Member Functions

 StringVector ()
 Default constructor. More...
 
 StringVector (const std::string &sStr)
 Create a StringVector instance from a string. More...
 
 StringVector (const char *sStr)
 Create a StringVector instance from a string. More...
 
 StringVector (bool val)
 Create a StringVector instance from a boolean. More...
 
 StringVector (const std::vector< std::string > &vect)
 Constructor from a std::vector<std::string>. It is assumed that the vector is already prepared for the local string definition. More...
 
 StringVector (const StringVector &vect)
 Copy a StringVector instance. More...
 
 StringVector (const std::vector< bool > &vect)
 Create a StringVector instance from a std::vector<bool>. More...
 
 StringVector (size_t n, const std::string &sStr=std::string())
 Create a StringVector with n elements. More...
 
 StringVector (StringVector &&vect)=default
 
StringVectoroperator= (const StringVector &sVect)
 Assignment operator overload for a StringVector instance. More...
 
StringVectoroperator= (StringVector &&sVect)=default
 
StringVectoroperator= (const std::vector< bool > &vect)
 Assignment operator overload for a std::vector<bool> instance. More...
 
void push_back (const std::string &sStr)
 Append a string to the end of this vector. Will be stored as local string. More...
 
void push_back (const char *sStr)
 Append a string to the end of this vector. Will be stored as local string. More...
 
void push_back (const mu::value_type &vVal)
 Append a mu::value_type to the end of this vector. More...
 
void push_back (size_t nVal)
 Append a size_t to the end of this vector. More...
 
void push_back (int nVal)
 Append an int to the end of this vector. More...
 
void push_back (long long int nVal)
 Append a long long int to the end of this vector. More...
 
void push_back (bool nVal)
 Append a boolean to the end of this vector. More...
 
void push_generic (const std::string &sStr)
 Append a generic string value to the end of this vector. Depending on the existence of surrounding quotation marks, it will be considered as local string or as a generic value. More...
 
bool is_string (size_t i) const
 Check whether the i-th element represents a string or a numeric value. More...
 
void convert_to_string (size_t i, size_t minChars=0)
 Convert the i-th element to a string. More...
 
StringView operator[] (size_t i) const
 Return a view to the i-th element. More...
 
StringArg getArg (size_t i) const
 Create a StringArg instance from the i-th or the 1st element, if this vector is a singleton. More...
 
std::string getMasked (size_t i) const
 Return the contained string with the internal quotation marks as escaped variants. More...
 
std::string & getRef (size_t i)
 Return a reference to the i-th element in this string. More...
 
std::vector< bool > operator== (const StringVector &sVect) const
 Equality operator overload. More...
 
std::vector< bool > operator!= (const StringVector &sVect) const
 Inequality operator overload. More...
 
std::vector< bool > operator< (const StringVector &sVect) const
 Less-than operator overload. More...
 
std::vector< bool > operator<= (const StringVector &sVect) const
 Lesser-equal operator overload. More...
 
std::vector< bool > operator> (const StringVector &sVect) const
 Greater-than operator overload. More...
 
std::vector< bool > operator>= (const StringVector &sVect) const
 Greater-equal operator overload. More...
 
std::vector< bool > and_f (const StringVector &sVect) const
 This member function represents an AND operator. More...
 
std::vector< bool > or_f (const StringVector &sVect) const
 This member function represents an OR operator. More...
 
std::vector< bool > xor_f (const StringVector &sVect) const
 This member function represents an XOR operator. More...
 
StringVector operator+ (const StringVector &sVect) const
 Concatenate two StringVectors. More...
 
StringVectoroperator+= (const StringVector &sVect)
 Append a StringVector to this instance. More...
 
StringVectorevalIfElse (const StringVector &sLogicals, const StringVector &sIfBranch, const StringVector &sElseBranch)
 Assign the results of an if-else construct to this StringVector instance. More...
 

Static Public Member Functions

static StringVector empty_string ()
 Static member function to create a StringVector with one component with zero length. More...
 
static StringVector convert_internal (const std::string &sInternal)
 Static member function to create a StringVector instance from an internal string. More...
 
static StringVector convert_literal (const std::string &sLiteral)
 Static member function to create a StringVector instance from a string literal. More...
 

Private Member Functions

StringView getVectorized (size_t i) const
 Get either the i-th element or the 1st element, if this vector has only one component (and is a singleton). More...
 
mu::value_type getNumericalVectorized (size_t i) const
 Get either the i-th element or the 1st element converted as numerical value, if this vector has only one component (and is a singleton). More...
 
bool getBooleanVectorized (size_t i) const
 Get either the i-th element or the 1st element converted as boolean, if this vector has only one component (and is a singleton). More...
 
void assign (const StringVector &sVect)
 Assign another StringVector instance. More...
 
void assign (const std::vector< bool > &vect)
 Assign an instance of a boolean vector. More...
 
StringVector operator+ (const std::string &sLiteral) const
 Concatenate a StringVector and a string literal. More...
 
StringVectoroperator+= (const std::string &sLiteral)
 Append a string literal to this StringVector instance. More...
 

Static Private Member Functions

static StringView makePureString (StringView sStr)
 Static member function to convert the contained string into a pur C++ string. More...
 
static std::string makeLocalString (const std::string &sStr)
 Static member function to convert the string literal to an internal string for this class. More...
 

Private Attributes

const std::string m_sDUMMY
 

Detailed Description

This class is an extension to the std::vector<std::string> to provide the vector-like functionalities as requested by the string parser. It also provides the functionality to distinguish between a string and a numerical value.

Definition at line 145 of file stringdatastructures.hpp.

Constructor & Destructor Documentation

◆ StringVector() [1/9]

StringVector::StringVector ( )

Default constructor.

Definition at line 173 of file stringdatastructures.cpp.

Referenced by convert_internal(), convert_literal(), operator+(), and operator+=().

◆ StringVector() [2/9]

StringVector::StringVector ( const std::string &  sStr)

Create a StringVector instance from a string.

Parameters
sStrconst std::string&

Definition at line 197 of file stringdatastructures.cpp.

◆ StringVector() [3/9]

StringVector::StringVector ( const char *  sStr)

Create a StringVector instance from a string.

Parameters
sStrconst char*

Definition at line 208 of file stringdatastructures.cpp.

◆ StringVector() [4/9]

StringVector::StringVector ( bool  val)

Create a StringVector instance from a boolean.

Parameters
sStrconst std::string&

Definition at line 219 of file stringdatastructures.cpp.

◆ StringVector() [5/9]

StringVector::StringVector ( const std::vector< std::string > &  vect)

Constructor from a std::vector<std::string>. It is assumed that the vector is already prepared for the local string definition.

Parameters
vectconst std::vector<std::string>&

Definition at line 186 of file stringdatastructures.cpp.

◆ StringVector() [6/9]

StringVector::StringVector ( const StringVector vect)

Copy a StringVector instance.

Parameters
vectconst StringVector&

Definition at line 229 of file stringdatastructures.cpp.

References assign().

Here is the call graph for this function:

◆ StringVector() [7/9]

StringVector::StringVector ( const std::vector< bool > &  vect)

Create a StringVector instance from a std::vector<bool>.

Parameters
vectconst std::vector<bool>&

Definition at line 242 of file stringdatastructures.cpp.

References assign().

Here is the call graph for this function:

◆ StringVector() [8/9]

StringVector::StringVector ( size_t  n,
const std::string &  sStr = std::string() 
)

Create a StringVector with n elements.

Parameters
nsize_t
sStrconst std::string&

Definition at line 255 of file stringdatastructures.cpp.

◆ StringVector() [9/9]

StringVector::StringVector ( StringVector &&  vect)
default

Member Function Documentation

◆ and_f()

std::vector< bool > StringVector::and_f ( const StringVector sVect) const

This member function represents an AND operator.

Parameters
sVectconst StringVector&
Returns
std::vector<bool>

Definition at line 746 of file stringdatastructures.cpp.

References getBooleanVectorized(), and max.

Referenced by NumeRe::StringParser::evaluateStack().

Here is the call graph for this function:

◆ assign() [1/2]

void StringVector::assign ( const std::vector< bool > &  vect)
private

Assign an instance of a boolean vector.

Parameters
vectconst std::vector<bool>&
Returns
void

Definition at line 159 of file stringdatastructures.cpp.

◆ assign() [2/2]

void StringVector::assign ( const StringVector sVect)
private

Assign another StringVector instance.

Parameters
sVectconst StringVector&
Returns
void

Definition at line 146 of file stringdatastructures.cpp.

Referenced by evalIfElse(), operator+=(), operator=(), and StringVector().

◆ convert_internal()

StringVector StringVector::convert_internal ( const std::string &  sInternal)
static

Static member function to create a StringVector instance from an internal string.

Parameters
sInternalconst std::string&
Returns
StringVector

Definition at line 281 of file stringdatastructures.cpp.

References StringVector().

Referenced by empty_string().

Here is the call graph for this function:

◆ convert_literal()

StringVector StringVector::convert_literal ( const std::string &  sLiteral)
static

Static member function to create a StringVector instance from a string literal.

Parameters
sLiteralconst std::string&
Returns
StringVector

Definition at line 295 of file stringdatastructures.cpp.

References makeLocalString(), and StringVector().

Referenced by NumeRe::StringParser::evaluateStack().

Here is the call graph for this function:

◆ convert_to_string()

void StringVector::convert_to_string ( size_t  i,
size_t  minChars = 0 
)

Convert the i-th element to a string.

Parameters
isize_t
minCharssize_t Only used for non-string values
Returns
void

Definition at line 474 of file stringdatastructures.cpp.

References is_string().

Referenced by NumeRe::StringFuncHandler::applySpecialStringFuncs(), and NumeRe::StringParser::numToString().

Here is the call graph for this function:

◆ empty_string()

StringVector StringVector::empty_string ( )
static

Static member function to create a StringVector with one component with zero length.

Returns
StringVector

Definition at line 267 of file stringdatastructures.cpp.

References convert_internal().

Referenced by strfnc_getenvvar(), strfnc_getfilelist(), strfnc_getfolderlist(), strfnc_getopt(), strfnc_max(), strfnc_min(), strfnc_replace(), strfnc_replaceall(), strfnc_split(), strfnc_strip(), strfnc_substr(), strfnc_sum(), strfnc_textparse(), and strfnc_to_string().

Here is the call graph for this function:

◆ evalIfElse()

StringVector & StringVector::evalIfElse ( const StringVector sLogicals,
const StringVector sIfBranch,
const StringVector sElseBranch 
)

Assign the results of an if-else construct to this StringVector instance.

Parameters
sLogicalsconst StringVector&
sIfBranchconst StringVector&
sElseBranchconst StringVector&
Returns
StringVector&

Definition at line 877 of file stringdatastructures.cpp.

References assign(), getArg(), getBooleanVectorized(), StringArg::getRef(), getRef(), and max.

Here is the call graph for this function:

◆ getArg()

StringArg StringVector::getArg ( size_t  i) const

Create a StringArg instance from the i-th or the 1st element, if this vector is a singleton.

Parameters
isize_t
Returns
StringArg

Definition at line 509 of file stringdatastructures.cpp.

Referenced by NumeRe::StringFuncHandler::callFunction(), NumeRe::StringFuncHandler::callFunctionParallel(), NumeRe::StringFuncHandler::callMultiFunction(), NumeRe::StringFuncHandler::callMultiFunctionParallel(), and evalIfElse().

◆ getBooleanVectorized()

bool StringVector::getBooleanVectorized ( size_t  i) const
private

Get either the i-th element or the 1st element converted as boolean, if this vector has only one component (and is a singleton).

Parameters
isize_t
Returns
bool

Definition at line 118 of file stringdatastructures.cpp.

References mu::ParserBase::Eval(), NumeReKernel::getInstance(), NumeReKernel::getParser(), getVectorized(), is_string(), StringViewBase::length(), and mu::ParserBase::SetExpr().

Referenced by and_f(), evalIfElse(), or_f(), and xor_f().

Here is the call graph for this function:

◆ getMasked()

std::string StringVector::getMasked ( size_t  i) const

Return the contained string with the internal quotation marks as escaped variants.

Parameters
isize_t
Returns
std::string

Definition at line 528 of file stringdatastructures.cpp.

References m_sDUMMY, and NEWSTRING.

◆ getNumericalVectorized()

mu::value_type StringVector::getNumericalVectorized ( size_t  i) const
private

Get either the i-th element or the 1st element converted as numerical value, if this vector has only one component (and is a singleton).

Parameters
isize_t
Returns
mu::value_type

Definition at line 88 of file stringdatastructures.cpp.

References mu::ParserBase::Eval(), NumeReKernel::getInstance(), NumeReKernel::getParser(), getVectorized(), is_string(), and mu::ParserBase::SetExpr().

Referenced by operator!=(), operator==(), operator>(), and operator>=().

Here is the call graph for this function:

◆ getRef()

std::string & StringVector::getRef ( size_t  i)

Return a reference to the i-th element in this string.

Parameters
isize_t
Returns
std::string&

Definition at line 579 of file stringdatastructures.cpp.

References toString().

Referenced by NumeRe::StringFuncHandler::applySpecialStringFuncs(), NumeRe::StringParser::createStringOutput(), NumeRe::StringParser::createTerminalOutput(), NumeRe::StringParser::eval(), evalIfElse(), operator+(), strfnc_getkeyval(), and strfnc_idxtolog().

Here is the call graph for this function:

◆ getVectorized()

StringView StringVector::getVectorized ( size_t  i) const
private

Get either the i-th element or the 1st element, if this vector has only one component (and is a singleton).

Parameters
isize_t
Returns
StringView

Definition at line 67 of file stringdatastructures.cpp.

References m_sDUMMY, and makePureString().

Referenced by getBooleanVectorized(), getNumericalVectorized(), operator!=(), operator+(), operator==(), operator>(), and operator>=().

Here is the call graph for this function:

◆ is_string()

bool StringVector::is_string ( size_t  i) const

◆ makeLocalString()

std::string StringVector::makeLocalString ( const std::string &  sStr)
staticprivate

Static member function to convert the string literal to an internal string for this class.

Parameters
sStrconst std::string&
Returns
std::string

Definition at line 49 of file stringdatastructures.cpp.

References toInternalString().

Referenced by convert_literal(), and push_generic().

Here is the call graph for this function:

◆ makePureString()

StringView StringVector::makePureString ( StringView  sStr)
staticprivate

Static member function to convert the contained string into a pur C++ string.

Parameters
sStrStringView
Returns
StringView

Definition at line 31 of file stringdatastructures.cpp.

References StringViewBase::front(), StringViewBase::length(), and StringView::subview().

Referenced by getVectorized(), and operator[]().

Here is the call graph for this function:

◆ operator!=()

std::vector< bool > StringVector::operator!= ( const StringVector sVect) const

Inequality operator overload.

Parameters
sVectconst StringVector&
Returns
std::vector<bool>

Definition at line 620 of file stringdatastructures.cpp.

References getNumericalVectorized(), getVectorized(), is_string(), and max.

Here is the call graph for this function:

◆ operator+() [1/2]

StringVector StringVector::operator+ ( const std::string &  sLiteral) const
private

Concatenate a StringVector and a string literal.

Parameters
sLiteralconst std::string&
Returns
StringVector

Definition at line 846 of file stringdatastructures.cpp.

References operator+(), and StringVector().

Referenced by operator+().

Here is the call graph for this function:

◆ operator+() [2/2]

StringVector StringVector::operator+ ( const StringVector sVect) const

Concatenate two StringVectors.

Parameters
sVectconst StringVector&
Returns
StringVector

Definition at line 808 of file stringdatastructures.cpp.

References getRef(), getVectorized(), is_string(), max, and StringViewBase::to_string().

Here is the call graph for this function:

◆ operator+=() [1/2]

StringVector & StringVector::operator+= ( const std::string &  sLiteral)
private

Append a string literal to this StringVector instance.

Parameters
sLiteralconst std::string&
Returns
StringVector&

Definition at line 860 of file stringdatastructures.cpp.

References assign(), and StringVector().

Here is the call graph for this function:

◆ operator+=() [2/2]

StringVector & StringVector::operator+= ( const StringVector sVect)

Append a StringVector to this instance.

Parameters
sVectconst StringVector&
Returns
StringVector&

Definition at line 831 of file stringdatastructures.cpp.

References assign().

Here is the call graph for this function:

◆ operator<()

std::vector< bool > StringVector::operator< ( const StringVector sVect) const

Less-than operator overload.

Parameters
sVectconst StringVector&
Returns
std::vector<bool>

Definition at line 620 of file stringdatastructures.cpp.

◆ operator<=()

std::vector< bool > StringVector::operator<= ( const StringVector sVect) const

Lesser-equal operator overload.

Parameters
sVectconst StringVector&
Returns
std::vector<bool>

Definition at line 620 of file stringdatastructures.cpp.

◆ operator=() [1/3]

StringVector & StringVector::operator= ( const std::vector< bool > &  vect)

Assignment operator overload for a std::vector<bool> instance.

Parameters
vectconst std::vector<bool>&
Returns
StringVector&

Definition at line 324 of file stringdatastructures.cpp.

References assign().

Here is the call graph for this function:

◆ operator=() [2/3]

StringVector & StringVector::operator= ( const StringVector sVect)

Assignment operator overload for a StringVector instance.

Parameters
sVectconst StringVector&
Returns
StringVector&

Definition at line 309 of file stringdatastructures.cpp.

References assign().

Here is the call graph for this function:

◆ operator=() [3/3]

StringVector & StringVector::operator= ( StringVector &&  sVect)
default

◆ operator==()

std::vector< bool > StringVector::operator== ( const StringVector sVect) const

Equality operator overload.

Parameters
sVectconst StringVector&
Returns
std::vector<bool>

Definition at line 595 of file stringdatastructures.cpp.

References getNumericalVectorized(), getVectorized(), is_string(), and max.

Here is the call graph for this function:

◆ operator>()

std::vector< bool > StringVector::operator> ( const StringVector sVect) const

Greater-than operator overload.

Parameters
sVectconst StringVector&
Returns
std::vector<bool>

Definition at line 695 of file stringdatastructures.cpp.

References getNumericalVectorized(), getVectorized(), is_string(), and max.

Here is the call graph for this function:

◆ operator>=()

std::vector< bool > StringVector::operator>= ( const StringVector sVect) const

Greater-equal operator overload.

Parameters
sVectconst StringVector&
Returns
std::vector<bool>

Definition at line 720 of file stringdatastructures.cpp.

References getNumericalVectorized(), getVectorized(), is_string(), and max.

Here is the call graph for this function:

◆ operator[]()

StringView StringVector::operator[] ( size_t  i) const

Return a view to the i-th element.

Parameters
isize_t
Returns
StringView

Definition at line 491 of file stringdatastructures.cpp.

References m_sDUMMY, and makePureString().

Here is the call graph for this function:

◆ or_f()

std::vector< bool > StringVector::or_f ( const StringVector sVect) const

This member function represents an OR operator.

Parameters
sVectconst StringVector&
Returns
std::vector<bool>

Definition at line 767 of file stringdatastructures.cpp.

References getBooleanVectorized(), and max.

Referenced by NumeRe::StringParser::evaluateStack().

Here is the call graph for this function:

◆ push_back() [1/7]

void StringVector::push_back ( bool  nVal)

Append a boolean to the end of this vector.

Parameters
nValbool
Returns
void

Definition at line 423 of file stringdatastructures.cpp.

References toString().

Here is the call graph for this function:

◆ push_back() [2/7]

void StringVector::push_back ( const char *  sStr)

Append a string to the end of this vector. Will be stored as local string.

Parameters
sStrconst char*
Returns
void

Definition at line 353 of file stringdatastructures.cpp.

◆ push_back() [3/7]

void StringVector::push_back ( const mu::value_type vVal)

Append a mu::value_type to the end of this vector.

Parameters
vValconst mu::value_type&
Returns
void

Definition at line 367 of file stringdatastructures.cpp.

References toString().

Here is the call graph for this function:

◆ push_back() [4/7]

◆ push_back() [5/7]

void StringVector::push_back ( int  nVal)

Append an int to the end of this vector.

Parameters
nValint
Returns
void

Definition at line 395 of file stringdatastructures.cpp.

References toString().

Here is the call graph for this function:

◆ push_back() [6/7]

void StringVector::push_back ( long long int  nVal)

Append a long long int to the end of this vector.

Parameters
nVallong long int
Returns
void

Definition at line 409 of file stringdatastructures.cpp.

References toString().

Here is the call graph for this function:

◆ push_back() [7/7]

void StringVector::push_back ( size_t  nVal)

Append a size_t to the end of this vector.

Parameters
nValsize_t
Returns
void

Definition at line 381 of file stringdatastructures.cpp.

References toString().

Here is the call graph for this function:

◆ push_generic()

void StringVector::push_generic ( const std::string &  sStr)

Append a generic string value to the end of this vector. Depending on the existence of surrounding quotation marks, it will be considered as local string or as a generic value.

Parameters
sStrconst std::string&
Returns
void

Definition at line 440 of file stringdatastructures.cpp.

References makeLocalString().

Referenced by NumeRe::StringFuncHandler::argumentParser(), NumeRe::StringParser::eval(), NumeRe::StringFuncHandler::evalFunction(), NumeRe::StringVarFactory::evaluateStringVectors(), strfnc_getfileinfo(), strfnc_getkeyval(), strfnc_strunique(), and StringResult::StringResult().

Here is the call graph for this function:

◆ xor_f()

std::vector< bool > StringVector::xor_f ( const StringVector sVect) const

This member function represents an XOR operator.

Parameters
sVectconst StringVector&
Returns
std::vector<bool>

Definition at line 788 of file stringdatastructures.cpp.

References getBooleanVectorized(), and max.

Referenced by NumeRe::StringParser::evaluateStack().

Here is the call graph for this function:

Member Data Documentation

◆ m_sDUMMY

const std::string StringVector::m_sDUMMY
private

Definition at line 148 of file stringdatastructures.hpp.

Referenced by getMasked(), getVectorized(), and operator[]().


The documentation for this class was generated from the following files: