Mantid
|
This class takes a string representing multiple files and parses it into a vector of vectors of file names. More...
#include <MultiFileNameParser.h>
Public Member Functions | |
std::string | dirString () const |
Return the parsed directory string. More... | |
std::string | extString () const |
Return the parsed extension string. More... | |
std::vector< std::vector< std::string > > | fileNames () const |
Return the vector of vectors of parsed file names. More... | |
std::string | instString () const |
Return the parsed instrument string. More... | |
void | parse (const std::string &multiFileName) |
Parse the given multiFileNameString. More... | |
std::vector< std::vector< unsigned int > > | parseMultiRunString (std::string runString) |
Parses a string consisting of only run number info, into a vector of vector of run numbers. More... | |
Parser () | |
Constructor. More... | |
std::vector< std::vector< unsigned int > > | runs () const |
Return the vector of vectors of parsed file names. More... | |
std::string | runString () const |
Return the parsed run string. More... | |
void | setTrimWhiteSpaces (const bool &setting) |
Set the flag for trimming whitespaces in run string. More... | |
bool | trimWhiteSpaces () const |
Return the setting for trimming whitespaces in run string. More... | |
std::string | underscoreString () const |
Return the parsed underscore string. More... | |
~Parser ()=default | |
Destructor. More... | |
Private Member Functions | |
void | clear () |
Clear all member variables. More... | |
void | split () |
Split the string to parse into its component parts. More... | |
Private Attributes | |
std::string | m_dirString |
The various sections of the given string to parse. More... | |
std::string | m_extString |
std::vector< std::vector< std::string > > | m_fileNames |
A vector of vectors of the parsed file names. More... | |
std::string | m_instString |
std::string | m_multiFileName |
The given string to parse. More... | |
std::vector< std::vector< unsigned int > > | m_runs |
A vector of vectors of the parsed runs. More... | |
std::string | m_runString |
bool | m_trimWhiteSpaces |
Flag to determine if string input should be trimmed of whitespace. More... | |
std::string | m_underscoreString |
std::set< std::string, ReverseCaselessCompare > | m_validInstNames |
All the valid instrument names. More... | |
This class takes a string representing multiple files and parses it into a vector of vectors of file names.
Filenames to be added are placed in the same sub vectors.
The string to parse should be of the format [dir][inst][under][runs][ext], where:
[dir] (Optional) = The OS-specific file directory, e.g. "c:\data\" [inst] (Optional) = The instrument name, e.g. "IRS" or "PG3". If none provided then use default. [under] (Optional) = An underscore. [runs] (Required) = The run numbers, e.g. "0102, 0110-0115, 0120, 0130:0140:2" [ext] (Optional) = The file extension, e.g. ".raw"
NOTE: This parser does not parse strings of the form: [dir][inst][under][runs][ext],[dir][inst][under][runs][ext]
Definition at line 62 of file MultiFileNameParser.h.
Mantid::Kernel::MultiFileNameParsing::Parser::Parser | ( | ) |
Constructor.
Definition at line 138 of file MultiFileNameParser.cpp.
References Mantid::Kernel::ConfigServiceImpl::getFacilities(), Mantid::Kernel::SingletonHolder< T >::Instance(), and m_validInstNames.
|
default |
Destructor.
|
private |
Clear all member variables.
Clears all member variables.
Definition at line 246 of file MultiFileNameParser.cpp.
References m_dirString, m_extString, m_fileNames, m_instString, m_multiFileName, m_runs, m_runString, and m_underscoreString.
Referenced by parse().
|
inline |
Return the parsed directory string.
Definition at line 77 of file MultiFileNameParser.h.
|
inline |
Return the parsed extension string.
Definition at line 85 of file MultiFileNameParser.h.
|
inline |
Return the vector of vectors of parsed file names.
Definition at line 75 of file MultiFileNameParser.h.
Referenced by Mantid::API::MultipleFileProperty::setValueAsMultipleFiles().
|
inline |
Return the parsed instrument string.
Definition at line 79 of file MultiFileNameParser.h.
Referenced by Mantid::Kernel::MultiFileNameParsing::suggestWorkspaceName().
void Mantid::Kernel::MultiFileNameParsing::Parser::parse | ( | const std::string & | multiFileName | ) |
Parse the given multiFileNameString.
Takes the given multiFileName string, and calls other parts of the parser to generate a corresponding vector of vectors of file names.
multiFileName | :: the string containing the multiple file names to be parsed. |
Definition at line 161 of file MultiFileNameParser.cpp.
References clear(), m_dirString, m_extString, m_fileNames, m_instString, m_multiFileName, m_runs, m_runString, parseMultiRunString(), and split().
Referenced by Mantid::API::MultipleFileProperty::setValueAsMultipleFiles(), and Mantid::Kernel::MultiFileNameParsing::suggestWorkspaceName().
std::vector< std::vector< unsigned int > > Mantid::Kernel::MultiFileNameParsing::Parser::parseMultiRunString | ( | std::string | runString | ) |
Parses a string consisting of only run number info, into a vector of vector of run numbers.
Parses a string containing a comma separated list of run "tokens", where each run token is of one of the allowed forms (a single run or a range of runs or an added range of runs, etc.)
runString | :: a string containing the runs to parse, in the correct format. |
std::runtime_error | when runString provided is in an incorrect format. |
Definition at line 192 of file MultiFileNameParser.cpp.
References runString(), and trimWhiteSpaces().
Referenced by parse().
|
inline |
Return the vector of vectors of parsed file names.
Definition at line 73 of file MultiFileNameParser.h.
Referenced by Mantid::Kernel::MultiFileNameParsing::suggestWorkspaceName().
|
inline |
Return the parsed run string.
Definition at line 83 of file MultiFileNameParser.h.
Referenced by parseMultiRunString().
void Mantid::Kernel::MultiFileNameParsing::Parser::setTrimWhiteSpaces | ( | const bool & | setting | ) |
Set the flag for trimming whitespaces in run string.
Sets if the property is set to automatically trim string unput values of whitespace.
setting | The new setting value |
Definition at line 237 of file MultiFileNameParser.cpp.
References m_trimWhiteSpaces.
Referenced by Mantid::API::MultipleFileProperty::setValueAsMultipleFiles().
|
private |
Split the string to parse into its component parts.
Splits up the m_multiFileName string into component parts, to be used elsewhere by the parser.
Some validation is done here, and exceptions thrown if required components are missing.
std::runtime_error | if a required component is not present in the string. |
Definition at line 265 of file MultiFileNameParser.cpp.
References Mantid::Kernel::SingletonHolder< T >::Instance(), Mantid::Kernel::MultiFileNameParsing::Regexs::LIST, m_dirString, m_extString, m_instString, m_multiFileName, m_runString, m_underscoreString, m_validInstNames, and trimWhiteSpaces().
Referenced by parse().
bool Mantid::Kernel::MultiFileNameParsing::Parser::trimWhiteSpaces | ( | ) | const |
Return the setting for trimming whitespaces in run string.
Returns value of trimming whitespace from input.
Definition at line 229 of file MultiFileNameParser.cpp.
References m_trimWhiteSpaces.
Referenced by parseMultiRunString(), and split().
|
inline |
Return the parsed underscore string.
Definition at line 81 of file MultiFileNameParser.h.
Referenced by Mantid::Kernel::MultiFileNameParsing::suggestWorkspaceName().
|
private |
The various sections of the given string to parse.
Definition at line 107 of file MultiFileNameParser.h.
|
private |
Definition at line 107 of file MultiFileNameParser.h.
|
private |
A vector of vectors of the parsed file names.
Definition at line 103 of file MultiFileNameParser.h.
|
private |
Definition at line 107 of file MultiFileNameParser.h.
|
private |
The given string to parse.
Definition at line 105 of file MultiFileNameParser.h.
|
private |
A vector of vectors of the parsed runs.
Definition at line 101 of file MultiFileNameParser.h.
|
private |
Definition at line 107 of file MultiFileNameParser.h.
|
private |
Flag to determine if string input should be trimmed of whitespace.
Definition at line 111 of file MultiFileNameParser.h.
Referenced by setTrimWhiteSpaces(), and trimWhiteSpaces().
|
private |
Definition at line 107 of file MultiFileNameParser.h.
|
private |
All the valid instrument names.
Definition at line 109 of file MultiFileNameParser.h.