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

Method CanParseString

IO/GeoJSON/vtkGeoJSONReader.cxx:230–256  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

228
229//------------------------------------------------------------------------------
230int vtkGeoJSONReader::GeoJSONReaderInternal::CanParseString(char* input, Json::Value& root)
231{
232 if (!input)
233 {
234 vtkGenericWarningMacro(<< "Input string is empty");
235 return VTK_ERROR;
236 }
237
238 Json::CharReaderBuilder builder;
239 builder["collectComments"] = false;
240
241 std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
242
243 std::string formattedErrors;
244
245 // parse the entire geoJSON data into the Json::Value root
246 bool parsedSuccess = reader->parse(input, input + strlen(input), &root, &formattedErrors);
247
248 if (!parsedSuccess)
249 {
250 // Report failures and their locations in the document
251 vtkGenericWarningMacro(<< "Failed to parse JSON" << endl << formattedErrors);
252 return VTK_ERROR;
253 }
254
255 return VTK_OK;
256}
257
258//------------------------------------------------------------------------------
259void vtkGeoJSONReader::GeoJSONReaderInternal::ParseFeatureProperties(

Callers 1

RequestDataMethod · 0.80

Calls 2

newCharReaderMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected