29 #ifndef UTIL_HH_INCLUDED 30 #define UTIL_HH_INCLUDED 32 #if !(__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900)) 33 #error Must have C++11 or newer. 53 #ifdef PROJ_MSVC_DLL_EXPORT 54 #define PROJ_DLL __declspec(dllexport) 55 #elif defined(PROJ_MSVC_DLL_IMPORT) 56 #define PROJ_DLL __declspec(dllimport) 66 #define NS_PROJ osgeo::proj 67 #define NS_PROJ_START \ 76 #define PROJ_OPAQUE_PRIVATE_DATA \ 79 std::unique_ptr<Private> d; \ 82 Private *getPrivate() noexcept { return d.get(); } \ 83 const Private *getPrivate() const noexcept { return d.get(); } \ 89 #define INLINED_MAKE_SHARED \ 90 template <typename T, typename... Args> \ 91 static std::shared_ptr<T> make_shared(Args &&... args) { \ 92 return std::shared_ptr<T>(new T(std::forward<Args>(args)...)); \ 94 template <typename T, typename... Args> \ 95 static util::nn_shared_ptr<T> nn_make_shared(Args &&... args) { \ 96 return util::nn_shared_ptr<T>( \ 97 util::i_promise_i_checked_for_null, \ 98 std::shared_ptr<T>(new T(std::forward<Args>(args)...))); \ 103 #define INLINED_MAKE_UNIQUE \ 104 template <typename T, typename... Args> \ 105 static std::unique_ptr<T> make_unique(Args &&... args) { \ 106 return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); \ 109 #ifdef DOXYGEN_ENABLED 110 #define PROJ_FRIEND(mytype) 111 #define PROJ_FRIEND_OPTIONAL(mytype) 113 #define PROJ_FRIEND(mytype) friend class mytype 114 #define PROJ_FRIEND_OPTIONAL(mytype) friend class util::optional<mytype> 118 #define PROJ_PRIVATE public 121 #if defined(__GNUC__) 122 #define PROJ_NO_INLINE __attribute__((noinline)) 123 #define PROJ_NO_RETURN __attribute__((noreturn)) 127 #define PROJ_PURE_DECL const noexcept __attribute__((pure)) 132 #define PROJ_CONST_DECL const noexcept __attribute__((const)) 134 #define PROJ_NO_RETURN 135 #define PROJ_NO_INLINE 136 #define PROJ_PURE_DECL const noexcept 137 #define PROJ_CONST_DECL const noexcept 139 #define PROJ_PURE_DEFN const noexcept 140 #define PROJ_CONST_DEFN const noexcept 156 using ::dropbox::oxygen::i_promise_i_checked_for_null;
157 using ::dropbox::oxygen::nn;
158 using ::dropbox::oxygen::nn_dynamic_pointer_cast;
159 using ::dropbox::oxygen::nn_make_shared;
162 using ::dropbox::oxygen::nn_static_pointer_cast;
164 template <
typename T>
using nn_shared_ptr = nn<std::shared_ptr<T>>;
166 #define NN_NO_CHECK(p) \ 167 ::dropbox::oxygen::nn<typename std::remove_const< \ 168 typename std::remove_reference<decltype(p)>::type>::type>( \ 169 dropbox::oxygen::i_promise_i_checked_for_null, (p)) 174 #define PROJ_NOEXCEPT noexcept 181 inline optional() : hasVal_(
false) {}
182 inline explicit optional(
const T &val) : hasVal_(
true), val_(val) {}
184 : hasVal_(
true), val_(std::forward<T>(val)) {}
188 : hasVal_(other.hasVal_),
190 val_(std::forward<T>(other.val_)) {
191 other.hasVal_ =
false;
194 inline optional &operator=(
const T &val) {
199 inline optional &operator=(T &&val) noexcept {
201 val_ = std::forward<T>(val);
206 hasVal_ = other.hasVal_;
207 val_ = std::forward<T>(other.val_);
208 other.hasVal_ =
false;
224 inline explicit operator bool() const noexcept {
return hasVal_; }
227 inline bool has_value() const noexcept {
return hasVal_; }
248 : util::nn<BaseObjectPtr>(x) {}
251 : util::nn<BaseObjectPtr>(NN_NO_CHECK(std::move(x.as_nullable()))) {}
252 explicit BaseObjectNNPtr(::dropbox::oxygen::i_promise_i_checked_for_null_t,
254 : util::nn<BaseObjectPtr>(i_promise_i_checked_for_null,
277 shared_from_this()
const;
285 PROJ_OPAQUE_PRIVATE_DATA
311 PROJ_DLL
virtual bool 313 Criterion criterion = Criterion::STRICT)
const = 0;
335 PROJ_DLL
BoxedValue(
const char *stringValueIn);
338 PROJ_DLL BoxedValue(
const std::string &stringValueIn);
340 PROJ_DLL BoxedValue(
int integerValueIn);
342 PROJ_DLL BoxedValue(
bool booleanValueIn);
347 BoxedValue(
const BoxedValue &other);
349 PROJ_DLL ~BoxedValue()
override;
351 PROJ_DLL
const Type &type()
const;
352 PROJ_DLL
const std::string &stringValue()
const;
353 PROJ_DLL
int integerValue()
const;
354 PROJ_DLL
bool booleanValue()
const;
358 PROJ_OPAQUE_PRIVATE_DATA
359 BoxedValue &operator=(
const BoxedValue &) =
delete;
391 std::vector<BaseObjectNNPtr>::const_iterator
393 std::vector<BaseObjectNNPtr>::const_iterator end()
const;
404 PROJ_OPAQUE_PRIVATE_DATA
414 PROJ_DLL PropertyMap(
const PropertyMap &other);
415 PROJ_DLL ~PropertyMap();
418 PROJ_DLL PropertyMap &
set(
const std::string &key,
423 inline PropertyMap &
set(
const std::string &key,
424 const nn_shared_ptr<T> &val) {
432 PROJ_DLL PropertyMap &
set(
const std::string &key,
const char *val);
434 PROJ_DLL PropertyMap &
set(
const std::string &key,
const std::string &val);
436 PROJ_DLL PropertyMap &
set(
const std::string &key,
int val);
438 PROJ_DLL PropertyMap &
set(
const std::string &key,
bool val);
440 PROJ_DLL PropertyMap &
set(
const std::string &key,
441 const std::vector<std::string> &array);
445 std::map<std::string, BaseObjectNNPtr>::iterator
446 find(
const std::string &key)
const;
447 std::map<std::string, BaseObjectNNPtr>::iterator end()
const;
450 bool getStringValue(
const std::string &key, std::string &outVal)
const;
452 static PropertyMap createAndSetName(
const char *name);
453 static PropertyMap createAndSetName(
const std::string &name);
457 PropertyMap &operator=(
const PropertyMap &) =
delete;
459 PropertyMap &
set(
const std::string &key,
const BoxedValue &val);
461 PROJ_OPAQUE_PRIVATE_DATA
502 PROJ_DLL
virtual std::string toString()
const = 0;
515 PROJ_OPAQUE_PRIVATE_DATA
533 PROJ_DLL
bool isGlobal()
const;
542 const std::string &separator()
const;
547 PROJ_OPAQUE_PRIVATE_DATA
571 PROJ_DLL std::string toString()
const override;
577 explicit LocalName(
const std::string &nameIn);
583 PROJ_OPAQUE_PRIVATE_DATA
601 const std::string &name);
604 const std::vector<std::string> &parsedNames);
619 inline const std::string &
toString() PROJ_CONST_DECL {
return name_; }
622 inline operator std::string() PROJ_CONST_DECL {
return toString(); }
625 inline bool operator==(
const CodeList &other) PROJ_CONST_DECL {
626 return name_ == other.name_;
628 inline bool operator!=(
const CodeList &other) PROJ_CONST_DECL {
629 return name_ != other.name_;
633 explicit CodeList(
const std::string &nameIn) : name_(nameIn) {}
650 PROJ_DLL
explicit Exception(
const char *message);
651 PROJ_DLL
explicit Exception(
const std::string &message);
652 PROJ_DLL Exception(
const Exception &other);
653 PROJ_DLL ~Exception()
override;
655 PROJ_DLL
virtual const char *what()
const noexcept
override;
667 PROJ_DLL
explicit InvalidValueTypeException(
const std::string &message);
668 PROJ_DLL InvalidValueTypeException(
const InvalidValueTypeException &other);
669 PROJ_DLL ~InvalidValueTypeException()
override;
682 PROJ_DLL
explicit UnsupportedOperationException(
const std::string &message);
684 UnsupportedOperationException(
const UnsupportedOperationException &other);
685 PROJ_DLL ~UnsupportedOperationException()
override;
693 #endif // UTIL_HH_INCLUDED Interface for an object that can be compared to another.
Definition: util.hpp:292
Abstract class to define an enumeration of values.
Definition: util.hpp:611
std::shared_ptr< NameSpace > NameSpacePtr
Definition: util.hpp:474
std::shared_ptr< ArrayOfBaseObject > ArrayOfBaseObjectPtr
Definition: util.hpp:373
std::shared_ptr< LocalName > LocalNamePtr
Definition: util.hpp:468
A sequence of identifiers rooted within the context of a namespace.
Definition: util.hpp:492
Factory for generic names.
Definition: util.hpp:595
Root exception class.
Definition: util.hpp:645
bool has_value() const noexcept
Definition: util.hpp:227
std::shared_ptr< BaseObject > BaseObjectPtr
Definition: util.hpp:238
Array of BaseObject.
Definition: util.hpp:379
Encapsulate standard datatypes in an object.
Definition: util.hpp:320
Criterion
Comparison criterion.
Definition: util.hpp:299
Exception thrown when an invalid value type is set as the value of a key of a PropertyMap.
Definition: util.hpp:663
std::shared_ptr< GenericName > GenericNamePtr
Definition: util.hpp:480
util::nn< LocalNamePtr > LocalNameNNPtr
Definition: util.hpp:470
util::nn< ArrayOfBaseObjectPtr > ArrayOfBaseObjectNNPtr
Definition: util.hpp:375
const T * operator->() const
Definition: util.hpp:218
Wrapper of a std::map<std::string, BaseObjectNNPtr>
Definition: util.hpp:410
const std::string & toString() PROJ_CONST_DECL
Definition: util.hpp:619
Definition: common.cpp:63
Class that can be derived from, to emulate Java's Object behaviour.
Definition: util.hpp:268
util::nn< GenericNamePtr > GenericNameNNPtr
Definition: util.hpp:482
Exception Thrown to indicate that the requested operation is not supported.
Definition: util.hpp:678
std::shared_ptr< BoxedValue > BoxedValuePtr
Definition: util.hpp:365
Identifier within a NameSpace for a local object.
Definition: util.hpp:564
util::nn< BoxedValuePtr > BoxedValueNNPtr
Definition: util.hpp:367
Loose transposition of std::optional available from C++17.
Definition: util.hpp:178
const T & operator*() const
Definition: util.hpp:221
A domain in which names given by strings are defined.
Definition: util.hpp:527
util::nn< NameSpacePtr > NameSpaceNNPtr
Definition: util.hpp:476