1 // Copyright (C) 2015-2023 CEA, EDF
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author: Roman NIKOLAEV (roman.nikolaev@opencascade.com)
21 #ifndef __vtkJSONReader_h_
22 #define __vtkJSONReader_h_
24 #include <vtkTableAlgorithm.h>
25 #include <vtk_jsoncpp.h> // For json parser
27 //---------------------------------------------------
28 class VTK_EXPORT vtkJSONException : public std::exception
31 vtkJSONException(const char* reason);
32 ~vtkJSONException() noexcept;
33 const char* what() const noexcept;
41 class VTK_EXPORT vtkJSONReader : public vtkTableAlgorithm
44 static vtkJSONReader* New();
45 vtkTypeMacro(vtkJSONReader, vtkTableAlgorithm)
46 void PrintSelf(ostream& os, vtkIndent indent) override;
48 // Specifies the name of the file
49 vtkGetStringMacro(FileName);
50 vtkSetStringMacro(FileName);
53 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
57 ~vtkJSONReader() override;
59 // Parse the Json Value corresponding to the root data from the file
60 virtual void Parse(Json::Value& root, vtkTable* theTable);
62 // Verify if file exists and can be read by the parser
63 // If exists, parse into Jsoncpp data structure
64 int CanParseFile(const char* fname, Json::Value& root);
66 // name of the file to read from
70 vtkJSONReader(const vtkJSONReader&) = delete;
71 void operator=(const vtkJSONReader&) = delete;
74 #endif //__vtkJSONReader_h_