| 1 |
/****************************************************************************** |
| 2 |
* |
| 3 |
* Project: SAP HANA Spatial Driver |
| 4 |
* Purpose: OGRHanaUtils class declaration |
| 5 |
* Author: Maxim Rylov |
| 6 |
* |
| 7 |
****************************************************************************** |
| 8 |
* Copyright (c) 2020, SAP SE |
| 9 |
* |
| 10 |
* SPDX-License-Identifier: MIT |
| 11 |
****************************************************************************/ |
| 12 |
|
| 13 |
#ifndef OGRHANAUTILS_H_INCLUDED |
| 14 |
#define OGRHANAUTILS_H_INCLUDED |
| 15 |
|
| 16 |
#include "ogr_core.h" |
| 17 |
#include "ogr_feature.h" |
| 18 |
|
| 19 |
#include "cpl_string.h" |
| 20 |
|
| 21 |
#include <limits> |
| 22 |
#include <vector> |
| 23 |
|
| 24 |
namespace OGRHANA |
| 25 |
{ |
| 26 |
|
| 27 |
constexpr const char *ARRAY_VALUES_DELIMITER = "^%^"; |
| 28 |
|
| 29 |
class HanaVersion |
| 30 |
{ |
| 31 |
|
| 32 |
public: |
| 33 |
explicit HanaVersion(unsigned int major, unsigned int minor, |
| 34 |
unsigned int patch) |
| 35 |
: components_{major, minor, patch} |
| 36 |
{ |
| 37 |
} |
| 38 |
|
| 39 |
HanaVersion() : components_{0, 0, 0} |
| 40 |
{ |
| 41 |
} |
| 42 |
|
| 43 |
unsigned int major() const |
| 44 |
{ |
| 45 |
return components_[0]; |
| 46 |
} |
| 47 |
|
| 48 |
unsigned int minor() const |
| 49 |
{ |
| 50 |
return components_[1]; |
| 51 |
} |
| 52 |
|
| 53 |
unsigned int patch() const |
| 54 |
{ |
| 55 |
return components_[2]; |
| 56 |
} |
| 57 |
|
| 58 |
bool operator<=(const HanaVersion &other) |
| 59 |
{ |
| 60 |
for (size_t i = 0; i < 3; ++i) |
| 61 |
if (components_[i] != other.components_[i]) |
| 62 |
return components_[i] < other.components_[i]; |
| 63 |
return true; |
| 64 |
} |
| 65 |
|
| 66 |
bool operator>=(const HanaVersion &other) |
| 67 |
{ |
| 68 |
return !(*this <= other) || (*this == other); |
| 69 |
} |
| 70 |
|
| 71 |
bool operator==(const HanaVersion &other) |
| 72 |
{ |
| 73 |
for (size_t i = 0; i < 3; ++i) |
| 74 |
if (components_[i] != other.components_[i]) |
| 75 |
return false; |
| 76 |
return true; |
| 77 |
} |
| 78 |
|
| 79 |
public: |
| 80 |
static HanaVersion fromString(const char *str); |
| 81 |
|
| 82 |
private: |
| 83 |
unsigned int components_[3]; |
| 84 |
}; |
| 85 |
|
| 86 |
const char *SkipLeadingSpaces(const char *value); |
| 87 |
CPLString JoinStrings(const std::vector<CPLString> &strs, const char *delimiter, |
| 88 |
CPLString (*decorator)(const CPLString &str) = nullptr); |
| 89 |
std::vector<CPLString> SplitStrings(const char *str, const char *delimiter); |
| 90 |
|
| 91 |
CPLString GetFullColumnNameQuoted(const CPLString &schemaName, |
| 92 |
const CPLString &tableName, |
| 93 |
const CPLString &columnName); |
| 94 |
CPLString GetFullTableName(const CPLString &schemaName, |
| 95 |
const CPLString &tableName); |
| 96 |
CPLString GetFullTableNameQuoted(const CPLString &schemaName, |
| 97 |
const CPLString &tableName); |
| 98 |
CPLString Literal(const CPLString &value); |
| 99 |
CPLString QuotedIdentifier(const CPLString &value); |
| 100 |
|
| 101 |
bool IsArrayField(OGRFieldType fieldType); |
| 102 |
bool IsGeometryTypeSupported(OGRwkbGeometryType wkbType); |
| 103 |
OGRwkbGeometryType ToWkbType(const char *type, bool hasZ, bool hasM); |
| 104 |
int ToPlanarSRID(int srid); |
| 105 |
|
| 106 |
} // namespace OGRHANA |
| 107 |
|
| 108 |
#endif /* ndef OGRHANAUTILS_H_INCLUDED */ |