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;
153 {
return reinterpret_cast<OGRFieldDefnH>(poFieldDefn); }
159 {
return reinterpret_cast<OGRFieldDefn*>(hFieldDefn); }
191 mutable int bNullable;
202 void SetName(
const char * );
216 { bNullable = bNullableIn; }
224 {
return reinterpret_cast<OGRGeomFieldDefnH>(poGeomFieldDefn); }
230 {
return reinterpret_cast<OGRGeomFieldDefn*>(hGeomFieldDefn); }
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;
289 virtual OGRErr DeleteFieldDefn(
int iField );
290 virtual OGRErr ReorderFieldDefns(
int* panMap );
292 virtual int GetGeomFieldCount()
const;
295 virtual int GetGeomFieldIndex(
const char * )
const;
299 virtual OGRErr DeleteGeomFieldDefn(
int iGeomField );
311 virtual int IsGeometryIgnored()
const;
312 virtual void SetGeometryIgnored(
int bIgnore );
315 { bIgnoreStyle = bIgnore; }
317 virtual int IsSame(
const OGRFeatureDefn * poOtherFeatureDefn )
const;
320 void ReserveSpaceForFields(
int nFieldCountIn);
323 std::vector<int> ComputeMapForSetFrom(
const OGRFeatureDefn* poSrcFDefn,
324 bool bForgiving =
true )
const;
326 static OGRFeatureDefn *CreateFeatureDefn(
const char *pszName =
nullptr );
333 {
return reinterpret_cast<OGRFeatureDefnH>(poFeatureDefn); }
339 {
return reinterpret_cast<OGRFeatureDefn*>(hFeatureDefn); }
361 char *m_pszNativeData;
362 char *m_pszNativeMediaType;
364 bool SetFieldInternal(
int i,
OGRField * puValue );
368 mutable char *m_pszStyleString;
370 mutable char *m_pszTmpFieldValue;
384 std::unique_ptr<Private> m_poPrivate;
406 FieldValue& operator= (
const std::string& osVal);
408 FieldValue& operator= (
const std::vector<int>& oArray);
410 FieldValue& operator= (
const std::vector<GIntBig>& oArray);
412 FieldValue& operator= (
const std::vector<double>& oArray);
414 FieldValue& operator= (
const std::vector<std::string>& oArray);
424 void SetDateTime(
int nYear,
int nMonth,
int nDay,
425 int nHour=0,
int nMinute=0,
float fSecond=0.f,
429 int GetIndex()
const;
433 const char*
GetName()
const {
return GetDefn()->GetNameRef(); }
441 bool empty()
const {
return IsUnset(); }
445 bool IsUnset()
const;
452 const OGRField *GetRawValue()
const;
470 double GetDouble()
const {
return GetRawValue()->Real; }
476 const char*
GetString()
const {
return GetRawValue()->String; }
479 bool GetDateTime(
int *pnYear,
int *pnMonth,
481 int *pnHour,
int *pnMinute,
483 int *pnTZFlag )
const;
486 operator int ()
const {
return GetAsInteger(); }
488 operator GIntBig()
const {
return GetAsInteger64(); }
490 operator double ()
const {
return GetAsDouble(); }
492 operator const char*()
const {
return GetAsString(); }
494 operator const std::vector<int>& ()
const {
return GetAsIntegerList(); }
496 operator const std::vector<GIntBig>& ()
const {
return GetAsInteger64List(); }
498 operator const std::vector<double>& ()
const {
return GetAsDoubleList(); }
500 operator const std::vector<std::string>& ()
const {
return GetAsStringList(); }
505 int GetAsInteger()
const;
507 GIntBig GetAsInteger64()
const;
509 double GetAsDouble()
const;
511 const char* GetAsString()
const;
513 const std::vector<int>& GetAsIntegerList()
const;
515 const std::vector<GIntBig>& GetAsInteger64List()
const;
517 const std::vector<double>& GetAsDoubleList()
const;
519 const std::vector<std::string>& GetAsStringList()
const;
527 std::unique_ptr<Private> m_poPrivate;
561 const FieldValue operator[](
int iField)
const;
567 const FieldValue operator[](
const char* pszFieldName)
const;
568 FieldValue operator[](
const char* pszFieldName);
579 int GetGeomFieldCount()
const 589 const OGRGeometry* GetGeomFieldRef(
int iField )
const;
591 OGRGeometry* GetGeomFieldRef(
const char* pszFName );
592 const OGRGeometry* GetGeomFieldRef(
const char* pszFName )
const;
599 int GetFieldCount()
const 608 int IsFieldSet(
int iField )
const;
610 void UnsetField(
int iField );
612 bool IsFieldNull(
int iField )
const;
614 void SetFieldNull(
int iField );
616 bool IsFieldSetAndNotNull(
int iField )
const;
621 int GetFieldAsInteger(
int i )
const;
622 GIntBig GetFieldAsInteger64(
int i )
const;
623 double GetFieldAsDouble(
int i )
const;
624 const char *GetFieldAsString(
int i )
const;
625 const int *GetFieldAsIntegerList(
int i,
int *pnCount )
const;
626 const GIntBig *GetFieldAsInteger64List(
int i,
int *pnCount )
const;
627 const double *GetFieldAsDoubleList(
int i,
int *pnCount )
const;
628 char **GetFieldAsStringList(
int i )
const;
629 GByte *GetFieldAsBinary(
int i,
int *pnCount )
const;
630 int GetFieldAsDateTime(
int i,
631 int *pnYear,
int *pnMonth,
633 int *pnHour,
int *pnMinute,
635 int *pnTZFlag )
const;
636 int GetFieldAsDateTime(
int i,
637 int *pnYear,
int *pnMonth,
639 int *pnHour,
int *pnMinute,
641 int *pnTZFlag )
const;
642 char *GetFieldAsSerializedJSon(
int i )
const;
645 {
return GetFieldAsInteger( GetFieldIndex(pszFName) ); }
647 {
return GetFieldAsInteger64( GetFieldIndex(pszFName) ); }
649 {
return GetFieldAsDouble( GetFieldIndex(pszFName) ); }
651 {
return GetFieldAsString( GetFieldIndex(pszFName) ); }
654 {
return GetFieldAsIntegerList( GetFieldIndex(pszFName),
658 {
return GetFieldAsInteger64List( GetFieldIndex(pszFName),
662 {
return GetFieldAsDoubleList( GetFieldIndex(pszFName),
665 {
return GetFieldAsStringList(GetFieldIndex(pszFName)); }
667 void SetField(
int i,
int nValue );
668 void SetField(
int i,
GIntBig nValue );
669 void SetField(
int i,
double dfValue );
670 void SetField(
int i,
const char * pszValue );
671 void SetField(
int i,
int nCount,
const int * panValues );
672 void SetField(
int i,
int nCount,
674 void SetField(
int i,
int nCount,
const double * padfValues );
675 void SetField(
int i,
const char *
const * papszValues );
676 void SetField(
int i,
OGRField * puValue );
677 void SetField(
int i,
int nCount,
GByte * pabyBinary );
678 void SetField(
int i,
int nYear,
int nMonth,
int nDay,
679 int nHour=0,
int nMinute=0,
float fSecond=0.f,
683 { SetField( GetFieldIndex(pszFName), nValue ); }
685 { SetField( GetFieldIndex(pszFName), nValue ); }
686 void SetField(
const char *pszFName,
double dfValue )
687 { SetField( GetFieldIndex(pszFName), dfValue ); }
688 void SetField(
const char *pszFName,
const char * pszValue )
689 { SetField( GetFieldIndex(pszFName), pszValue ); }
691 const int * panValues )
692 { SetField(GetFieldIndex(pszFName),nCount,panValues); }
695 { SetField(GetFieldIndex(pszFName),nCount,panValues); }
697 const double * padfValues )
698 {SetField(GetFieldIndex(pszFName),nCount,padfValues); }
699 void SetField(
const char *pszFName,
const char *
const * papszValues )
700 { SetField( GetFieldIndex(pszFName), papszValues); }
702 { SetField( GetFieldIndex(pszFName), puValue ); }
704 int nYear,
int nMonth,
int nDay,
705 int nHour=0,
int nMinute=0,
float fSecond=0.f,
707 { SetField( GetFieldIndex(pszFName),
709 nHour, nMinute, fSecond, nTZFlag ); }
714 void DumpReadable( FILE *,
char** papszOptions =
nullptr )
const;
722 const int *panRemapSource );
725 const int *panRemapSource );
728 int Validate(
int nValidateFlags,
729 int bEmitError )
const;
730 void FillUnsetWithDefault(
int bNotNullableOnly,
731 char** papszOptions );
733 virtual const char *GetStyleString()
const;
734 virtual void SetStyleString(
const char * );
735 virtual void SetStyleStringDirectly(
char * );
742 virtual void SetStyleTableDirectly(
OGRStyleTable *poStyleTable );
746 {
return m_pszNativeMediaType; }
747 void SetNativeData(
const char* pszNativeData );
748 void SetNativeMediaType(
const char* pszNativeMediaType );
757 {
return reinterpret_cast<OGRFeatureH>(poFeature); }
763 {
return reinterpret_cast<OGRFeature*>(hFeature); }
770 struct CPL_DLL OGRFeatureUniquePtrDeleter
801 class swq_custom_func_registrar;
803 class CPL_DLL OGRFeatureQuery
809 char **FieldCollector(
void *,
char ** );
814 int CanUseIndex( swq_expr_node*,
OGRLayer * );
818 swq_custom_func_registrar* poCustomFuncRegistrar );
825 swq_custom_func_registrar*
826 poCustomFuncRegistrar =
nullptr );
829 swq_custom_func_registrar*
830 poCustomFuncRegistrar =
nullptr );
837 char **GetUsedFields();
839 void *GetSWQExpr() {
return pSWQExpr; }
static OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
Definition: ogr_feature.h:332
void SetField(const char *pszFName, int nCount, const int *panValues)
Set field to list of integers value.
Definition: ogr_feature.h:690
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Definition: ogr_feature.h:779
void SetField(const char *pszFName, int nCount, const double *padfValues)
Set field to list of doubles value.
Definition: ogr_feature.h:696
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:130
OGRFieldSubType
Definition: ogr_core.h:622
static OGRFeature * FromHandle(OGRFeatureH hFeature)
Definition: ogr_feature.h:762
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Definition: ogr_feature.h:69
void * OGRFeatureH
Definition: ogr_feature.h:64
double GetDouble() const
Definition: ogr_feature.h:470
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:686
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:618
static OGRFeatureDefn * FromHandle(OGRFeatureDefnH hFeatureDefn)
Definition: ogr_feature.h:338
void SetNullable(int bNullableIn)
Set whether this geometry field can receive null values.
Definition: ogr_feature.h:215
Definition: ogr_feature.h:182
const OGRFeatureDefn * GetDefnRef() const
Fetch feature definition.
Definition: ogr_feature.h:571
static OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
Definition: ogr_feature.h:152
const OGRFieldDefn * GetFieldDefnRef(int iField) const
Fetch definition for this field.
Definition: ogr_feature.h:601
static OGRGeomFieldDefn * FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
Definition: ogr_feature.h:229
virtual void SetStyleIgnored(int bIgnore)
Set whether the style can be omitted when fetching features.
Definition: ogr_feature.h:314
void SetField(const char *pszFName, OGRField *puValue)
Set field.
Definition: ogr_feature.h:701
Definition: ogr_feature.h:565
const OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField) const
Fetch definition for this geometry field.
Definition: ogr_feature.h:583
ConstFieldIterator end() const
Definition: ogrfeature.cpp:7091
virtual int GetGeomFieldCount() const
Fetch number of geometry fields on this feature.
Definition: ogrfeaturedefn.cpp:631
int OGRBoolean
Definition: ogr_core.h:306
void * OGRStyleTableH
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:619
unsigned char GByte
Definition: cpl_port.h:213
const GIntBig * GetFieldAsInteger64List(const char *pszFName, int *pnCount) const
Fetch field value as a list of 64 bit integers.
Definition: ogr_feature.h:656
const char * GetNativeMediaType() const
Returns the native media type for the feature.
Definition: ogr_feature.h:745
Definition: ogr_feature.h:259
Definition: ogrfeature.cpp:7047
static OGRFieldDefn * FromHandle(OGRFieldDefnH hFieldDefn)
Definition: ogr_feature.h:158
const char * GetFieldAsString(const char *pszFName) const
Fetch field value as a string.
Definition: ogr_feature.h:650
void SetField(const char *pszFName, const char *const *papszValues)
Set field to list of strings value.
Definition: ogr_feature.h:699
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:652
GIntBig GetFieldAsInteger64(const char *pszFName) const
Fetch field value as integer 64 bit.
Definition: ogr_feature.h:646
OGRFieldSubType GetSubType() const
Definition: ogr_feature.h:437
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:682
Definition: ogr_feature.h:92
virtual int GetFieldCount() const
Fetch number of fields on this feature.
Definition: ogrfeaturedefn.cpp:285
void * OGRFieldDefnH
Definition: ogr_feature.h:60
#define MAX(a, b)
Definition: cpl_port.h:397
void * OGRFieldDefnH
Definition: ogr_api.h:297
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Definition: ogr_api.h:306
virtual int IsStyleIgnored() const
Determine whether the style can be omitted when fetching features.
Definition: ogr_feature.h:313
int GetReferenceCount() const
Fetch current reference count.
Definition: ogr_feature.h:308
void Unset()
Definition: ogr_feature.h:422
const double * GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
Fetch field value as a list of doubles.
Definition: ogr_feature.h:660
OGRwkbGeometryType
Definition: ogr_core.h:317
Definition: ogr_feature.h:523
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:603
const char * GetNativeData() const
Returns the native data for the feature.
Definition: ogr_feature.h:744
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:113
GIntBig GetFID() const
Get feature identifier.
Definition: ogr_feature.h:711
void SetPrecision(int nPrecisionIn)
Set the formatting precision for this field in characters.
Definition: ogr_feature.h:131
Definition: ogr_geometry.h:286
char ** GetFieldAsStringList(const char *pszFName) const
Fetch field value as a list of strings.
Definition: ogr_feature.h:664
int GetFieldAsInteger(const char *pszFName) const
Fetch field value as integer.
Definition: ogr_feature.h:644
char ** CSLConstList
Definition: cpl_port.h:1184
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:141
static OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
Definition: ogr_feature.h:223
void SetWidth(int nWidthIn)
Set the formatting width for this field in characters.
Definition: ogr_feature.h:128
Definition: ogr_feature.h:380
OGRJustification
Definition: ogr_core.h:638
void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
Set field to list of 64 bit integers value.
Definition: ogr_feature.h:693
virtual OGRStyleTable * GetStyleTable() const
Definition: ogr_feature.h:740
int Reference()
Increments the reference count by one.
Definition: ogr_feature.h:306
int IsNullable() const
Return whether this field can receive null values.
Definition: ogr_feature.h:144
double GetFieldAsDouble(const char *pszFName) const
Fetch field value as a double.
Definition: ogr_feature.h:648
OGRFieldType
Definition: ogr_core.h:594
void * OGRFeatureDefnH
Definition: ogr_feature.h:62
Definition: ogr_spatialref.h:145
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:684
const char * GetString() const
Definition: ogr_feature.h:476
void * OGRFeatureH
Definition: ogr_api.h:301
int Dereference()
Decrements the reference count by one.
Definition: ogr_feature.h:307
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
Definition: ogr_core.h:679
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:212
Definition: ogrsf_frmts.h:70
Definition: ogrfeature.cpp:7030
GIntBig GetInteger64() const
Definition: ogr_feature.h:464
OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField)
Fetch definition for this geometry field.
Definition: ogr_feature.h:581
Definition: ogr_feature.h:353
virtual OGRFieldDefn * GetFieldDefn(int i)
Fetch field definition.
Definition: ogrfeaturedefn.cpp:329
ConstFieldIterator begin() const
Definition: ogrfeature.cpp:7086
static OGRFeatureH ToHandle(OGRFeature *poFeature)
Definition: ogr_feature.h:756
OGRFieldType GetType() const
Fetch type of this field.
Definition: ogr_feature.h:115
Definition: ogr_featurestyle.h:84
long long GIntBig
Definition: cpl_port.h:246
void SetField(const char *pszFName, const char *pszValue)
Set field to string value.
Definition: ogr_feature.h:688
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Definition: ogrsf_frmts.h:285
bool empty() const
Definition: ogr_feature.h:441
const char * GetName() const
Definition: ogr_feature.h:433
void SetJustify(OGRJustification eJustifyIn)
Set the justification for this field.
Definition: ogr_feature.h:124
int OGRErr
Definition: ogr_core.h:290
int GetFieldIndex(const char *pszName) const
Fetch the field index given field name.
Definition: ogr_feature.h:605
int GetInteger() const
Definition: ogr_feature.h:458
OGRFeatureDefn * GetDefnRef()
Fetch feature definition.
Definition: ogr_feature.h:570
void * OGRFeatureDefnH
Definition: ogr_api.h:299
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Definition: ogrsf_frmts.h:290
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:703
OGRFieldType GetType() const
Definition: ogr_feature.h:435
int GetGeomFieldIndex(const char *pszName) const
Fetch the geometry field index given geometry field name.
Definition: ogr_feature.h:585
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)
Definition: cpl_port.h:987
void SetNullable(int bNullableIn)
Set whether this field can receive null values.
Definition: ogr_feature.h:145
#define CPL_WARN_UNUSED_RESULT
Definition: cpl_port.h:929