📄 iso8211.h
字号:
/****************************************************************************** * $Id: iso8211.h,v 1.1.1.1 2004/12/29 07:54:56 jay-be-em Exp $ * * Project: ISO 8211 Access * Purpose: Main declarations for ISO 8211. * Author: Frank Warmerdam, warmerdam@pobox.com * ****************************************************************************** * Copyright (c) 1999, Frank Warmerdam <warmerdam@pobox.com> * * 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: iso8211.h,v $ * Revision 1.1.1.1 2004/12/29 07:54:56 jay-be-em * Initial import * * Revision 1.19 2004/01/06 18:59:18 warmerda * make enum identifiers more unique * * Revision 1.18 2004/01/06 18:53:41 warmerda * made data_type_code and data_struct_code global for HP C++ builds * * Revision 1.17 2003/09/03 20:36:26 warmerda * added subfield writing support * * Revision 1.16 2003/08/21 21:21:44 warmerda * expose the binary format type for a subfield defn * * Revision 1.15 2003/07/03 15:38:46 warmerda * some write capabilities added * * Revision 1.14 2001/08/29 17:47:33 warmerda * added GetInstanceData * * Revision 1.13 2001/08/24 19:41:19 warmerda * fixed cloning problems * * Revision 1.12 2001/08/24 16:30:55 warmerda * added DDFRecord update in place methods for S57 updating * * Revision 1.11 2000/09/19 14:08:51 warmerda * keep and report _extendedCharSet * * Revision 1.10 2000/06/16 18:02:08 warmerda * added SetRepeatingFlag hack support * * Revision 1.9 2000/01/31 18:03:39 warmerda * completely rewrote format expansion to make more general * * Revision 1.8 1999/11/18 19:03:04 warmerda * expanded tabs * * Revision 1.7 1999/11/18 19:02:38 warmerda * added failquietly to open * * Revision 1.6 1999/09/20 19:29:30 warmerda * make forgiving of UNIT/FIELD terminator mixup in Tiger SDTS files * * Revision 1.5 1999/08/13 03:26:29 warmerda * added Rewind() * * Revision 1.4 1999/05/07 14:11:22 warmerda * added subfield value fetches on record, and other odds and ends. * * Revision 1.3 1999/05/06 14:23:32 warmerda * added DDFBinaryString * * Revision 1.2 1999/04/27 22:09:50 warmerda * updated docs * * Revision 1.1 1999/04/27 18:45:09 warmerda * New * */#ifndef _ISO8211_H_INCLUDED#define _ISO8211_H_INCLUDED#include "cpl_port.h"/** General data type */typedef enum { DDFInt, DDFFloat, DDFString, DDFBinaryString} DDFDataType; /************************************************************************//* These should really be private to the library ... they are *//* mostly conveniences. *//************************************************************************/long DDFScanInt( const char *pszString, int nMaxChars );int DDFScanVariable( const char * pszString, int nMaxChars, int nDelimChar );char *DDFFetchVariable( const char *pszString, int nMaxChars, int nDelimChar1, int nDelimChar2, int *pnConsumedChars );#define DDF_FIELD_TERMINATOR 30#define DDF_UNIT_TERMINATOR 31/************************************************************************//* Predeclarations *//************************************************************************/class DDFFieldDefn;class DDFSubfieldDefn;class DDFRecord;class DDFField;/************************************************************************//* DDFModule *//************************************************************************//** The primary class for reading ISO 8211 files. This class contains all the information read from the DDR record, and is used to read records from the file. */ class DDFModule{ public: DDFModule(); ~DDFModule(); int Open( const char * pszFilename, int bFailQuietly = FALSE ); int Create( const char *pszFilename ); void Close(); int Initialize( char chInterchangeLevel = '3', char chLeaderIden = 'L', char chCodeExtensionIndicator = 'E', char chVersionNumber = '1', char chAppIndicator = ' ', const char *pszExtendedCharSet = " ! ", int nSizeFieldLength = 3, int nSizeFieldPos = 4, int nSizeFieldTag = 4 ); void Dump( FILE * fp ); DDFRecord *ReadRecord( void ); void Rewind( long nOffset = -1 ); DDFFieldDefn *FindFieldDefn( const char * ); /** Fetch the number of defined fields. */ int GetFieldCount() { return nFieldDefnCount; } DDFFieldDefn *GetField(int); void AddField( DDFFieldDefn *poNewFDefn ); // This is really just for internal use. int GetFieldControlLength() { return _fieldControlLength; } void AddCloneRecord( DDFRecord * ); void RemoveCloneRecord( DDFRecord * ); // This is just for DDFRecord. FILE *GetFP() { return fpDDF; } private: FILE *fpDDF; int bReadOnly; long nFirstRecordOffset; char _interchangeLevel; char _inlineCodeExtensionIndicator; char _versionNumber; char _appIndicator; int _fieldControlLength; char _extendedCharSet[4]; long _recLength; char _leaderIden; long _fieldAreaStart; long _sizeFieldLength; long _sizeFieldPos; long _sizeFieldTag; // One DirEntry per field. int nFieldDefnCount; DDFFieldDefn **papoFieldDefns; DDFRecord *poRecord; int nCloneCount; int nMaxCloneCount; DDFRecord **papoClones;};/************************************************************************//* DDFFieldDefn *//************************************************************************/ typedef enum { dsc_elementary, dsc_vector, dsc_array, dsc_concatenated } DDF_data_struct_code; typedef enum { dtc_char_string, dtc_implicit_point, dtc_explicit_point, dtc_explicit_point_scaled, dtc_char_bit_string, dtc_bit_string, dtc_mixed_data_type } DDF_data_type_code;/** * Information from the DDR defining one field. Note that just because * a field is defined for a DDFModule doesn't mean that it actually occurs * on any records in the module. DDFFieldDefns are normally just significant * as containers of the DDFSubfieldDefns. */class DDFFieldDefn{ public: DDFFieldDefn(); ~DDFFieldDefn(); int Create( const char *pszTag, const char *pszFieldName, const char *pszDescription, DDF_data_struct_code eDataStructCode, DDF_data_type_code eDataTypeCode, const char *pszFormat = NULL ); void AddSubfield( DDFSubfieldDefn *poNewSFDefn, int bDontAddToFormat = FALSE ); void AddSubfield( const char *pszName, const char *pszFormat ); int GenerateDDREntry( char **ppachData, int *pnLength ); int Initialize( DDFModule * poModule, const char *pszTag, int nSize, const char * pachRecord ); void Dump( FILE * fp ); /** Fetch a pointer to the field name (tag). * @return this is an internal copy and shouldn't be freed. */ const char *GetName() { return pszTag; } /** Fetch a longer descriptio of this field. * @return this is an internal copy and shouldn't be freed. */ const char *GetDescription() { return _fieldName; } /** Get the number of subfields. */ int GetSubfieldCount() { return nSubfieldCount; } DDFSubfieldDefn *GetSubfield( int i ); DDFSubfieldDefn *FindSubfieldDefn( const char * ); /** * Get the width of this field. This function isn't normally used * by applications. * * @return The width of the field in bytes, or zero if the field is not * apparently of a fixed width. */ int GetFixedWidth() { return nFixedWidth; } /** * Fetch repeating flag. * @see DDFField::GetRepeatCount() * @return TRUE if the field is marked as repeating. */ int IsRepeating() { return bRepeatingSubfields; } static char *ExpandFormat( const char * ); /** this is just for an S-57 hack for swedish data */ void SetRepeatingFlag( int n ) { bRepeatingSubfields = n; } char *GetDefaultValue( int *pnSize );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -