GDAL
ogr_feature.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Project: OpenGIS Simple Features Reference Implementation
4 * Purpose: Class for representing a whole feature, and layer schemas.
5 * Author: Frank Warmerdam, warmerdam@pobox.com
6 *
7 ******************************************************************************
8 * Copyright (c) 1999, Les Technologies SoftMap Inc.
9 * Copyright (c) 2008-2013, Even Rouault <even dot rouault at spatialys.com>
10 *
11 * SPDX-License-Identifier: MIT
12 ****************************************************************************/
13
14#ifndef OGR_FEATURE_H_INCLUDED
15#define OGR_FEATURE_H_INCLUDED
16
17#include "cpl_atomic_ops.h"
18#include "gdal_fwd.h"
19#include "ogr_featurestyle.h"
20#include "ogr_geometry.h"
22
23#include <cstddef>
24
25#include <exception>
26#include <memory>
27#include <string>
28#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
29#include <string_view>
30#endif
31#include <vector>
32
39class OGRStyleTable;
40
41/************************************************************************/
42/* OGRFieldDefn */
43/************************************************************************/
44
71class CPL_DLL OGRFieldDefn
72{
73 private:
74 char *pszName;
75 char *pszAlternativeName;
76 OGRFieldType eType;
77 OGRJustification eJustify;
78 int nWidth; // Zero is variable.
79 int nPrecision;
80 char *pszDefault;
81
82 int bIgnore;
83 OGRFieldSubType eSubType;
84
85 int bNullable;
86 int bUnique;
87
88 // Used by drivers (GPKG) to track generated fields
89 bool m_bGenerated = false;
90
91 std::string m_osDomainName{}; // field domain name. Might be empty
92
93 std::string m_osComment{}; // field comment. Might be empty
94
95 int m_nTZFlag = OGR_TZFLAG_UNKNOWN;
96 bool m_bSealed = false;
97
98 public:
99 OGRFieldDefn(const char *, OGRFieldType);
100 explicit OGRFieldDefn(const OGRFieldDefn *);
102
103 // Copy constructor
104 OGRFieldDefn(const OGRFieldDefn &oOther);
105
106 // Copy assignment operator
107 OGRFieldDefn &operator=(const OGRFieldDefn &oOther);
108
109 void SetName(const char *);
110
111 const char *GetNameRef() const
112 {
113 return pszName;
114 }
115
116 void SetAlternativeName(const char *);
117
118 const char *GetAlternativeNameRef() const
119 {
120 return pszAlternativeName;
121 }
122
124 {
125 return eType;
126 }
127
128 void SetType(OGRFieldType eTypeIn);
129 static const char *GetFieldTypeName(OGRFieldType);
130 static OGRFieldType GetFieldTypeByName(const char *);
131
133 {
134 return eSubType;
135 }
136
137 void SetSubType(OGRFieldSubType eSubTypeIn);
138 static const char *GetFieldSubTypeName(OGRFieldSubType);
139 static OGRFieldSubType GetFieldSubTypeByName(const char *);
140
142 {
143 return eJustify;
144 }
145
147 {
148 eJustify = eJustifyIn;
149 }
150
151 int GetWidth() const
152 {
153 return nWidth;
154 }
155
156 void SetWidth(int nWidthIn);
157
158 int GetPrecision() const
159 {
160 return nPrecision;
161 }
162
163 void SetPrecision(int nPrecisionIn);
164
165 int GetTZFlag() const
166 {
167 return m_nTZFlag;
168 }
169
170 void SetTZFlag(int nTZFlag);
171
172 void Set(const char *, OGRFieldType, int = 0, int = 0,
173 OGRJustification = OJUndefined);
174
175 void SetDefault(const char *);
176 const char *GetDefault() const;
177 int IsDefaultDriverSpecific() const;
178
179 int IsIgnored() const
180 {
181 return bIgnore;
182 }
183
184 void SetIgnored(int bIgnoreIn)
185 {
186 bIgnore = bIgnoreIn;
187 }
188
189 int IsNullable() const
190 {
191 return bNullable;
192 }
193
194 void SetNullable(int bNullableIn);
195
196 int IsUnique() const
197 {
198 return bUnique;
199 }
200
209 bool IsGenerated() const
210 {
211 return m_bGenerated;
212 }
213
219 void SetGenerated(bool bGeneratedIn)
220 {
221 m_bGenerated = bGeneratedIn;
222 }
223
224 void SetUnique(int bUniqueIn);
225
226 const std::string &GetDomainName() const
227 {
228 return m_osDomainName;
229 }
230
231 void SetDomainName(const std::string &osDomainName);
232
233 const std::string &GetComment() const
234 {
235 return m_osComment;
236 }
237
238 void SetComment(const std::string &osComment);
239
240 int IsSame(const OGRFieldDefn *) const;
241
244 static inline OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
245 {
246 return reinterpret_cast<OGRFieldDefnH>(poFieldDefn);
247 }
248
251 static inline OGRFieldDefn *FromHandle(OGRFieldDefnH hFieldDefn)
252 {
253 return reinterpret_cast<OGRFieldDefn *>(hFieldDefn);
254 }
255
256 void Seal();
257
258 void Unseal();
259
261 struct CPL_DLL TemporaryUnsealer
262 {
263 private:
264 OGRFieldDefn *m_poFieldDefn = nullptr;
265 CPL_DISALLOW_COPY_ASSIGN(TemporaryUnsealer)
266 public:
267 explicit TemporaryUnsealer(OGRFieldDefn *poFieldDefn)
268 : m_poFieldDefn(poFieldDefn)
269 {
270 m_poFieldDefn->Unseal();
271 }
272
273 TemporaryUnsealer(TemporaryUnsealer &&) = default;
274 TemporaryUnsealer &operator=(TemporaryUnsealer &&) = default;
275
276 ~TemporaryUnsealer()
277 {
278 m_poFieldDefn->Seal();
279 }
280
281 OGRFieldDefn *operator->()
282 {
283 return m_poFieldDefn;
284 }
285 };
286
289 TemporaryUnsealer GetTemporaryUnsealer();
290};
291
292#ifdef GDAL_COMPILATION
304inline OGRFieldDefn::TemporaryUnsealer whileUnsealing(OGRFieldDefn *object)
305{
306 return object->GetTemporaryUnsealer();
307}
308#endif
309
310/************************************************************************/
311/* OGRGeomFieldDefn */
312/************************************************************************/
313
334class CPL_DLL OGRGeomFieldDefn
335{
336 protected:
338 char *pszName = nullptr;
339 OGRwkbGeometryType eGeomType =
340 wkbUnknown; /* all values possible except wkbNone */
341 mutable OGRSpatialReferenceRefCountedPtr poSRS = nullptr;
342
343 int bIgnore = false;
344 mutable int bNullable = true;
345 bool m_bSealed = false;
346 OGRGeomCoordinatePrecision m_oCoordPrecision{};
347
348 void Initialize(const char *, OGRwkbGeometryType);
350
351 public:
352 OGRGeomFieldDefn(const char *pszNameIn, OGRwkbGeometryType eGeomTypeIn);
353 explicit OGRGeomFieldDefn(const OGRGeomFieldDefn *);
354 virtual ~OGRGeomFieldDefn();
355
356 // Copy constructor
357 OGRGeomFieldDefn(const OGRGeomFieldDefn &oOther);
358
359 // Move constructor
361
362 // Copy assignment operator
363 OGRGeomFieldDefn &operator=(const OGRGeomFieldDefn &oOther);
364
365 // Move assignment operator
366 OGRGeomFieldDefn &operator=(OGRGeomFieldDefn &&oOther);
367
368 void SetName(const char *);
369
370 const char *GetNameRef() const
371 {
372 return pszName;
373 }
374
376 {
377 return eGeomType;
378 }
379
380 void SetType(OGRwkbGeometryType eTypeIn);
381
382 virtual const OGRSpatialReference *GetSpatialRef() const;
383 void SetSpatialRef(const OGRSpatialReference *poSRSIn);
384 void SetSpatialRef(OGRSpatialReferenceRefCountedPtr poSRSIn);
385
386 int IsIgnored() const
387 {
388 return bIgnore;
389 }
390
391 void SetIgnored(int bIgnoreIn)
392 {
393 bIgnore = bIgnoreIn;
394 }
395
396 int IsNullable() const
397 {
398 return bNullable;
399 }
400
401 void SetNullable(int bNullableIn);
402
404 {
405 return m_oCoordPrecision;
406 }
407
408 void SetCoordinatePrecision(const OGRGeomCoordinatePrecision &prec);
409
410 int IsSame(const OGRGeomFieldDefn *) const;
411
414 static inline OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
415 {
416 return reinterpret_cast<OGRGeomFieldDefnH>(poGeomFieldDefn);
417 }
418
421 static inline OGRGeomFieldDefn *FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
422 {
423 return reinterpret_cast<OGRGeomFieldDefn *>(hGeomFieldDefn);
424 }
425
426 void Seal();
427
428 void Unseal();
429
431 struct CPL_DLL TemporaryUnsealer
432 {
433 private:
434 OGRGeomFieldDefn *m_poFieldDefn = nullptr;
435 CPL_DISALLOW_COPY_ASSIGN(TemporaryUnsealer)
436 public:
437 explicit TemporaryUnsealer(OGRGeomFieldDefn *poFieldDefn)
438 : m_poFieldDefn(poFieldDefn)
439 {
440 m_poFieldDefn->Unseal();
441 }
442
443 TemporaryUnsealer(TemporaryUnsealer &&) = default;
444 TemporaryUnsealer &operator=(TemporaryUnsealer &&) = default;
445
446 ~TemporaryUnsealer()
447 {
448 m_poFieldDefn->Seal();
449 }
450
451 OGRGeomFieldDefn *operator->()
452 {
453 return m_poFieldDefn;
454 }
455 };
456
459 TemporaryUnsealer GetTemporaryUnsealer();
460
461 private:
462 OGRSpatialReferenceRefCountedPtr &GetRefCountedSRS() const
463 {
464 GetSpatialRef();
465 return poSRS;
466 }
467};
468
469#ifdef GDAL_COMPILATION
481inline OGRGeomFieldDefn::TemporaryUnsealer
482whileUnsealing(OGRGeomFieldDefn *object)
483{
484 return object->GetTemporaryUnsealer();
485}
486#endif
487
488/************************************************************************/
489/* OGRFeatureDefn */
490/************************************************************************/
491
520class CPL_DLL OGRFeatureDefn
521{
522 protected:
524 volatile int nRefCount = 0;
525
526 mutable std::vector<std::unique_ptr<OGRFieldDefn>> apoFieldDefn{};
527 mutable std::vector<std::unique_ptr<OGRGeomFieldDefn>> apoGeomFieldDefn{};
528
529 char *pszFeatureClassName = nullptr;
530
531 bool bIgnoreStyle = false;
532
533 friend class TemporaryUnsealer;
534 bool m_bSealed = false;
535 int m_nTemporaryUnsealCount = 0;
537
538 public:
539 explicit OGRFeatureDefn(const char *pszName = nullptr);
540 virtual ~OGRFeatureDefn();
541
542 void SetName(const char *pszName);
543 virtual const char *GetName() const;
544
545 virtual int GetFieldCount() const;
546 virtual OGRFieldDefn *GetFieldDefn(int i);
547 virtual const OGRFieldDefn *GetFieldDefn(int i) const;
548 virtual int GetFieldIndex(const char *) const;
549 int GetFieldIndexCaseSensitive(const char *) const;
550
552
556 template <class OwnerT, class ChildT> struct CPL_DLL Fields
557 {
558 private:
559 OwnerT m_poFDefn;
560
561 public:
562 inline explicit Fields(OwnerT poFDefn) : m_poFDefn(poFDefn)
563 {
564 }
565
566 struct CPL_DLL Iterator
567 {
568 private:
569 OwnerT m_poFDefn;
570 const int m_nFieldCount;
571 int m_nIdx;
572 ChildT m_curValue{};
573
574 public:
575 inline Iterator(OwnerT poFDefn, int nIdx)
576 : m_poFDefn(poFDefn), m_nFieldCount(poFDefn->GetFieldCount()),
577 m_nIdx(nIdx)
578 {
579 if (m_nIdx < m_nFieldCount)
580 m_curValue = m_poFDefn->GetFieldDefn(m_nIdx);
581 }
582
583 inline const ChildT &operator*() const
584 {
585 return m_curValue;
586 }
587
588 inline ChildT &operator*()
589 {
590 return m_curValue;
591 }
592
593 inline Iterator &operator++()
594 {
595 m_nIdx++;
596 if (m_nIdx < m_nFieldCount)
597 m_curValue = m_poFDefn->GetFieldDefn(m_nIdx);
598 else
599 m_curValue = nullptr;
600 return *this;
601 }
602
603 inline bool operator!=(const Iterator &it) const
604 {
605 return m_nIdx != it.m_nIdx;
606 }
607 };
608
609 inline Iterator begin() const
610 {
611 return Iterator(m_poFDefn, 0);
612 }
613
614 inline Iterator end() const
615 {
616 return Iterator(m_poFDefn, m_poFDefn->GetFieldCount());
617 }
618
619 inline size_t size() const
620 {
621 return static_cast<std::size_t>(m_poFDefn->GetFieldCount());
622 }
623
624 inline ChildT operator[](size_t i)
625 {
626 return m_poFDefn->GetFieldDefn(static_cast<int>(i));
627 }
628 };
629
631
633 using NonConstFields = Fields<OGRFeatureDefn *, OGRFieldDefn *>;
634
646 {
647 return NonConstFields(this);
648 }
649
651 using ConstFields = Fields<const OGRFeatureDefn *, const OGRFieldDefn *>;
652
663 inline ConstFields GetFields() const
664 {
665 return ConstFields(this);
666 }
667
669 // That method should only be called if there's a guarantee that
670 // GetFieldCount() has been called before
671 int GetFieldCountUnsafe() const
672 {
673 return static_cast<int>(apoFieldDefn.size());
674 }
675
676 // Those methods don't check i is n range.
677 OGRFieldDefn *GetFieldDefnUnsafe(int i)
678 {
679 if (apoFieldDefn.empty())
680 GetFieldDefn(i);
681 return apoFieldDefn[static_cast<std::size_t>(i)].get();
682 }
683
684 const OGRFieldDefn *GetFieldDefnUnsafe(int i) const
685 {
686 if (apoFieldDefn.empty())
687 GetFieldDefn(i);
688 return apoFieldDefn[static_cast<std::size_t>(i)].get();
689 }
690
692
693 virtual void AddFieldDefn(const OGRFieldDefn *);
694 virtual OGRErr DeleteFieldDefn(int iField);
695
704 virtual std::unique_ptr<OGRFieldDefn> StealFieldDefn(int iField);
705
706 virtual void AddFieldDefn(std::unique_ptr<OGRFieldDefn> &&poFieldDefn);
707
708 virtual OGRErr ReorderFieldDefns(const int *panMap);
709
718 virtual std::unique_ptr<OGRGeomFieldDefn> StealGeomFieldDefn(int iField);
719
720 virtual int GetGeomFieldCount() const;
721 virtual OGRGeomFieldDefn *GetGeomFieldDefn(int i);
722 virtual const OGRGeomFieldDefn *GetGeomFieldDefn(int i) const;
723 virtual int GetGeomFieldIndex(const char *) const;
724
726
730 template <class OwnerT, class ChildT> struct CPL_DLL GeomFields
731 {
732 private:
733 OwnerT m_poFDefn;
734
735 public:
736 inline explicit GeomFields(OwnerT poFDefn) : m_poFDefn(poFDefn)
737 {
738 }
739
740 struct CPL_DLL Iterator
741 {
742 private:
743 OwnerT m_poFDefn;
744 int m_nIdx;
745
746 public:
747 inline Iterator(OwnerT poFDefn, int nIdx)
748 : m_poFDefn(poFDefn), m_nIdx(nIdx)
749 {
750 }
751
752 inline ChildT operator*() const
753 {
754 return m_poFDefn->GetGeomFieldDefn(m_nIdx);
755 }
756
757 inline Iterator &operator++()
758 {
759 m_nIdx++;
760 return *this;
761 }
762
763 inline bool operator!=(const Iterator &it) const
764 {
765 return m_nIdx != it.m_nIdx;
766 }
767 };
768
769 inline Iterator begin()
770 {
771 return Iterator(m_poFDefn, 0);
772 }
773
774 inline Iterator end()
775 {
776 return Iterator(m_poFDefn, m_poFDefn->GetGeomFieldCount());
777 }
778
779 inline size_t size() const
780 {
781 return static_cast<std::size_t>(m_poFDefn->GetGeomFieldCount());
782 }
783
784 inline ChildT operator[](size_t i) const
785 {
786 return m_poFDefn->GetGeomFieldDefn(static_cast<int>(i));
787 }
788 };
789
791
793 using NonConstGeomFields = GeomFields<OGRFeatureDefn *, OGRGeomFieldDefn *>;
794
806 {
807 return NonConstGeomFields(this);
808 }
809
812 GeomFields<const OGRFeatureDefn *, const OGRGeomFieldDefn *>;
813
825 {
826 return ConstGeomFields(this);
827 }
828
829 virtual void AddGeomFieldDefn(const OGRGeomFieldDefn *);
830 virtual void AddGeomFieldDefn(std::unique_ptr<OGRGeomFieldDefn> &&);
831 virtual OGRErr DeleteGeomFieldDefn(int iGeomField);
832
833 virtual OGRwkbGeometryType GetGeomType() const;
834 virtual void SetGeomType(OGRwkbGeometryType);
835
836 virtual OGRFeatureDefn *Clone() const;
837
838#ifdef DEPRECATE_OGRFEATUREDEFN_REF_COUNTING
839 int Reference()
840 CPL_WARN_DEPRECATED("Use OGRFeatureDefnRefCountedPtr instead")
841 {
842 return CPLAtomicInc(&nRefCount);
843 }
844
845 int Dereference()
846 CPL_WARN_DEPRECATED("Use OGRFeatureDefnRefCountedPtr instead")
847 {
848 return CPLAtomicDec(&nRefCount);
849 }
850
851 int GetReferenceCount() const
852 CPL_WARN_DEPRECATED("Use OGRFeatureDefnRefCountedPtr instead")
853 {
854 return nRefCount;
855 }
856
857 void Release()
858 CPL_WARN_DEPRECATED("Use OGRFeatureDefnRefCountedPtr instead");
859#else
861 {
862 return CPLAtomicInc(&nRefCount);
863 }
864
866#if defined(GDAL_COMPILATION) && !defined(DOXYGEN_XML)
867 CPL_WARN_DEPRECATED("Use Release() instead")
868#endif
869 {
870 return CPLAtomicDec(&nRefCount);
871 }
872
874 {
875 return nRefCount;
876 }
877
878 void Release();
879#endif
880
881 virtual int IsGeometryIgnored() const;
882 virtual void SetGeometryIgnored(int bIgnore);
883
884 virtual bool IsStyleIgnored() const
885 {
886 return bIgnoreStyle;
887 }
888
889 virtual void SetStyleIgnored(bool bIgnore)
890 {
891 bIgnoreStyle = bIgnore;
892 }
893
894 virtual int IsSame(const OGRFeatureDefn *poOtherFeatureDefn) const;
895
897 void ReserveSpaceForFields(int nFieldCountIn);
899
900 std::vector<int> ComputeMapForSetFrom(const OGRFeatureDefn *poSrcFDefn,
901 bool bForgiving = true) const;
902
903 static OGRFeatureDefn *CreateFeatureDefn(const char *pszName = nullptr);
904 static void DestroyFeatureDefn(OGRFeatureDefn *);
905
908 static inline OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
909 {
910 return reinterpret_cast<OGRFeatureDefnH>(poFeatureDefn);
911 }
912
915 static inline OGRFeatureDefn *FromHandle(OGRFeatureDefnH hFeatureDefn)
916 {
917 return reinterpret_cast<OGRFeatureDefn *>(hFeatureDefn);
918 }
919
920 void Seal(bool bSealFields);
921
922 void Unseal(bool bUnsealFields);
923
925 struct CPL_DLL TemporaryUnsealer
926 {
927 private:
928 OGRFeatureDefn *m_poFeatureDefn = nullptr;
929 bool m_bSealFields = false;
930 CPL_DISALLOW_COPY_ASSIGN(TemporaryUnsealer)
931 public:
932 explicit TemporaryUnsealer(OGRFeatureDefn *poFeatureDefn,
933 bool bSealFields);
934
935 TemporaryUnsealer(TemporaryUnsealer &&) = default;
936 TemporaryUnsealer &operator=(TemporaryUnsealer &&) = default;
937
938 ~TemporaryUnsealer();
939
940 OGRFeatureDefn *operator->()
941 {
942 return m_poFeatureDefn;
943 }
944 };
945
948 TemporaryUnsealer GetTemporaryUnsealer(bool bSealFields = true);
949
950 private:
952};
953
956#include "ogr_refcountedptr.h"
957
958template <>
959struct OGRRefCountedPtr<OGRFeatureDefn>
960 : public OGRRefCountedPtrBase<OGRFeatureDefn>
961{
964 inline explicit OGRRefCountedPtr(OGRFeatureDefn *poFDefn = nullptr,
965 bool add_ref = true)
966 : OGRRefCountedPtrBase<OGRFeatureDefn>(poFDefn, add_ref)
967 {
968 }
969
972 inline explicit OGRRefCountedPtr(std::nullptr_t)
973 {
974 }
975
978 inline static OGRRefCountedPtr makeInstance(const char *pszName)
979 {
980 // Initial ref_count of OGRFeatureDefn is 0, so do add a ref
981 return OGRRefCountedPtr(new OGRFeatureDefn(pszName),
982 /* add_ref = */ true);
983 }
984};
985
993using OGRFeatureDefnRefCountedPtr = OGRRefCountedPtr<OGRFeatureDefn>;
994
997#ifdef GDAL_COMPILATION
1018inline OGRFeatureDefn::TemporaryUnsealer whileUnsealing(OGRFeatureDefn *object,
1019 bool bSealFields = true)
1020{
1021 return object->GetTemporaryUnsealer(bSealFields);
1022}
1023
1024inline OGRFeatureDefn::TemporaryUnsealer
1025whileUnsealing(OGRFeatureDefnRefCountedPtr &object, bool bSealFields = true)
1026{
1027 return object->GetTemporaryUnsealer(bSealFields);
1028}
1029
1030#endif
1031
1032/************************************************************************/
1033/* OGRFeature */
1034/************************************************************************/
1035
1040class CPL_DLL OGRFeature
1041{
1042 private:
1043 GIntBig nFID;
1044 const OGRFeatureDefn *poDefn;
1045 OGRGeometry **papoGeometries;
1046 OGRField *pauFields;
1047 char *m_pszNativeData;
1048 char *m_pszNativeMediaType;
1049
1050 bool SetFieldInternal(int i, const OGRField *puValue);
1051
1052 protected:
1054 mutable char *m_pszStyleString;
1055 mutable OGRStyleTable *m_poStyleTable;
1056 mutable char *m_pszTmpFieldValue;
1058
1059 bool CopySelfTo(OGRFeature *poNew) const;
1060
1061 public:
1062 explicit OGRFeature(const OGRFeatureDefn *);
1063 virtual ~OGRFeature();
1064
1066 class CPL_DLL FieldValue
1067 {
1068 friend class OGRFeature;
1069 struct Private;
1070 std::unique_ptr<Private> m_poPrivate;
1071
1072 FieldValue(OGRFeature *poFeature, int iFieldIndex);
1073 FieldValue(const OGRFeature *poFeature, int iFieldIndex);
1074 FieldValue(const FieldValue &oOther) = delete;
1075 FieldValue &Assign(const FieldValue &oOther);
1076
1077 public:
1079 ~FieldValue();
1080
1081 FieldValue &operator=(FieldValue &&oOther);
1083
1085 FieldValue &operator=(const FieldValue &oOther);
1087 FieldValue &operator=(int nVal);
1089 FieldValue &operator=(GIntBig nVal);
1091 FieldValue &operator=(double dfVal);
1093 FieldValue &operator=(const char *pszVal);
1095 FieldValue &operator=(const std::string &osVal);
1097 FieldValue &operator=(const std::vector<int> &oArray);
1099 FieldValue &operator=(const std::vector<GIntBig> &oArray);
1101 FieldValue &operator=(const std::vector<double> &oArray);
1103 FieldValue &operator=(const std::vector<std::string> &oArray);
1105 FieldValue &operator=(CSLConstList papszValues);
1107 void SetNull();
1109 void clear();
1110
1112 void Unset()
1113 {
1114 clear();
1115 }
1116
1118 void SetDateTime(int nYear, int nMonth, int nDay, int nHour = 0,
1119 int nMinute = 0, float fSecond = 0.f, int nTZFlag = 0);
1120
1122 int GetIndex() const;
1124 const OGRFieldDefn *GetDefn() const;
1125
1127 const char *GetName() const
1128 {
1129 return GetDefn()->GetNameRef();
1130 }
1131
1134 {
1135 return GetDefn()->GetType();
1136 }
1137
1140 {
1141 return GetDefn()->GetSubType();
1142 }
1143
1145 // cppcheck-suppress functionStatic
1146 bool empty() const
1147 {
1148 return IsUnset();
1149 }
1150
1152 // cppcheck-suppress functionStatic
1153 bool IsUnset() const;
1154
1156 // cppcheck-suppress functionStatic
1157 bool IsNull() const;
1158
1160 const OGRField *GetRawValue() const;
1161
1165 // cppcheck-suppress functionStatic
1166 int GetInteger() const
1167 {
1168 return GetRawValue()->Integer;
1169 }
1170
1174 // cppcheck-suppress functionStatic
1176 {
1177 return GetRawValue()->Integer64;
1178 }
1179
1183 // cppcheck-suppress functionStatic
1184 double GetDouble() const
1185 {
1186 return GetRawValue()->Real;
1187 }
1188
1192 // cppcheck-suppress functionStatic
1193 const char *GetString() const
1194 {
1195 return GetRawValue()->String;
1196 }
1197
1199 bool GetDateTime(int *pnYear, int *pnMonth, int *pnDay, int *pnHour,
1200 int *pnMinute, float *pfSecond, int *pnTZFlag) const;
1201
1203 operator int() const
1204 {
1205 return GetAsInteger();
1206 }
1207
1210 operator GIntBig() const
1211 {
1212 return GetAsInteger64();
1213 }
1214
1216 operator double() const
1217 {
1218 return GetAsDouble();
1219 }
1220
1222 operator const char *() const
1223 {
1224 return GetAsString();
1225 }
1226
1228 operator const std::vector<int> &() const
1229 {
1230 return GetAsIntegerList();
1231 }
1232
1235 operator const std::vector<GIntBig> &() const
1236 {
1237 return GetAsInteger64List();
1238 }
1239
1241 operator const std::vector<double> &() const
1242 {
1243 return GetAsDoubleList();
1244 }
1245
1247 operator const std::vector<std::string> &() const
1248 {
1249 return GetAsStringList();
1250 }
1251
1253 operator CSLConstList() const;
1254
1256 int GetAsInteger() const;
1259 GIntBig GetAsInteger64() const;
1261 double GetAsDouble() const;
1263 const char *GetAsString() const;
1265 const std::vector<int> &GetAsIntegerList() const;
1268 const std::vector<GIntBig> &GetAsInteger64List() const;
1270 const std::vector<double> &GetAsDoubleList() const;
1272 const std::vector<std::string> &GetAsStringList() const;
1273 };
1274
1277 {
1278 friend class OGRFeature;
1279 struct Private;
1280 std::unique_ptr<Private> m_poPrivate;
1281
1282 ConstFieldIterator(const OGRFeature *poSelf, int nPos);
1283
1284 public:
1287 ConstFieldIterator &&oOther) noexcept; // declared but not defined.
1288 // Needed for gcc 5.4 at least
1290 const FieldValue &operator*() const;
1291 ConstFieldIterator &operator++();
1292 bool operator!=(const ConstFieldIterator &it) const;
1294 };
1295
1312 ConstFieldIterator begin() const;
1314 ConstFieldIterator end() const;
1315
1316 const FieldValue operator[](int iField) const;
1317 FieldValue operator[](int iField);
1318
1319#if defined(__clang__)
1320#pragma clang diagnostic push
1321#pragma clang diagnostic ignored "-Wweak-vtables"
1322#endif
1323
1326 class FieldNotFoundException final : public std::exception
1327 {
1328 };
1329
1330#if defined(__clang__)
1331#pragma clang diagnostic pop
1332#endif
1333
1334 const FieldValue operator[](const char *pszFieldName) const;
1335 FieldValue operator[](const char *pszFieldName);
1336
1338 {
1339 return poDefn;
1340 }
1341
1343 void SetFDefnUnsafe(OGRFeatureDefn *poNewFDefn);
1345
1346 OGRErr SetGeometryDirectly(OGRGeometry *);
1347 OGRErr SetGeometry(const OGRGeometry *);
1348 OGRErr SetGeometry(std::unique_ptr<OGRGeometry>);
1349 OGRGeometry *GetGeometryRef();
1350 const OGRGeometry *GetGeometryRef() const;
1351 OGRGeometry *StealGeometry() CPL_WARN_UNUSED_RESULT;
1352
1353 int GetGeomFieldCount() const
1354 {
1355 return poDefn->GetGeomFieldCount();
1356 }
1357
1358 const OGRGeomFieldDefn *GetGeomFieldDefnRef(int iField) const
1359 {
1360 return poDefn->GetGeomFieldDefn(iField);
1361 }
1362
1363 int GetGeomFieldIndex(const char *pszName) const
1364 {
1365 return poDefn->GetGeomFieldIndex(pszName);
1366 }
1367
1368 OGRGeometry *GetGeomFieldRef(int iField);
1369 const OGRGeometry *GetGeomFieldRef(int iField) const;
1370 OGRGeometry *StealGeometry(int iField);
1371 OGRGeometry *GetGeomFieldRef(const char *pszFName);
1372 const OGRGeometry *GetGeomFieldRef(const char *pszFName) const;
1373 OGRErr SetGeomFieldDirectly(int iField, OGRGeometry *);
1374 OGRErr SetGeomField(int iField, const OGRGeometry *);
1375 OGRErr SetGeomField(int iField, std::unique_ptr<OGRGeometry>);
1376
1377 void Reset();
1378
1379 OGRFeature *Clone() const CPL_WARN_UNUSED_RESULT;
1380 virtual OGRBoolean Equal(const OGRFeature *poFeature) const;
1381
1382 int GetFieldCount() const
1383 {
1384 return poDefn->GetFieldCount();
1385 }
1386
1387 const OGRFieldDefn *GetFieldDefnRef(int iField) const
1388 {
1389 return poDefn->GetFieldDefn(iField);
1390 }
1391
1392 int GetFieldIndex(const char *pszName) const
1393 {
1394 return poDefn->GetFieldIndex(pszName);
1395 }
1396
1397 int IsFieldSet(int iField) const;
1398
1399 void UnsetField(int iField);
1400
1401 bool IsFieldNull(int iField) const;
1402
1403 void SetFieldNull(int iField);
1404
1405 bool IsFieldSetAndNotNull(int iField) const;
1406
1408 {
1409 return pauFields + i;
1410 }
1411
1412 const OGRField *GetRawFieldRef(int i) const
1413 {
1414 return pauFields + i;
1415 }
1416
1417 int GetFieldAsInteger(int i) const;
1418 GIntBig GetFieldAsInteger64(int i) const;
1419 double GetFieldAsDouble(int i) const;
1420 const char *GetFieldAsString(int i) const;
1421 const char *GetFieldAsISO8601DateTime(int i,
1422 CSLConstList papszOptions) const;
1423 const int *GetFieldAsIntegerList(int i, int *pnCount) const;
1424 const GIntBig *GetFieldAsInteger64List(int i, int *pnCount) const;
1425 const double *GetFieldAsDoubleList(int i, int *pnCount) const;
1426 char **GetFieldAsStringList(int i) const;
1427 GByte *GetFieldAsBinary(int i, int *pnCount) const;
1428 int GetFieldAsDateTime(int i, int *pnYear, int *pnMonth, int *pnDay,
1429 int *pnHour, int *pnMinute, int *pnSecond,
1430 int *pnTZFlag) const;
1431 int GetFieldAsDateTime(int i, int *pnYear, int *pnMonth, int *pnDay,
1432 int *pnHour, int *pnMinute, float *pfSecond,
1433 int *pnTZFlag) const;
1434 char *GetFieldAsSerializedJSon(int i) const;
1435
1437 bool IsFieldSetUnsafe(int i) const
1438 {
1439 return !(pauFields[i].Set.nMarker1 == OGRUnsetMarker &&
1440 pauFields[i].Set.nMarker2 == OGRUnsetMarker &&
1441 pauFields[i].Set.nMarker3 == OGRUnsetMarker);
1442 }
1443
1444 bool IsFieldNullUnsafe(int i) const
1445 {
1446 return (pauFields[i].Set.nMarker1 == OGRNullMarker &&
1447 pauFields[i].Set.nMarker2 == OGRNullMarker &&
1448 pauFields[i].Set.nMarker3 == OGRNullMarker);
1449 }
1450
1451 bool IsFieldSetAndNotNullUnsafe(int i) const
1452 {
1453 return IsFieldSetUnsafe(i) && !IsFieldNullUnsafe(i);
1454 }
1455
1456 // Those methods should only be called on a field that is of the type
1457 // consistent with the value, and that is set.
1458 int GetFieldAsIntegerUnsafe(int i) const
1459 {
1460 return pauFields[i].Integer;
1461 }
1462
1463 GIntBig GetFieldAsInteger64Unsafe(int i) const
1464 {
1465 return pauFields[i].Integer64;
1466 }
1467
1468 double GetFieldAsDoubleUnsafe(int i) const
1469 {
1470 return pauFields[i].Real;
1471 }
1472
1473 const char *GetFieldAsStringUnsafe(int i) const
1474 {
1475 return pauFields[i].String;
1476 }
1477
1479
1480 int GetFieldAsInteger(const char *pszFName) const
1481 {
1482 return GetFieldAsInteger(GetFieldIndex(pszFName));
1483 }
1484
1485 GIntBig GetFieldAsInteger64(const char *pszFName) const
1486 {
1487 return GetFieldAsInteger64(GetFieldIndex(pszFName));
1488 }
1489
1490 double GetFieldAsDouble(const char *pszFName) const
1491 {
1492 return GetFieldAsDouble(GetFieldIndex(pszFName));
1493 }
1494
1495 const char *GetFieldAsString(const char *pszFName) const
1496 {
1497 return GetFieldAsString(GetFieldIndex(pszFName));
1498 }
1499
1500 const char *GetFieldAsISO8601DateTime(const char *pszFName,
1501 CSLConstList papszOptions) const
1502 {
1503 return GetFieldAsISO8601DateTime(GetFieldIndex(pszFName), papszOptions);
1504 }
1505
1506 const int *GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
1507 {
1508 return GetFieldAsIntegerList(GetFieldIndex(pszFName), pnCount);
1509 }
1510
1511 const GIntBig *GetFieldAsInteger64List(const char *pszFName,
1512 int *pnCount) const
1513 {
1514 return GetFieldAsInteger64List(GetFieldIndex(pszFName), pnCount);
1515 }
1516
1517 const double *GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
1518 {
1519 return GetFieldAsDoubleList(GetFieldIndex(pszFName), pnCount);
1520 }
1521
1522 char **GetFieldAsStringList(const char *pszFName) const
1523 {
1524 return GetFieldAsStringList(GetFieldIndex(pszFName));
1525 }
1526
1527 void SetField(int i, int nValue);
1528 void SetField(int i, GIntBig nValue);
1529 void SetField(int i, double dfValue);
1530 void SetField(int i, const char *pszValue);
1531#if defined(DOXYGEN_SKIP) || __cplusplus >= 201703L || \
1532 (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
1533 void SetField(int i, std::string_view svValue);
1534
1536 inline void SetField(int i, const std::string &osValue)
1537 {
1538 SetField(i, osValue.c_str());
1539 }
1540
1542#endif
1543 void SetField(int i, int nCount, const int *panValues);
1544 void SetField(int i, int nCount, const GIntBig *panValues);
1545 void SetField(int i, int nCount, const double *padfValues);
1546 void SetField(int i, const char *const *papszValues);
1547 void SetField(int i, const OGRField *puValue);
1548 void SetField(int i, int nCount, const void *pabyBinary);
1549 void SetField(int i, int nYear, int nMonth, int nDay, int nHour = 0,
1550 int nMinute = 0, float fSecond = 0.f, int nTZFlag = 0);
1551
1553 // Those methods should only be called on a field that is of the type
1554 // consistent with the value, and in a unset state.
1555 void SetFieldSameTypeUnsafe(int i, int nValue)
1556 {
1557 pauFields[i].Integer = nValue;
1558 pauFields[i].Set.nMarker2 = 0;
1559 pauFields[i].Set.nMarker3 = 0;
1560 }
1561
1562 void SetFieldSameTypeUnsafe(int i, GIntBig nValue)
1563 {
1564 pauFields[i].Integer64 = nValue;
1565 }
1566
1567 void SetFieldSameTypeUnsafe(int i, double dfValue)
1568 {
1569 pauFields[i].Real = dfValue;
1570 }
1571
1572 void SetFieldSameTypeUnsafe(int i, char *pszValueTransferred)
1573 {
1574 pauFields[i].String = pszValueTransferred;
1575 }
1576
1578
1579 void SetField(const char *pszFName, int nValue)
1580 {
1581 SetField(GetFieldIndex(pszFName), nValue);
1582 }
1583
1584 void SetField(const char *pszFName, GIntBig nValue)
1585 {
1586 SetField(GetFieldIndex(pszFName), nValue);
1587 }
1588
1589 void SetField(const char *pszFName, double dfValue)
1590 {
1591 SetField(GetFieldIndex(pszFName), dfValue);
1592 }
1593
1594 void SetField(const char *pszFName, const char *pszValue)
1595 {
1596 SetField(GetFieldIndex(pszFName), pszValue);
1597 }
1598
1599 void SetField(const char *pszFName, int nCount, const int *panValues)
1600 {
1601 SetField(GetFieldIndex(pszFName), nCount, panValues);
1602 }
1603
1604 void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
1605 {
1606 SetField(GetFieldIndex(pszFName), nCount, panValues);
1607 }
1608
1609 void SetField(const char *pszFName, int nCount, const double *padfValues)
1610 {
1611 SetField(GetFieldIndex(pszFName), nCount, padfValues);
1612 }
1613
1614 void SetField(const char *pszFName, const char *const *papszValues)
1615 {
1616 SetField(GetFieldIndex(pszFName), papszValues);
1617 }
1618
1619 void SetField(const char *pszFName, const OGRField *puValue)
1620 {
1621 SetField(GetFieldIndex(pszFName), puValue);
1622 }
1623
1624 void SetField(const char *pszFName, int nYear, int nMonth, int nDay,
1625 int nHour = 0, int nMinute = 0, float fSecond = 0.f,
1626 int nTZFlag = 0)
1627 {
1628 SetField(GetFieldIndex(pszFName), nYear, nMonth, nDay, nHour, nMinute,
1629 fSecond, nTZFlag);
1630 }
1631
1633 {
1634 return nFID;
1635 }
1636
1637 virtual OGRErr SetFID(GIntBig nFIDIn);
1638
1639 void DumpReadable(FILE *, CSLConstList papszOptions = nullptr) const;
1640 std::string DumpReadableAsString(CSLConstList papszOptions = nullptr) const;
1641
1642 OGRErr SetFrom(const OGRFeature *, int bForgiving = TRUE);
1643 OGRErr SetFrom(const OGRFeature *, const int *panMap, int bForgiving = TRUE,
1644 bool bUseISO8601ForDateTimeAsString = false);
1645 OGRErr SetFieldsFrom(const OGRFeature *, const int *panMap,
1646 int bForgiving = TRUE,
1647 bool bUseISO8601ForDateTimeAsString = false);
1648
1650 OGRErr RemapFields(const OGRFeatureDefn *poNewDefn,
1651 const int *panRemapSource);
1652 void AppendField();
1653 OGRErr RemapGeomFields(const OGRFeatureDefn *poNewDefn,
1654 const int *panRemapSource);
1656
1657 int Validate(int nValidateFlags, int bEmitError) const;
1658 void FillUnsetWithDefault(int bNotNullableOnly, CSLConstList papszOptions);
1659
1660 bool SerializeToBinary(std::vector<GByte> &abyBuffer) const;
1661 bool DeserializeFromBinary(const GByte *pabyBuffer, size_t nSize);
1662
1663 virtual const char *GetStyleString() const;
1664 virtual void SetStyleString(const char *);
1665 virtual void SetStyleStringDirectly(char *);
1666
1671 {
1672 return m_poStyleTable;
1673 } /* f.i.x.m.e: add a const qualifier for return type */
1674
1675 virtual void SetStyleTable(OGRStyleTable *poStyleTable);
1676 virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable);
1677
1678 const char *GetNativeData() const
1679 {
1680 return m_pszNativeData;
1681 }
1682
1683 const char *GetNativeMediaType() const
1684 {
1685 return m_pszNativeMediaType;
1686 }
1687
1688 void SetNativeData(const char *pszNativeData);
1689 void SetNativeMediaType(const char *pszNativeMediaType);
1690
1691 static OGRFeature *CreateFeature(const OGRFeatureDefn *);
1692 static void DestroyFeature(OGRFeature *);
1693
1696 static inline OGRFeatureH ToHandle(OGRFeature *poFeature)
1697 {
1698 return reinterpret_cast<OGRFeatureH>(poFeature);
1699 }
1700
1703 static inline OGRFeature *FromHandle(OGRFeatureH hFeature)
1704 {
1705 return reinterpret_cast<OGRFeature *>(hFeature);
1706 }
1707
1708 private:
1710};
1711
1713struct CPL_DLL OGRFeatureUniquePtrDeleter
1714{
1715 void operator()(OGRFeature *) const;
1716};
1717
1719
1722typedef std::unique_ptr<OGRFeature, OGRFeatureUniquePtrDeleter>
1724
1726
1727inline OGRFeature::ConstFieldIterator begin(const OGRFeature *poFeature)
1728{
1729 return poFeature->begin();
1730}
1731
1733inline OGRFeature::ConstFieldIterator end(const OGRFeature *poFeature)
1734{
1735 return poFeature->end();
1736}
1737
1740begin(const OGRFeatureUniquePtr &poFeature)
1741{
1742 return poFeature->begin();
1743}
1744
1747{
1748 return poFeature->end();
1749}
1750
1752
1753/************************************************************************/
1754/* OGRFieldDomain */
1755/************************************************************************/
1756
1757/* clang-format off */
1777/* clang-format on */
1778
1779class CPL_DLL OGRFieldDomain
1780{
1781 protected:
1783 std::string m_osName;
1784 std::string m_osDescription;
1785 OGRFieldDomainType m_eDomainType;
1786 OGRFieldType m_eFieldType;
1787 OGRFieldSubType m_eFieldSubType;
1790
1791 OGRFieldDomain(const std::string &osName, const std::string &osDescription,
1792 OGRFieldDomainType eDomainType, OGRFieldType eFieldType,
1793 OGRFieldSubType eFieldSubType);
1796 public:
1802
1807 virtual OGRFieldDomain *Clone() const = 0;
1808
1813 const std::string &GetName() const
1814 {
1815 return m_osName;
1816 }
1817
1823 const std::string &GetDescription() const
1824 {
1825 return m_osDescription;
1826 }
1827
1833 {
1834 return m_eDomainType;
1835 }
1836
1842 {
1843 return m_eFieldType;
1844 }
1845
1851 {
1852 return m_eFieldSubType;
1853 }
1854
1856 static inline OGRFieldDomainH ToHandle(OGRFieldDomain *poFieldDomain)
1857 {
1858 return reinterpret_cast<OGRFieldDomainH>(poFieldDomain);
1859 }
1860
1862 static inline OGRFieldDomain *FromHandle(OGRFieldDomainH hFieldDomain)
1863 {
1864 return reinterpret_cast<OGRFieldDomain *>(hFieldDomain);
1865 }
1866
1872 {
1873 return m_eSplitPolicy;
1874 }
1875
1881 {
1882 m_eSplitPolicy = policy;
1883 }
1884
1890 {
1891 return m_eMergePolicy;
1892 }
1893
1899 {
1900 m_eMergePolicy = policy;
1901 }
1902};
1903
1910class CPL_DLL OGRCodedFieldDomain final : public OGRFieldDomain
1911{
1912 private:
1913 std::vector<OGRCodedValue> m_asValues{};
1914
1915 OGRCodedFieldDomain(const OGRCodedFieldDomain &) = delete;
1916 OGRCodedFieldDomain &operator=(const OGRCodedFieldDomain &) = delete;
1917
1918 public:
1934 OGRCodedFieldDomain(const std::string &osName,
1935 const std::string &osDescription,
1936 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1937 std::vector<OGRCodedValue> &&asValues);
1938
1939 ~OGRCodedFieldDomain() override;
1940
1941 OGRCodedFieldDomain *Clone() const override;
1942
1949 {
1950 return m_asValues.data();
1951 }
1952};
1953
1956class CPL_DLL OGRRangeFieldDomain final : public OGRFieldDomain
1957{
1958 private:
1959 OGRField m_sMin;
1960 OGRField m_sMax;
1961 bool m_bMinIsInclusive;
1962 bool m_bMaxIsInclusive;
1963
1964 OGRRangeFieldDomain(const OGRRangeFieldDomain &) = delete;
1965 OGRRangeFieldDomain &operator=(const OGRRangeFieldDomain &) = delete;
1966
1967 public:
1995 OGRRangeFieldDomain(const std::string &osName,
1996 const std::string &osDescription,
1997 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1998 const OGRField &sMin, bool bMinIsInclusive,
1999 const OGRField &sMax, bool bMaxIsInclusive);
2000
2001 OGRRangeFieldDomain *Clone() const override;
2002
2016 const OGRField &GetMin(bool &bIsInclusiveOut) const
2017 {
2018 bIsInclusiveOut = m_bMinIsInclusive;
2019 return m_sMin;
2020 }
2021
2035 const OGRField &GetMax(bool &bIsInclusiveOut) const
2036 {
2037 bIsInclusiveOut = m_bMaxIsInclusive;
2038 return m_sMax;
2039 }
2040};
2041
2046class CPL_DLL OGRGlobFieldDomain final : public OGRFieldDomain
2047{
2048 private:
2049 std::string m_osGlob;
2050
2051 OGRGlobFieldDomain(const OGRGlobFieldDomain &) = delete;
2052 OGRGlobFieldDomain &operator=(const OGRGlobFieldDomain &) = delete;
2053
2054 public:
2065 OGRGlobFieldDomain(const std::string &osName,
2066 const std::string &osDescription,
2067 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
2068 const std::string &osBlob);
2069
2070 OGRGlobFieldDomain *Clone() const override;
2071
2076 const std::string &GetGlob() const
2077 {
2078 return m_osGlob;
2079 }
2080};
2081
2082/************************************************************************/
2083/* OGRFeatureQuery */
2084/************************************************************************/
2085
2087class OGRLayer;
2088class swq_expr_node;
2089class swq_custom_func_registrar;
2090struct swq_evaluation_context;
2091
2092class CPL_DLL OGRFeatureQuery
2093{
2094 private:
2095 const OGRFeatureDefn *poTargetDefn;
2096 void *pSWQExpr;
2097 swq_evaluation_context *m_psContext = nullptr;
2098
2099 char **FieldCollector(void *, char **);
2100
2101 static GIntBig *EvaluateAgainstIndices(const swq_expr_node *, OGRLayer *,
2102 GIntBig &nFIDCount);
2103
2104 static int CanUseIndex(const swq_expr_node *, OGRLayer *);
2105
2106 OGRErr Compile(const OGRLayer *, const OGRFeatureDefn *, const char *,
2107 int bCheck,
2108 swq_custom_func_registrar *poCustomFuncRegistrar);
2109
2110 CPL_DISALLOW_COPY_ASSIGN(OGRFeatureQuery)
2111
2112 public:
2113 OGRFeatureQuery();
2114 ~OGRFeatureQuery();
2115
2116 OGRErr Compile(const OGRLayer *, const char *, int bCheck = TRUE,
2117 swq_custom_func_registrar *poCustomFuncRegistrar = nullptr);
2118 OGRErr Compile(const OGRFeatureDefn *, const char *, int bCheck = TRUE,
2119 swq_custom_func_registrar *poCustomFuncRegistrar = nullptr);
2120 int Evaluate(OGRFeature *);
2121
2122 GIntBig *EvaluateAgainstIndices(OGRLayer *, OGRErr *);
2123
2124 int CanUseIndex(OGRLayer *);
2125
2126 char **GetUsedFields();
2127
2128 void *GetSWQExpr()
2129 {
2130 return pSWQExpr;
2131 }
2132};
2133
2135
2136#endif /* ndef OGR_FEATURE_H_INCLUDED */
Definition of a coded / enumerated field domain.
Definition ogr_feature.h:1911
const OGRCodedValue * GetEnumeration() const
Get the enumeration as (code, value) pairs.
Definition ogr_feature.h:1948
Definition of a feature class or feature layer.
Definition ogr_feature.h:521
int Reference()
Increments the reference count by one.
Definition ogr_feature.h:860
ConstFields GetFields() const
Return an object that can be used to iterate over non-geometry fields.
Definition ogr_feature.h:663
ConstGeomFields GetGeomFields() const
Return an object that can be used to iterate over geometry fields.
Definition ogr_feature.h:824
virtual int GetFieldCount() const
Fetch number of fields on this feature.
Definition ogrfeaturedefn.cpp:268
virtual OGRFieldDefn * GetFieldDefn(int i)
Fetch field definition.
Definition ogrfeaturedefn.cpp:312
NonConstGeomFields GetGeomFields()
Return an object that can be used to iterate over geometry fields.
Definition ogr_feature.h:805
virtual bool IsStyleIgnored() const
Determine whether the style can be omitted when fetching features.
Definition ogr_feature.h:884
int Dereference()
Decrements the reference count by one.
Definition ogr_feature.h:865
static OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
Convert a OGRFeatureDefn* to a OGRFeatureDefnH.
Definition ogr_feature.h:908
Fields< OGRFeatureDefn *, OGRFieldDefn * > NonConstFields
Return type of GetFields()
Definition ogr_feature.h:633
static OGRFeatureDefn * FromHandle(OGRFeatureDefnH hFeatureDefn)
Convert a OGRFeatureDefnH to a OGRFeatureDefn*.
Definition ogr_feature.h:915
GeomFields< OGRFeatureDefn *, OGRGeomFieldDefn * > NonConstGeomFields
Return type of GetGeomFields()
Definition ogr_feature.h:793
virtual OGRGeomFieldDefn * GetGeomFieldDefn(int i)
Fetch geometry field definition.
Definition ogrfeaturedefn.cpp:713
Fields< const OGRFeatureDefn *, const OGRFieldDefn * > ConstFields
Return type of GetFields() const.
Definition ogr_feature.h:651
virtual int GetGeomFieldCount() const
Fetch number of geometry fields on this feature.
Definition ogrfeaturedefn.cpp:666
GeomFields< const OGRFeatureDefn *, const OGRGeomFieldDefn * > ConstGeomFields
Return type of GetGeomFields() const.
Definition ogr_feature.h:812
virtual int GetFieldIndex(const char *) const
Find field by name.
Definition ogrfeaturedefn.cpp:1279
int GetReferenceCount() const
Fetch current reference count.
Definition ogr_feature.h:873
virtual int GetGeomFieldIndex(const char *) const
Find geometry field by name.
Definition ogrfeaturedefn.cpp:957
virtual void SetStyleIgnored(bool bIgnore)
Set whether the style can be omitted when fetching features.
Definition ogr_feature.h:889
NonConstFields GetFields()
Return an object that can be used to iterate over non-geometry fields.
Definition ogr_feature.h:645
Field value iterator class.
Definition ogr_feature.h:1277
Exception raised by operator[](const char*) when a field is not found.
Definition ogr_feature.h:1327
Field value.
Definition ogr_feature.h:1067
bool empty() const
Return whether the field value is unset/empty.
Definition ogr_feature.h:1146
int GetInteger() const
Return the integer value.
Definition ogr_feature.h:1166
OGRFieldType GetType() const
Return field type.
Definition ogr_feature.h:1133
void Unset()
Unset the field.
Definition ogr_feature.h:1112
double GetDouble() const
Return the double value.
Definition ogr_feature.h:1184
const char * GetName() const
Return field name.
Definition ogr_feature.h:1127
GIntBig GetInteger64() const
Return the 64-bit integer value.
Definition ogr_feature.h:1175
OGRFieldSubType GetSubType() const
Return field subtype.
Definition ogr_feature.h:1139
const char * GetString() const
Return the string value.
Definition ogr_feature.h:1193
A simple feature, including geometry and attributes.
Definition ogr_feature.h:1041
const char * GetFieldAsISO8601DateTime(const char *pszFName, CSLConstList papszOptions) const
Fetch OFTDateTime field value as a ISO8601 representation.
Definition ogr_feature.h:1500
static OGRFeatureH ToHandle(OGRFeature *poFeature)
Convert a OGRFeature* to a OGRFeatureH.
Definition ogr_feature.h:1696
char ** GetFieldAsStringList(const char *pszFName) const
Fetch field value as a list of strings.
Definition ogr_feature.h:1522
ConstFieldIterator end() const
Return end of field value iterator.
Definition ogrfeature.cpp:8397
ConstFieldIterator begin() const
Return begin of field value iterator.
Definition ogrfeature.cpp:8392
void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
Set field to list of 64 bit integers value.
Definition ogr_feature.h:1604
const OGRFeatureDefn * GetDefnRef() const
Fetch feature definition.
Definition ogr_feature.h:1337
const double * GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
Fetch field value as a list of doubles.
Definition ogr_feature.h:1517
void SetField(const char *pszFName, int nCount, const int *panValues)
This method currently on has an effect of OFTIntegerList, OFTInteger64List and OFTRealList fields.
Definition ogr_feature.h:1599
void SetField(const char *pszFName, GIntBig nValue)
Set field to 64 bit integer value.
Definition ogr_feature.h:1584
void SetField(const char *pszFName, const char *pszValue)
Set field to string value.
Definition ogr_feature.h:1594
void SetField(const char *pszFName, int nValue)
Set field to integer value.
Definition ogr_feature.h:1579
const OGRFieldDefn * GetFieldDefnRef(int iField) const
Fetch definition for this field.
Definition ogr_feature.h:1387
void SetField(const char *pszFName, int nYear, int nMonth, int nDay, int nHour=0, int nMinute=0, float fSecond=0.f, int nTZFlag=0)
Set field to date.
Definition ogr_feature.h:1624
const OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField) const
Fetch definition for this geometry field.
Definition ogr_feature.h:1358
const char * GetNativeData() const
Returns the native data for the feature.
Definition ogr_feature.h:1678
int GetFieldIndex(const char *pszName) const
Fetch the field index given field name.
Definition ogr_feature.h:1392
int GetGeomFieldIndex(const char *pszName) const
Fetch the geometry field index given geometry field name.
Definition ogr_feature.h:1363
GIntBig GetFieldAsInteger64(const char *pszFName) const
Fetch field value as integer 64 bit.
Definition ogr_feature.h:1485
const int * GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
Fetch field value as a list of integers.
Definition ogr_feature.h:1506
void SetField(const char *pszFName, double dfValue)
Set field to double value.
Definition ogr_feature.h:1589
const char * GetFieldAsString(const char *pszFName) const
Fetch field value as a string.
Definition ogr_feature.h:1495
void SetField(const char *pszFName, const char *const *papszValues)
This method currently on has an effect of OFTStringList fields.
Definition ogr_feature.h:1614
const OGRField * GetRawFieldRef(int i) const
Fetch a pointer to the internal field value given the index.
Definition ogr_feature.h:1412
int GetFieldAsInteger(const char *pszFName) const
Fetch field value as integer.
Definition ogr_feature.h:1480
const char * GetNativeMediaType() const
Returns the native media type for the feature.
Definition ogr_feature.h:1683
void SetField(const char *pszFName, const OGRField *puValue)
Set field.
Definition ogr_feature.h:1619
GIntBig GetFID() const
Get feature identifier.
Definition ogr_feature.h:1632
OGRField * GetRawFieldRef(int i)
Fetch a pointer to the internal field value given the index.
Definition ogr_feature.h:1407
void SetField(const char *pszFName, int nCount, const double *padfValues)
This method currently on has an effect of OFTIntegerList, OFTInteger64List, OFTRealList fields.
Definition ogr_feature.h:1609
virtual OGRStyleTable * GetStyleTable() const
Return style table.
Definition ogr_feature.h:1670
double GetFieldAsDouble(const char *pszFName) const
Fetch field value as a double.
Definition ogr_feature.h:1490
static OGRFeature * FromHandle(OGRFeatureH hFeature)
Convert a OGRFeatureH to a OGRFeature*.
Definition ogr_feature.h:1703
const GIntBig * GetFieldAsInteger64List(const char *pszFName, int *pnCount) const
Fetch field value as a list of 64 bit integers.
Definition ogr_feature.h:1511
Definition of an attribute of an OGRFeatureDefn.
Definition ogr_feature.h:72
const char * GetNameRef() const
Fetch name of this field.
Definition ogr_feature.h:111
void Unseal()
Unseal a OGRFieldDefn.
Definition ogrfielddefn.cpp:2297
int IsNullable() const
Return whether this field can receive null values.
Definition ogr_feature.h:189
void Seal()
Seal a OGRFieldDefn.
Definition ogrfielddefn.cpp:2278
int IsUnique() const
Return whether this field has a unique constraint.
Definition ogr_feature.h:196
OGRFieldSubType GetSubType() const
Fetch subtype of this field.
Definition ogr_feature.h:132
bool IsGenerated() const
Return whether the field is a generated field.
Definition ogr_feature.h:209
OGRJustification GetJustify() const
Get the justification for this field.
Definition ogr_feature.h:141
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition ogr_feature.h:184
int GetPrecision() const
Get the formatting precision for this field.
Definition ogr_feature.h:158
OGRFieldType GetType() const
Fetch type of this field.
Definition ogr_feature.h:123
int GetWidth() const
Get the formatting width for this field.
Definition ogr_feature.h:151
const std::string & GetComment() const
Return the (optional) comment for this field.
Definition ogr_feature.h:233
int GetTZFlag() const
Get the time zone flag.
Definition ogr_feature.h:165
void SetGenerated(bool bGeneratedIn)
SetGenerated set the field generated status.
Definition ogr_feature.h:219
void SetJustify(OGRJustification eJustifyIn)
Set the justification for this field.
Definition ogr_feature.h:146
const char * GetAlternativeNameRef() const
Fetch the alternative name (or "alias") for this field.
Definition ogr_feature.h:118
static OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
Convert a OGRFieldDefn* to a OGRFieldDefnH.
Definition ogr_feature.h:244
const std::string & GetDomainName() const
Return the name of the field domain for this field.
Definition ogr_feature.h:226
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition ogr_feature.h:179
static OGRFieldDefn * FromHandle(OGRFieldDefnH hFieldDefn)
Convert a OGRFieldDefnH to a OGRFieldDefn*.
Definition ogr_feature.h:251
Definition of a field domain.
Definition ogr_feature.h:1780
OGRFieldDomainMergePolicy GetMergePolicy() const
Get the merge policy.
Definition ogr_feature.h:1889
void SetMergePolicy(OGRFieldDomainMergePolicy policy)
Set the merge policy.
Definition ogr_feature.h:1898
static OGRFieldDomain * FromHandle(OGRFieldDomainH hFieldDomain)
Convert a OGRFieldDomainH to a OGRFieldDomain*.
Definition ogr_feature.h:1862
virtual OGRFieldDomain * Clone() const =0
Clone.
OGRFieldSubType GetFieldSubType() const
Get the field subtype.
Definition ogr_feature.h:1850
const std::string & GetName() const
Get the name of the field domain.
Definition ogr_feature.h:1813
const std::string & GetDescription() const
Get the description of the field domain.
Definition ogr_feature.h:1823
OGRFieldDomainSplitPolicy GetSplitPolicy() const
Get the split policy.
Definition ogr_feature.h:1871
static OGRFieldDomainH ToHandle(OGRFieldDomain *poFieldDomain)
Convert a OGRFieldDomain* to a OGRFieldDomainH.
Definition ogr_feature.h:1856
OGRFieldType GetFieldType() const
Get the field type.
Definition ogr_feature.h:1841
OGRFieldDomainType GetDomainType() const
Get the type of the field domain.
Definition ogr_feature.h:1832
void SetSplitPolicy(OGRFieldDomainSplitPolicy policy)
Set the split policy.
Definition ogr_feature.h:1880
virtual ~OGRFieldDomain()
Destructor.
Definition of a geometry field of an OGRFeatureDefn.
Definition ogr_feature.h:335
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition ogr_feature.h:391
void Seal()
Seal a OGRGeomFieldDefn.
Definition ogrgeomfielddefn.cpp:905
void Unseal()
Unseal a OGRGeomFieldDefn.
Definition ogrgeomfielddefn.cpp:924
static OGRGeomFieldDefn * FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
Convert a OGRGeomFieldDefnH to a OGRGeomFieldDefn*.
Definition ogr_feature.h:421
int IsNullable() const
Return whether this geometry field can receive null values.
Definition ogr_feature.h:396
OGRwkbGeometryType GetType() const
Fetch geometry type of this field.
Definition ogr_feature.h:375
const OGRGeomCoordinatePrecision & GetCoordinatePrecision() const
Return the coordinate precision associated to this geometry field.
Definition ogr_feature.h:403
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition ogr_feature.h:386
static OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
Convert a OGRGeomFieldDefn* to a OGRGeomFieldDefnH.
Definition ogr_feature.h:414
const char * GetNameRef() const
Fetch name of this field.
Definition ogr_feature.h:370
Abstract base class for all geometry classes.
Definition ogr_geometry.h:357
Definition of a field domain for field content validated by a glob.
Definition ogr_feature.h:2047
const std::string & GetGlob() const
Get the glob expression.
Definition ogr_feature.h:2076
This class represents a layer of simple features, with access methods.
Definition ogrsf_frmts.h:61
Definition of a numeric field domain with a range of validity for values.
Definition ogr_feature.h:1957
const OGRField & GetMax(bool &bIsInclusiveOut) const
Get the maximum value.
Definition ogr_feature.h:2035
const OGRField & GetMin(bool &bIsInclusiveOut) const
Get the minimum value.
Definition ogr_feature.h:2016
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:152
This class represents a style table.
Definition ogr_featurestyle.h:69
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition cpl_port.h:1101
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1252
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition cpl_port.h:1035
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:165
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:195
Forward definitions of GDAL/OGR/OSR C handle types.
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition gdal_fwd.h:122
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition gdal_fwd.h:124
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition gdal_fwd.h:141
struct OGRFieldDomainHS * OGRFieldDomainH
Opaque type for a field domain definition (OGRFieldDomain)
Definition gdal_fwd.h:131
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition gdal_fwd.h:128
#define OGRUnsetMarker
Special value set in OGRField.Set.nMarker1, nMarker2 and nMarker3 for a unset field.
Definition ogr_core.h:863
#define OGR_TZFLAG_UNKNOWN
Time zone flag indicating unknown timezone.
Definition ogr_core.h:876
int OGRBoolean
Type for a OGR boolean.
Definition ogr_core.h:404
OGRFieldSubType
List of field subtypes.
Definition ogr_core.h:817
OGRFieldDomainMergePolicy
Merge policy for field domains.
Definition ogr_core.h:1269
@ OFDMP_DEFAULT_VALUE
Default value.
Definition ogr_core.h:1271
OGRFieldDomainType
Type of field domain.
Definition ogr_core.h:1234
OGRJustification
Display justification for field values.
Definition ogr_core.h:841
OGRFieldType
List of feature field types.
Definition ogr_core.h:790
#define OGRNullMarker
Special value set in OGRField.Set.nMarker1, nMarker2 and nMarker3 for a null field.
Definition ogr_core.h:870
OGRwkbGeometryType
List of well known binary geometry types.
Definition ogr_core.h:423
@ wkbUnknown
unknown type, non-standard
Definition ogr_core.h:424
int OGRErr
Type for a OGR error.
Definition ogr_core.h:388
OGRFieldDomainSplitPolicy
Split policy for field domains.
Definition ogr_core.h:1251
@ OFDSP_DEFAULT_VALUE
Default value.
Definition ogr_core.h:1253
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition ogr_feature.h:1723
Simple feature style classes.
Geometry coordinate precision class.
Simple feature geometry classes.
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition ogrsf_frmts.h:478
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition ogrsf_frmts.h:486
Associates a code and a value.
Definition ogr_core.h:1221
Geometry coordinate precision.
Definition ogr_geomcoordinateprecision.h:40
OGRFeature field attribute value union.
Definition ogr_core.h:904