GDAL
ogr_feature.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id$
3  *
4  * Project: OpenGIS Simple Features Reference Implementation
5  * Purpose: Class for representing a whole feature, and layer schemas.
6  * Author: Frank Warmerdam, warmerdam@pobox.com
7  *
8  ******************************************************************************
9  * Copyright (c) 1999, Les Technologies SoftMap Inc.
10  * Copyright (c) 2008-2013, Even Rouault <even dot rouault at spatialys.com>
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a
13  * copy of this software and associated documentation files (the "Software"),
14  * to deal in the Software without restriction, including without limitation
15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  * and/or sell copies of the Software, and to permit persons to whom the
17  * Software is furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included
20  * in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28  * DEALINGS IN THE SOFTWARE.
29  ****************************************************************************/
30 
31 #ifndef OGR_FEATURE_H_INCLUDED
32 #define OGR_FEATURE_H_INCLUDED
33 
34 #include "cpl_atomic_ops.h"
35 #include "ogr_featurestyle.h"
36 #include "ogr_geometry.h"
37 
38 #include <cstddef>
39 
40 #include <exception>
41 #include <memory>
42 #include <string>
43 #include <vector>
44 
51 #ifndef DEFINE_OGRFeatureH
52 
53 #define DEFINE_OGRFeatureH
54 
55 #ifdef DEBUG
56 typedef struct OGRFieldDefnHS *OGRFieldDefnH;
57 typedef struct OGRFeatureDefnHS *OGRFeatureDefnH;
58 typedef struct OGRFeatureHS *OGRFeatureH;
59 typedef struct OGRStyleTableHS *OGRStyleTableH;
60 #else
61 
62 typedef void *OGRFieldDefnH;
64 typedef void *OGRFeatureDefnH;
66 typedef void *OGRFeatureH;
68 typedef void *OGRStyleTableH;
69 #endif
70 
71 typedef struct OGRGeomFieldDefnHS *OGRGeomFieldDefnH;
72 
74 typedef struct OGRFieldDomainHS *OGRFieldDomainH;
75 #endif /* DEFINE_OGRFeatureH */
76 
77 class OGRStyleTable;
78 
79 /************************************************************************/
80 /* OGRFieldDefn */
81 /************************************************************************/
82 
103 class CPL_DLL OGRFieldDefn
104 {
105  private:
106  char *pszName;
107  char *pszAlternativeName;
108  OGRFieldType eType;
109  OGRJustification eJustify;
110  int nWidth; // Zero is variable.
111  int nPrecision;
112  char *pszDefault;
113 
114  int bIgnore;
115  OGRFieldSubType eSubType;
116 
117  int bNullable;
118  int bUnique;
119 
120  std::string m_osDomainName{}; // field domain name. Might be empty
121 
122  std::string m_osComment{}; // field comment. Might be empty
123 
124  public:
125  OGRFieldDefn(const char *, OGRFieldType);
126  explicit OGRFieldDefn(const OGRFieldDefn *);
127  ~OGRFieldDefn();
128 
129  void SetName(const char *);
130  const char *GetNameRef() const
131  {
132  return pszName;
133  }
134 
135  void SetAlternativeName(const char *);
136  const char *GetAlternativeNameRef() const
137  {
138  return pszAlternativeName;
139  }
140 
142  {
143  return eType;
144  }
145  void SetType(OGRFieldType eTypeIn);
146  static const char *GetFieldTypeName(OGRFieldType);
147 
149  {
150  return eSubType;
151  }
152  void SetSubType(OGRFieldSubType eSubTypeIn);
153  static const char *GetFieldSubTypeName(OGRFieldSubType);
154 
156  {
157  return eJustify;
158  }
159  void SetJustify(OGRJustification eJustifyIn)
160  {
161  eJustify = eJustifyIn;
162  }
163 
164  int GetWidth() const
165  {
166  return nWidth;
167  }
168  void SetWidth(int nWidthIn)
169  {
170  nWidth = MAX(0, nWidthIn);
171  }
172 
173  int GetPrecision() const
174  {
175  return nPrecision;
176  }
177  void SetPrecision(int nPrecisionIn)
178  {
179  nPrecision = nPrecisionIn;
180  }
181 
182  void Set(const char *, OGRFieldType, int = 0, int = 0,
183  OGRJustification = OJUndefined);
184 
185  void SetDefault(const char *);
186  const char *GetDefault() const;
187  int IsDefaultDriverSpecific() const;
188 
189  int IsIgnored() const
190  {
191  return bIgnore;
192  }
193  void SetIgnored(int bIgnoreIn)
194  {
195  bIgnore = bIgnoreIn;
196  }
197 
198  int IsNullable() const
199  {
200  return bNullable;
201  }
202  void SetNullable(int bNullableIn)
203  {
204  bNullable = bNullableIn;
205  }
206 
207  int IsUnique() const
208  {
209  return bUnique;
210  }
211  void SetUnique(int bUniqueIn)
212  {
213  bUnique = bUniqueIn;
214  }
215 
216  const std::string &GetDomainName() const
217  {
218  return m_osDomainName;
219  }
220  void SetDomainName(const std::string &osDomainName)
221  {
222  m_osDomainName = osDomainName;
223  }
224 
225  const std::string &GetComment() const
226  {
227  return m_osComment;
228  }
229  void SetComment(const std::string &osComment)
230  {
231  m_osComment = osComment;
232  }
233 
234  int IsSame(const OGRFieldDefn *) const;
235 
239  static inline OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
240  {
241  return reinterpret_cast<OGRFieldDefnH>(poFieldDefn);
242  }
243 
247  static inline OGRFieldDefn *FromHandle(OGRFieldDefnH hFieldDefn)
248  {
249  return reinterpret_cast<OGRFieldDefn *>(hFieldDefn);
250  }
251 
252  private:
254 };
255 
256 /************************************************************************/
257 /* OGRGeomFieldDefn */
258 /************************************************************************/
259 
275 class CPL_DLL OGRGeomFieldDefn
276 {
277  protected:
279  char *pszName = nullptr;
280  OGRwkbGeometryType eGeomType =
281  wkbUnknown; /* all values possible except wkbNone */
282  mutable const OGRSpatialReference *poSRS = nullptr;
283 
284  int bIgnore = false;
285  mutable int bNullable = true;
286 
287  void Initialize(const char *, OGRwkbGeometryType);
289 
290  public:
291  OGRGeomFieldDefn(const char *pszNameIn, OGRwkbGeometryType eGeomTypeIn);
292  explicit OGRGeomFieldDefn(const OGRGeomFieldDefn *);
293  virtual ~OGRGeomFieldDefn();
294 
295  void SetName(const char *);
296  const char *GetNameRef() const
297  {
298  return pszName;
299  }
300 
302  {
303  return eGeomType;
304  }
305  void SetType(OGRwkbGeometryType eTypeIn);
306 
307  virtual const OGRSpatialReference *GetSpatialRef() const;
308  void SetSpatialRef(const OGRSpatialReference *poSRSIn);
309 
310  int IsIgnored() const
311  {
312  return bIgnore;
313  }
314  void SetIgnored(int bIgnoreIn)
315  {
316  bIgnore = bIgnoreIn;
317  }
318 
319  int IsNullable() const
320  {
321  return bNullable;
322  }
323  void SetNullable(int bNullableIn)
324  {
325  bNullable = bNullableIn;
326  }
327 
328  int IsSame(const OGRGeomFieldDefn *) const;
329 
333  static inline OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
334  {
335  return reinterpret_cast<OGRGeomFieldDefnH>(poGeomFieldDefn);
336  }
337 
341  static inline OGRGeomFieldDefn *FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
342  {
343  return reinterpret_cast<OGRGeomFieldDefn *>(hGeomFieldDefn);
344  }
345 
346  private:
348 };
349 
350 /************************************************************************/
351 /* OGRFeatureDefn */
352 /************************************************************************/
353 
374 class CPL_DLL OGRFeatureDefn
375 {
376  protected:
378  volatile int nRefCount = 0;
379 
380  mutable std::vector<std::unique_ptr<OGRFieldDefn>> apoFieldDefn{};
381  mutable std::vector<std::unique_ptr<OGRGeomFieldDefn>> apoGeomFieldDefn{};
382 
383  char *pszFeatureClassName = nullptr;
384 
385  bool bIgnoreStyle = false;
387 
388  public:
389  explicit OGRFeatureDefn(const char *pszName = nullptr);
390  virtual ~OGRFeatureDefn();
391 
392  void SetName(const char *pszName);
393  virtual const char *GetName() const;
394 
395  virtual int GetFieldCount() const;
396  virtual OGRFieldDefn *GetFieldDefn(int i);
397  virtual const OGRFieldDefn *GetFieldDefn(int i) const;
398  virtual int GetFieldIndex(const char *) const;
399  int GetFieldIndexCaseSensitive(const char *) const;
400 
402 
406  struct CPL_DLL Fields
407  {
408  private:
409  OGRFeatureDefn *m_poFDefn;
410 
411  public:
412  inline explicit Fields(OGRFeatureDefn *poFDefn) : m_poFDefn(poFDefn)
413  {
414  }
415 
416  struct CPL_DLL ConstIterator
417  {
418  private:
419  OGRFeatureDefn *m_poFDefn;
420  int m_nIdx;
421 
422  public:
423  inline ConstIterator(OGRFeatureDefn *poFDefn, int nIdx)
424  : m_poFDefn(poFDefn), m_nIdx(nIdx)
425  {
426  }
427 
428  inline const OGRFieldDefn *operator*() const
429  {
430  return m_poFDefn->GetFieldDefn(m_nIdx);
431  }
432  inline ConstIterator &operator++()
433  {
434  m_nIdx++;
435  return *this;
436  }
437  inline bool operator!=(const ConstIterator &it) const
438  {
439  return m_nIdx != it.m_nIdx;
440  }
441  };
442 
443  inline ConstIterator begin()
444  {
445  return ConstIterator(m_poFDefn, 0);
446  }
447  inline ConstIterator end()
448  {
449  return ConstIterator(m_poFDefn, m_poFDefn->GetFieldCount());
450  }
451 
452  inline size_t size() const
453  {
454  return static_cast<std::size_t>(m_poFDefn->GetFieldCount());
455  }
456  inline OGRFieldDefn *operator[](size_t i)
457  {
458  return m_poFDefn->GetFieldDefn(static_cast<int>(i));
459  }
460  inline const OGRFieldDefn *operator[](size_t i) const
461  {
462  return m_poFDefn->GetFieldDefn(static_cast<int>(i));
463  }
464  };
466 
477  inline Fields GetFields()
478  {
479  return Fields(this);
480  }
481 
483  // That method should only be called if there's a guarantee that
484  // GetFieldCount() has been called before
485  int GetFieldCountUnsafe() const
486  {
487  return static_cast<int>(apoFieldDefn.size());
488  }
489 
490  // Those methods don't check i is n range.
491  OGRFieldDefn *GetFieldDefnUnsafe(int i)
492  {
493  if (apoFieldDefn.empty())
494  GetFieldDefn(i);
495  return apoFieldDefn[static_cast<std::size_t>(i)].get();
496  }
497  const OGRFieldDefn *GetFieldDefnUnsafe(int i) const
498  {
499  if (apoFieldDefn.empty())
500  GetFieldDefn(i);
501  return apoFieldDefn[static_cast<std::size_t>(i)].get();
502  }
504 
505  virtual void AddFieldDefn(const OGRFieldDefn *);
506  virtual OGRErr DeleteFieldDefn(int iField);
507  virtual OGRErr ReorderFieldDefns(const int *panMap);
508 
509  virtual int GetGeomFieldCount() const;
510  virtual OGRGeomFieldDefn *GetGeomFieldDefn(int i);
511  virtual const OGRGeomFieldDefn *GetGeomFieldDefn(int i) const;
512  virtual int GetGeomFieldIndex(const char *) const;
513 
515 
519  struct CPL_DLL GeomFields
520  {
521  private:
522  OGRFeatureDefn *m_poFDefn;
523 
524  public:
525  inline explicit GeomFields(OGRFeatureDefn *poFDefn) : m_poFDefn(poFDefn)
526  {
527  }
528 
529  struct CPL_DLL ConstIterator
530  {
531  private:
532  OGRFeatureDefn *m_poFDefn;
533  int m_nIdx;
534 
535  public:
536  inline ConstIterator(OGRFeatureDefn *poFDefn, int nIdx)
537  : m_poFDefn(poFDefn), m_nIdx(nIdx)
538  {
539  }
540 
541  inline const OGRGeomFieldDefn *operator*() const
542  {
543  return m_poFDefn->GetGeomFieldDefn(m_nIdx);
544  }
545  inline ConstIterator &operator++()
546  {
547  m_nIdx++;
548  return *this;
549  }
550  inline bool operator!=(const ConstIterator &it) const
551  {
552  return m_nIdx != it.m_nIdx;
553  }
554  };
555 
556  inline ConstIterator begin()
557  {
558  return ConstIterator(m_poFDefn, 0);
559  }
560  inline ConstIterator end()
561  {
562  return ConstIterator(m_poFDefn, m_poFDefn->GetGeomFieldCount());
563  }
564 
565  inline size_t size() const
566  {
567  return static_cast<std::size_t>(m_poFDefn->GetGeomFieldCount());
568  }
569  inline OGRGeomFieldDefn *operator[](size_t i)
570  {
571  return m_poFDefn->GetGeomFieldDefn(static_cast<int>(i));
572  }
573  inline const OGRGeomFieldDefn *operator[](size_t i) const
574  {
575  return m_poFDefn->GetGeomFieldDefn(static_cast<int>(i));
576  }
577  };
579 
590  inline GeomFields GetGeomFields()
591  {
592  return GeomFields(this);
593  }
594 
595  virtual void AddGeomFieldDefn(const OGRGeomFieldDefn *);
596  virtual void AddGeomFieldDefn(std::unique_ptr<OGRGeomFieldDefn> &&);
597  virtual OGRErr DeleteGeomFieldDefn(int iGeomField);
598 
599  virtual OGRwkbGeometryType GetGeomType() const;
600  virtual void SetGeomType(OGRwkbGeometryType);
601 
602  virtual OGRFeatureDefn *Clone() const;
603 
604  int Reference()
605  {
606  return CPLAtomicInc(&nRefCount);
607  }
609  {
610  return CPLAtomicDec(&nRefCount);
611  }
612  int GetReferenceCount() const
613  {
614  return nRefCount;
615  }
616  void Release();
617 
618  virtual int IsGeometryIgnored() const;
619  virtual void SetGeometryIgnored(int bIgnore);
620  virtual bool IsStyleIgnored() const
621  {
622  return bIgnoreStyle;
623  }
624  virtual void SetStyleIgnored(bool bIgnore)
625  {
626  bIgnoreStyle = bIgnore;
627  }
628 
629  virtual int IsSame(const OGRFeatureDefn *poOtherFeatureDefn) const;
630 
632  void ReserveSpaceForFields(int nFieldCountIn);
634 
635  std::vector<int> ComputeMapForSetFrom(const OGRFeatureDefn *poSrcFDefn,
636  bool bForgiving = true) const;
637 
638  static OGRFeatureDefn *CreateFeatureDefn(const char *pszName = nullptr);
639  static void DestroyFeatureDefn(OGRFeatureDefn *);
640 
644  static inline OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
645  {
646  return reinterpret_cast<OGRFeatureDefnH>(poFeatureDefn);
647  }
648 
652  static inline OGRFeatureDefn *FromHandle(OGRFeatureDefnH hFeatureDefn)
653  {
654  return reinterpret_cast<OGRFeatureDefn *>(hFeatureDefn);
655  }
656 
657  private:
659 };
660 
661 /************************************************************************/
662 /* OGRFeature */
663 /************************************************************************/
664 
669 class CPL_DLL OGRFeature
670 {
671  private:
672  GIntBig nFID;
673  OGRFeatureDefn *poDefn;
674  OGRGeometry **papoGeometries;
675  OGRField *pauFields;
676  char *m_pszNativeData;
677  char *m_pszNativeMediaType;
678 
679  bool SetFieldInternal(int i, const OGRField *puValue);
680 
681  protected:
683  mutable char *m_pszStyleString;
684  mutable OGRStyleTable *m_poStyleTable;
685  mutable char *m_pszTmpFieldValue;
687 
688  bool CopySelfTo(OGRFeature *poNew) const;
689 
690  public:
691  explicit OGRFeature(OGRFeatureDefn *);
692  virtual ~OGRFeature();
693 
695  class CPL_DLL FieldValue
696  {
697  friend class OGRFeature;
698  struct Private;
699  std::unique_ptr<Private> m_poPrivate;
700 
701  FieldValue(OGRFeature *poFeature, int iFieldIndex);
702  FieldValue(const OGRFeature *poFeature, int iFieldIndex);
703  FieldValue(const FieldValue &oOther) = delete;
704  FieldValue &Assign(const FieldValue &oOther);
705 
706  public:
708  ~FieldValue();
709 
710  FieldValue &operator=(FieldValue &&oOther);
712 
714  FieldValue &operator=(const FieldValue &oOther);
716  FieldValue &operator=(int nVal);
718  FieldValue &operator=(GIntBig nVal);
720  FieldValue &operator=(double dfVal);
722  FieldValue &operator=(const char *pszVal);
724  FieldValue &operator=(const std::string &osVal);
726  FieldValue &operator=(const std::vector<int> &oArray);
728  FieldValue &operator=(const std::vector<GIntBig> &oArray);
730  FieldValue &operator=(const std::vector<double> &oArray);
732  FieldValue &operator=(const std::vector<std::string> &oArray);
734  FieldValue &operator=(CSLConstList papszValues);
736  void SetNull();
738  void clear();
740  void Unset()
741  {
742  clear();
743  }
745  void SetDateTime(int nYear, int nMonth, int nDay, int nHour = 0,
746  int nMinute = 0, float fSecond = 0.f, int nTZFlag = 0);
747 
749  int GetIndex() const;
751  const OGRFieldDefn *GetDefn() const;
753  const char *GetName() const
754  {
755  return GetDefn()->GetNameRef();
756  }
759  {
760  return GetDefn()->GetType();
761  }
764  {
765  return GetDefn()->GetSubType();
766  }
767 
769  // cppcheck-suppress functionStatic
770  bool empty() const
771  {
772  return IsUnset();
773  }
774 
776  // cppcheck-suppress functionStatic
777  bool IsUnset() const;
778 
780  // cppcheck-suppress functionStatic
781  bool IsNull() const;
782 
784  const OGRField *GetRawValue() const;
785 
789  // cppcheck-suppress functionStatic
790  int GetInteger() const
791  {
792  return GetRawValue()->Integer;
793  }
794 
798  // cppcheck-suppress functionStatic
800  {
801  return GetRawValue()->Integer64;
802  }
803 
807  // cppcheck-suppress functionStatic
808  double GetDouble() const
809  {
810  return GetRawValue()->Real;
811  }
812 
816  // cppcheck-suppress functionStatic
817  const char *GetString() const
818  {
819  return GetRawValue()->String;
820  }
821 
823  bool GetDateTime(int *pnYear, int *pnMonth, int *pnDay, int *pnHour,
824  int *pnMinute, float *pfSecond, int *pnTZFlag) const;
825 
827  operator int() const
828  {
829  return GetAsInteger();
830  }
833  operator GIntBig() const
834  {
835  return GetAsInteger64();
836  }
838  operator double() const
839  {
840  return GetAsDouble();
841  }
843  operator const char *() const
844  {
845  return GetAsString();
846  }
848  operator const std::vector<int> &() const
849  {
850  return GetAsIntegerList();
851  }
854  operator const std::vector<GIntBig> &() const
855  {
856  return GetAsInteger64List();
857  }
859  operator const std::vector<double> &() const
860  {
861  return GetAsDoubleList();
862  }
864  operator const std::vector<std::string> &() const
865  {
866  return GetAsStringList();
867  }
869  operator CSLConstList() const;
870 
872  int GetAsInteger() const;
875  GIntBig GetAsInteger64() const;
877  double GetAsDouble() const;
879  const char *GetAsString() const;
881  const std::vector<int> &GetAsIntegerList() const;
884  const std::vector<GIntBig> &GetAsInteger64List() const;
886  const std::vector<double> &GetAsDoubleList() const;
888  const std::vector<std::string> &GetAsStringList() const;
889  };
890 
892  class CPL_DLL ConstFieldIterator
893  {
894  friend class OGRFeature;
895  struct Private;
896  std::unique_ptr<Private> m_poPrivate;
897 
898  ConstFieldIterator(const OGRFeature *poSelf, int nPos);
899 
900  public:
903  ConstFieldIterator &&oOther) noexcept; // declared but not defined.
904  // Needed for gcc 5.4 at least
906  const FieldValue &operator*() const;
907  ConstFieldIterator &operator++();
908  bool operator!=(const ConstFieldIterator &it) const;
910  };
911 
929  ConstFieldIterator begin() const;
931  ConstFieldIterator end() const;
932 
933  const FieldValue operator[](int iField) const;
934  FieldValue operator[](int iField);
935 
938  class FieldNotFoundException : public std::exception
939  {
940  };
941 
942  const FieldValue operator[](const char *pszFieldName) const;
943  FieldValue operator[](const char *pszFieldName);
944 
946  {
947  return poDefn;
948  }
949  const OGRFeatureDefn *GetDefnRef() const
950  {
951  return poDefn;
952  }
953 
955  void SetFDefnUnsafe(OGRFeatureDefn *poNewFDefn);
957 
958  OGRErr SetGeometryDirectly(OGRGeometry *);
959  OGRErr SetGeometry(const OGRGeometry *);
960  OGRGeometry *GetGeometryRef();
961  const OGRGeometry *GetGeometryRef() const;
962  OGRGeometry *StealGeometry() CPL_WARN_UNUSED_RESULT;
963 
964  int GetGeomFieldCount() const
965  {
966  return poDefn->GetGeomFieldCount();
967  }
969  {
970  return poDefn->GetGeomFieldDefn(iField);
971  }
972  const OGRGeomFieldDefn *GetGeomFieldDefnRef(int iField) const
973  {
974  return poDefn->GetGeomFieldDefn(iField);
975  }
976  int GetGeomFieldIndex(const char *pszName) const
977  {
978  return poDefn->GetGeomFieldIndex(pszName);
979  }
980 
981  OGRGeometry *GetGeomFieldRef(int iField);
982  const OGRGeometry *GetGeomFieldRef(int iField) const;
983  OGRGeometry *StealGeometry(int iField);
984  OGRGeometry *GetGeomFieldRef(const char *pszFName);
985  const OGRGeometry *GetGeomFieldRef(const char *pszFName) const;
986  OGRErr SetGeomFieldDirectly(int iField, OGRGeometry *);
987  OGRErr SetGeomField(int iField, const OGRGeometry *);
988 
989  void Reset();
990 
991  OGRFeature *Clone() const CPL_WARN_UNUSED_RESULT;
992  virtual OGRBoolean Equal(const OGRFeature *poFeature) const;
993 
994  int GetFieldCount() const
995  {
996  return poDefn->GetFieldCount();
997  }
998  const OGRFieldDefn *GetFieldDefnRef(int iField) const
999  {
1000  return poDefn->GetFieldDefn(iField);
1001  }
1003  {
1004  return poDefn->GetFieldDefn(iField);
1005  }
1006  int GetFieldIndex(const char *pszName) const
1007  {
1008  return poDefn->GetFieldIndex(pszName);
1009  }
1010 
1011  int IsFieldSet(int iField) const;
1012 
1013  void UnsetField(int iField);
1014 
1015  bool IsFieldNull(int iField) const;
1016 
1017  void SetFieldNull(int iField);
1018 
1019  bool IsFieldSetAndNotNull(int iField) const;
1020 
1022  {
1023  return pauFields + i;
1024  }
1025  const OGRField *GetRawFieldRef(int i) const
1026  {
1027  return pauFields + i;
1028  }
1029 
1030  int GetFieldAsInteger(int i) const;
1031  GIntBig GetFieldAsInteger64(int i) const;
1032  double GetFieldAsDouble(int i) const;
1033  const char *GetFieldAsString(int i) const;
1034  const char *GetFieldAsISO8601DateTime(int i,
1035  CSLConstList papszOptions) const;
1036  const int *GetFieldAsIntegerList(int i, int *pnCount) const;
1037  const GIntBig *GetFieldAsInteger64List(int i, int *pnCount) const;
1038  const double *GetFieldAsDoubleList(int i, int *pnCount) const;
1039  char **GetFieldAsStringList(int i) const;
1040  GByte *GetFieldAsBinary(int i, int *pnCount) const;
1041  int GetFieldAsDateTime(int i, int *pnYear, int *pnMonth, int *pnDay,
1042  int *pnHour, int *pnMinute, int *pnSecond,
1043  int *pnTZFlag) const;
1044  int GetFieldAsDateTime(int i, int *pnYear, int *pnMonth, int *pnDay,
1045  int *pnHour, int *pnMinute, float *pfSecond,
1046  int *pnTZFlag) const;
1047  char *GetFieldAsSerializedJSon(int i) const;
1048 
1050  bool IsFieldSetUnsafe(int i) const
1051  {
1052  return !(pauFields[i].Set.nMarker1 == OGRUnsetMarker &&
1053  pauFields[i].Set.nMarker2 == OGRUnsetMarker &&
1054  pauFields[i].Set.nMarker3 == OGRUnsetMarker);
1055  }
1056  bool IsFieldNullUnsafe(int i) const
1057  {
1058  return (pauFields[i].Set.nMarker1 == OGRNullMarker &&
1059  pauFields[i].Set.nMarker2 == OGRNullMarker &&
1060  pauFields[i].Set.nMarker3 == OGRNullMarker);
1061  }
1062  bool IsFieldSetAndNotNullUnsafe(int i) const
1063  {
1064  return IsFieldSetUnsafe(i) && !IsFieldNullUnsafe(i);
1065  }
1066  // Those methods should only be called on a field that is of the type
1067  // consistent with the value, and that is set.
1068  int GetFieldAsIntegerUnsafe(int i) const
1069  {
1070  return pauFields[i].Integer;
1071  }
1072  GIntBig GetFieldAsInteger64Unsafe(int i) const
1073  {
1074  return pauFields[i].Integer64;
1075  }
1076  double GetFieldAsDoubleUnsafe(int i) const
1077  {
1078  return pauFields[i].Real;
1079  }
1080  const char *GetFieldAsStringUnsafe(int i) const
1081  {
1082  return pauFields[i].String;
1083  }
1085 
1086  int GetFieldAsInteger(const char *pszFName) const
1087  {
1088  return GetFieldAsInteger(GetFieldIndex(pszFName));
1089  }
1090  GIntBig GetFieldAsInteger64(const char *pszFName) const
1091  {
1092  return GetFieldAsInteger64(GetFieldIndex(pszFName));
1093  }
1094  double GetFieldAsDouble(const char *pszFName) const
1095  {
1096  return GetFieldAsDouble(GetFieldIndex(pszFName));
1097  }
1098  const char *GetFieldAsString(const char *pszFName) const
1099  {
1100  return GetFieldAsString(GetFieldIndex(pszFName));
1101  }
1102  const char *GetFieldAsISO8601DateTime(const char *pszFName,
1103  CSLConstList papszOptions) const
1104  {
1105  return GetFieldAsISO8601DateTime(GetFieldIndex(pszFName), papszOptions);
1106  }
1107  const int *GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
1108  {
1109  return GetFieldAsIntegerList(GetFieldIndex(pszFName), pnCount);
1110  }
1111  const GIntBig *GetFieldAsInteger64List(const char *pszFName,
1112  int *pnCount) const
1113  {
1114  return GetFieldAsInteger64List(GetFieldIndex(pszFName), pnCount);
1115  }
1116  const double *GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
1117  {
1118  return GetFieldAsDoubleList(GetFieldIndex(pszFName), pnCount);
1119  }
1120  char **GetFieldAsStringList(const char *pszFName) const
1121  {
1122  return GetFieldAsStringList(GetFieldIndex(pszFName));
1123  }
1124 
1125  void SetField(int i, int nValue);
1126  void SetField(int i, GIntBig nValue);
1127  void SetField(int i, double dfValue);
1128  void SetField(int i, const char *pszValue);
1129  void SetField(int i, int nCount, const int *panValues);
1130  void SetField(int i, int nCount, const GIntBig *panValues);
1131  void SetField(int i, int nCount, const double *padfValues);
1132  void SetField(int i, const char *const *papszValues);
1133  void SetField(int i, const OGRField *puValue);
1134  void SetField(int i, int nCount, const void *pabyBinary);
1135  void SetField(int i, int nYear, int nMonth, int nDay, int nHour = 0,
1136  int nMinute = 0, float fSecond = 0.f, int nTZFlag = 0);
1137 
1139  // Those methods should only be called on a field that is of the type
1140  // consistent with the value, and in a unset state.
1141  void SetFieldSameTypeUnsafe(int i, int nValue)
1142  {
1143  pauFields[i].Integer = nValue;
1144  pauFields[i].Set.nMarker2 = 0;
1145  pauFields[i].Set.nMarker3 = 0;
1146  }
1147  void SetFieldSameTypeUnsafe(int i, GIntBig nValue)
1148  {
1149  pauFields[i].Integer64 = nValue;
1150  }
1151  void SetFieldSameTypeUnsafe(int i, double dfValue)
1152  {
1153  pauFields[i].Real = dfValue;
1154  }
1155  void SetFieldSameTypeUnsafe(int i, char *pszValueTransferred)
1156  {
1157  pauFields[i].String = pszValueTransferred;
1158  }
1160 
1161  void SetField(const char *pszFName, int nValue)
1162  {
1163  SetField(GetFieldIndex(pszFName), nValue);
1164  }
1165  void SetField(const char *pszFName, GIntBig nValue)
1166  {
1167  SetField(GetFieldIndex(pszFName), nValue);
1168  }
1169  void SetField(const char *pszFName, double dfValue)
1170  {
1171  SetField(GetFieldIndex(pszFName), dfValue);
1172  }
1173  void SetField(const char *pszFName, const char *pszValue)
1174  {
1175  SetField(GetFieldIndex(pszFName), pszValue);
1176  }
1177  void SetField(const char *pszFName, int nCount, const int *panValues)
1178  {
1179  SetField(GetFieldIndex(pszFName), nCount, panValues);
1180  }
1181  void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
1182  {
1183  SetField(GetFieldIndex(pszFName), nCount, panValues);
1184  }
1185  void SetField(const char *pszFName, int nCount, const double *padfValues)
1186  {
1187  SetField(GetFieldIndex(pszFName), nCount, padfValues);
1188  }
1189  void SetField(const char *pszFName, const char *const *papszValues)
1190  {
1191  SetField(GetFieldIndex(pszFName), papszValues);
1192  }
1193  void SetField(const char *pszFName, const OGRField *puValue)
1194  {
1195  SetField(GetFieldIndex(pszFName), puValue);
1196  }
1197  void SetField(const char *pszFName, int nYear, int nMonth, int nDay,
1198  int nHour = 0, int nMinute = 0, float fSecond = 0.f,
1199  int nTZFlag = 0)
1200  {
1201  SetField(GetFieldIndex(pszFName), nYear, nMonth, nDay, nHour, nMinute,
1202  fSecond, nTZFlag);
1203  }
1204 
1205  GIntBig GetFID() const
1206  {
1207  return nFID;
1208  }
1209  virtual OGRErr SetFID(GIntBig nFIDIn);
1210 
1211  void DumpReadable(FILE *, CSLConstList papszOptions = nullptr) const;
1212  std::string DumpReadableAsString(CSLConstList papszOptions = nullptr) const;
1213 
1214  OGRErr SetFrom(const OGRFeature *, int = TRUE);
1215  OGRErr SetFrom(const OGRFeature *, const int *, int = TRUE);
1216  OGRErr SetFieldsFrom(const OGRFeature *, const int *, int = TRUE);
1217 
1219  OGRErr RemapFields(OGRFeatureDefn *poNewDefn, const int *panRemapSource);
1220  void AppendField();
1221  OGRErr RemapGeomFields(OGRFeatureDefn *poNewDefn,
1222  const int *panRemapSource);
1224 
1225  int Validate(int nValidateFlags, int bEmitError) const;
1226  void FillUnsetWithDefault(int bNotNullableOnly, char **papszOptions);
1227 
1228  virtual const char *GetStyleString() const;
1229  virtual void SetStyleString(const char *);
1230  virtual void SetStyleStringDirectly(char *);
1231 
1235  virtual OGRStyleTable *GetStyleTable() const
1236  {
1237  return m_poStyleTable;
1238  } /* f.i.x.m.e: add a const qualifier for return type */
1239  virtual void SetStyleTable(OGRStyleTable *poStyleTable);
1240  virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable);
1241 
1242  const char *GetNativeData() const
1243  {
1244  return m_pszNativeData;
1245  }
1246  const char *GetNativeMediaType() const
1247  {
1248  return m_pszNativeMediaType;
1249  }
1250  void SetNativeData(const char *pszNativeData);
1251  void SetNativeMediaType(const char *pszNativeMediaType);
1252 
1253  static OGRFeature *CreateFeature(OGRFeatureDefn *);
1254  static void DestroyFeature(OGRFeature *);
1255 
1259  static inline OGRFeatureH ToHandle(OGRFeature *poFeature)
1260  {
1261  return reinterpret_cast<OGRFeatureH>(poFeature);
1262  }
1263 
1267  static inline OGRFeature *FromHandle(OGRFeatureH hFeature)
1268  {
1269  return reinterpret_cast<OGRFeature *>(hFeature);
1270  }
1271 
1272  private:
1274 };
1275 
1277 struct CPL_DLL OGRFeatureUniquePtrDeleter
1278 {
1279  void operator()(OGRFeature *) const;
1280 };
1282 
1286 typedef std::unique_ptr<OGRFeature, OGRFeatureUniquePtrDeleter>
1288 
1290 
1291 inline OGRFeature::ConstFieldIterator begin(const OGRFeature *poFeature)
1292 {
1293  return poFeature->begin();
1294 }
1296 inline OGRFeature::ConstFieldIterator end(const OGRFeature *poFeature)
1297 {
1298  return poFeature->end();
1299 }
1300 
1303 begin(const OGRFeatureUniquePtr &poFeature)
1304 {
1305  return poFeature->begin();
1306 }
1309 {
1310  return poFeature->end();
1311 }
1312 
1314 
1315 /************************************************************************/
1316 /* OGRFieldDomain */
1317 /************************************************************************/
1318 
1319 /* clang-format off */
1339 /* clang-format on */
1340 
1341 class CPL_DLL OGRFieldDomain
1342 {
1343  protected:
1345  std::string m_osName;
1346  std::string m_osDescription;
1347  OGRFieldDomainType m_eDomainType;
1348  OGRFieldType m_eFieldType;
1349  OGRFieldSubType m_eFieldSubType;
1352 
1353  OGRFieldDomain(const std::string &osName, const std::string &osDescription,
1354  OGRFieldDomainType eDomainType, OGRFieldType eFieldType,
1355  OGRFieldSubType eFieldSubType);
1358  public:
1363  virtual ~OGRFieldDomain() = 0;
1364 
1369  virtual OGRFieldDomain *Clone() const = 0;
1370 
1375  const std::string &GetName() const
1376  {
1377  return m_osName;
1378  }
1379 
1385  const std::string &GetDescription() const
1386  {
1387  return m_osDescription;
1388  }
1389 
1395  {
1396  return m_eDomainType;
1397  }
1398 
1404  {
1405  return m_eFieldType;
1406  }
1407 
1413  {
1414  return m_eFieldSubType;
1415  }
1416 
1418  static inline OGRFieldDomainH ToHandle(OGRFieldDomain *poFieldDomain)
1419  {
1420  return reinterpret_cast<OGRFieldDomainH>(poFieldDomain);
1421  }
1422 
1424  static inline OGRFieldDomain *FromHandle(OGRFieldDomainH hFieldDomain)
1425  {
1426  return reinterpret_cast<OGRFieldDomain *>(hFieldDomain);
1427  }
1428 
1434  {
1435  return m_eSplitPolicy;
1436  }
1437 
1443  {
1444  m_eSplitPolicy = policy;
1445  }
1446 
1452  {
1453  return m_eMergePolicy;
1454  }
1455 
1461  {
1462  m_eMergePolicy = policy;
1463  }
1464 };
1465 
1472 class CPL_DLL OGRCodedFieldDomain final : public OGRFieldDomain
1473 {
1474  private:
1475  std::vector<OGRCodedValue> m_asValues{};
1476 
1477  OGRCodedFieldDomain(const OGRCodedFieldDomain &) = delete;
1478  OGRCodedFieldDomain &operator=(const OGRCodedFieldDomain &) = delete;
1479 
1480  public:
1496  OGRCodedFieldDomain(const std::string &osName,
1497  const std::string &osDescription,
1498  OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1499  std::vector<OGRCodedValue> &&asValues);
1500 
1501  ~OGRCodedFieldDomain() override;
1502 
1503  OGRCodedFieldDomain *Clone() const override;
1504 
1511  {
1512  return m_asValues.data();
1513  }
1514 };
1515 
1518 class CPL_DLL OGRRangeFieldDomain final : public OGRFieldDomain
1519 {
1520  private:
1521  OGRField m_sMin;
1522  OGRField m_sMax;
1523  bool m_bMinIsInclusive;
1524  bool m_bMaxIsInclusive;
1525 
1526  OGRRangeFieldDomain(const OGRRangeFieldDomain &) = delete;
1527  OGRRangeFieldDomain &operator=(const OGRRangeFieldDomain &) = delete;
1528 
1529  public:
1557  OGRRangeFieldDomain(const std::string &osName,
1558  const std::string &osDescription,
1559  OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1560  const OGRField &sMin, bool bMinIsInclusive,
1561  const OGRField &sMax, bool bMaxIsInclusive);
1562 
1563  OGRRangeFieldDomain *Clone() const override
1564  {
1565  auto poDomain = new OGRRangeFieldDomain(
1566  m_osName, m_osDescription, m_eFieldType, m_eFieldSubType, m_sMin,
1567  m_bMinIsInclusive, m_sMax, m_bMaxIsInclusive);
1568  poDomain->SetMergePolicy(m_eMergePolicy);
1569  poDomain->SetSplitPolicy(m_eSplitPolicy);
1570  return poDomain;
1571  }
1572 
1586  const OGRField &GetMin(bool &bIsInclusiveOut) const
1587  {
1588  bIsInclusiveOut = m_bMinIsInclusive;
1589  return m_sMin;
1590  }
1591 
1605  const OGRField &GetMax(bool &bIsInclusiveOut) const
1606  {
1607  bIsInclusiveOut = m_bMaxIsInclusive;
1608  return m_sMax;
1609  }
1610 };
1611 
1616 class CPL_DLL OGRGlobFieldDomain final : public OGRFieldDomain
1617 {
1618  private:
1619  std::string m_osGlob;
1620 
1621  OGRGlobFieldDomain(const OGRGlobFieldDomain &) = delete;
1622  OGRGlobFieldDomain &operator=(const OGRGlobFieldDomain &) = delete;
1623 
1624  public:
1635  OGRGlobFieldDomain(const std::string &osName,
1636  const std::string &osDescription,
1637  OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1638  const std::string &osBlob);
1639 
1640  OGRGlobFieldDomain *Clone() const override
1641  {
1642  auto poDomain = new OGRGlobFieldDomain(
1643  m_osName, m_osDescription, m_eFieldType, m_eFieldSubType, m_osGlob);
1644  poDomain->SetMergePolicy(m_eMergePolicy);
1645  poDomain->SetSplitPolicy(m_eSplitPolicy);
1646  return poDomain;
1647  }
1648 
1653  const std::string &GetGlob() const
1654  {
1655  return m_osGlob;
1656  }
1657 };
1658 
1659 /************************************************************************/
1660 /* OGRFeatureQuery */
1661 /************************************************************************/
1662 
1664 class OGRLayer;
1665 class swq_expr_node;
1666 class swq_custom_func_registrar;
1667 
1668 class CPL_DLL OGRFeatureQuery
1669 {
1670  private:
1671  OGRFeatureDefn *poTargetDefn;
1672  void *pSWQExpr;
1673 
1674  char **FieldCollector(void *, char **);
1675 
1676  GIntBig *EvaluateAgainstIndices(swq_expr_node *, OGRLayer *,
1677  GIntBig &nFIDCount);
1678 
1679  int CanUseIndex(swq_expr_node *, OGRLayer *);
1680 
1681  OGRErr Compile(OGRLayer *, OGRFeatureDefn *, const char *, int bCheck,
1682  swq_custom_func_registrar *poCustomFuncRegistrar);
1683 
1684  CPL_DISALLOW_COPY_ASSIGN(OGRFeatureQuery)
1685 
1686  public:
1687  OGRFeatureQuery();
1688  ~OGRFeatureQuery();
1689 
1690  OGRErr Compile(OGRLayer *, const char *, int bCheck = TRUE,
1691  swq_custom_func_registrar *poCustomFuncRegistrar = nullptr);
1692  OGRErr Compile(OGRFeatureDefn *, const char *, int bCheck = TRUE,
1693  swq_custom_func_registrar *poCustomFuncRegistrar = nullptr);
1694  int Evaluate(OGRFeature *);
1695 
1696  GIntBig *EvaluateAgainstIndices(OGRLayer *, OGRErr *);
1697 
1698  int CanUseIndex(OGRLayer *);
1699 
1700  char **GetUsedFields();
1701 
1702  void *GetSWQExpr()
1703  {
1704  return pSWQExpr;
1705  }
1706 };
1708 
1709 #endif /* ndef OGR_FEATURE_H_INCLUDED */
MAX
#define MAX(a, b)
Macro to compute the maximum of 2 values.
Definition: cpl_port.h:394
OGRNullMarker
#define OGRNullMarker
Special value set in OGRField.Set.nMarker1, nMarker2 and nMarker3 for a null field.
Definition: ogr_core.h:867
OGRFeature::GetFieldAsDoubleList
const double * GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
Fetch field value as a list of doubles.
Definition: ogr_feature.h:1116
OGRFeature::FieldValue::GetString
const char * GetString() const
Return the string value.
Definition: ogr_feature.h:817
OGRFeatureDefn::FromHandle
static OGRFeatureDefn * FromHandle(OGRFeatureDefnH hFeatureDefn)
Convert a OGRFeatureDefnH to a OGRFeatureDefn*.
Definition: ogr_feature.h:652
OGRFeature::FieldValue::GetSubType
OGRFieldSubType GetSubType() const
Return field subtype.
Definition: ogr_feature.h:763
OGRFieldDomain::GetSplitPolicy
OGRFieldDomainSplitPolicy GetSplitPolicy() const
Get the split policy.
Definition: ogr_feature.h:1433
OGRFeatureDefn::GetFields
Fields GetFields()
Return an object that can be used to iterate over non-geometry fields.
Definition: ogr_feature.h:477
OGRFieldDomainMergePolicy
OGRFieldDomainMergePolicy
Merge policy for field domains.
Definition: ogr_core.h:1246
OGRFeatureDefn::IsStyleIgnored
virtual bool IsStyleIgnored() const
Determine whether the style can be omitted when fetching features.
Definition: ogr_feature.h:620
OFDSP_DEFAULT_VALUE
@ OFDSP_DEFAULT_VALUE
Default value.
Definition: ogr_core.h:1231
OGRFieldDomainType
OGRFieldDomainType
Type of field domain.
Definition: ogr_core.h:1211
GByte
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:205
OGRFieldDefnH
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition: ogr_feature.h:62
OGRFeature::FieldNotFoundException
Exception raised by operator[](const char*) when a field is not found.
Definition: ogr_feature.h:938
OGRCodedFieldDomain::GetEnumeration
const OGRCodedValue * GetEnumeration() const
Get the enumeration as (code, value) pairs.
Definition: ogr_feature.h:1510
OGRFeature::SetField
void SetField(const char *pszFName, GIntBig nValue)
Set field to 64 bit integer value. OFTInteger, OFTInteger64 and OFTReal fields will be set directly....
Definition: ogr_feature.h:1165
OGRFeature::GetFieldAsStringList
char ** GetFieldAsStringList(const char *pszFName) const
Fetch field value as a list of strings.
Definition: ogr_feature.h:1120
OGRFieldDefn::GetDomainName
const std::string & GetDomainName() const
Return the name of the field domain for this field.
Definition: ogr_feature.h:216
OGRFeature::ConstFieldIterator
Field value iterator class.
Definition: ogr_feature.h:892
OGRFieldDefn::SetDomainName
void SetDomainName(const std::string &osDomainName)
Set the name of the field domain for this field.
Definition: ogr_feature.h:220
OGRFeature::GetStyleTable
virtual OGRStyleTable * GetStyleTable() const
Return style table.
Definition: ogr_feature.h:1235
OGRFieldDefn::SetJustify
void SetJustify(OGRJustification eJustifyIn)
Set the justification for this field.
Definition: ogr_feature.h:159
begin
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:364
OGRFeature::FieldValue::GetType
OGRFieldType GetType() const
Return field type.
Definition: ogr_feature.h:758
OGRGeomFieldDefn::SetIgnored
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:314
OGRStyleTable
This class represents a style table.
Definition: ogr_featurestyle.h:84
OGRFieldDomain::SetMergePolicy
void SetMergePolicy(OGRFieldDomainMergePolicy policy)
Set the merge policy.
Definition: ogr_feature.h:1460
OGRFieldDefn::SetIgnored
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:193
OGRFeature::ToHandle
static OGRFeatureH ToHandle(OGRFeature *poFeature)
Convert a OGRFeature* to a OGRFeatureH.
Definition: ogr_feature.h:1259
OGRFeature::FieldValue::GetName
const char * GetName() const
Return field name.
Definition: ogr_feature.h:753
OGRFeatureDefn::GetGeomFieldIndex
virtual int GetGeomFieldIndex(const char *) const
Find geometry field by name.
Definition: ogrfeaturedefn.cpp:875
OGRFeature::GetFieldDefnRef
OGRFieldDefn * GetFieldDefnRef(int iField)
Fetch definition for this field.
Definition: ogr_feature.h:1002
OGRFieldDefn::GetWidth
int GetWidth() const
Get the formatting width for this field.
Definition: ogr_feature.h:164
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:166
OGRGeomFieldDefnH
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition: ogr_feature.h:71
OGRStyleTableH
void * OGRStyleTableH
Opaque type for a style table (OGRStyleTable)
Definition: ogr_feature.h:68
OGRFieldDomain::FromHandle
static OGRFieldDomain * FromHandle(OGRFieldDomainH hFieldDomain)
Convert a OGRFieldDomainH to a OGRFieldDomain*.
Definition: ogr_feature.h:1424
OGRFeatureH
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition: ogr_feature.h:66
OGRFieldDomain::SetSplitPolicy
void SetSplitPolicy(OGRFieldDomainSplitPolicy policy)
Set the split policy.
Definition: ogr_feature.h:1442
OGRFeature::SetField
void SetField(const char *pszFName, const OGRField *puValue)
Set field.
Definition: ogr_feature.h:1193
OGRRangeFieldDomain::GetMin
const OGRField & GetMin(bool &bIsInclusiveOut) const
Get the minimum value.
Definition: ogr_feature.h:1586
OGRFeature::GetFieldAsDouble
double GetFieldAsDouble(const char *pszFName) const
Fetch field value as a double.
Definition: ogr_feature.h:1094
OGRGeometry
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:334
OGRFieldDomain::GetDescription
const std::string & GetDescription() const
Get the description of the field domain.
Definition: ogr_feature.h:1385
OGRFieldDomain::Clone
virtual OGRFieldDomain * Clone() const =0
Clone.
OGRFeature::GetGeomFieldDefnRef
OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField)
Fetch definition for this geometry field.
Definition: ogr_feature.h:968
OGRLayer
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:72
OGRFeature::FieldValue::empty
bool empty() const
Return whether the field value is unset/empty.
Definition: ogr_feature.h:770
OFDMP_DEFAULT_VALUE
@ OFDMP_DEFAULT_VALUE
Default value.
Definition: ogr_core.h:1249
OGRGeomFieldDefn::ToHandle
static OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
Convert a OGRGeomFieldDefn* to a OGRGeomFieldDefnH.
Definition: ogr_feature.h:333
OGRFieldDefn::GetPrecision
int GetPrecision() const
Get the formatting precision for this field. This should normally be zero for fields of types other t...
Definition: ogr_feature.h:173
ogr_geometry.h
OGRGeomFieldDefn::GetNameRef
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:296
OGRGeomFieldDefn::IsIgnored
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:310
OGRFeatureUniquePtr
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition: ogr_feature.h:1287
OGRRangeFieldDomain::GetMax
const OGRField & GetMax(bool &bIsInclusiveOut) const
Get the maximum value.
Definition: ogr_feature.h:1605
OGRFeatureH
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition: ogr_api.h:361
OGRFeature::GetGeomFieldIndex
int GetGeomFieldIndex(const char *pszName) const
Fetch the geometry field index given geometry field name.
Definition: ogr_feature.h:976
OGRFieldDefn::GetNameRef
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:130
OGRBoolean
int OGRBoolean
Type for a OGR boolean.
Definition: ogr_core.h:395
OGRFeatureDefnH
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition: ogr_api.h:359
OGRFieldDefn::SetPrecision
void SetPrecision(int nPrecisionIn)
Set the formatting precision for this field in characters.
Definition: ogr_feature.h:177
OGRFeatureDefn::GetFieldDefn
virtual OGRFieldDefn * GetFieldDefn(int i)
Fetch field definition.
Definition: ogrfeaturedefn.cpp:312
OGRFeature::FieldValue
Field value.
Definition: ogr_feature.h:695
OGRGeomFieldDefnH
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition: ogr_api.h:366
OGRFieldDefn::GetComment
const std::string & GetComment() const
Return the (optional) comment for this field.
Definition: ogr_feature.h:225
OGRFeature::begin
ConstFieldIterator begin() const
Return begin of field value iterator.
Definition: ogrfeature.cpp:7455
OGRFieldDefn::SetComment
void SetComment(const std::string &osComment)
Set the comment for this field.
Definition: ogr_feature.h:229
OGRFieldDomain::GetMergePolicy
OGRFieldDomainMergePolicy GetMergePolicy() const
Get the merge policy.
Definition: ogr_feature.h:1451
OGRFieldDefn::IsUnique
int IsUnique() const
Return whether this field has a unique constraint.
Definition: ogr_feature.h:207
OGRGlobFieldDomain
Definition of a field domain for field content validated by a glob.
Definition: ogr_feature.h:1616
OGRField
OGRFeature field attribute value union.
Definition: ogr_core.h:877
OGRFeature::GetDefnRef
OGRFeatureDefn * GetDefnRef()
Fetch feature definition.
Definition: ogr_feature.h:945
OGRFeatureDefn::GetGeomFieldDefn
virtual OGRGeomFieldDefn * GetGeomFieldDefn(int i)
Fetch geometry field definition.
Definition: ogrfeaturedefn.cpp:640
OGRFeature::SetField
void SetField(const char *pszFName, int nCount, const double *padfValues)
Definition: ogr_feature.h:1185
OGRCodedValue
Associates a code and a value.
Definition: ogr_core.h:1198
OGRFeature::GetFieldIndex
int GetFieldIndex(const char *pszName) const
Fetch the field index given field name.
Definition: ogr_feature.h:1006
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1195
OGRFeature::FieldValue::Unset
void Unset()
Unset the field.
Definition: ogr_feature.h:740
OGRFeatureDefn::GetFieldCount
virtual int GetFieldCount() const
Fetch number of fields on this feature.
Definition: ogrfeaturedefn.cpp:268
OGRFeature::SetField
void SetField(const char *pszFName, const char *pszValue)
Set field to string value.
Definition: ogr_feature.h:1173
OGRFieldDomain::GetName
const std::string & GetName() const
Get the name of the field domain.
Definition: ogr_feature.h:1375
OGRFeature::SetField
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:1197
OGRFieldDefn::FromHandle
static OGRFieldDefn * FromHandle(OGRFieldDefnH hFieldDefn)
Convert a OGRFieldDefnH to a OGRFieldDefn*.
Definition: ogr_feature.h:247
OGRFieldDomainH
struct OGRFieldDomainHS * OGRFieldDomainH
Opaque type for a field domain definition (OGRFieldDomain)
Definition: ogr_api.h:369
OGRFieldDefn
Definition of an attribute of an OGRFeatureDefn.
Definition: ogr_feature.h:103
OGRGeomFieldDefn::IsNullable
int IsNullable() const
Return whether this geometry field can receive null values.
Definition: ogr_feature.h:319
ogr_featurestyle.h
OGRFieldDefn::SetUnique
void SetUnique(int bUniqueIn)
Set whether this field has a unique constraint.
Definition: ogr_feature.h:211
OGRFeature::SetField
void SetField(const char *pszFName, int nCount, const int *panValues)
Definition: ogr_feature.h:1177
OGRUnsetMarker
#define OGRUnsetMarker
Special value set in OGRField.Set.nMarker1, nMarker2 and nMarker3 for a unset field.
Definition: ogr_core.h:859
OGRRangeFieldDomain
Definition of a numeric field domain with a range of validity for values.
Definition: ogr_feature.h:1518
OGRJustification
OGRJustification
Display justification for field values.
Definition: ogr_core.h:836
OGRFeatureDefn::SetStyleIgnored
virtual void SetStyleIgnored(bool bIgnore)
Set whether the style can be omitted when fetching features.
Definition: ogr_feature.h:624
OGRFieldDefnH
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition: ogr_api.h:357
OGRFieldDomain::GetFieldType
OGRFieldType GetFieldType() const
Get the field type.
Definition: ogr_feature.h:1403
OGRGeomFieldDefn
Definition of a geometry field of an OGRFeatureDefn.
Definition: ogr_feature.h:275
OGRFeature::FieldValue::GetDouble
double GetDouble() const
Return the double value.
Definition: ogr_feature.h:808
OGRFeature::GetFieldAsInteger64List
const GIntBig * GetFieldAsInteger64List(const char *pszFName, int *pnCount) const
Fetch field value as a list of 64 bit integers.
Definition: ogr_feature.h:1111
OGRFieldDomain
Definition of a field domain.
Definition: ogr_feature.h:1341
OGRFeature::FromHandle
static OGRFeature * FromHandle(OGRFeatureH hFeature)
Convert a OGRFeatureH to a OGRFeature*.
Definition: ogr_feature.h:1267
OGRFeatureDefn::Dereference
int Dereference()
Decrements the reference count by one.
Definition: ogr_feature.h:608
end
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:372
OGRFieldDefn::GetType
OGRFieldType GetType() const
Fetch type of this field.
Definition: ogr_feature.h:141
OGRFeatureDefn::GetFieldIndex
virtual int GetFieldIndex(const char *) const
Find field by name.
Definition: ogrfeaturedefn.cpp:1177
OGRFieldDomain::GetFieldSubType
OGRFieldSubType GetFieldSubType() const
Get the field subtype.
Definition: ogr_feature.h:1412
OGRFieldDefn::GetAlternativeNameRef
const char * GetAlternativeNameRef() const
Fetch the alternative name (or "alias") for this field.
Definition: ogr_feature.h:136
OGRFieldDomainSplitPolicy
OGRFieldDomainSplitPolicy
Split policy for field domains.
Definition: ogr_core.h:1228
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:378
OGRFeatureDefn::GetGeomFields
GeomFields GetGeomFields()
Return an object that can be used to iterate over geometry fields.
Definition: ogr_feature.h:590
OGRFieldDomain::ToHandle
static OGRFieldDomainH ToHandle(OGRFieldDomain *poFieldDomain)
Convert a OGRFieldDomain* to a OGRFieldDomainH.
Definition: ogr_feature.h:1418
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:235
OGRFeature::GetFieldDefnRef
const OGRFieldDefn * GetFieldDefnRef(int iField) const
Fetch definition for this field.
Definition: ogr_feature.h:998
OGRFeature::FieldValue::GetInteger
int GetInteger() const
Return the integer value.
Definition: ogr_feature.h:790
OGRFeature::GetRawFieldRef
const OGRField * GetRawFieldRef(int i) const
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:1025
OGRwkbGeometryType
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:406
OGRFieldDefn::IsIgnored
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:189
OGRFeature::SetField
void SetField(const char *pszFName, double dfValue)
Set field to double value.
Definition: ogr_feature.h:1169
CPL_WARN_UNUSED_RESULT
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:985
OGRFeature::GetRawFieldRef
OGRField * GetRawFieldRef(int i)
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:1021
OGRFeatureDefn::Reference
int Reference()
Increments the reference count by one.
Definition: ogr_feature.h:604
OGRCodedFieldDomain
Definition of a coded / enumerated field domain.
Definition: ogr_feature.h:1472
OGRFeature
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:669
OGRFeature::end
ConstFieldIterator end() const
Return end of field value iterator.
Definition: ogrfeature.cpp:7460
OGRFeature::GetGeomFieldDefnRef
const OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField) const
Fetch definition for this geometry field.
Definition: ogr_feature.h:972
OGRGeomFieldDefn::GetType
OGRwkbGeometryType GetType() const
Fetch geometry type of this field.
Definition: ogr_feature.h:301
OGRFeature::GetNativeMediaType
const char * GetNativeMediaType() const
Returns the native media type for the feature.
Definition: ogr_feature.h:1246
OGRFieldSubType
OGRFieldSubType
List of field subtypes.
Definition: ogr_core.h:811
OGRFieldDefn::SetNullable
void SetNullable(int bNullableIn)
Set whether this field can receive null values.
Definition: ogr_feature.h:202
OGRGeomFieldDefn::SetNullable
void SetNullable(int bNullableIn)
Set whether this geometry field can receive null values.
Definition: ogr_feature.h:323
OGRRangeFieldDomain::Clone
OGRRangeFieldDomain * Clone() const override
Clone.
Definition: ogr_feature.h:1563
OGRGeomFieldDefn::FromHandle
static OGRGeomFieldDefn * FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
Convert a OGRGeomFieldDefnH to a OGRGeomFieldDefn*.
Definition: ogr_feature.h:341
OGRFeatureDefn::ToHandle
static OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
Convert a OGRFeatureDefn* to a OGRFeatureDefnH.
Definition: ogr_feature.h:644
OGRFieldDefn::IsNullable
int IsNullable() const
Return whether this field can receive null values.
Definition: ogr_feature.h:198
OGRFieldType
OGRFieldType
List of feature field types.
Definition: ogr_core.h:783
OGRFeatureDefnH
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition: ogr_feature.h:64
OGRFeatureDefn::GetGeomFieldCount
virtual int GetGeomFieldCount() const
Fetch number of geometry fields on this feature.
Definition: ogrfeaturedefn.cpp:591
OGRFeature::GetFieldAsInteger64
GIntBig GetFieldAsInteger64(const char *pszFName) const
Fetch field value as integer 64 bit.
Definition: ogr_feature.h:1090
OGRFeature::GetFieldAsString
const char * GetFieldAsString(const char *pszFName) const
Fetch field value as a string.
Definition: ogr_feature.h:1098
OGRFeature::FieldValue::GetInteger64
GIntBig GetInteger64() const
Return the 64-bit integer value.
Definition: ogr_feature.h:799
OGRFeature::SetField
void SetField(const char *pszFName, const char *const *papszValues)
Definition: ogr_feature.h:1189
OGRFieldDefn::SetWidth
void SetWidth(int nWidthIn)
Set the formatting width for this field in characters.
Definition: ogr_feature.h:168
OGRFeatureDefn
Definition of a feature class or feature layer.
Definition: ogr_feature.h:374
OGRGlobFieldDomain::GetGlob
const std::string & GetGlob() const
Get the glob expression.
Definition: ogr_feature.h:1653
OGRFeature::GetFieldAsInteger
int GetFieldAsInteger(const char *pszFName) const
Fetch field value as integer.
Definition: ogr_feature.h:1086
OGRFeatureDefn::GetReferenceCount
int GetReferenceCount() const
Fetch current reference count.
Definition: ogr_feature.h:612
OGRFieldDefn::GetSubType
OGRFieldSubType GetSubType() const
Fetch subtype of this field.
Definition: ogr_feature.h:148
OGRFeature::SetField
void SetField(const char *pszFName, int nValue)
Set field to integer value. OFTInteger, OFTInteger64 and OFTReal fields will be set directly....
Definition: ogr_feature.h:1161
OGRFeature::GetFieldAsIntegerList
const int * GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
Fetch field value as a list of integers.
Definition: ogr_feature.h:1107
wkbUnknown
@ wkbUnknown
unknown type, non-standard
Definition: ogr_core.h:408
OGRFieldDomainH
struct OGRFieldDomainHS * OGRFieldDomainH
Opaque type for a field domain definition (OGRFieldDomain)
Definition: ogr_feature.h:74
OGRGlobFieldDomain::Clone
OGRGlobFieldDomain * Clone() const override
Clone.
Definition: ogr_feature.h:1640
CPL_DISALLOW_COPY_ASSIGN
#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:1051
OGRFieldDefn::GetJustify
OGRJustification GetJustify() const
Get the justification for this field.
Definition: ogr_feature.h:155
OGRFeature::GetNativeData
const char * GetNativeData() const
Returns the native data for the feature.
Definition: ogr_feature.h:1242
OGRFeature::GetFieldAsISO8601DateTime
const char * GetFieldAsISO8601DateTime(const char *pszFName, CSLConstList papszOptions) const
Fetch OFTDateTime field value as a ISO8601 representation.
Definition: ogr_feature.h:1102
OGRFieldDomain::GetDomainType
OGRFieldDomainType GetDomainType() const
Get the type of the field domain.
Definition: ogr_feature.h:1394
OGRFeature::GetFID
GIntBig GetFID() const
Get feature identifier.
Definition: ogr_feature.h:1205
OGRFeature::SetField
void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
Set field to list of 64 bit integers value.
Definition: ogr_feature.h:1181
OGRFieldDefn::ToHandle
static OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
Convert a OGRFieldDefn* to a OGRFieldDefnH.
Definition: ogr_feature.h:239