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

📄 iso8211.h

📁 国际海图标准S-57格式数据读取源码VC
💻 H
字号:
#pragma once#ifndef _ISO8211_H_INCLUDED#define _ISO8211_H_INCLUDED/**  General data type    */typedef enum DDF_DATA_TYPE {    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                               *//************************************************************************/class DDFModule{public:	DDFModule();	~DDFModule();	int Open(const char * pszFilename, int bFailQuietly = FALSE);	int Create (const char *pszFilename);	void Close();	int Initialize(char chIntercharngeLevel ='3',						char chLeaderIden='L',						char chCodeExtensionIndicator ='E',						char chVersionNumber = '1',						char chAppIndicator=' ',						const char *pszExtendedCharSet =" ! ",						int nSizwFieldLength = 3,						int nSizeFieldPos = 4,						int nSizeFieldTag = 4);	void Dump (FILE *fp);	DDFRecord *ReadRecord (void);	void Rewind(long nOffset =-1);	DDFFieldDefn * FindFieldDefn (const char *);	/** 获取定义域的数量*/	int GetFieldCount() {return nFieldDefnCount;}	DDFFieldDefn * GetField (int);	void AddField (DDFFieldDefn *poNewFDefn);	int GetFieldControlLength (){return _fieldControlLength;}	void AddCloneRecord (DDFRecord *);	void RemoveCloneRecord (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;	int nFieldDefnCount;	DDFFieldDefn **papoFieldDefns;	DDFRecord *poRecord;	int nCloneCount;	int nMaxCloneCount;	DDFRecord **papoClones;};/************************************************************************//*                             DDFFieldDefn                             *//************************************************************************/  typedef enum  DDF_DATA_STRUCT_CODE { 	  dsc_elementary,	  dsc_vector,	  dsc_array, 	  dsc_concatenated   } DDF_data_struct_code ;  typedef enum DDF_DATA_TYPE_CODE  { 	  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 ;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);	const char *GetName() {return pszTag;}	const char *GetDescritpion () {return _fieldName;}		int GetSubfieldCount () {return nSubfieldCount;}    	DDFSubfieldDefn *GetSubfield (int i);	DDFSubfieldDefn *FindSubfieldDefn (const char *);	int GetFixedWidth() {return nFixedWidth;}	int IsRepeating() {return bRepeatingSubfields;}	static char *ExpandFormat (const char *);	void SetRepeatingFlag (int n ) {bRepeatingSubfields = n;}    char * GetDefaultValue (int *pnSize);private:	static char *ExtractSubstring (const char*);	DDFModule *poModule;	char * pszTag;	char * _fieldName;	char * _arrayDescr;	char * _formatControls;	int bRepeatingSubfields;	int nFixedWidth;	int BuildSubfields();	int ApplyFormats();	DDF_data_struct_code _data_struct_code;    DDF_data_type_code _data_type_code;	int nSubfieldCount;	DDFSubfieldDefn **papoSubfields;};/************************************************************************//*                           DDFSubfieldDefn                            *//************************************************************************/class DDFSubfieldDefn{public:	DDFSubfieldDefn();	~DDFSubfieldDefn();	void SetName(const char *pszName);	const char * GetName() {return pszName;}	const char * GetFormat () {return pszFormatString;}	int SetFormat (const char *pszFormat);	DDFDataType GetType() {return eType;}    double ExtractFloatData (const char *pachData,int nMaxBytes,											int *pnConsumedBytes);	int ExtractIntData (const char *pachData,int  nMaxBytes,								int * pnConsumedBytes);    const char *ExtractStringData (const char *pachData,int nMaxBytes,													int * pnConsumedBytes);	int GetDataLength (const char * ,int ,int *);	void DumpData (const char *pachDate, int nMaxBytes,FILE *fp);	int FormatStringValue (char *pachData, int nBytesAvailable,										int * pnBytesUsed,const char *pszValue,										int nValueLength =-1);	int FormatIntValue (char *pachData,int nByteAvailable,								int *pnBytesUsed,int nNewValue);	int FormatFloatValue (char *pachData,int nBytesAvailable,									int *pnBytesUsed,double dfNewValue);	int GetWidth () {return nFormatWidth;}	int GetDefaultValue (char *pachData,int nBYtesAvailable,								int *pnBytesUsed);	void Dump (FILE *fp);   	/**  Binary format: this is the digit immediately following the B or b for  binary formats.   */	typedef enum {		NotBinary=0,		UInt=1,		SInt=2,		FPReal=3,		FloatReal=4,		FloatComplex=5	} DDFBinaryFormat;	DDFBinaryFormat GetBinaryFormat (void ) const {return eBinaryFormat;}private:	char *pszName;	char *pszFormatString;	DDFDataType eType;	DDFBinaryFormat eBinaryFormat;		int bIsVariable;	char chFormatDelimeter;	int nFormatWidth;	int nMaxBufChars;	char *pachBuffer;};/************************************************************************//*                              DDFRecord																							   *//************************************************************************/class DDFRecord{public:	DDFRecord (DDFModule *);	~DDFRecord ();	DDFRecord *Clone ();	DDFRecord *CloneOn(DDFModule *);	void Dump (FILE *);	int GetFieldCount() {return nFieldCount;}	DDFField *FindField (const char*,int =0);	DDFField *GetField (int);	int GetIntSubfield (const char *,int ,const char *,int, int * =NULL);	double GetFloatSubfield (const char *,int,const char *,int, int * =NULL);	const char * GetStringSubfield (const char *,int,const char *,int, int * = NULL);	int SetIntSubfield (const char * pszField, int iFieldIndex,								const char *pszSubfileld, int iSubfieldIndex,								int nValue);	int SetStringSubfield (const char *pszField,int iFieldIndex,									const char *pszSubfield,int iSubfieldIndex,									const char *pszValue,int nValueLength = -1);    int SetFloatSubfield (const char *pszField,int iFieldIndex,									const char *pszSubfield,int iSubfieldIndex,									double dfNewValue);	int GetDataSize () {return nDataSize;}	const char *GetData() {return pachData;}    	DDFModule * GetModule() {return poModule;}    	int ResizeField (DDFField *poField, int nNewDataSize);	int DeleteField (DDFField *poField);	DDFField * AddField (DDFFieldDefn *);	int CreateDefaultFieldInstance (DDFField *poField,int iIndexWithinField);	int SetFieldRaw (DDFField *poField, int iIndexWithinField,							const char *pachRawData,int nRawDataSize);	int UpdateFieldRaw (DDFField *poField,int iIndexWithinField,									int nStartOffset,int nOldSize,									const char * pachRawData,int nRawDataSize);	int Write ();	int Read ();	void Clear();	int ResetDirectory();	private:	int ReadHeader();	DDFModule *poModule;	int nReuseHeader;		int nFieldOffset;	int _sizeFieldTag;	int _sizeFieldPos;	int _sizeFieldLength;	int nDataSize;	char *pachData;	int nFieldCount;	DDFField *paoFields;	int bIsClone;};/************************************************************************//*                               DDFField                               *//************************************************************************/class DDFField{public:	void Initialize (DDFFieldDefn *,const char *pszData,							int nSize);	void Dump (FILE * fp);	const char * GetSubfieldData (DDFSubfieldDefn *,												int * =NULL,int =0);	const char *GetInstanceData (int nInstance,int *pnSize);	const char * GetData () {return pachData;}	int GetDataSize() {return nDataSize;}	int GetRepeatCount ();	DDFFieldDefn * GetFieldDefn () {return poDefn;}private:	DDFFieldDefn *poDefn;	int nDataSize;	const char *pachData;};#endif /* ndef _ISO8211_H_INCLUDED */

⌨️ 快捷键说明

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