| 173 | } |
| 174 | |
| 175 | Options Options::fromFile(const std::string& filename, bool throwOnOpenError) |
| 176 | { |
| 177 | if (!FileUtils::fileExists(filename)) |
| 178 | { |
| 179 | if (throwOnOpenError) |
| 180 | throw pdal_error("Can't read options file '" + filename + "'."); |
| 181 | else |
| 182 | return Options(); |
| 183 | } |
| 184 | |
| 185 | std::string s = FileUtils::readFileIntoString(filename); |
| 186 | |
| 187 | size_t cnt = Utils::extractSpaces(s, 0); |
| 188 | if (s[cnt] == '{') |
| 189 | return fromJsonFile(filename, s); |
| 190 | else if (s[cnt] == '-') |
| 191 | return fromCmdlineFile(filename, s); |
| 192 | else |
| 193 | throw pdal_error("Option file '" + filename + "' not valid JSON or " |
| 194 | "command-line format."); |
| 195 | } |
| 196 | |
| 197 | |
| 198 | Options Options::fromJsonFile(const std::string& filename, const std::string& s) |
nothing calls this directly
no test coverage detected