# OGRFieldDefn Class Reference

`#include <ogr_feature.h>`

List of all members.

## Public Member Functions
| OGRFieldDefn (const char *, OGRFieldType)
| Constructor.
| OGRFieldDefn (OGRFieldDefn *)
| Constructor.
void | SetName (const char *)
| Reset the name of this field.
const char * | GetNameRef ()
| Fetch name of this field.
OGRFieldType | GetType ()
| Fetch type of this field.
void | SetType (OGRFieldType eTypeIn)
| Set the type of this field. This should never be done to an OGRFieldDefn that is already part of an OGRFeatureDefn.
OGRJustification | GetJustify ()
| Get the justification for this field.
void | SetJustify (OGRJustification eJustifyIn)
| Set the justification for this field.
int | GetWidth ()
| Get the formatting width for this field.
void | SetWidth (int nWidthIn)
| Set the formatting width for this field in characters.
int | GetPrecision ()
| Get the formatting precision for this field. This should normally be zero for fields of types other than OFTReal.
void | SetPrecision (int nPrecisionIn)
| Set the formatting precision for this field in characters.
void | Set (const char *, OGRFieldType, int=0, int=0, OGRJustification=OJUndefined)
| Set defining parameters for a field in one call.
void | SetDefault (const OGRField *)
| Set default field value.
## Static Public Member Functions
static const char * | GetFieldTypeName (OGRFieldType)
| Fetch human readable name for a field type.

## Detailed Description

Definition of an attribute of an OGRFeatureDefn.

## Constructor & Destructor Documentation

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

Constructor.

Parameters:

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

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

Constructor.

Create by cloning an existing field definition.

Parameters:

  | poPrototype | the field definition to clone.

References GetJustify(), GetNameRef(), GetPrecision(), GetType(), GetWidth(), SetJustify(), SetPrecision(), and SetWidth().

## Member Function Documentation

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.

References OFTBinary, OFTDate, OFTDateTime, OFTInteger, OFTIntegerList, OFTReal, OFTRealList, OFTString, OFTStringList, and OFTTime.

Referenced by OGRFeature::DumpReadable(), and OGR_GetFieldTypeName().

OGRJustification OGRFieldDefn::GetJustify | ( |  | ) | `[inline]`

Get the justification for this field.

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

Returns:
  the justification.

Referenced by OGRFieldDefn().

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.

Referenced by OGRFeature::DumpReadable(), OGRDataSource::ExecuteSQL(), OGRFieldDefn(), and OGRFeature::SetFrom().

int OGRFieldDefn::GetPrecision | ( |  | ) | `[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.

Referenced by OGRFeature::GetFieldAsString(), and OGRFieldDefn().

OGRFieldType OGRFieldDefn::GetType | ( |  | ) | `[inline]`

Fetch type of this field.

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

Returns:
  field type.

Referenced by OGRFeature::DumpReadable(), OGRFeature::Equal(), OGRDataSource::ExecuteSQL(), OGRFeature::GetFieldAsBinary(), OGRFeature::GetFieldAsDateTime(), OGRFeature::GetFieldAsDouble(), OGRFeature::GetFieldAsDoubleList(), OGRFeature::GetFieldAsInteger(), OGRFeature::GetFieldAsIntegerList(), OGRFeature::GetFieldAsString(), OGRFeature::GetFieldAsStringList(), OGRFieldDefn(), OGRFeature::SetField(), OGRFeature::SetFrom(), and OGRFeature::UnsetField().

int OGRFieldDefn::GetWidth | ( |  | ) | `[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.

Referenced by OGRFeature::GetFieldAsString(), and OGRFieldDefn().

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.

References SetJustify(), SetName(), SetPrecision(), SetType(), and SetWidth().

void OGRFieldDefn::SetDefault | ( | const OGRField * | puDefaultIn | ) |

Set default field value.

Currently use of OGRFieldDefn "defaults" is discouraged. This feature may be fleshed out in the future.

References OFTInteger, OFTReal, and OFTString.

void OGRFieldDefn::SetJustify | ( | OGRJustification | eJustify | ) | `[inline]`

Set the justification for this field.

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

Parameters:

  | eJustify | the new justification.

Referenced by OGRFieldDefn(), and Set().

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.

Referenced by Set().

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.

Referenced by OGRFieldDefn(), and Set().

void OGRFieldDefn::SetType | ( | OGRFieldType | eType | ) | `[inline]`

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:

  | eType | the new field type.

Referenced by Set().

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.

Referenced by OGRFieldDefn(), and Set().

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

- ogr_feature.h
- ogrfielddefn.cpp

Generated for GDAL by 1.5.7.1.