Skip to content
Snippets Groups Projects
Commit c409cda1 authored by Adrien Matta's avatar Adrien Matta :skull_crossbones:
Browse files

* Adding functionnality to aliases

        - now can support a list of vector
parent 2f7bdd3f
No related branches found
No related tags found
1 merge request!27Draft: [Epic] Preparation of the environement for the new GaseousDetectorScorers...
......@@ -221,7 +221,23 @@ TVector3 NPL::InputBlock::GetTVector3(std::string Token, std::string default_uni
return TVector3(x, y, z);
}
////////////////////////////////////////////////////////////////////////////////
std::vector<std::string> NPL::InputBlock::GetVectorString(std::string Token) {
std::vector<std::string> NPL::InputBlock::GetVectorList(std::string Token, std::string separator) {
auto line = GetValue(Token);
std::vector<std::string> val;
while (line.find("(") != std::string::npos) {
auto start = line.find_first_of("(");
auto stop = line.find_first_of(")");
auto b = line.begin();
auto v = line.substr(start, stop - start + 1);
v.replace(v.find("("), 1, "");
v.replace(v.find(")"), 1, "");
val.push_back(v);
line.erase(b + start, b + stop + 1);
}
return val;
}
////////////////////////////////////////////////////////////////////////////////
std::vector<std::string> NPL::InputBlock::GetVectorString(std::string Token, std::string separator) {
int verbose = 1; // NPOptionManager::getInstance()->GetVerboseLevel();
std::stringstream iss(GetValue(Token));
......@@ -397,6 +413,9 @@ void NPL::InputParser::TreatAliases() {
name += alias[i]->GetMainValue();
std::string action = alias[i]->GetString("Action");
std::vector<std::string> value = alias[i]->GetVectorString("Value");
if (value[0].find("(") != std::string::npos)
value = alias[i]->GetVectorList("Value");
if (action == "Replace" && value.size() != 1)
NPL::SendErrorAndExit("NPL::InputParser", "Inplace alias can only take one value");
......
......@@ -80,7 +80,8 @@ namespace NPL {
TVector3 GetTVector3(std::string Token, std::string default_unit);
std::vector<double> GetVectorDouble(std::string Token, std::string default_unit);
std::vector<int> GetVectorInt(std::string Token);
std::vector<std::string> GetVectorString(std::string Token);
std::vector<std::string> GetVectorString(std::string Token, std::string separator = " ");
std::vector<std::string> GetVectorList(std::string Token, std::string separator = " ");
std::vector<NPL::InputBlock*> GetSubBlock(std::string Token);
std::vector<std::string> GetLines() { return m_Lines; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment