1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
|
/******************************************************************************
*
* Project: PROJ
* Purpose: ISO19111:2019 implementation
* Author: Even Rouault <even dot rouault at spatialys dot com>
*
******************************************************************************
* Copyright (c) 2018, Even Rouault <even dot rouault at spatialys dot com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#ifndef UTIL_HH_INCLUDED
#define UTIL_HH_INCLUDED
#if !(__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900))
#error Must have C++11 or newer.
#endif
#include <exception>
#include <map>
#include <memory>
#include <string>
#include <vector>
#ifndef NS_PROJ
/** osgeo namespace */
namespace osgeo {
/** osgeo.proj namespace */
namespace proj {}
} // namespace osgeo
#endif
//! @cond Doxygen_Suppress
#ifndef PROJ_DLL
#ifdef PROJ_MSVC_DLL_EXPORT
#define PROJ_DLL __declspec(dllexport)
#elif defined(PROJ_MSVC_DLL_IMPORT)
#define PROJ_DLL __declspec(dllimport)
#elif defined(__GNUC__)
#define PROJ_DLL __attribute__((visibility("default")))
#else
#define PROJ_DLL
#endif
#endif
#ifndef PROJ_MSVC_DLL
#ifdef PROJ_MSVC_DLL_EXPORT
#define PROJ_MSVC_DLL PROJ_DLL
#define PROJ_GCC_DLL
#define PROJ_INTERNAL
#elif defined(PROJ_MSVC_DLL_IMPORT)
#define PROJ_MSVC_DLL PROJ_DLL
#define PROJ_GCC_DLL
#define PROJ_INTERNAL
#elif defined(__GNUC__)
#define PROJ_MSVC_DLL
#define PROJ_GCC_DLL PROJ_DLL
#if !defined(__MINGW32__)
#define PROJ_INTERNAL __attribute__((visibility("hidden")))
#else
#define PROJ_INTERNAL
#endif
#else
#define PROJ_MSVC_DLL
#define PROJ_GCC_DLL
#define PROJ_INTERNAL
#endif
#define PROJ_FOR_TEST PROJ_DLL
#endif
#include "nn.hpp"
/* To allow customizing the base namespace of PROJ */
#ifdef PROJ_INTERNAL_CPP_NAMESPACE
#define NS_PROJ osgeo::internalproj
#define NS_PROJ_START \
namespace osgeo { \
namespace internalproj {
#define NS_PROJ_END \
} \
}
#else
#ifndef NS_PROJ
#define NS_PROJ osgeo::proj
#define NS_PROJ_START \
namespace osgeo { \
namespace proj {
#define NS_PROJ_END \
} \
}
#endif
#endif
// Private-implementation (Pimpl) pattern
#define PROJ_OPAQUE_PRIVATE_DATA \
private: \
struct PROJ_INTERNAL Private; \
std::unique_ptr<Private> d; \
\
protected: \
PROJ_INTERNAL Private *getPrivate() noexcept { return d.get(); } \
PROJ_INTERNAL const Private *getPrivate() const noexcept { \
return d.get(); \
} \
\
private:
// To include in the protected/private section of a class definition,
// to be able to call make_shared on a protected/private constructor
#define INLINED_MAKE_SHARED \
template <typename T, typename... Args> \
static std::shared_ptr<T> make_shared(Args &&... args) { \
return std::shared_ptr<T>(new T(std::forward<Args>(args)...)); \
} \
template <typename T, typename... Args> \
static util::nn_shared_ptr<T> nn_make_shared(Args &&... args) { \
return util::nn_shared_ptr<T>( \
util::i_promise_i_checked_for_null, \
std::shared_ptr<T>(new T(std::forward<Args>(args)...))); \
}
// To include in the protected/private section of a class definition,
// to be able to call make_unique on a protected/private constructor
#define INLINED_MAKE_UNIQUE \
template <typename T, typename... Args> \
static std::unique_ptr<T> make_unique(Args &&... args) { \
return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); \
}
#ifdef DOXYGEN_ENABLED
#define PROJ_FRIEND(mytype)
#define PROJ_FRIEND_OPTIONAL(mytype)
#else
#define PROJ_FRIEND(mytype) friend class mytype
#define PROJ_FRIEND_OPTIONAL(mytype) friend class util::optional<mytype>
#endif
#ifndef PROJ_PRIVATE
#define PROJ_PRIVATE public
#endif
#if defined(__GNUC__)
#define PROJ_NO_INLINE __attribute__((noinline))
#define PROJ_NO_RETURN __attribute__((noreturn))
// Applies to a function that has no side effect.
#define PROJ_PURE_DECL const noexcept __attribute__((pure))
#else
#define PROJ_NO_RETURN
#define PROJ_NO_INLINE
#define PROJ_PURE_DECL const noexcept
#endif
#define PROJ_PURE_DEFN const noexcept
//! @endcond
NS_PROJ_START
//! @cond Doxygen_Suppress
namespace io {
class DatabaseContext;
using DatabaseContextPtr = std::shared_ptr<DatabaseContext>;
}
//! @endcond
/** osgeo.proj.util namespace.
*
* \brief A set of base types from ISO 19103, \ref GeoAPI and other PROJ
* specific classes.
*/
namespace util {
//! @cond Doxygen_Suppress
// Import a few classes from nn.hpp to expose them under our ::util namespace
// for conveniency.
using ::dropbox::oxygen::i_promise_i_checked_for_null;
using ::dropbox::oxygen::nn;
using ::dropbox::oxygen::nn_dynamic_pointer_cast;
using ::dropbox::oxygen::nn_make_shared;
// For return statements, to convert from derived type to base type
using ::dropbox::oxygen::nn_static_pointer_cast;
template <typename T> using nn_shared_ptr = nn<std::shared_ptr<T>>;
#define NN_NO_CHECK(p) \
::dropbox::oxygen::nn<typename std::remove_const< \
typename std::remove_reference<decltype(p)>::type>::type>( \
dropbox::oxygen::i_promise_i_checked_for_null, (p))
//! @endcond
// To avoid formatting differences between clang-format 3.8 and 7
#define PROJ_NOEXCEPT noexcept
/** \brief Loose transposition of [std::optional]
* (https://en.cppreference.com/w/cpp/utility/optional) available from C++17. */
template <class T> class optional {
public:
//! @cond Doxygen_Suppress
inline optional() : hasVal_(false) {}
inline explicit optional(const T &val) : hasVal_(true), val_(val) {}
inline explicit optional(T &&val)
: hasVal_(true), val_(std::forward<T>(val)) {}
inline optional(const optional &) = default;
inline optional(optional &&other) PROJ_NOEXCEPT
: hasVal_(other.hasVal_),
// cppcheck-suppress functionStatic
val_(std::forward<T>(other.val_)) {
other.hasVal_ = false;
}
inline optional &operator=(const T &val) {
hasVal_ = true;
val_ = val;
return *this;
}
inline optional &operator=(T &&val) noexcept {
hasVal_ = true;
val_ = std::forward<T>(val);
return *this;
}
inline optional &operator=(const optional &) = default;
inline optional &operator=(optional &&other) noexcept {
hasVal_ = other.hasVal_;
val_ = std::forward<T>(other.val_);
other.hasVal_ = false;
return *this;
}
inline T *operator->() { return &val_; }
inline T &operator*() { return val_; }
//! @endcond
/** Returns a pointer to the contained value. */
inline const T *operator->() const { return &val_; }
/** Returns a reference to the contained value. */
inline const T &operator*() const { return val_; }
/** Return whether the optional has a value */
inline explicit operator bool() const noexcept { return hasVal_; }
/** Return whether the optional has a value */
inline bool has_value() const noexcept { return hasVal_; }
private:
bool hasVal_;
T val_{};
};
// ---------------------------------------------------------------------------
class BaseObject;
/** Shared pointer of BaseObject. */
using BaseObjectPtr = std::shared_ptr<BaseObject>;
#if 1
/** Non-null shared pointer of BaseObject. */
struct BaseObjectNNPtr : public util::nn<BaseObjectPtr> {
// This trick enables to avoid inlining of the destructor.
// This is mostly an alias of the base class.
//! @cond Doxygen_Suppress
template <class T>
// cppcheck-suppress noExplicitConstructor
BaseObjectNNPtr(const util::nn<std::shared_ptr<T>> &x)
: util::nn<BaseObjectPtr>(x) {}
template <class T>
// cppcheck-suppress noExplicitConstructor
BaseObjectNNPtr(util::nn<std::shared_ptr<T>> &&x) noexcept
: util::nn<BaseObjectPtr>(NN_NO_CHECK(std::move(x.as_nullable()))) {}
explicit BaseObjectNNPtr(::dropbox::oxygen::i_promise_i_checked_for_null_t,
BaseObjectPtr &&arg) noexcept
: util::nn<BaseObjectPtr>(i_promise_i_checked_for_null,
std::move(arg)) {}
BaseObjectNNPtr(const BaseObjectNNPtr &) = default;
BaseObjectNNPtr &operator=(const BaseObjectNNPtr &) = default;
PROJ_DLL ~BaseObjectNNPtr();
//! @endcond
};
#else
using BaseObjectNNPtr = util::nn<BaseObjectPtr>;
#endif
/** \brief Class that can be derived from, to emulate Java's Object behaviour.
*/
class PROJ_GCC_DLL BaseObject {
public:
//! @cond Doxygen_Suppress
virtual PROJ_DLL ~BaseObject();
//! @endcond
PROJ_PRIVATE :
//! @cond Doxygen_Suppress
PROJ_INTERNAL BaseObjectNNPtr
shared_from_this() const;
//! @endcond
protected:
PROJ_INTERNAL BaseObject();
PROJ_INTERNAL void assignSelf(const BaseObjectNNPtr &self);
private:
PROJ_OPAQUE_PRIVATE_DATA
};
// ---------------------------------------------------------------------------
/** \brief Interface for an object that can be compared to another.
*/
class PROJ_GCC_DLL IComparable {
public:
//! @cond Doxygen_Suppress
PROJ_DLL virtual ~IComparable();
//! @endcond
/** \brief Comparison criterion. */
enum class PROJ_MSVC_DLL Criterion {
/** All properties are identical. */
STRICT,
/** The objects are equivalent for the purpose of coordinate
* operations. They can differ by the name of their objects,
* identifiers, other metadata.
* Parameters may be expressed in different units, provided that the
* value is (with some tolerance) the same once expressed in a
* common unit.
*/
EQUIVALENT,
/** Same as EQUIVALENT, relaxed with an exception that the axis order
* of the base CRS of a DerivedCRS/ProjectedCRS or the axis order of
* a GeographicCRS is ignored. Only to be used
* with DerivedCRS/ProjectedCRS/GeographicCRS */
EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS,
};
PROJ_DLL bool
isEquivalentTo(const IComparable *other,
Criterion criterion = Criterion::STRICT,
const io::DatabaseContextPtr &dbContext = nullptr) const;
PROJ_PRIVATE :
//! @cond Doxygen_Suppress
PROJ_INTERNAL virtual bool
_isEquivalentTo(
const IComparable *other, Criterion criterion = Criterion::STRICT,
const io::DatabaseContextPtr &dbContext = nullptr) const = 0;
//! @endcond
};
// ---------------------------------------------------------------------------
/** \brief Encapsulate standard datatypes in an object.
*/
class BoxedValue final : public BaseObject {
public:
//! @cond Doxygen_Suppress
/** Type of data stored in the BoxedValue. */
enum class Type {
/** a std::string */
STRING,
/** an integer */
INTEGER,
/** a boolean */
BOOLEAN
};
//! @endcond
// cppcheck-suppress noExplicitConstructor
PROJ_DLL BoxedValue(const char *stringValueIn); // needed to avoid the bool
// constructor to be taken !
// cppcheck-suppress noExplicitConstructor
PROJ_DLL BoxedValue(const std::string &stringValueIn);
// cppcheck-suppress noExplicitConstructor
PROJ_DLL BoxedValue(int integerValueIn);
// cppcheck-suppress noExplicitConstructor
PROJ_DLL BoxedValue(bool booleanValueIn);
PROJ_PRIVATE :
//! @cond Doxygen_Suppress
PROJ_INTERNAL
BoxedValue(const BoxedValue &other);
PROJ_DLL ~BoxedValue() override;
PROJ_INTERNAL const Type &type() const;
PROJ_INTERNAL const std::string &stringValue() const;
PROJ_INTERNAL int integerValue() const;
PROJ_INTERNAL bool booleanValue() const;
//! @endcond
private:
PROJ_OPAQUE_PRIVATE_DATA
BoxedValue &operator=(const BoxedValue &) = delete;
PROJ_INTERNAL BoxedValue();
};
/** Shared pointer of BoxedValue. */
using BoxedValuePtr = std::shared_ptr<BoxedValue>;
/** Non-null shared pointer of BoxedValue. */
using BoxedValueNNPtr = util::nn<BoxedValuePtr>;
// ---------------------------------------------------------------------------
class ArrayOfBaseObject;
/** Shared pointer of ArrayOfBaseObject. */
using ArrayOfBaseObjectPtr = std::shared_ptr<ArrayOfBaseObject>;
/** Non-null shared pointer of ArrayOfBaseObject. */
using ArrayOfBaseObjectNNPtr = util::nn<ArrayOfBaseObjectPtr>;
/** \brief Array of BaseObject.
*/
class ArrayOfBaseObject final : public BaseObject {
public:
//! @cond Doxygen_Suppress
PROJ_DLL ~ArrayOfBaseObject() override;
//! @endcond
PROJ_DLL void add(const BaseObjectNNPtr &obj);
PROJ_DLL static ArrayOfBaseObjectNNPtr create();
PROJ_PRIVATE :
//! @cond Doxygen_Suppress
std::vector<BaseObjectNNPtr>::const_iterator
begin() const;
std::vector<BaseObjectNNPtr>::const_iterator end() const;
bool empty() const;
//! @endcond
protected:
ArrayOfBaseObject();
INLINED_MAKE_SHARED
private:
ArrayOfBaseObject(const ArrayOfBaseObject &other) = delete;
ArrayOfBaseObject &operator=(const ArrayOfBaseObject &other) = delete;
PROJ_OPAQUE_PRIVATE_DATA
};
// ---------------------------------------------------------------------------
/** \brief Wrapper of a std::map<std::string, BaseObjectNNPtr> */
class PropertyMap {
public:
PROJ_DLL PropertyMap();
//! @cond Doxygen_Suppress
PROJ_DLL PropertyMap(const PropertyMap &other);
PROJ_DLL ~PropertyMap();
//! @endcond
PROJ_DLL PropertyMap &set(const std::string &key,
const BaseObjectNNPtr &val);
//! @cond Doxygen_Suppress
template <class T>
inline PropertyMap &set(const std::string &key,
const nn_shared_ptr<T> &val) {
return set(
key, BaseObjectNNPtr(i_promise_i_checked_for_null,
BaseObjectPtr(val.as_nullable(), val.get())));
}
//! @endcond
// needed to avoid the bool constructor to be taken !
PROJ_DLL PropertyMap &set(const std::string &key, const char *val);
PROJ_DLL PropertyMap &set(const std::string &key, const std::string &val);
PROJ_DLL PropertyMap &set(const std::string &key, int val);
PROJ_DLL PropertyMap &set(const std::string &key, bool val);
PROJ_DLL PropertyMap &set(const std::string &key,
const std::vector<std::string> &array);
PROJ_PRIVATE :
//! @cond Doxygen_Suppress
const BaseObjectNNPtr *
get(const std::string &key) const;
// throw(InvalidValueTypeException)
bool getStringValue(const std::string &key, std::string &outVal) const;
bool getStringValue(const std::string &key,
optional<std::string> &outVal) const;
void unset(const std::string &key);
static PropertyMap createAndSetName(const char *name);
static PropertyMap createAndSetName(const std::string &name);
//! @endcond
private:
PropertyMap &operator=(const PropertyMap &) = delete;
PROJ_OPAQUE_PRIVATE_DATA
};
// ---------------------------------------------------------------------------
class LocalName;
/** Shared pointer of LocalName. */
using LocalNamePtr = std::shared_ptr<LocalName>;
/** Non-null shared pointer of LocalName. */
using LocalNameNNPtr = util::nn<LocalNamePtr>;
class NameSpace;
/** Shared pointer of NameSpace. */
using NameSpacePtr = std::shared_ptr<NameSpace>;
/** Non-null shared pointer of NameSpace. */
using NameSpaceNNPtr = util::nn<NameSpacePtr>;
class GenericName;
/** Shared pointer of GenericName. */
using GenericNamePtr = std::shared_ptr<GenericName>;
/** Non-null shared pointer of GenericName. */
using GenericNameNNPtr = util::nn<GenericNamePtr>;
// ---------------------------------------------------------------------------
/** \brief A sequence of identifiers rooted within the context of a namespace.
*
* \remark Simplified version of [GenericName]
* (http://www.geoapi.org/3.0/javadoc/org/opengis/util/GenericName.html) from
* \ref GeoAPI
*/
class GenericName : public BaseObject {
public:
//! @cond Doxygen_Suppress
PROJ_DLL virtual ~GenericName() override;
//! @endcond
/** \brief Return the scope of the object, possibly a global one. */
PROJ_DLL virtual const NameSpacePtr scope() const = 0;
/** \brief Return the LocalName as a string. */
PROJ_DLL virtual std::string toString() const = 0;
/** \brief Return a fully qualified name corresponding to the local name.
*
* The namespace of the resulting name is a global one.
*/
PROJ_DLL virtual GenericNameNNPtr toFullyQualifiedName() const = 0;
protected:
GenericName();
GenericName(const GenericName &other);
private:
PROJ_OPAQUE_PRIVATE_DATA
GenericName &operator=(const GenericName &other) = delete;
};
// ---------------------------------------------------------------------------
/** \brief A domain in which names given by strings are defined.
*
* \remark Simplified version of [NameSpace]
* (http://www.geoapi.org/3.0/javadoc/org/opengis/util/NameSpace.html) from \ref
* GeoAPI
*/
class NameSpace {
public:
//! @cond Doxygen_Suppress
PROJ_DLL ~NameSpace();
//! @endcond
PROJ_DLL bool isGlobal() const;
PROJ_DLL const GenericNamePtr &name() const;
protected:
PROJ_FRIEND(NameFactory);
PROJ_FRIEND(LocalName);
explicit NameSpace(const GenericNamePtr &name);
NameSpace(const NameSpace &other);
NameSpaceNNPtr getGlobalFromThis() const;
const std::string &separator() const;
static const NameSpaceNNPtr GLOBAL;
INLINED_MAKE_SHARED
private:
PROJ_OPAQUE_PRIVATE_DATA
NameSpace &operator=(const NameSpace &other) = delete;
static NameSpaceNNPtr createGLOBAL();
};
// ---------------------------------------------------------------------------
/** \brief Identifier within a NameSpace for a local object.
*
* Local names are names which are directly accessible to and maintained by a
* NameSpace within which they are local, indicated by the scope.
*
* \remark Simplified version of [LocalName]
* (http://www.geoapi.org/3.0/javadoc/org/opengis/util/LocalName.html) from \ref
* GeoAPI
*/
class LocalName : public GenericName {
public:
//! @cond Doxygen_Suppress
PROJ_DLL ~LocalName() override;
//! @endcond
PROJ_DLL const NameSpacePtr scope() const override;
PROJ_DLL std::string toString() const override;
PROJ_DLL GenericNameNNPtr toFullyQualifiedName() const override;
protected:
PROJ_FRIEND(NameFactory);
PROJ_FRIEND(NameSpace);
explicit LocalName(const std::string &nameIn);
LocalName(const LocalName &other);
LocalName(const NameSpacePtr &ns, const std::string &name);
INLINED_MAKE_SHARED
private:
PROJ_OPAQUE_PRIVATE_DATA
LocalName &operator=(const LocalName &other) = delete;
};
// ---------------------------------------------------------------------------
/** \brief Factory for generic names.
*
* \remark Simplified version of [NameFactory]
* (http://www.geoapi.org/3.0/javadoc/org/opengis/util/NameFactory.html) from
* \ref GeoAPI
*/
class NameFactory {
public:
PROJ_DLL static NameSpaceNNPtr
createNameSpace(const GenericNameNNPtr &name,
const PropertyMap &properties);
PROJ_DLL static LocalNameNNPtr createLocalName(const NameSpacePtr &scope,
const std::string &name);
PROJ_DLL static GenericNameNNPtr
createGenericName(const NameSpacePtr &scope,
const std::vector<std::string> &parsedNames);
};
// ---------------------------------------------------------------------------
/** \brief Abstract class to define an enumeration of values.
*/
class CodeList {
public:
//! @cond Doxygen_Suppress
PROJ_DLL ~CodeList();
//! @endcond
/** Return the CodeList item as a string. */
// cppcheck-suppress functionStatic
inline const std::string &toString() PROJ_PURE_DECL { return name_; }
/** Return the CodeList item as a string. */
inline operator std::string() PROJ_PURE_DECL { return toString(); }
//! @cond Doxygen_Suppress
inline bool operator==(const CodeList &other) PROJ_PURE_DECL {
return name_ == other.name_;
}
inline bool operator!=(const CodeList &other) PROJ_PURE_DECL {
return name_ != other.name_;
}
//! @endcond
protected:
explicit CodeList(const std::string &nameIn) : name_(nameIn) {}
CodeList(const CodeList &other) = default;
CodeList &operator=(const CodeList &other);
private:
std::string name_{};
};
// ---------------------------------------------------------------------------
/** \brief Root exception class.
*/
class PROJ_GCC_DLL Exception : public std::exception {
std::string msg_;
public:
//! @cond Doxygen_Suppress
PROJ_INTERNAL explicit Exception(const char *message);
PROJ_INTERNAL explicit Exception(const std::string &message);
PROJ_DLL Exception(const Exception &other);
PROJ_DLL ~Exception() override;
//! @endcond
PROJ_DLL virtual const char *what() const noexcept override;
};
// ---------------------------------------------------------------------------
/** \brief Exception thrown when an invalid value type is set as the value of
* a key of a PropertyMap.
*/
class PROJ_GCC_DLL InvalidValueTypeException : public Exception {
public:
//! @cond Doxygen_Suppress
PROJ_INTERNAL explicit InvalidValueTypeException(const char *message);
PROJ_INTERNAL explicit InvalidValueTypeException(
const std::string &message);
PROJ_DLL InvalidValueTypeException(const InvalidValueTypeException &other);
PROJ_DLL ~InvalidValueTypeException() override;
//! @endcond
};
// ---------------------------------------------------------------------------
/** \brief Exception Thrown to indicate that the requested operation is not
* supported.
*/
class PROJ_GCC_DLL UnsupportedOperationException : public Exception {
public:
//! @cond Doxygen_Suppress
PROJ_INTERNAL explicit UnsupportedOperationException(const char *message);
PROJ_INTERNAL explicit UnsupportedOperationException(
const std::string &message);
PROJ_DLL
UnsupportedOperationException(const UnsupportedOperationException &other);
PROJ_DLL ~UnsupportedOperationException() override;
//! @endcond
};
} // namespace util
NS_PROJ_END
#endif // UTIL_HH_INCLUDED
|