Overte C++ Documentation
RecurseOctreeToJSONOperator.h
1 //
2 // RecurseOctreeToJSONOperator.h
3 // libraries/entities/src
4 //
5 // Created by Simon Walton on Oct 11, 2018.
6 // Copyright 2018 High Fidelity, Inc.
7 // Copyright 2023 Overte e.V.
8 //
9 // Distributed under the Apache License, Version 2.0.
10 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
11 // SPDX-License-Identifier: Apache-2.0
12 //
13 
14 #include "EntityTree.h"
15 
16 #include <ScriptValue.h>
17 
18 class ScriptEngine;
19 
20 class RecurseOctreeToJSONOperator : public RecurseOctreeOperator {
21 public:
22  RecurseOctreeToJSONOperator(const OctreeElementPointer&, ScriptEngine* engine, QString jsonPrefix = QString(), bool skipDefaults = true,
23  bool skipThoseWithBadParents = false);
24  virtual bool preRecursion(const OctreeElementPointer& element) override { return true; };
25  virtual bool postRecursion(const OctreeElementPointer& element) override;
26 
27  QString getJson() const { return _json; }
28 
29 private:
30  void processEntity(const EntityItemPointer& entity);
31 
32  ScriptEngine* _engine;
33  ScriptValue _toStringMethod;
34 
35  QString _json;
36  const bool _skipDefaults;
37  bool _skipThoseWithBadParents;
38  bool _comma { false };
39 };
derive from this class to use the Octree::recurseTreeWithOperator() method
Definition: Octree.h:43
Provides an engine-independent interface for a scripting engine.
Definition: ScriptEngine.h:93
[ScriptInterface] Provides an engine-independent interface for QScriptValue
Definition: ScriptValue.h:40