Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::Kernel::MultiFileNameParsing::Parser Class Reference

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, ReverseCaselessComparem_validInstNames
 All the valid instrument names. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Parser()

Mantid::Kernel::MultiFileNameParsing::Parser::Parser ( )

◆ ~Parser()

Mantid::Kernel::MultiFileNameParsing::Parser::~Parser ( )
default

Destructor.

Member Function Documentation

◆ clear()

void Mantid::Kernel::MultiFileNameParsing::Parser::clear ( )
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().

◆ dirString()

std::string Mantid::Kernel::MultiFileNameParsing::Parser::dirString ( ) const
inline

Return the parsed directory string.

Definition at line 77 of file MultiFileNameParser.h.

◆ extString()

std::string Mantid::Kernel::MultiFileNameParsing::Parser::extString ( ) const
inline

Return the parsed extension string.

Definition at line 85 of file MultiFileNameParser.h.

◆ fileNames()

std::vector< std::vector< std::string > > Mantid::Kernel::MultiFileNameParsing::Parser::fileNames ( ) const
inline

Return the vector of vectors of parsed file names.

Definition at line 75 of file MultiFileNameParser.h.

Referenced by Mantid::API::MultipleFileProperty::setValueAsMultipleFiles().

◆ instString()

std::string Mantid::Kernel::MultiFileNameParsing::Parser::instString ( ) const
inline

Return the parsed instrument string.

Definition at line 79 of file MultiFileNameParser.h.

Referenced by Mantid::Kernel::MultiFileNameParsing::suggestWorkspaceName().

◆ parse()

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.

Parameters
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().

◆ parseMultiRunString()

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.)

Parameters
runString:: a string containing the runs to parse, in the correct format.
Returns
a vector of vectors of unsigned ints, one int for each run, where runs to be added are contained in the same sub-vector.
Exceptions
std::runtime_errorwhen runString provided is in an incorrect format.

Definition at line 192 of file MultiFileNameParser.cpp.

References runString(), and trimWhiteSpaces().

Referenced by parse().

◆ runs()

std::vector< std::vector< unsigned int > > Mantid::Kernel::MultiFileNameParsing::Parser::runs ( ) const
inline

Return the vector of vectors of parsed file names.

Definition at line 73 of file MultiFileNameParser.h.

Referenced by Mantid::Kernel::MultiFileNameParsing::suggestWorkspaceName().

◆ runString()

std::string Mantid::Kernel::MultiFileNameParsing::Parser::runString ( ) const
inline

Return the parsed run string.

Definition at line 83 of file MultiFileNameParser.h.

Referenced by parseMultiRunString().

◆ setTrimWhiteSpaces()

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.

Parameters
settingThe new setting value

Definition at line 237 of file MultiFileNameParser.cpp.

References m_trimWhiteSpaces.

Referenced by Mantid::API::MultipleFileProperty::setValueAsMultipleFiles().

◆ split()

void Mantid::Kernel::MultiFileNameParsing::Parser::split ( )
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.

Exceptions
std::runtime_errorif 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().

◆ trimWhiteSpaces()

bool Mantid::Kernel::MultiFileNameParsing::Parser::trimWhiteSpaces ( ) const

Return the setting for trimming whitespaces in run string.

Returns value of trimming whitespace from input.

Returns
True/False

Definition at line 229 of file MultiFileNameParser.cpp.

References m_trimWhiteSpaces.

Referenced by parseMultiRunString(), and split().

◆ underscoreString()

std::string Mantid::Kernel::MultiFileNameParsing::Parser::underscoreString ( ) const
inline

Return the parsed underscore string.

Definition at line 81 of file MultiFileNameParser.h.

Referenced by Mantid::Kernel::MultiFileNameParsing::suggestWorkspaceName().

Member Data Documentation

◆ m_dirString

std::string Mantid::Kernel::MultiFileNameParsing::Parser::m_dirString
private

The various sections of the given string to parse.

Definition at line 107 of file MultiFileNameParser.h.

Referenced by clear(), parse(), and split().

◆ m_extString

std::string Mantid::Kernel::MultiFileNameParsing::Parser::m_extString
private

Definition at line 107 of file MultiFileNameParser.h.

Referenced by clear(), parse(), and split().

◆ m_fileNames

std::vector<std::vector<std::string> > Mantid::Kernel::MultiFileNameParsing::Parser::m_fileNames
private

A vector of vectors of the parsed file names.

Definition at line 103 of file MultiFileNameParser.h.

Referenced by clear(), and parse().

◆ m_instString

std::string Mantid::Kernel::MultiFileNameParsing::Parser::m_instString
private

Definition at line 107 of file MultiFileNameParser.h.

Referenced by clear(), parse(), and split().

◆ m_multiFileName

std::string Mantid::Kernel::MultiFileNameParsing::Parser::m_multiFileName
private

The given string to parse.

Definition at line 105 of file MultiFileNameParser.h.

Referenced by clear(), parse(), and split().

◆ m_runs

std::vector<std::vector<unsigned int> > Mantid::Kernel::MultiFileNameParsing::Parser::m_runs
private

A vector of vectors of the parsed runs.

Definition at line 101 of file MultiFileNameParser.h.

Referenced by clear(), and parse().

◆ m_runString

std::string Mantid::Kernel::MultiFileNameParsing::Parser::m_runString
private

Definition at line 107 of file MultiFileNameParser.h.

Referenced by clear(), parse(), and split().

◆ m_trimWhiteSpaces

bool Mantid::Kernel::MultiFileNameParsing::Parser::m_trimWhiteSpaces
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().

◆ m_underscoreString

std::string Mantid::Kernel::MultiFileNameParsing::Parser::m_underscoreString
private

Definition at line 107 of file MultiFileNameParser.h.

Referenced by clear(), and split().

◆ m_validInstNames

std::set<std::string, ReverseCaselessCompare> Mantid::Kernel::MultiFileNameParsing::Parser::m_validInstNames
private

All the valid instrument names.

Definition at line 109 of file MultiFileNameParser.h.

Referenced by Parser(), and split().


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