MCPcopy Create free account
hub / github.com/PDAL/PDAL / fromFile

Method fromFile

pdal/Options.cpp:175–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175Options 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
198Options Options::fromJsonFile(const std::string& filename, const std::string& s)

Callers

nothing calls this directly

Calls 3

readFileIntoStringFunction · 0.85
fileExistsFunction · 0.70
OptionsClass · 0.70

Tested by

no test coverage detected