Mantid
|
This class parses a given string into vector of vectors of numbers. More...
#include <UserStringParser.h>
Public Member Functions | |
std::vector< std::vector< unsigned int > > | parse (const std::string &userString) |
parses a given string into a vector of vector of numbers More... | |
Private Member Functions | |
bool | Contains (const std::string &input, char ch) |
This method checks the input string contains the character ch. More... | |
void | convertToNumbers (const std::string &input, const std::vector< std::string > &tokens, unsigned int &start, unsigned int &end, unsigned int &step) |
converts the parsed tokens to numbers More... | |
bool | isValid (const std::string &input, std::vector< std::string > &tokens) |
validates the input string More... | |
bool | isValidStepSeparator (const std::string &input, const std::vector< std::string > &tokens) |
This method checks the separator preceded by the step string is valid colon ':' is valid separator for step string. More... | |
void | parse (const std::string &userString, std::vector< std::vector< unsigned int > > &numbers) |
convert the string into numbers More... | |
std::vector< std::vector< unsigned int > > | separateColon (const std::string &input) |
separates a given string to vector of vector of numbers using colon as the delimeter More... | |
std::vector< std::string > | separateComma (const std::string &) |
separate a given string to a vector of comma separated strings More... | |
std::vector< unsigned int > | separateDelimiters (const std::string &input, const std::string &delimiters) |
separate delimiter string from input string and return a vector of numbers created from the separated string More... | |
void | Tokenize (const std::string &input, const std::string &delimiter, unsigned int &start, unsigned int &end, unsigned int &step) |
This method removes the separator string from the input string and converts the tokens to unisgned int. More... | |
unsigned int | toUInt (const std::string &input) |
converts a string to int. More... | |
This class parses a given string into vector of vectors of numbers.
For example : 60,61+62,63-66,67:70,71-75:2 This gives a vector containing 8 vectors as Vec[8] and Vec[0] is a vector containing 1 element 60 Vec[1] is a vector containing elements 61,62 Vec[2] is a vector containing elements 63,64,65,66, Vec[3] is a vector containing element 67,Vec[4] is a vector containing element 68, Vec[5] is a vector containing element 69,Vec[6] is a vector containing element 70 , vec[7] is a vector containing element 71,73,75
Definition at line 36 of file UserStringParser.h.
|
private |
This method checks the input string contains the character ch.
This method checks input string contains character ch.
input | - the input string |
ch | - character ch to search |
Definition at line 76 of file UserStringParser.cpp.
Referenced by parse().
|
private |
converts the parsed tokens to numbers
This method checks the input string is valid format.
input | - input string to validate |
tokens | - vector containing separated values. |
start | - start number |
end | - end number |
step | - step used for incrementing |
Definition at line 179 of file UserStringParser.cpp.
References toUInt().
Referenced by Tokenize().
|
private |
validates the input string
|
private |
This method checks the separator preceded by the step string is valid colon ':' is valid separator for step string.
input | - input string to validate |
tokens | - vector containing separated values. |
Definition at line 157 of file UserStringParser.cpp.
References index.
Referenced by Tokenize().
std::vector< std::vector< unsigned int > > Mantid::Kernel::UserStringParser::parse | ( | const std::string & | userString | ) |
parses a given string into a vector of vector of numbers
This method parses a given string of numbers and returns a vector of vector of numbers.
userString | - the string to parse |
Definition at line 21 of file UserStringParser.cpp.
References parse(), and separateComma().
Referenced by parse().
|
private |
convert the string into numbers
This method parses a given string of numbers and returns a vector of vector of numbers.
userString | - the input string to parse |
numbers- | a vector containing vectors of numbers. |
Definition at line 45 of file UserStringParser.cpp.
References Contains(), separateColon(), separateDelimiters(), toUInt(), and value.
|
private |
separates a given string to vector of vector of numbers using colon as the delimeter
This method parses a given string of numbers into colon separated tokens.
input | - the string to parse |
Definition at line 95 of file UserStringParser.cpp.
References Tokenize().
Referenced by parse().
|
private |
separate a given string to a vector of comma separated strings
This method parses a given string of numbers into comma separated tokens.
input | - the string to parse |
Definition at line 85 of file UserStringParser.cpp.
References Mantid::Kernel::StringTokenizer::asVector(), and Mantid::Kernel::StringTokenizer::TOK_TRIM.
Referenced by parse().
|
private |
separate delimiter string from input string and return a vector of numbers created from the separated string
This method parses a given string of numbers into tokens using the separator character symbol.
input | - the string to parse |
delimiters | - the string used as separator |
Definition at line 114 of file UserStringParser.cpp.
References Tokenize().
Referenced by parse().
|
private |
This method removes the separator string from the input string and converts the tokens to unisgned int.
This method parses a given string of numbers into tokens based on the given separator returns numbers corresponding to separated tokens and separators if any.
input | - the string to parse |
delimiter | - character to separate |
start | - a number corresponding to the string before delimiter |
end | - a number corresponding to the string after delimiter |
step | - number used to increment from the start num generate the series of numbers . |
Definition at line 138 of file UserStringParser.cpp.
References Mantid::Kernel::StringTokenizer::asVector(), convertToNumbers(), and isValidStepSeparator().
Referenced by separateColon(), and separateDelimiters().
|
private |
converts a string to int.
This method converts a string to unsigned int.
input | - the string to parse |
Definition at line 209 of file UserStringParser.cpp.
Referenced by convertToNumbers(), and parse().