StringHelper Class Reference

Back to the index.

Static Public Member Functions | List of all members
StringHelper Class Reference

A helper class, with static functions for common string operations. More...

#include <StringHelper.h>

Inheritance diagram for StringHelper:
UnitTestable

Static Public Member Functions

static uint64_t ParseNumber (const char *str, bool &error)
 Parses a string into a 64-bit number. More...
 
static vector< string > SplitStringIntoVector (const string &str, const char splitter)
 Splits a string with a certain delimiter into a vector of strings. More...
 
static void RunUnitTests (int &nSucceeded, int &nFailures)
 
- Static Public Member Functions inherited from UnitTestable
static void RunUnitTests (int &nSucceeded, int &nFailures)
 Runs unit test cases. More...
 

Detailed Description

A helper class, with static functions for common string operations.

Definition at line 39 of file StringHelper.h.

Member Function Documentation

◆ ParseNumber()

uint64_t StringHelper::ParseNumber ( const char *  str,
bool &  error 
)
static

Parses a string into a 64-bit number.

Parameters
strA pointer to a character string.
errorSet to false if a parsed value is returned, true on parse errors.
Returns
A uint64_t, representing the parsed value.

Definition at line 34 of file StringHelper.cc.

Referenced by Component::CheckVariableWrite(), FileLoader_raw::LoadIntoComponent(), and StateVariable::SetValue().

◆ RunUnitTests()

static void StringHelper::RunUnitTests ( int &  nSucceeded,
int &  nFailures 
)
static

◆ SplitStringIntoVector()

vector< string > StringHelper::SplitStringIntoVector ( const string &  str,
const char  splitter 
)
static

Splits a string with a certain delimiter into a vector of strings.

E.g. if the input string is "A:B:C" and the splitter is ':', then the resulting vector consists of 3 strings: "A", "B", and "C".

NOTE: The current implementation is very slow, but it at least it works.

Parameters
strA string to split.
splitterSet to false if a parsed value is returned, true on parse errors.
Returns
A vector of strings (without the splitter char).

Definition at line 99 of file StringHelper.cc.

Referenced by ComponentFactory::CreateComponent(), FileLoader_raw::DetectFileType(), and FileLoader_raw::LoadIntoComponent().


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

Generated on Tue Mar 24 2020 14:04:48 for GXemul by doxygen 1.8.17