MCPcopy Create free account
hub / github.com/SuperElastix/elastix / MakeStringOfCommandLineArguments

Method MakeStringOfCommandLineArguments

Core/Main/elxMainExeUtilities.cxx:119–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117
118
119std::string
120elastix::MakeStringOfCommandLineArguments(const char * const * const arguments)
121{
122 std::ostringstream outputStringStream;
123
124 if ((arguments == nullptr) || (*arguments == nullptr) || (*(arguments + 1) == nullptr))
125 {
126 assert(!"There should be at least two arguments!");
127 }
128 else
129 {
130 const auto AddDoubleQuotesIfStringHasSpace = [](const std::string & str) {
131 return (str.find(' ') == std::string::npos) ? str : ('"' + str + '"');
132 };
133
134 // Skip the first argument, as it is usually just the executable name.
135 outputStringStream << "\nCommand-line arguments: \n " << AddDoubleQuotesIfStringHasSpace(*(arguments + 1));
136
137 auto argument = arguments + 2;
138 while (*argument != nullptr)
139 {
140 outputStringStream << ' ' << AddDoubleQuotesIfStringHasSpace(*argument);
141 ++argument;
142 }
143 outputStringStream << '\n';
144 }
145 return outputStringStream.str();
146}
147
148bool
149elastix::ToLogLevel(const std::string & str, log::level & logLevel)

Callers

nothing calls this directly

Calls 1

strMethod · 0.80

Tested by

no test coverage detected