31 #ifndef OGR_FEATURE_H_INCLUDED 32 #define OGR_FEATURE_H_INCLUDED 34 #include "cpl_atomic_ops.h" 49 #ifndef DEFINE_OGRFeatureH 51 #define DEFINE_OGRFeatureH 112 void SetName(
const char * );
125 { eJustify = eJustifyIn; }
132 { nPrecision = nPrecisionIn; }
137 void SetDefault(
const char* );
138 const char *GetDefault()
const;
139 int IsDefaultDriverSpecific()
const;
186 char *pszName =
nullptr;
191 mutable int bNullable =
true;
202 void SetName(
const char * );
216 { bNullable = bNullableIn; }
263 volatile int nRefCount;
265 mutable int nFieldCount;
268 mutable int nGeomFieldCount;
271 char *pszFeatureClassName;
280 void SetName(
const char* pszName );
281 virtual const char *GetName()
const;
283 virtual int GetFieldCount()
const;
285 virtual const OGRFieldDefn *GetFieldDefn(
int i )
const;
286 virtual int GetFieldIndex(
const char * )
const;
287 int GetFieldIndexCaseSensitive(
const char * )
const;
290 virtual OGRErr DeleteFieldDefn(
int iField );
291 virtual OGRErr ReorderFieldDefns(
int* panMap );
293 virtual int GetGeomFieldCount()
const;
296 virtual int GetGeomFieldIndex(
const char * )
const;
300 virtual OGRErr DeleteGeomFieldDefn(
int iGeomField );
312 virtual int IsGeometryIgnored()
const;
313 virtual void SetGeometryIgnored(
int bIgnore );
316 { bIgnoreStyle = bIgnore; }
318 virtual int IsSame(
const OGRFeatureDefn * poOtherFeatureDefn )
const;
321 void ReserveSpaceForFields(
int nFieldCountIn);
324 std::vector<int> ComputeMapForSetFrom(
const OGRFeatureDefn* poSrcFDefn,
325 bool bForgiving =
true )
const;
327 static OGRFeatureDefn *CreateFeatureDefn(
const char *pszName =
nullptr );
362 char *m_pszNativeData;
363 char *m_pszNativeMediaType;
365 bool SetFieldInternal(
int i,
OGRField * puValue );
369 mutable char *m_pszStyleString;
371 mutable char *m_pszTmpFieldValue;
385 std::unique_ptr<Private> m_poPrivate;
407 FieldValue& operator= (
const std::string& osVal);
409 FieldValue& operator= (
const std::vector<int>& oArray);
411 FieldValue& operator= (
const std::vector<GIntBig>& oArray);
413 FieldValue& operator= (
const std::vector<double>& oArray);
415 FieldValue& operator= (
const std::vector<std::string>& oArray);
425 void SetDateTime(
int nYear,
int nMonth,
int nDay,
426 int nHour=0,
int nMinute=0,
float fSecond=0.f,
430 int GetIndex()
const;
442 bool empty()
const {
return IsUnset(); }
446 bool IsUnset()
const;
453 const OGRField *GetRawValue()
const;
471 double GetDouble()
const {
return GetRawValue()->Real; }
477 const char*
GetString()
const {
return GetRawValue()->String; }
480 bool GetDateTime(
int *pnYear,
int *pnMonth,
482 int *pnHour,
int *pnMinute,
484 int *pnTZFlag )
const;
487 operator int ()
const {
return GetAsInteger(); }
489 operator GIntBig()
const {
return GetAsInteger64(); }
491 operator double ()
const {
return GetAsDouble(); }
493 operator const char*()
const {
return GetAsString(); }
495 operator const std::vector<int>& ()
const {
return GetAsIntegerList(); }
497 operator const std::vector<GIntBig>& ()
const {
return GetAsInteger64List(); }
499 operator const std::vector<double>& ()
const {
return GetAsDoubleList(); }
501 operator const std::vector<std::string>& ()
const {
return GetAsStringList(); }
506 int GetAsInteger()
const;
508 GIntBig GetAsInteger64()
const;
510 double GetAsDouble()
const;
512 const char* GetAsString()
const;
514 const std::vector<int>& GetAsIntegerList()
const;
516 const std::vector<GIntBig>& GetAsInteger64List()
const;
518 const std::vector<double>& GetAsDoubleList()
const;
520 const std::vector<std::string>& GetAsStringList()
const;
528 std::unique_ptr<Private> m_poPrivate;
562 const FieldValue operator[](
int iField)
const;
568 const FieldValue operator[](
const char* pszFieldName)
const;
569 FieldValue operator[](
const char* pszFieldName);
590 const OGRGeometry* GetGeomFieldRef(
int iField )
const;
592 OGRGeometry* GetGeomFieldRef(
const char* pszFName );
593 const OGRGeometry* GetGeomFieldRef(
const char* pszFName )
const;
609 int IsFieldSet(
int iField )
const;
611 void UnsetField(
int iField );
613 bool IsFieldNull(
int iField )
const;
615 void SetFieldNull(
int iField );
617 bool IsFieldSetAndNotNull(
int iField )
const;
622 int GetFieldAsInteger(
int i )
const;
623 GIntBig GetFieldAsInteger64(
int i )
const;
624 double GetFieldAsDouble(
int i )
const;
625 const char *GetFieldAsString(
int i )
const;
626 const int *GetFieldAsIntegerList(
int i,
int *pnCount )
const;
627 const GIntBig *GetFieldAsInteger64List(
int i,
int *pnCount )
const;
628 const double *GetFieldAsDoubleList(
int i,
int *pnCount )
const;
629 char **GetFieldAsStringList(
int i )
const;
630 GByte *GetFieldAsBinary(
int i,
int *pnCount )
const;
631 int GetFieldAsDateTime(
int i,
632 int *pnYear,
int *pnMonth,
634 int *pnHour,
int *pnMinute,
636 int *pnTZFlag )
const;
637 int GetFieldAsDateTime(
int i,
638 int *pnYear,
int *pnMonth,
640 int *pnHour,
int *pnMinute,
642 int *pnTZFlag )
const;
643 char *GetFieldAsSerializedJSon(
int i )
const;
646 {
return GetFieldAsInteger( GetFieldIndex(pszFName) ); }
648 {
return GetFieldAsInteger64( GetFieldIndex(pszFName) ); }
650 {
return GetFieldAsDouble( GetFieldIndex(pszFName) ); }
652 {
return GetFieldAsString( GetFieldIndex(pszFName) ); }
655 {
return GetFieldAsIntegerList( GetFieldIndex(pszFName),
659 {
return GetFieldAsInteger64List( GetFieldIndex(pszFName),
663 {
return GetFieldAsDoubleList( GetFieldIndex(pszFName),
666 {
return GetFieldAsStringList(GetFieldIndex(pszFName)); }
668 void SetField(
int i,
int nValue );
669 void SetField(
int i,
GIntBig nValue );
670 void SetField(
int i,
double dfValue );
671 void SetField(
int i,
const char * pszValue );
672 void SetField(
int i,
int nCount,
const int * panValues );
673 void SetField(
int i,
int nCount,
675 void SetField(
int i,
int nCount,
const double * padfValues );
676 void SetField(
int i,
const char *
const * papszValues );
677 void SetField(
int i,
OGRField * puValue );
678 void SetField(
int i,
int nCount,
GByte * pabyBinary );
679 void SetField(
int i,
int nYear,
int nMonth,
int nDay,
680 int nHour=0,
int nMinute=0,
float fSecond=0.f,
684 { SetField( GetFieldIndex(pszFName), nValue ); }
686 { SetField( GetFieldIndex(pszFName), nValue ); }
687 void SetField(
const char *pszFName,
double dfValue )
688 { SetField( GetFieldIndex(pszFName), dfValue ); }
689 void SetField(
const char *pszFName,
const char * pszValue )
690 { SetField( GetFieldIndex(pszFName), pszValue ); }
692 const int * panValues )
693 { SetField(GetFieldIndex(pszFName),nCount,panValues); }
696 { SetField(GetFieldIndex(pszFName),nCount,panValues); }
698 const double * padfValues )
699 {SetField(GetFieldIndex(pszFName),nCount,padfValues); }
700 void SetField(
const char *pszFName,
const char *
const * papszValues )
701 { SetField( GetFieldIndex(pszFName), papszValues); }
703 { SetField( GetFieldIndex(pszFName), puValue ); }
705 int nYear,
int nMonth,
int nDay,
706 int nHour=0,
int nMinute=0,
float fSecond=0.f,
708 { SetField( GetFieldIndex(pszFName),
710 nHour, nMinute, fSecond, nTZFlag ); }
715 void DumpReadable( FILE *,
char** papszOptions =
nullptr )
const;
723 const int *panRemapSource );
726 const int *panRemapSource );
729 int Validate(
int nValidateFlags,
730 int bEmitError )
const;
731 void FillUnsetWithDefault(
int bNotNullableOnly,
732 char** papszOptions );
734 virtual const char *GetStyleString()
const;
735 virtual void SetStyleString(
const char * );
736 virtual void SetStyleStringDirectly(
char * );
743 virtual void SetStyleTableDirectly(
OGRStyleTable *poStyleTable );
747 {
return m_pszNativeMediaType; }
748 void SetNativeData(
const char* pszNativeData );
749 void SetNativeMediaType(
const char* pszNativeMediaType );
758 {
return reinterpret_cast<OGRFeatureH>(poFeature); }
764 {
return reinterpret_cast<OGRFeature*
>(hFeature); }
771 struct CPL_DLL OGRFeatureUniquePtrDeleter
802 class swq_custom_func_registrar;
804 class CPL_DLL OGRFeatureQuery
810 char **FieldCollector(
void *,
char ** );
815 int CanUseIndex( swq_expr_node*,
OGRLayer * );
819 swq_custom_func_registrar* poCustomFuncRegistrar );
829 swq_custom_func_registrar*
830 poCustomFuncRegistrar =
nullptr );
833 swq_custom_func_registrar*
834 poCustomFuncRegistrar =
nullptr );
841 char **GetUsedFields();
843 void *GetSWQExpr() {
return pSWQExpr; }
static OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
Convert a OGRFeatureDefn* to a OGRFeatureDefnH.
Definition: ogr_feature.h:333
void SetField(const char *pszFName, int nCount, const int *panValues)
Set field to list of integers value.
Definition: ogr_feature.h:691
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition: ogr_feature.h:780
void SetField(const char *pszFName, int nCount, const double *padfValues)
Set field to list of doubles value.
Definition: ogr_feature.h:697
int GetPrecision() const
Get the formatting precision for this field.
Definition: ogr_feature.h:130
OGRFieldSubType
List of field subtypes.
Definition: ogr_core.h:622
static OGRFeature * FromHandle(OGRFeatureH hFeature)
Convert a OGRFeatureH to a OGRFeature*.
Definition: ogr_feature.h:763
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition: ogr_feature.h:69
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition: ogr_feature.h:64
double GetDouble() const
Return the double value.
Definition: ogr_feature.h:471
int IsNullable() const
Return whether this geometry field can receive null values.
Definition: ogr_feature.h:214
void SetField(const char *pszFName, double dfValue)
Set field to double value.
Definition: ogr_feature.h:687
OGRwkbGeometryType GetType() const
Fetch geometry type of this field.
Definition: ogr_feature.h:205
OGRJustification GetJustify() const
Get the justification for this field.
Definition: ogr_feature.h:123
OGRField * GetRawFieldRef(int i)
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:619
static OGRFeatureDefn * FromHandle(OGRFeatureDefnH hFeatureDefn)
Convert a OGRFeatureDefnH to a OGRFeatureDefn*.
Definition: ogr_feature.h:339
int GetGeomFieldCount() const
Fetch number of geometry fields on this feature.
Definition: ogr_feature.h:580
void SetNullable(int bNullableIn)
Set whether this geometry field can receive null values.
Definition: ogr_feature.h:215
Definition of a geometry field of an OGRFeatureDefn.
Definition: ogr_feature.h:182
const OGRFeatureDefn * GetDefnRef() const
Fetch feature definition.
Definition: ogr_feature.h:572
static OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
Convert a OGRFieldDefn* to a OGRFieldDefnH.
Definition: ogr_feature.h:152
const OGRFieldDefn * GetFieldDefnRef(int iField) const
Fetch definition for this field.
Definition: ogr_feature.h:602
static OGRGeomFieldDefn * FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
Convert a OGRGeomFieldDefnH to a OGRGeomFieldDefn*.
Definition: ogr_feature.h:229
virtual void SetStyleIgnored(int bIgnore)
Set whether the style can be omitted when fetching features.
Definition: ogr_feature.h:315
void SetField(const char *pszFName, OGRField *puValue)
Set field.
Definition: ogr_feature.h:702
Exception raised by operator[](const char*) when a field is not found.
Definition: ogr_feature.h:566
const OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField) const
Fetch definition for this geometry field.
Definition: ogr_feature.h:584
ConstFieldIterator end() const
Return end of field value iterator.
Definition: ogrfeature.cpp:7093
virtual int GetGeomFieldCount() const
Fetch number of geometry fields on this feature.
Definition: ogrfeaturedefn.cpp:631
int OGRBoolean
Type for a OGR boolean.
Definition: ogr_core.h:306
void * OGRStyleTableH
Opaque type for a style table (OGRStyleTable)
Definition: ogr_feature.h:66
const OGRField * GetRawFieldRef(int i) const
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:620
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:215
const GIntBig * GetFieldAsInteger64List(const char *pszFName, int *pnCount) const
Fetch field value as a list of 64 bit integers.
Definition: ogr_feature.h:657
const char * GetNativeMediaType() const
Returns the native media type for the feature.
Definition: ogr_feature.h:746
Definition of a feature class or feature layer.
Definition: ogr_feature.h:259
unknown type, non-standard
Definition: ogr_core.h:319
static OGRFieldDefn * FromHandle(OGRFieldDefnH hFieldDefn)
Convert a OGRFieldDefnH to a OGRFieldDefn*.
Definition: ogr_feature.h:158
const char * GetFieldAsString(const char *pszFName) const
Fetch field value as a string.
Definition: ogr_feature.h:651
void SetField(const char *pszFName, const char *const *papszValues)
Set field to list of strings value.
Definition: ogr_feature.h:700
virtual int GetGeomFieldIndex(const char *) const
Find geometry field by name.
Definition: ogrfeaturedefn.cpp:915
const int * GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
Fetch field value as a list of integers.
Definition: ogr_feature.h:653
GIntBig GetFieldAsInteger64(const char *pszFName) const
Fetch field value as integer 64 bit.
Definition: ogr_feature.h:647
OGRFieldSubType GetSubType() const
Return field subtype.
Definition: ogr_feature.h:438
Simple feature style classes.
void SetField(const char *pszFName, int nValue)
Set field to integer value.
Definition: ogr_feature.h:683
Definition of an attribute of an OGRFeatureDefn.
Definition: ogr_feature.h:92
virtual int GetFieldCount() const
Fetch number of fields on this feature.
Definition: ogrfeaturedefn.cpp:285
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition: ogr_feature.h:60
#define MAX(a, b)
Macro to compute the maximum of 2 values.
Definition: cpl_port.h:399
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition: ogr_api.h:297
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition: ogr_api.h:306
virtual int IsStyleIgnored() const
Determine whether the style can be omitted when fetching features.
Definition: ogr_feature.h:314
int GetReferenceCount() const
Fetch current reference count.
Definition: ogr_feature.h:309
void Unset()
Unset the field.
Definition: ogr_feature.h:423
const double * GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
Fetch field value as a list of doubles.
Definition: ogr_feature.h:661
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:317
Field value iterator class.
Definition: ogr_feature.h:524
virtual OGRGeomFieldDefn * GetGeomFieldDefn(int i)
Fetch geometry field definition.
Definition: ogrfeaturedefn.cpp:680
OGRFieldDefn * GetFieldDefnRef(int iField)
Fetch definition for this field.
Definition: ogr_feature.h:604
const char * GetNativeData() const
Returns the native data for the feature.
Definition: ogr_feature.h:745
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:113
GIntBig GetFID() const
Get feature identifier.
Definition: ogr_feature.h:712
void SetPrecision(int nPrecisionIn)
Set the formatting precision for this field in characters.
Definition: ogr_feature.h:131
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:286
char ** GetFieldAsStringList(const char *pszFName) const
Fetch field value as a list of strings.
Definition: ogr_feature.h:665
int GetFieldAsInteger(const char *pszFName) const
Fetch field value as integer.
Definition: ogr_feature.h:645
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1186
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:141
static OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
Convert a OGRGeomFieldDefn* to a OGRGeomFieldDefnH.
Definition: ogr_feature.h:223
void SetWidth(int nWidthIn)
Set the formatting width for this field in characters.
Definition: ogr_feature.h:128
Field value.
Definition: ogr_feature.h:381
OGRJustification
Display justification for field values.
Definition: ogr_core.h:642
void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
Set field to list of 64 bit integers value.
Definition: ogr_feature.h:694
virtual OGRStyleTable * GetStyleTable() const
Return style table.
Definition: ogr_feature.h:741
int Reference()
Increments the reference count by one.
Definition: ogr_feature.h:307
int IsNullable() const
Return whether this field can receive null values.
Definition: ogr_feature.h:144
int GetFieldCount() const
Fetch number of fields on this feature.
Definition: ogr_feature.h:600
double GetFieldAsDouble(const char *pszFName) const
Fetch field value as a double.
Definition: ogr_feature.h:649
OGRFieldType
List of feature field types.
Definition: ogr_core.h:594
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition: ogr_feature.h:62
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:147
void SetField(const char *pszFName, GIntBig nValue)
Set field to 64 bit integer value.
Definition: ogr_feature.h:685
const char * GetString() const
Return the string value.
Definition: ogr_feature.h:477
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition: ogr_api.h:301
int Dereference()
Decrements the reference count by one.
Definition: ogr_feature.h:308
OGRFieldSubType GetSubType() const
Fetch subtype of this field.
Definition: ogr_feature.h:119
virtual int GetFieldIndex(const char *) const
Find field by name.
Definition: ogrfeaturedefn.cpp:1217
OGRFeature field attribute value union.
Definition: ogr_core.h:683
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:212
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:70
GIntBig GetInteger64() const
Return the 64-bit integer value.
Definition: ogr_feature.h:465
OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField)
Fetch definition for this geometry field.
Definition: ogr_feature.h:582
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:354
virtual OGRFieldDefn * GetFieldDefn(int i)
Fetch field definition.
Definition: ogrfeaturedefn.cpp:329
ConstFieldIterator begin() const
Return begin of field value iterator.
Definition: ogrfeature.cpp:7088
static OGRFeatureH ToHandle(OGRFeature *poFeature)
Convert a OGRFeature* to a OGRFeatureH.
Definition: ogr_feature.h:757
OGRFieldType GetType() const
Fetch type of this field.
Definition: ogr_feature.h:115
This class represents a style table.
Definition: ogr_featurestyle.h:84
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:248
void SetField(const char *pszFName, const char *pszValue)
Set field to string value.
Definition: ogr_feature.h:689
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:287
bool empty() const
Return whether the field value is unset/empty.
Definition: ogr_feature.h:442
Simple feature geometry classes.
const char * GetName() const
Return field name.
Definition: ogr_feature.h:434
void SetJustify(OGRJustification eJustifyIn)
Set the justification for this field.
Definition: ogr_feature.h:124
int OGRErr
Simple container for a bounding region.
Definition: ogr_core.h:290
int GetFieldIndex(const char *pszName) const
Fetch the field index given field name.
Definition: ogr_feature.h:606
int GetInteger() const
Return the integer value.
Definition: ogr_feature.h:459
OGRFeatureDefn * GetDefnRef()
Fetch feature definition.
Definition: ogr_feature.h:571
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition: ogr_api.h:299
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:292
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:704
OGRFieldType GetType() const
Return field type.
Definition: ogr_feature.h:436
int GetGeomFieldIndex(const char *pszName) const
Fetch the geometry field index given geometry field name.
Definition: ogr_feature.h:586
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:203
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:211
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:142
int GetWidth() const
Get the formatting width for this field.
Definition: ogr_feature.h:127
#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:989
void SetNullable(int bNullableIn)
Set whether this field can receive null values.
Definition: ogr_feature.h:145
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:931