VR-Forces 5.0.2 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) 2019 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 
169  void modifyTextNode(osgEarth::XmlElement* element, const std::string& text);
170 
172  std::set<std::string> getUniqueChildKeysOfConfig(const osgEarth::Config& config) const;
173 
175  std::set<std::string> getUniqueChildKeysOfElement(const osgEarth::Util::XmlElement* element) const;
176 
179  std::string findNameOfConfig(const osgEarth::Config& config);
180 
182  virtual bool checkExternalReference(const std::string& text);
183 
186  virtual bool findUrl(const std::string& text, std::string& url);
187 
189  virtual void parseExternalReference(const std::string& text);
190 
192  DtUnicode fileName() const;
193 
195  const ExternalFileList& externalFileList() const;
196 
198  virtual const DtOsgEarthFile* findOsgEarthFileByFileName(const DtUnicode& fileName) const;
199 
202  std::vector< std::pair<std::string, std::string> > getXmlElementNodes() const;
203 
207  virtual XmlElementKey getXmlElementKey(const osgEarth::XmlElement* parent, const osgEarth::XmlElement* element) const;
208 
210  virtual osgEarth::XmlElement* root();
211 
216  virtual bool findXmlElementKey(const std::string& type, const std::string& name, DtOsgEarthFile::XmlElementKey& key)const;
217 
225  virtual bool findXmlElementKey(osgEarth::Util::XmlElement* element, const std::string& type, const std::string& name,
226  DtOsgEarthFile::XmlElementKey& key, int currentDepth = 0, int maxDepth = 2)const;
227 
229  virtual void setFileName(const DtUnicode& fileName);
230 
232  virtual void save();
233 
235  virtual void save(const DtUnicode& fileName);
236 
238  virtual std::string getXmlElementType(const osgEarth::Util::XmlElement* element) const;
239 
245  virtual int getXmlElementIndex(const osgEarth::Util::XmlElement* parent, const osgEarth::Util::XmlElement* element) const;
246 
248  virtual std::string getXmlElementName(const osgEarth::Util::XmlElement* element) const;
249 
251  DtOsgEarthFile* findOsgEarthFile(const std::string& type, const std::string& name);
252 
253  protected:
254 
256  virtual void processXmlNode(const osgEarth::Util::XmlNode* node);
257 
259  virtual void processXmlElement(const osgEarth::Util::XmlElement* element);
260 
262  virtual void processXmlText(const osgEarth::Util::XmlText* text);
263 
269  void addOrModifyConfig(size_t startPos, osgEarth::XmlElement* element, const osgEarth::Config& config, int index);
270 
277  void addOrModifySimpleConfig(size_t startPos, osgEarth::Util::XmlElement* element, const std::string& key, const std::string& value, int index);
278 
284  void addOrModifyNonSimpleConfig(size_t startPos, osgEarth::Util::XmlElement* element, const osgEarth::Config& config, int index);
285 
291  virtual bool modifyXmlAttribute(size_t startPos, osgEarth::Util::XmlElement* element, const std::string& key, const std::string& newValue);
292 
297  virtual bool removeXmlAttribute(size_t startPos, osgEarth::Util::XmlElement* element, const std::string& key);
298 
304  virtual bool removeXmlElement(size_t startPos, osgEarth::Util::XmlElement* parent, const std::string& key, int index);
305 
312  virtual bool moveXmlElement(size_t startPos, osgEarth::Util::XmlElement* parent, const std::string& key, int index, int newIndex);
313 
320  virtual bool modifyXmlSimpleElement(size_t startPos, osgEarth::Util::XmlElement* element, const std::string& key, const std::string& newValue, int index);
321 
327  virtual bool addXmlAttribute(size_t startPos, osgEarth::Util::XmlElement* element, const std::string& key, const std::string& newValue);
328 
334  virtual bool addXmlSimpleElement(size_t startPos, osgEarth::Util::XmlElement* element, const std::string& key, const std::string& newValue, int index);
335 
341  virtual bool addXmlNonSimpleElement(size_t startPos, osgEarth::Util::XmlElement* element, const osgEarth::Config& config, int index);
342 
347  virtual bool addXmlTextNode(size_t startPos, osgEarth::Util::XmlElement* element, const std::string& text);
348 
351  virtual std::string getConfigString(const osgEarth::Config& config);
352 
356  virtual std::string getXmlAttributeString(const std::string& key, const std::string& value);
357 
361  virtual std::string getSimpleConfigString(const std::string& key, const std::string& value);
362 
367  virtual void updateAttribute(osgEarth::Util::XmlElement* element, const std::string& key, const std::string& newValue);
368 
373  virtual void removeAttribute(osgEarth::Util::XmlElement* element, const std::string& key);
374 
379  virtual void removeElement(osgEarth::Util::XmlElement* element, const std::string& key, int index);
380 
386  virtual void updateSimpleElement(osgEarth::Util::XmlElement* element, const std::string& key, const std::string& newValue, int index);
387 
392  virtual void addAttribute(osgEarth::Util::XmlElement* element, const std::string& key, const std::string& value);
393 
398  virtual void addSimpleElement(osgEarth::Util::XmlElement* element, const std::string& key, const std::string& newValue);
399 
404  virtual void addNonSimpleElement(osgEarth::Util::XmlElement* element, osgEarth::Util::XmlElement* child);
405 
409  virtual void addTextNode(osgEarth::Util::XmlElement* element, const std::string& text);
410 
414  virtual bool hasAttribute(const osgEarth::Util::XmlElement* element, const std::string& key);
415 
421  virtual osgEarth::XmlElement* findSubElement(const osgEarth::Util::XmlElement* element, const std::string& key, int index);
422 
426  virtual int findSubElementMaximumIndex(const osgEarth::XmlElement* element, const std::string& key);
427 
432  virtual bool hasChild(const osgEarth::Config& config, const std::string& key, int index);
433 
438  virtual size_t findStartPos(size_t startPos, const osgEarth::Util::XmlElement* element, const XmlElementKey& key);
439 
441  virtual std::string getElementStartPattern(const std::string& key) const;
442 
444  virtual std::string getElementEndPattern(const osgEarth::Util::XmlElement* element) const;
445 
447  virtual std::string getElementEndPattern(const std::string& key) const;
448 
450  virtual std::string getAttributeStartPattern(const std::string& key) const;
451 
457  virtual bool getAttributeValue(size_t startPos, size_t endPos, const std::string& key, std::string& value) const;
458 
464  virtual bool getElementValue(size_t startPos, size_t endPos, const std::string& key, std::string& value) const;
465 
468  std::string formatValue(const std::string& value) const;
469 
472  virtual bool isReservedKeyWord(const std::string& key) const;
473 
481  virtual bool ifElementHasChild(osgEarth::Util::XmlElement* root, const std::string& type, const std::string& name, int currentDepth = 0, int maxDepth = 2);
482 
483  private:
485  DtOsgEarthFile();
489  DtOsgEarthFile &operator=(const DtOsgEarthFile&);
490 
491  protected:
492  osgEarth::Util::XmlElement* myRoot;
494  std::string myModifiedText;
495  std::string myOriginalText;
497  };
498 
502  {
503  public:
504 
507 
509  virtual ~DtOsgEarthFileParser();
510 
513  virtual void parse(const DtUnicode& fileName);
514 
519  virtual void addConfig(const std::string& parentType, const std::string& parentName, const osgEarth::Config& config);
520 
524  virtual void removeConfig(const std::string& type, const std::string& name);
525 
530  virtual void moveConfig(const std::string& type, const std::string& name, int newIndex);
531 
535  virtual void updateConfig(const std::string& name, const std::string& type, const osgEarth::Config& config);
536 
541  virtual void updateName(const std::string& oldName, const std::string& type, const std::string& newName);
542 
546  virtual void modifyConfig(const std::string& name, const osgEarth::Config& config);
547 
549  virtual DtOsgEarthFile* rootFile();
550 
554  virtual const DtOsgEarthFile* findOsgEarthFile(const DtUnicode& fileName) const;
555 
557  virtual bool hasExternalFiles() const;
558 
561  virtual void save(const DtUnicode& fileName);
562 
565  virtual void setRootFileName(const DtUnicode& fileName);
566 
567  protected:
569 
570  private:
574  DtOsgEarthFileParser &operator=(const DtOsgEarthFileParser&);
575  };
576 }
XmlElementKey.
Definition: DtOsgEarthFileParser.h:43
DtOsgEarthFileParser.
Definition: DtOsgEarthFileParser.h:501
osgEarth::Util::XmlElement * myRoot
Definition: DtOsgEarthFileParser.h:492
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:568
DtUnicode myFileName
Definition: DtOsgEarthFileParser.h:496
std::string myModifiedText
Definition: DtOsgEarthFileParser.h:494
ExternalFileList myExternalFileList
Definition: DtOsgEarthFileParser.h:493
std::string myOriginalText
Definition: DtOsgEarthFileParser.h:495
bool operator==(const DtTextureAtlasIndexParser::StringOrFloatAttrib &lhs, const DtTextureAtlasIndexParser::StringOrFloatAttrib &rhs)
needed for search comparison code
Definition: DtTextureAtlasIndexParser.h:153
DtOsgEarthFile.
Definition: DtOsgEarthFileParser.h:32
Contains DLL export macros.
std::string myType
Definition: DtOsgEarthFileParser.h:96

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)