MCPcopy Create free account
hub / github.com/Kitware/VTK / CanParseFile

Method CanParseFile

IO/GeoJSON/vtkGeoJSONReader.cxx:194–227  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

192
193//------------------------------------------------------------------------------
194int vtkGeoJSONReader::GeoJSONReaderInternal::CanParseFile(const char* filename, Json::Value& root)
195{
196 if (!filename)
197 {
198 vtkGenericWarningMacro(<< "Input filename not specified");
199 return VTK_ERROR;
200 }
201
202 vtksys::ifstream file;
203 file.open(filename);
204
205 if (!file.is_open())
206 {
207 vtkGenericWarningMacro(<< "Unable to Open File " << filename);
208 return VTK_ERROR;
209 }
210
211 Json::CharReaderBuilder builder;
212 builder["collectComments"] = false;
213
214 std::string formattedErrors;
215
216 // parse the entire geoJSON data into the Json::Value root
217 bool parsedSuccess = parseFromStream(builder, file, &root, &formattedErrors);
218
219 if (!parsedSuccess)
220 {
221 // Report failures and their locations in the document
222 vtkGenericWarningMacro(<< "Failed to parse JSON" << endl << formattedErrors);
223 return VTK_ERROR;
224 }
225
226 return VTK_OK;
227}
228
229//------------------------------------------------------------------------------
230int vtkGeoJSONReader::GeoJSONReaderInternal::CanParseString(char* input, Json::Value& root)

Callers 1

RequestDataMethod · 0.45

Calls 3

parseFromStreamFunction · 0.85
is_openMethod · 0.80
openMethod · 0.45

Tested by

no test coverage detected