ArcGIS Procedural Runtime  3.2.10650
NamePreparator.h
1 /*
2  COPYRIGHT (c) 2012-2024 Esri R&D Center Zurich
3  TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
4  Unpublished material - all rights reserved under the
5  Copyright Laws of the United States and applicable international
6  laws, treaties, and conventions.
7 
8  For additional information, contact:
9  Environmental Systems Research Institute, Inc.
10  Attn: Contracts and Legal Services Department
11  380 New York Street
12  Redlands, California, 92373
13  USA
14 
15  email: contracts@esri.com
16 */
17 
18 #ifndef PRTX_NAMEPREPARATOR_H_
19 #define PRTX_NAMEPREPARATOR_H_
20 
21 #include "prtx/prtx.h"
22 
23 #include <string>
24 #include <memory>
25 
26 #ifdef _MSC_VER
27 # pragma warning(push)
28 # pragma warning(disable : 4251 4275)
29 #endif
30 
31 
32 namespace prtx {
33 
34 
38 class PRTX_EXPORTS_API NamePreparator {
39 public:
44  struct NamespaceInfo {
45  virtual ~NamespaceInfo() {};
46 
47  virtual void reset() = 0;
48  virtual uint32_t getType() const = 0;
49  };
50 
51  typedef std::shared_ptr<NamespaceInfo> NamespacePtr;
52 
57  enum Entity {
58  ENTITY_MATERIAL,
59  ENTITY_MESH,
60  ENTITY_SHAPE,
61  ENTITY_NODE,
62  ENTITY_TEXTURE,
63  ENTITY_FILE,
64  ENTITY_CUSTOM
65  };
66 
67 public:
68  virtual ~NamePreparator() {}
69 
73  virtual NamespacePtr newNamespace() = 0;
74 
83  virtual void legalize(std::wstring& name, uint32_t entity) = 0;
84 
88  virtual std::wstring legalized(const std::wstring& name, uint32_t entity) {
89  std::wstring s(name);
90  legalize(s, entity);
91  return s;
92  }
93 
101  virtual void uniquify(std::wstring& name, uint32_t entity, const NamespacePtr& ns) = 0;
102 
106  virtual std::wstring uniquified(const std::wstring& name, uint32_t entity, const NamespacePtr& ns) {
107  std::wstring s(name);
108  uniquify(s, entity, ns);
109  return s;
110  }
111 
115  void legalizeAndUniquify(std::wstring& name, uint32_t entity, const NamespacePtr& ns) {
116  legalize(name, entity);
117  uniquify(name, entity, ns);
118  }
119 
123  std::wstring legalizedAndUniquified(const std::wstring& name, uint32_t entity, const NamespacePtr& ns) {
124  std::wstring s(name);
125  legalizeAndUniquify(s, entity, ns);
126  return s;
127  }
128 };
129 
130 
136 class PRTX_EXPORTS_API DefaultNamePreparator : public prtx::NamePreparator {
137 public:
141  DefaultNamePreparator(const std::wstring& delimiter = L"_", const std::wstring& filenameDelimiter = L"_");
142 
143  DefaultNamePreparator(const DefaultNamePreparator&) = delete;
144  DefaultNamePreparator& operator=(const DefaultNamePreparator&) = delete;
145  virtual ~DefaultNamePreparator() = default;
146 
147  NamespacePtr newNamespace() override;
148 
160  void legalize(std::wstring& name, uint32_t entity) override;
161 
170  void uniquify(std::wstring& name, uint32_t entity, const NamespacePtr& ns) override;
171 
176  void setDelimiter(const std::wstring& delimiter);
177 
182  void setFilenameDelimiter(const std::wstring& delimiter);
183 
184 private:
185  std::wstring mDelimiter;
186  std::wstring mFilenameDelimiter;
187 };
188 
189 
195 class PRTX_EXPORTS_API AsciiFileNamePreparator : public prtx::DefaultNamePreparator {
196 public:
200  AsciiFileNamePreparator(const std::wstring& delimiter = L"_", const std::wstring& filenameDelimiter = L"_");
201 
202  AsciiFileNamePreparator(const AsciiFileNamePreparator&) = delete;
203  AsciiFileNamePreparator& operator=(const AsciiFileNamePreparator&) = delete;
204  virtual ~AsciiFileNamePreparator() = default;
205 
217  void legalize(std::wstring& name, uint32_t entity) override;
218 };
219 
220 
221 } // namespace prtx
222 
223 
224 #ifdef _MSC_VER
225 # pragma warning(pop)
226 #endif
227 
228 
229 #endif /* PRTX_NAMEPREPARATOR_H_ */
The Procedural Runtime eXtension namespace. The prtx namespace contains the tools to extend the Proce...
Definition: AnnotationBuilder.h:35