⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ogrfielddefn.cpp

📁 在linux环境下
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** * $Id: ogrfielddefn.cpp,v 1.9 2003/05/28 19:16:42 warmerda Exp $ * * Project:  OpenGIS Simple Features Reference Implementation * Purpose:  The OGRFieldDefn class implementation. * Author:   Frank Warmerdam, warmerda@home.com * ****************************************************************************** * Copyright (c) 1999,  Les Technologies SoftMap Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** * * $Log: ogrfielddefn.cpp,v $ * Revision 1.9  2003/05/28 19:16:42  warmerda * fixed up argument names and stuff for docs * * Revision 1.8  2003/04/03 23:39:11  danmo * Small updates to C API docs (Normand S.) * * Revision 1.7  2003/03/31 15:55:42  danmo * Added C API function docs * * Revision 1.6  2002/09/26 18:12:38  warmerda * added C support * * Revision 1.5  2001/07/18 05:03:05  warmerda * added CPL_CVSID * * Revision 1.4  1999/11/18 19:02:19  warmerda * expanded tabs * * Revision 1.3  1999/11/04 21:07:09  warmerda * Added the Set() method. * * Revision 1.2  1999/07/05 17:19:52  warmerda * added docs * * Revision 1.1  1999/06/11 19:21:02  warmerda * New */#include "ogr_feature.h"#include "ogr_api.h"#include "ogr_p.h"CPL_CVSID("$Id: ogrfielddefn.cpp,v 1.9 2003/05/28 19:16:42 warmerda Exp $");/************************************************************************//*                            OGRFieldDefn()                            *//************************************************************************//** * Constructor. * * @param pszNameIn the name of the new field. * @param eTypeIn the type of the new field. */OGRFieldDefn::OGRFieldDefn( const char * pszNameIn, OGRFieldType eTypeIn ){    Initialize( pszNameIn, eTypeIn );}/************************************************************************//*                            OGRFieldDefn()                            *//************************************************************************//** * Constructor. * * Create by cloning an existing field definition. * * @param poPrototype the field definition to clone. */OGRFieldDefn::OGRFieldDefn( OGRFieldDefn *poPrototype ){    Initialize( poPrototype->GetNameRef(), poPrototype->GetType() );    SetJustify( poPrototype->GetJustify() );    SetWidth( poPrototype->GetWidth() );    SetPrecision( poPrototype->GetPrecision() );//    SetDefault( poPrototype->GetDefaultRef() );}/************************************************************************//*                           OGR_Fld_Create()                           *//************************************************************************//** * Create a new field definition. * * This function is the same as the CPP method OGRFieldDefn::OGRFieldDefn(). * * @param pszName the name of the new field definition. * @param eType the type of the new field definition. * @return handle to the new field definition. */OGRFieldDefnH OGR_Fld_Create( const char *pszName, OGRFieldType eType ){    return (OGRFieldDefnH) (new OGRFieldDefn(pszName,eType));}/************************************************************************//*                             Initialize()                             *//************************************************************************/void OGRFieldDefn::Initialize( const char * pszNameIn, OGRFieldType eTypeIn ){    pszName = CPLStrdup( pszNameIn );    eType = eTypeIn;    eJustify = OJUndefined;    nWidth = 0;         // should these be defined in some particular way    nPrecision = 0;     // for numbers?    memset( &uDefault, 0, sizeof(OGRField) );}/************************************************************************//*                           ~OGRFieldDefn()                            *//************************************************************************/OGRFieldDefn::~OGRFieldDefn(){    CPLFree( pszName );}/************************************************************************//*                          OGR_Fld_Destroy()                           *//************************************************************************//** * Destroy a field definition. * * @param hDefn handle to the field definition to destroy. */void OGR_Fld_Destroy( OGRFieldDefnH hDefn ){    delete (OGRFieldDefn *) hDefn;}/************************************************************************//*                              SetName()                               *//************************************************************************//** * Reset the name of this field. * * This method is the same as the C function OGR_Fld_SetName(). * * @param pszNameIn the new name to apply. */void OGRFieldDefn::SetName( const char * pszNameIn ){    CPLFree( pszName );    pszName = CPLStrdup( pszNameIn );}/************************************************************************//*                          OGR_Fld_SetName()                           *//************************************************************************//** * Reset the name of this field. * * This function is the same as the CPP method OGRFieldDefn::SetName(). * * @param hDefn handle to the field definition to apply the new name to. * @param pszName the new name to apply. */void OGR_Fld_SetName( OGRFieldDefnH hDefn, const char *pszName ){    ((OGRFieldDefn *) hDefn)->SetName( pszName );}/************************************************************************//*                             GetNameRef()                             *//************************************************************************//** * \fn const char *OGRFieldDefn::GetNameRef(); * * Fetch name of this field. * * This method is the same as the C function OGR_Fld_GetNameRef(). * * @return pointer to an internal name string that should not be freed or * modified. *//************************************************************************//*                         OGR_Fld_GetNameRef()                         *//************************************************************************//** * Fetch name of this field. * * This function is the same as the CPP method OGRFieldDefn::GetNameRef(). * * @param hDefn handle to the field definition. * @return the name of the field definition. *  */const char *OGR_Fld_GetNameRef( OGRFieldDefnH hDefn ){    return ((OGRFieldDefn *) hDefn)->GetNameRef();}/************************************************************************//*                              GetType()                               *//************************************************************************//** * \fn OGRFieldType OGRFieldDefn::GetType(); * * Fetch type of this field. * * This method is the same as the C function OGR_Fld_GetType(). * * @return field type. *//************************************************************************//*                          OGR_Fld_GetType()                           *//************************************************************************//** * Fetch type of this field. * * This function is the same as the CPP method OGRFieldDefn::GetType(). * * @param hDefn handle to the field definition to get type from. * @return field type. */OGRFieldType OGR_Fld_GetType( OGRFieldDefnH hDefn ){    return ((OGRFieldDefn *) hDefn)->GetType();}/************************************************************************//*                              SetType()                               *//************************************************************************//** * \fn void OGRFieldDefn::SetType( OGRFieldType eType ); * * 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(). * * @param eType the new field type. *//************************************************************************//*                          OGR_Fld_SetType()                           *//************************************************************************//** * Set the type of this field.  This should never be done to an OGRFieldDefn * that is already part of an OGRFeatureDefn. * * This function is the same as the CPP method OGRFieldDefn::SetType(). * * @param hDefn handle to the field definition to set type to. * @param eType the new field type. */void OGR_Fld_SetType( OGRFieldDefnH hDefn, OGRFieldType eType ){    ((OGRFieldDefn *) hDefn)->SetType( eType );}/************************************************************************//*                             SetDefault()                             *//************************************************************************//** * Set default field value. * * Currently use of OGRFieldDefn "defaults" is discouraged.  This feature * may be fleshed out in the future. * */void OGRFieldDefn::SetDefault( const OGRField * puDefaultIn ){    switch( eType )    {      case OFTInteger:      case OFTReal:        uDefault = *puDefaultIn;        break;      case OFTString://        CPLFree( uDefault.String );//        uDefault.String = CPLStrdup( puDefaultIn->String );        break;      default:        // add handling for other complex types.        CPLAssert( FALSE );        break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -