GDAL

- Main Page
- Related Pages
- Classes
- Files
- Download
- Issue Tracker

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | List of all members
OGRFieldDefn Class Reference

Definition of an attribute of an OGRFeatureDefn. More...

`#include <ogr_feature.h>`

## Public Member Functions
| OGRFieldDefn (const char *, OGRFieldType)
| Constructor. More...
| OGRFieldDefn (OGRFieldDefn *)
| Constructor. More...
void | SetName (const char *)
| Reset the name of this field. More...
const char * | GetNameRef ()
| Fetch name of this field. More...
OGRFieldType | GetType () const
| Fetch type of this field. More...
void | SetType (OGRFieldType eTypeIn)
| Set the type of this field. More...
OGRFieldSubType | GetSubType () const
| Fetch subtype of this field. More...
void | SetSubType (OGRFieldSubType eSubTypeIn)
| Set the subtype of this field. More...
OGRJustification | GetJustify () const
| Get the justification for this field. More...
void | SetJustify (OGRJustification eJustifyIn)
| Set the justification for this field. More...
int | GetWidth () const
| Get the formatting width for this field. More...
void | SetWidth (int nWidthIn)
| Set the formatting width for this field in characters. More...
int | GetPrecision () const
| Get the formatting precision for this field. More...
void | SetPrecision (int nPrecisionIn)
| Set the formatting precision for this field in characters. More...
void | Set (const char *, OGRFieldType, int=0, int=0, OGRJustification=OJUndefined)
| Set defining parameters for a field in one call. More...
void | SetDefault (const char *)
| Set default field value. More...
const char * | GetDefault () const
| Get default field value. More...
int | IsDefaultDriverSpecific () const
| Returns whether the default value is driver specific. More...
int | IsIgnored () const
| Return whether this field should be omitted when fetching features. More...
void | SetIgnored (int bIgnoreIn)
| Set whether this field should be omitted when fetching features. More...
int | IsNullable () const
| Return whether this field can receive null values. More...
void | SetNullable (int bNullableIn)
| Set whether this field can receive null values. More...
int | IsSame (const OGRFieldDefn *) const
| Test if the field definition is identical to the other one. More...

## Static Public Member Functions
static const char * | GetFieldTypeName (OGRFieldType)
| Fetch human readable name for a field type. More...
static const char * | GetFieldSubTypeName (OGRFieldSubType)
| Fetch human readable name for a field subtype. More...

## Detailed Description

Definition of an attribute of an OGRFeatureDefn.

A field is described by :

- a name. See SetName() / GetNameRef()
- a type: OFTString, OFTInteger, OFTReal, ... See SetType() / GetType()
- a subtype (optional): OFSTBoolean, ... See SetSubType() / GetSubType()
- a width (optional): maximal number of characters. See SetWidth() / GetWidth()
- a precision (optional): number of digits after decimal point. See SetPrecision() / GetPrecision()
- a NOT NULL constraint (optional). See SetNullable() / IsNullable()
- a default value (optional). See SetDefault() / GetDefault()
- a boolean to indicate whether it should be ignored when retrieving features. See SetIgnored() / IsIgnored()

## Constructor & Destructor Documentation

OGRFieldDefn::OGRFieldDefn | ( | const char * | pszNameIn,
|  | OGRFieldType | eTypeIn
| ) |  |

Constructor.

By default, fields have no width, precision, are nullable and not ignored.

Parameters

  pszNameIn | the name of the new field.
  eTypeIn | the type of the new field.

OGRFieldDefn::OGRFieldDefn | ( | OGRFieldDefn * | poPrototype | ) |
| explicit

Constructor.

Create by cloning an existing field definition.

Parameters

  poPrototype | the field definition to clone.

## Member Function Documentation

const char * OGRFieldDefn::GetDefault | ( |  | ) | const

Get default field value.

This function is the same as the C function OGR_Fld_GetDefault().

Returns
  default field value or NULL.

Since
  GDAL 2.0

const char * OGRFieldDefn::GetFieldSubTypeName | ( | OGRFieldSubType | eSubType | ) |
| static

Fetch human readable name for a field subtype.

This static method is the same as the C function OGR_GetFieldSubTypeName().

Parameters

  eSubType | the field subtype to get name for.

Returns
  pointer to an internal static name string. It should not be modified or freed.

Since
  GDAL 2.0

const char * OGRFieldDefn::GetFieldTypeName | ( | OGRFieldType | eType | ) |
| static

Fetch human readable name for a field type.

This static method is the same as the C function OGR_GetFieldTypeName().

Parameters

  eType | the field type to get name for.

Returns
  pointer to an internal static name string. It should not be modified or freed.

OGRJustification OGRFieldDefn::GetJustify | ( |  | ) | const
| inline

Get the justification for this field.

Note: no driver is know to use the concept of field justification.

This method is the same as the C function OGR_Fld_GetJustify().

Returns
  the justification.

const char * OGRFieldDefn::GetNameRef | ( |  | ) |
| inline

Fetch name of this field.

This method is the same as the C function OGR_Fld_GetNameRef().

Returns
  pointer to an internal name string that should not be freed or modified.

int OGRFieldDefn::GetPrecision | ( |  | ) | const
| inline

Get the formatting precision for this field.

This should normally be zero for fields of types other than OFTReal.

This method is the same as the C function OGR_Fld_GetPrecision().

Returns
  the precision.

OGRFieldSubType OGRFieldDefn::GetSubType | ( |  | ) | const
| inline

Fetch subtype of this field.

This method is the same as the C function OGR_Fld_GetSubType().

Returns
  field subtype.

Since
  GDAL 2.0

OGRFieldType OGRFieldDefn::GetType | ( |  | ) | const
| inline

Fetch type of this field.

This method is the same as the C function OGR_Fld_GetType().

Returns
  field type.

int OGRFieldDefn::GetWidth | ( |  | ) | const
| inline

Get the formatting width for this field.

This method is the same as the C function OGR_Fld_GetWidth().

Returns
  the width, zero means no specified width.

int OGRFieldDefn::IsDefaultDriverSpecific | ( |  | ) | const

Returns whether the default value is driver specific.

Driver specific default values are those that are not NULL, a numeric value, a literal value enclosed between single quote characters, CURRENT_TIMESTAMP, CURRENT_TIME, CURRENT_DATE or datetime literal value.

This method is the same as the C function OGR_Fld_IsDefaultDriverSpecific().

Returns
  TRUE if the default value is driver specific.

Since
  GDAL 2.0

int OGRFieldDefn::IsIgnored | ( |  | ) | const
| inline

Return whether this field should be omitted when fetching features.

This method is the same as the C function OGR_Fld_IsIgnored().

Returns
  ignore state

int OGRFieldDefn::IsNullable | ( |  | ) | const
| inline

Return whether this field can receive null values.

By default, fields are nullable.

Even if this method returns FALSE (i.e not-nullable field), it doesn't mean that OGRFeature::IsFieldSet() will necessary return TRUE, as fields can be temporary unset and null/not-null validation is usually done when OGRLayer::CreateFeature()/SetFeature() is called.

This method is the same as the C function OGR_Fld_IsNullable().

Returns
  TRUE if the field is authorized to be null.

Since
  GDAL 2.0

int OGRFieldDefn::IsSame | ( | const OGRFieldDefn * | poOtherFieldDefn | ) | const

Test if the field definition is identical to the other one.

Parameters

  poOtherFieldDefn | the other field definition to compare to.

Returns
  TRUE if the field definition is identical to the other one.

void OGRFieldDefn::Set | ( | const char * | pszNameIn,
|  | OGRFieldType | eTypeIn,
|  | int | nWidthIn = `0`,
|  | int | nPrecisionIn = `0`,
|  | OGRJustification | eJustifyIn = `OJUndefined`
| ) |  |

Set defining parameters for a field in one call.

This method is the same as the C function OGR_Fld_Set().

Parameters

  pszNameIn | the new name to assign.
  eTypeIn | the new type (one of the OFT values like OFTInteger).
  nWidthIn | the preferred formatting width. Defaults to zero indicating undefined.
  nPrecisionIn | number of decimals places for formatting, defaults to zero indicating undefined.
  eJustifyIn | the formatting justification (OJLeft or OJRight), defaults to OJUndefined.

void OGRFieldDefn::SetDefault | ( | const char * | pszDefaultIn | ) |

Set default field value.

The default field value is taken into account by drivers (generally those with a SQL interface) that support it at field creation time. OGR will generally not automatically set the default field value to null fields by itself when calling OGRFeature::CreateFeature() / OGRFeature::SetFeature(), but will let the low-level layers to do the job. So retrieving the feature from the layer is recommended.

The accepted values are NULL, a numeric value, a literal value enclosed between single quote characters (and inner single quote characters escaped by repetition of the single quote character), CURRENT_TIMESTAMP, CURRENT_TIME, CURRENT_DATE or a driver specific expression (that might be ignored by other drivers). For a datetime literal value, format should be 'YYYY/MM/DD HH:MM:SS[.sss]' (considered as UTC time).

Drivers that support writing DEFAULT clauses will advertize the GDAL_DCAP_DEFAULT_FIELDS driver metadata item.

This function is the same as the C function OGR_Fld_SetDefault().

Parameters

  pszDefaultIn | new default field value or NULL pointer.

Since
  GDAL 2.0

void OGRFieldDefn::SetIgnored | ( | int | ignore | ) |
| inline

Set whether this field should be omitted when fetching features.

This method is the same as the C function OGR_Fld_SetIgnored().

Parameters

  ignore | ignore state

void OGRFieldDefn::SetJustify | ( | OGRJustification | eJustify | ) |
| inline

Set the justification for this field.

Note: no driver is know to use the concept of field justification.

This method is the same as the C function OGR_Fld_SetJustify().

Parameters

  eJustify | the new justification.

void OGRFieldDefn::SetName | ( | const char * | pszNameIn | ) |

Reset the name of this field.

This method is the same as the C function OGR_Fld_SetName().

Parameters

  pszNameIn | the new name to apply.

void OGRFieldDefn::SetNullable | ( | int | bNullableIn | ) |
| inline

Set whether this field can receive null values.

By default, fields are nullable, so this method is generally called with FALSE to set a not-null constraint.

Drivers that support writing not-null constraint will advertize the GDAL_DCAP_NOTNULL_FIELDS driver metadata item.

This method is the same as the C function OGR_Fld_SetNullable().

Parameters

  bNullableIn | FALSE if the field must have a not-null constraint.

Since
  GDAL 2.0

void OGRFieldDefn::SetPrecision | ( | int | nPrecision | ) |
| inline

Set the formatting precision for this field in characters.

This should normally be zero for fields of types other than OFTReal.

This method is the same as the C function OGR_Fld_SetPrecision().

Parameters

  nPrecision | the new precision.

void OGRFieldDefn::SetSubType | ( | OGRFieldSubType | eSubTypeIn | ) |

Set the subtype of this field.

This should never be done to an OGRFieldDefn that is already part of an OGRFeatureDefn.

This method is the same as the C function OGR_Fld_SetSubType().

Parameters

  eSubTypeIn | the new field subtype.

Since
  GDAL 2.0

void OGRFieldDefn::SetType | ( | OGRFieldType | eTypeIn | ) |

Set the type of this field.

This should never be done to an OGRFieldDefn that is already part of an OGRFeatureDefn.

This method is the same as the C function OGR_Fld_SetType().

Parameters

  eTypeIn | the new field type.

void OGRFieldDefn::SetWidth | ( | int | nWidth | ) |
| inline

Set the formatting width for this field in characters.

This method is the same as the C function OGR_Fld_SetWidth().

Parameters

  nWidth | the new width.

The documentation for this class was generated from the following files:

- ogr_feature.h
- ogrfielddefn.cpp

Generated for GDAL by 1.8.8.