| 117 | |
| 118 | |
| 119 | std::string |
| 120 | elastix::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 | |
| 148 | bool |
| 149 | elastix::ToLogLevel(const std::string & str, log::level & logLevel) |