Namespaces | |
namespace | errors |
Classes | |
struct | Constructor_t |
Functions | |
int | TokeniseByDelimiter (const std::string &input, std::vector< std::string > &output, const char *delim) |
int | TokeniseByWhiteSpace (const std::string &input, std::vector< std::string > &output) |
std::string | GetOneWord (const std::string &in, size_t start=0, size_t stop=std::string::npos) |
Constructor_t | ParseConstructor (const std::string &input, char open='(', char close=')') throw (modules::parser::errors::unmatched_parenthesis) |
void | ToCppValid (std::string &input) |
const std::string & | ToCppValid (const std::string &input) |
void | ReplaceAll (std::string &input, const std::string &search, const std::string &replace) |
void | ReplaceWords (std::string &input, const std::string &search, const std::string &replace) |
const std::string & | ReplaceAll (const std::string &input, const std::string &search, const std::string &replace) |
size_t | RemoveWhitespace (std::string &input) |
size_t | RemoveWhitespace (std::string &input, std::string::iterator start, std::string::iterator end) |
void | TrimWhiteSpaceBeforeAfter (std::string &input) |
bool | IsWhitespace (char in) |
bool | IsDigit (char in) |
bool | IsDecimal (char in) |
bool | IsFloatChar (char in) |
bool | IsNotFloatChar (char in) |
bool | IsNumber (const std::string &input) |
int | GetNumber (const std::string &input) |
bool | IsTrue (const std::string &input) |
double | GetDouble (const std::string &input, size_t start=0, size_t stop=std::string::npos) |
bool | iequals (const std::string &a, const std::string &b) |
bool | iequals (const char a, const char b) |
Variables | |
const int | max_line = 2048 |
double modules::parser::GetDouble | ( | const std::string & | input, | |
size_t | start = 0 , |
|||
size_t | stop = std::string::npos | |||
) |
Definition at line 161 of file ModulesParser.cpp.
int modules::parser::GetNumber | ( | const std::string & | input | ) |
Definition at line 155 of file ModulesParser.cpp.
Referenced by ExportPulse::ParseRequest().
std::string modules::parser::GetOneWord | ( | const std::string & | in, | |
size_t | start = 0 , |
|||
size_t | stop = std::string::npos | |||
) |
Definition at line 33 of file ModulesParser.cpp.
Referenced by MakeAnalysedPulses::ParseGeneratorList().
bool modules::parser::iequals | ( | const char | a, | |
const char | b | |||
) |
Definition at line 167 of file ModulesParser.cpp.
bool modules::parser::iequals | ( | const std::string & | a, | |
const std::string & | b | |||
) |
Definition at line 173 of file ModulesParser.cpp.
Referenced by MakeAnalysedPulses::BeforeFirstEntry(), SetupNavigator::GetBank(), IDs::channel::GetDetectorEnum(), IDs::channel::GetSlowFastEnum(), and IDs::channel::operator=().
00173 { 00174 unsigned int sz = a.size(); 00175 if (b.size() != sz) return false; 00176 for (unsigned int i = 0; i < sz; ++i){ 00177 if (! iequals(a[i],b[i])) return false; 00178 } 00179 return true; 00180 }
bool modules::parser::IsDecimal | ( | char | in | ) |
Definition at line 139 of file ModulesParser.cpp.
Referenced by IsFloatChar().
bool modules::parser::IsDigit | ( | char | in | ) |
Definition at line 129 of file ModulesParser.cpp.
Referenced by IsFloatChar().
bool modules::parser::IsFloatChar | ( | char | in | ) |
Definition at line 143 of file ModulesParser.cpp.
References IsDecimal(), and IsDigit().
Referenced by IsNotFloatChar().
bool modules::parser::IsNotFloatChar | ( | char | in | ) |
Definition at line 147 of file ModulesParser.cpp.
References IsFloatChar().
Referenced by IsNumber().
00147 { 00148 return !IsFloatChar(in); 00149 }
bool modules::parser::IsNumber | ( | const std::string & | input | ) |
Definition at line 151 of file ModulesParser.cpp.
References IsNotFloatChar().
Referenced by ExportPulse::ParseRequest().
00151 { 00152 return std::find_if(input.begin(),input.end(),IsNotFloatChar) == input.end(); 00153 }
bool modules::parser::IsTrue | ( | const std::string & | input | ) |
Definition at line 182 of file ModulesParser.cpp.
Referenced by modules::options::GetBool().
bool modules::parser::IsWhitespace | ( | char | in | ) |
Definition at line 117 of file ModulesParser.cpp.
Referenced by RemoveWhitespace().
modules::parser::Constructor_t modules::parser::ParseConstructor | ( | const std::string & | input, | |
char | open = '(' , |
|||
char | close = ')' | |||
) | throw (modules::parser::errors::unmatched_parenthesis) |
Definition at line 41 of file ModulesParser.cpp.
References modules::parser::Constructor_t::before, modules::parser::Constructor_t::inside, and TrimWhiteSpaceBeforeAfter().
Referenced by modules::reader::AddModule(), ExportPulse::BeforeFirstEntry(), modules::reader::findSectionName(), and MakeDetectorPulses::ParseGeneratorList().
00042 { 00043 size_t end_br=std::string::npos; 00044 size_t start_br=input.find(open); 00045 Constructor_t retVal; 00046 // cut out the string before the first open character 00047 retVal.before=input.substr(0,start_br); 00048 // trim whitespace from the start and end of retVal.before string 00049 TrimWhiteSpaceBeforeAfter(retVal.before); 00050 // Look for the requested brackets 00051 if(start_br!=std::string::npos){ 00052 end_br=input.rfind(close); 00053 if(end_br==std::string::npos){ 00054 // No matching close, although there was an open 00055 throw modules::parser::errors::unmatched_parenthesis(open,close); 00056 } 00057 retVal.inside=input.substr(start_br+1,end_br-start_br-1); 00058 TrimWhiteSpaceBeforeAfter(retVal.inside); 00059 } 00060 return retVal; 00061 }
size_t modules::parser::RemoveWhitespace | ( | std::string & | input, | |
std::string::iterator | start, | |||
std::string::iterator | end | |||
) |
Definition at line 67 of file ModulesParser.cpp.
References IsWhitespace().
00067 { 00068 std::string::iterator new_end=std::remove_if(start,end,modules::parser::IsWhitespace); 00069 input.erase(new_end,end); 00070 return input.size(); 00071 }
size_t modules::parser::RemoveWhitespace | ( | std::string & | input | ) |
Definition at line 63 of file ModulesParser.cpp.
Referenced by ExportPulse::ParseRequest(), and TrimWhiteSpaceBeforeAfter().
00063 { 00064 return RemoveWhitespace(input, input.begin(),input.end()); 00065 }
const std::string & modules::parser::ReplaceAll | ( | const std::string & | input, | |
const std::string & | search, | |||
const std::string & | replace | |||
) |
Definition at line 81 of file ModulesParser.cpp.
00081 { 00082 static std::string output; 00083 output.clear(); 00084 for(std::string::const_iterator i_char=input.begin(); i_char!=input.end();++i_char){ 00085 if(std::find(search.begin(),search.end(), *i_char)!=search.end()){ 00086 output+=replace; 00087 } else{ 00088 output+=*i_char; 00089 } 00090 } 00091 return output; 00092 }
void modules::parser::ReplaceAll | ( | std::string & | input, | |
const std::string & | search, | |||
const std::string & | replace | |||
) |
Definition at line 94 of file ModulesParser.cpp.
Referenced by ToCppValid().
00094 { 00095 input=ReplaceAll(const_cast<const std::string&>(input),search,replace); 00096 }
void modules::parser::ReplaceWords | ( | std::string & | input, | |
const std::string & | search, | |||
const std::string & | replace | |||
) |
Definition at line 98 of file ModulesParser.cpp.
Referenced by modules::options::CheckValid(), and PulseViewer::ParseTriggerString().
const std::string & modules::parser::ToCppValid | ( | const std::string & | input | ) |
Definition at line 73 of file ModulesParser.cpp.
References ReplaceAll().
00073 { 00074 return ReplaceAll(input," :{}#*()-=+$%^&!.,/?","_" ); 00075 }
void modules::parser::ToCppValid | ( | std::string & | input | ) |
Definition at line 77 of file ModulesParser.cpp.
References ReplaceAll().
Referenced by SavePulses::BeforeFirstEntry(), PlotTDPs::BeforeFirstEntry(), PlotTDP_TDiff::BeforeFirstEntry(), PlotTAP_Integral::BeforeFirstEntry(), PlotIntegralRatios::BeforeFirstEntry(), FirstCompleteAPGenerator::DrawPulse(), ExportPulse::PulseInfo_t::MakeTPIName(), and IDs::source::str().
00077 { 00078 ReplaceAll(input," :{}#*()-=+$%^&!.,/?","_" ); 00079 }
int modules::parser::TokeniseByDelimiter | ( | const std::string & | input, | |
std::vector< std::string > & | output, | |||
const char * | delim | |||
) |
Definition at line 21 of file ModulesParser.cpp.
References max_line.
Referenced by TemplateFactory< BaseModule, OptionsType >::addArguments(), modules::reader::AddModule(), and MakeDetectorPulses::ParseGeneratorList().
00021 { 00022 char line[modules::parser::max_line]; 00023 strcpy(line,input.c_str()); 00024 char* word = strtok(line,delim); 00025 while(word != NULL){ 00026 //std::cout<<"ModulesOptions:GetVectorStringsByDelimiter() "<<word<<std::endl; 00027 output.push_back(word); 00028 word = strtok(NULL,delim); 00029 } 00030 return output.size(); 00031 }
int modules::parser::TokeniseByWhiteSpace | ( | const std::string & | input, | |
std::vector< std::string > & | output | |||
) |
Definition at line 14 of file ModulesParser.cpp.
Referenced by modules::reader::ProcessGlobalOption().
void modules::parser::TrimWhiteSpaceBeforeAfter | ( | std::string & | input | ) |
Definition at line 107 of file ModulesParser.cpp.
References RemoveWhitespace().
Referenced by modules::reader::AddModule(), modules::options::GetString(), and ParseConstructor().
00107 { 00108 size_t not_white=line.find_first_not_of(" \t"); 00109 if(not_white!=std::string::npos) 00110 RemoveWhitespace(line, line.begin(),line.begin()+not_white+1); 00111 00112 not_white=line.find_last_not_of(" \t"); 00113 if(not_white!=std::string::npos) 00114 RemoveWhitespace(line, line.begin()+not_white+1,line.end()); 00115 }
const int modules::parser::max_line = 2048 |
Definition at line 41 of file ModulesParser.h.
Referenced by TokeniseByDelimiter().