ATLAS Offline Software
Loading...
Searching...
No Matches
TrkExTools Namespace Reference

Functions

std::string getToolSuffix (const std::string &fullToolName)
 Return the name suffix, e.g. return 'myNiceTool' from 'ToolSvc.myNiceTool'.
std::vector< std::string > extractToolNames (const std::vector< std::string > &toolNameVector)
 return a vector of extracted names
bool validToolName (const std::string &toolName)
 indicate whether a string is a valid Tool variable name
std::string possibleToolNameError (const std::vector< std::string > &toolNameVector)
 Give an error message if tool names are invalid; empty string if good.
unsigned int numberOfUniqueEntries (const std::vector< std::string > &nameVector)
 Give the number of unique entries in a vector.

Function Documentation

◆ extractToolNames()

std::vector< std::string > TrkExTools::extractToolNames ( const std::vector< std::string > & toolNameVector)

return a vector of extracted names

Definition at line 19 of file TrkExToolsStringUtility.cxx.

19 {
20 std::vector<std::string> result(toolNameVector.size());
21 std::transform(toolNameVector.begin(),toolNameVector.end(),result.begin(), getToolSuffix );
22 return result;
23 }
std::string getToolSuffix(const std::string &fullToolName)
Return the name suffix, e.g. return 'myNiceTool' from 'ToolSvc.myNiceTool'.

◆ getToolSuffix()

std::string TrkExTools::getToolSuffix ( const std::string & fullToolName)

Return the name suffix, e.g. return 'myNiceTool' from 'ToolSvc.myNiceTool'.

Definition at line 14 of file TrkExToolsStringUtility.cxx.

14 {
15 return fullToolName.substr(fullToolName.find_last_of('.') + 1);
16 }

◆ numberOfUniqueEntries()

unsigned int TrkExTools::numberOfUniqueEntries ( const std::vector< std::string > & nameVector)

Give the number of unique entries in a vector.

Definition at line 45 of file TrkExToolsStringUtility.cxx.

45 {
46 std::set<std::string> setOfNames(nameVector.begin(), nameVector.end());
47 return setOfNames.size();
48 }

◆ possibleToolNameError()

std::string TrkExTools::possibleToolNameError ( const std::vector< std::string > & toolNameVector)

Give an error message if tool names are invalid; empty string if good.

Definition at line 34 of file TrkExToolsStringUtility.cxx.

34 {
35 std::string result{};
36 auto isEmpty = [](const std::string & s){return s.empty();};
37 if (std::any_of(toolNameVector.begin(), toolNameVector.end(), isEmpty) ) return "A tool name was empty.";
38 if (auto pTheTool=std::find_if_not(toolNameVector.begin(), toolNameVector.end(), validToolName); pTheTool != toolNameVector.end()) {
39 result = "A tool name was invalid: " + *pTheTool;
40 }
41 return result;
42 }
bool validToolName(const std::string &toolName)
indicate whether a string is a valid Tool variable name

◆ validToolName()

bool TrkExTools::validToolName ( const std::string & toolName)

indicate whether a string is a valid Tool variable name

Definition at line 26 of file TrkExToolsStringUtility.cxx.

26 {
27 //valid name can contain underscore or alphanumeric characters, but cannot start
28 //with a number
29 std::regex re{"^[a-zA-Z_][a-zA-Z0-9_]*(::)?[a-zA-Z0-9_]*$"};
30 return std::regex_match(toolName, re);
31 }
const boost::regex re(r_e)