1 // Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
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 // Autor: Roman NIKOLAEV (roman.nikolaev@opencascade.com)
21 #ifndef __vtkJSONParser_h_
22 #define __vtkJSONParser_h_
24 #include <vtkObject.h>
33 class vtkJSONMetaNode;
34 class vtkJSONInfoNode;
36 //---------------------------------------------------
37 class VTK_EXPORT vtkJSONException : public std::exception {
39 vtkJSONException(const char *reason);
40 ~vtkJSONException() throw ();
41 const char* what() const throw();
46 class VTK_EXPORT vtkJSONParser : public vtkObject
49 static vtkJSONParser* New();
52 // Specifies the name of the file
53 vtkGetStringMacro(FileName);
54 vtkSetStringMacro(FileName);
56 virtual int Parse(vtkTable* theTable);
60 //Struct to store cursor information
61 //----------------------------------
80 // name of the file to read from
81 //----------------------------------
84 // current line and column
85 //----------------------------------
90 //----------------------------------
91 std::vector<Info> CInfoVector;
94 //----------------------------------
98 //----------------------------------
99 std::vector<vtkJSONNode*> Nodes;
100 vtkJSONNode* CurrentNode;
101 vtkJSONMetaNode* MetaNode;
104 //----------------------------------
105 std::vector<char> ExpectedCharacters;
108 //----------------------------------
111 bool ParseObjectList;
112 bool ShortNamesFilled;
114 // Last parced string
115 //----------------------------------
117 std::vector<const char*> Strings;
118 std::vector<const char*> CurrentList;
119 std::vector<const char*> ShortNames;
121 // Last parced values
122 //----------------------------------
126 vtkJSONParser(const vtkJSONParser&); // Not implemented.
127 void operator=(const vtkJSONParser&); // Not implemented.
129 vtkJSONMetaNode* GetMetaNode();
130 vtkJSONInfoNode* GetInfoNode();
146 void processCharacter(const char ch);
148 void processMetaNode();
149 void processInfoNode();
151 void readDoubleValue();
153 char* getString(long b, long e);
157 bool isDigitsAllowed();
159 void checkShortName(const char* unit);
161 void finalize(vtkTable *t);
165 void throwSimpleException(const char* message);
167 void throwException(const char* message);
169 void throwException(const char* message, int ln, int cn);
171 void throwException(const char* message, int ln);
173 #endif //__vtkJSONParser_h_