Overte C++ Documentation
OctreeEntitiesFileParser.h
1 //
2 // OctreeEntititesFileParser.h
3 // libraries/octree/src
4 //
5 // Created by Simon Walton on Oct 15, 2018.
6 // Copyright 2018 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 // Parse the top-level of the Models object ourselves - use QJsonDocument for each Entity object.
13 
14 #ifndef hifi_OctreeEntitiesFileParser_h
15 #define hifi_OctreeEntitiesFileParser_h
16 
17 #include <QByteArray>
18 #include <QUrl>
19 #include <QVariant>
20 
21 class OctreeEntitiesFileParser {
22 public:
23  void setEntitiesString(const QByteArray& entitiesContents);
24  void setRelativeURL(const QUrl& relativeURL) { _relativeURL = relativeURL; }
25  bool parseEntities(QVariantMap& parsedEntities);
26  std::string getErrorString() const;
27 
28 private:
29  int nextToken();
30  std::string readString();
31  int readInteger();
32  bool readEntitiesArray(QVariantList& entitiesArray);
33  int findMatchingBrace() const;
34 
35  QByteArray _entitiesContents;
36  QUrl _relativeURL;
37  int _position { 0 };
38  int _line { 1 };
39  int _entitiesLength { 0 };
40  std::string _errorString;
41 };
42 
43 #endif // hifi_OctreeEntitiesFileParser_h