VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgEarthFileParser.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2026 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 
14 #include <osgEarth/Config>
15 #include <vrvUtil/DtUnicode.h>
16 
17 namespace osgEarth
18 {
19  namespace Util
20  {
21  class XmlNode;
22  class XmlElement;
23  class XmlText;
24  class XmlDocument;
25  }
26 }
27 
28 namespace makVrv
29 {
33  {
34  public:
35  typedef std::vector<osgEarth::Util::XmlText*> XmlTextList;
36  typedef std::vector<DtOsgEarthFile*> ExternalFileList;
37 
44  {
45  public:
46 
48  XmlElementKey();
49 
53  XmlElementKey(const char* type);
54 
58  XmlElementKey(const char* type, int index);
59 
63  XmlElementKey(const std::string& type);
64 
68  XmlElementKey(const std::string& type, int index);
69 
71  bool isValid() const;
72 
75  std::string type() const;
76 
79  int index() const;
80 
83  void setType(const std::string& type);
84 
87  void setIndex(int index);
88 
90  bool operator < (const XmlElementKey&) const;
91 
93  bool operator == (const XmlElementKey&) const;
94 
95  protected:
96  std::string myType;
97  int myIndex;
98  };
99 
102  DtOsgEarthFile(const DtUnicode& fileName);
103 
105  virtual ~DtOsgEarthFile();
106 
108  void load();
109 
111  void parseTextAndElements();
112 
116  void update(const XmlElementKey& key, const osgEarth::Config& config);
117 
119  void updateName(const XmlElementKey& key, const std::string& newName);
120 
122  void modify(const XmlElementKey& key, const osgEarth::Config& config);
123 
127  void add(const XmlElementKey& key, const osgEarth::Config& config);
128 
130  void remove(const XmlElementKey& key);
131 
133  void move(const XmlElementKey& key, int newIndex);
134 
136  void addTextNode(const XmlElementKey& key, const std::string& text);
137 
141  osgEarth::Util::XmlElement* findChildElement(osgEarth::Util::XmlElement* element, const XmlElementKey& key);
142 
146  osgEarth::Util::XmlElement* findParentElement(osgEarth::Util::XmlElement* element, const XmlElementKey& key);
147 
152  void updateConfig(size_t startPos, osgEarth::Util::XmlElement* element, const osgEarth::Config& config);
153 
154  void modifyConfig(size_t startPos, osgEarth::Util::XmlElement* element, const osgEarth::Config& config);
155 
160  void updateXmlText(size_t startPos, osgEarth::Util::XmlElement* element, const std::string& text);
161 
165  osgEarth::Util::XmlText* findXmlTextNode(osgEarth::Util::XmlElement* element);
166 
170  void modifyTextNode(osgEarth::XmlElement* element, const std::string& text);
171 
173  std::set<std::string> getUniqueChildKeysOfConfig(const osgEarth::Config& config) const;
174 
176  std::set<std::string> getUniqueChildKeysOfElement(const osgEarth::Util::XmlElement* element) const;
177 
180  std::string findNameOfConfig(const osgEarth::Config& config);
181 
183  virtual bool checkExternalReference(const std::string& text);
184 
188  virtual bool findUrl(const std::string& text, std::string& url);
189 
194  virtual bool isXmlInclude(const std::string& url) const;
195 
197  virtual void parseExternalReference(const std::string& text);
198 
200  DtUnicode fileName() const;
201 
203  const ExternalFileList& externalFileList() const;
204 
206  virtual const DtOsgEarthFile* findOsgEarthFileByFileName(const DtUnicode& fileName) const;
207 
210  std::vector< std::pair<std::string, std::string> > getXmlElementNodes() const;
211 
215  virtual XmlElementKey getXmlElementKey(const osgEarth::XmlElement* parent, const osgEarth::XmlElement* element) const;
216 
218  virtual osgEarth::XmlElement* root();
219 
225  virtual bool findXmlElementKey(const std::string& type, const std::string& name, DtOsgEarthFile::XmlElementKey& key)const;
226 
235  virtual bool findXmlElementKey(osgEarth::Util::XmlElement* element, const std::string& type, const std::string& name,
236  DtOsgEarthFile::XmlElementKey& key, int currentDepth = 0, int maxDepth = 2)const;
237 
239  virtual void setFileName(const DtUnicode& fileName);
240 
242  virtual void save();
243 
245  virtual void save(const DtUnicode& fileName);
246 
248  virtual std::string getXmlElementType(const osgEarth::Util::XmlElement* element) const;
249 
255  virtual int getXmlElementIndex(const osgEarth::Util::XmlElement* parent, const osgEarth::Util::XmlElement* element) const;
256 
258  virtual std::string getXmlElementName(const osgEarth::Util::XmlElement* element) const;
259 
261  DtOsgEarthFile* findOsgEarthFile(const std::string& type, const std::string& name);
262 
263  protected:
264 
266  virtual void processXmlNode(const osgEarth::Util::XmlNode* node);
267 
269  virtual void processXmlElement(const osgEarth::Util::XmlElement* element);
270 
272  virtual void processXmlText(const osgEarth::Util::XmlText* text);
273 
279  void addOrModifyConfig(size_t startPos, osgEarth::XmlElement* element, const osgEarth::Config& config, int index);
280 
287  void addOrModifySimpleConfig(size_t startPos, osgEarth::Util::XmlElement* element, const std::string& key, const std::string& value, int index);
288 
294  void addOrModifyNonSimpleConfig(size_t startPos, osgEarth::Util::XmlElement* element, const osgEarth::Config& config, int index);
295 
301  virtual bool modifyXmlAttribute(size_t startPos, osgEarth::Util::XmlElement* element, const std::string& key, const std::string& newValue);
302 
307  virtual bool removeXmlAttribute(size_t startPos, osgEarth::Util::XmlElement* element, const std::string& key);
308 
314  virtual bool removeXmlElement(size_t startPos, osgEarth::Util::XmlElement* parent, const std::string& key, int index);
315 
322  virtual bool moveXmlElement(size_t startPos, osgEarth::Util::XmlElement* parent, const std::string& key, int index, int newIndex);
323 
330  virtual bool modifyXmlSimpleElement(size_t startPos, osgEarth::Util::XmlElement* element, const std::string& key, const std::string& newValue, int index);
331 
337  virtual bool addXmlAttribute(size_t startPos, osgEarth::Util::XmlElement* element, const std::string& key, const std::string& newValue);
338 
345  virtual bool addXmlSimpleElement(size_t startPos, osgEarth::Util::XmlElement* element, const std::string& key, const std::string& newValue, int index);
346 
352  virtual bool addXmlNonSimpleElement(size_t startPos, osgEarth::Util::XmlElement* element, const osgEarth::Config& config, int index);
353 
358  virtual bool addXmlTextNode(size_t startPos, osgEarth::Util::XmlElement* element, const std::string& text);
359 
362  virtual std::string getConfigString(const osgEarth::Config& config);
363 
367  virtual std::string getXmlAttributeString(const std::string& key, const std::string& value);
368 
372  virtual std::string getSimpleConfigString(const std::string& key, const std::string& value);
373 
378  virtual void updateAttribute(osgEarth::Util::XmlElement* element, const std::string& key, const std::string& newValue);
379 
384  virtual void removeAttribute(osgEarth::Util::XmlElement* element, const std::string& key);
385 
390  virtual void removeElement(osgEarth::Util::XmlElement* element, const std::string& key, int index);
391 
397  virtual void updateSimpleElement(osgEarth::Util::XmlElement* element, const std::string& key, const std::string& newValue, int index);
398 
403  virtual void addAttribute(osgEarth::Util::XmlElement* element, const std::string& key, const std::string& value);
404 
409  virtual void addSimpleElement(osgEarth::Util::XmlElement* element, const std::string& key, const std::string& newValue);
410 
415  virtual void addNonSimpleElement(osgEarth::Util::XmlElement* element, osgEarth::Util::XmlElement* child);
416 
420  virtual void addTextNode(osgEarth::Util::XmlElement* element, const std::string& text);
421 
426  virtual bool hasAttribute(const osgEarth::Util::XmlElement* element, const std::string& key);
427 
433  virtual osgEarth::XmlElement* findSubElement(const osgEarth::Util::XmlElement* element, const std::string& key, int index);
434 
438  virtual int findSubElementMaximumIndex(const osgEarth::XmlElement* element, const std::string& key);
439 
444  virtual bool hasChild(const osgEarth::Config& config, const std::string& key, int index);
445 
450  virtual size_t findStartPos(size_t startPos, const osgEarth::Util::XmlElement* element, const XmlElementKey& key);
451 
453  virtual std::string getElementStartPattern(const std::string& key) const;
454 
456  virtual std::string getElementEndPattern(const osgEarth::Util::XmlElement* element) const;
457 
459  virtual std::string getElementEndPattern(const std::string& key) const;
460 
462  virtual std::string getAttributeStartPattern(const std::string& key) const;
463 
469  virtual bool getAttributeValue(size_t startPos, size_t endPos, const std::string& key, std::string& value) const;
470 
476  virtual bool getElementValue(size_t startPos, size_t endPos, const std::string& key, std::string& value) const;
477 
480  std::string formatValue(const std::string& value) const;
481 
484  virtual bool isReservedKeyWord(const std::string& key) const;
485 
493  virtual bool ifElementHasChild(osgEarth::Util::XmlElement* root, const std::string& type, const std::string& name, int currentDepth = 0, int maxDepth = 2);
494 
495  private:
497  DtOsgEarthFile();
501  DtOsgEarthFile &operator=(const DtOsgEarthFile&);
502 
503  protected:
504  osgEarth::Util::XmlElement* myRoot;
506  std::string myModifiedText;
507  std::string myOriginalText;
509  };
510 
514  {
515  public:
516 
519 
521  virtual ~DtOsgEarthFileParser();
522 
525  virtual void parse(const DtUnicode& fileName);
526 
531  virtual void addConfig(const std::string& parentType, const std::string& parentName, const osgEarth::Config& config);
532 
536  virtual void removeConfig(const std::string& type, const std::string& name);
537 
542  virtual void moveConfig(const std::string& type, const std::string& name, int newIndex);
543 
548  virtual void updateConfig(const std::string& name, const std::string& type, const osgEarth::Config& config);
549 
554  virtual void updateName(const std::string& oldName, const std::string& type, const std::string& newName);
555 
559  virtual void modifyConfig(const std::string& name, const osgEarth::Config& config);
560 
562  virtual DtOsgEarthFile* rootFile();
563 
567  virtual const DtOsgEarthFile* findOsgEarthFile(const DtUnicode& fileName) const;
568 
570  virtual bool hasExternalFiles() const;
571 
574  virtual void save(const DtUnicode& fileName);
575 
578  virtual void setRootFileName(const DtUnicode& fileName);
579 
580  protected:
582 
583  private:
587  DtOsgEarthFileParser &operator=(const DtOsgEarthFileParser&);
588  };
589 }
XmlElementKey.
Definition: DtOsgEarthFileParser.h:43
DtOsgEarthFileParser.
Definition: DtOsgEarthFileParser.h:513
osgEarth::Util::XmlElement * myRoot
Definition: DtOsgEarthFileParser.h:504
A unicode string. DtUnicode stores a UTF-16 encoded unicode string. Code Point, a Unicode character...
Definition: DtUnicode.h:33
std::vector< osgEarth::Util::XmlText * > XmlTextList
Definition: DtOsgEarthFileParser.h:35
std::vector< DtOsgEarthFile * > ExternalFileList
Definition: DtOsgEarthFileParser.h:36
int myIndex
Definition: DtOsgEarthFileParser.h:97
#define DT_DLL_VRVOSGEARTH
Definition: vrvOsgEarth.h:21
DtOsgEarthFile * myRootFile
Definition: DtOsgEarthFileParser.h:581
DtUnicode myFileName
Definition: DtOsgEarthFileParser.h:508
bool operator==(const DtMilStdKeyParams &a, const DtMilStdKeyParams &b)
Memberwise equality for DtMilStdKeyParams. Used by callers (e.g. DtMilStdIconVisualizer) to skip key ...
Definition: DtMilStdManagerInterface.h:58
std::string myModifiedText
Definition: DtOsgEarthFileParser.h:506
ExternalFileList myExternalFileList
Definition: DtOsgEarthFileParser.h:505
std::string myOriginalText
Definition: DtOsgEarthFileParser.h:507
DtOsgEarthFile.
Definition: DtOsgEarthFileParser.h:32
Contains DLL export macros.
std::string myType
Definition: DtOsgEarthFileParser.h:96

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)