📄 ugkfielddefn.cpp
字号:
// ugkfielddefn.cpp: implementation of the UGKFieldDefn class.////////////////////////////////////////////////////////////////////////#include "ugkfielddefn.h"#include "ugk_memopr.h"#include "ugk_string.h"/************************************************************************//* UGKFieldDefn() *//************************************************************************//** * Constructor. * * @param pszNameIn the name of the new field. * @param eTypeIn the type of the new field. */UGKFieldDefn::UGKFieldDefn( const char * pszNameIn, UGKFieldType eTypeIn ){ Initialize( pszNameIn, eTypeIn );}/************************************************************************//* UGKFieldDefn() *//************************************************************************//** * Constructor. * * Create by cloning an existing field definition. * * @param poPrototype the field definition to clone. */UGKFieldDefn::UGKFieldDefn( UGKFieldDefn *poPrototype ){ Initialize( poPrototype->GetNameRef(), poPrototype->GetType() ); SetJustify( poPrototype->GetJustify() ); SetWidth( poPrototype->GetWidth() ); SetPrecision( poPrototype->GetPrecision() );// SetDefault( poPrototype->GetDefaultRef() );}UGKFieldDefn::~UGKFieldDefn(){ UGK_Free( pszName );}/************************************************************************//* Initialize() *//* 初始化 *//************************************************************************/void UGKFieldDefn::Initialize( const char * pszNameIn, UGKFieldType eTypeIn ){ pszName = UGKStrdup( pszNameIn ); eType = eTypeIn; eJustify = OJUndefined; nWidth = 0; // should these be defined in some particular way nPrecision = 0; // for numbers? memset( &uDefault, 0, sizeof(UGKField) );}/************************************************************************//* SetName() *//************************************************************************//** * Reset the name of this field. * * @param pszNameIn the new name to apply. */void UGKFieldDefn::SetName( const char * pszNameIn ){ UGK_Free( pszName ); pszName = UGKStrdup( pszNameIn );}/************************************************************************//* Set() *//************************************************************************//* 设置该字段 *//** * Set defining parameters for a field in one call. * * @param pszNameIn the new name to assign. * @param eTypeIn the new type . * @param nWidthIn the preferred formatting width. Defaults to zero indicating * undefined. * @param nPrecisionIn number of decimals places for formatting, defaults to * zero indicating undefined. * @param eJustifyIn the formatting justification (OJLeft or OJRight), defaults * to OJUndefined. */void UGKFieldDefn::Set( const char *pszNameIn, UGKFieldType eTypeIn, int nWidthIn, int nPrecisionIn, UGKJustification eJustifyIn ){ SetName( pszNameIn ); SetType( eTypeIn ); SetWidth( nWidthIn ); SetPrecision( nPrecisionIn ); SetJustify( eJustifyIn );}/************************************************************************//* SetDefault() *//************************************************************************//** * Set default field value. * * Currently use of UGKFieldDefn "defaults" is discouraged. This feature * may be fleshed out in the future. * */void UGKFieldDefn::SetDefault( const UGKField * 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. assert( FALSE ); break; }}/************************************************************************//* GetFieldTypeName() *//************************************************************************//** * Fetch human readable name for a field type. * * @param eType the field type to get name for. * * @return pointer to an internal static name string. It should not be * modified or freed. */const char * UGKFieldDefn::GetFieldTypeName( UGKFieldType eType ){ switch( eType ) { case OFTInteger: return "Integer"; case OFTReal: return "Real"; case OFTString: return "String"; case OFTWideString: return "WideString"; case OFTIntegerList: return "IntegerList"; case OFTRealList: return "RealList"; case OFTStringList: return "StringList"; case OFTWideStringList: return "WideStringList"; case OFTBinary: return "Binary"; default: assert( FALSE ); return "(unknown)"; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -