1 // 2 // This file is part of the SDTS++ toolkit, written by the U.S. 3 // Geological Survey. It is experimental software, written to support 4 // USGS research and cartographic data production. 5 // 6 // SDTS++ is public domain software. It may be freely copied, 7 // distributed, and modified. The USGS welcomes user feedback, but makes 8 // no committment to any level of support for this code. See the SDTS 9 // web site at http://mcmcweb.er.usgs.gov/sdts for more information, 10 // including points of contact. 11 // 12 #ifndef INCLUDED_SIO_CONVERTER_H 13 #define INCLUDED_SIO_CONVERTER_H 14 15 #include <string> 16 17 #ifndef INCLUDED_SIO_BUFFER_H 18 #include <sdts++/io/sio_Buffer.h> 19 #endif 20 21 #ifdef USE_NAMESPACE 22 using namespace std; 23 #endif 24 25 class sc_Subfield; 26 27 /// 28 class sio_Converter 29 { 30 31 public: 32 33 /// sio_Converter()34 sio_Converter() {}; 35 36 /// ~sio_Converter()37 virtual ~sio_Converter() {}; 38 39 /** 40 Make a fixed subfield. Return the length of the data converted. 41 This method works to turn data from the file into the format used 42 internally. 43 */ 44 virtual long makeFixedSubfield(sc_Subfield& subfield, 45 char const* data, 46 long length) const = 0; 47 48 49 /** 50 Make a variable-length subfield. Return the length of the data 51 converted. This method works to turn data read from file into the 52 format used internally by the library. 53 */ 54 virtual long makeVarSubfield(sc_Subfield& subfield, 55 char const* data, 56 long maxLength, 57 char delimiter) const = 0; 58 59 /** 60 Append an end-of-unit marker to the output buffer. Useful mainly 61 for adding subfields that do not contain data. 62 */ 63 virtual long addEmptySubfield(sio_Buffer& buffer) const = 0; 64 65 66 /// Add a subfield (complete with it's values) to the output buffer. 67 virtual long addSubfield(sc_Subfield const& subf, 68 sio_Buffer& buffer) const = 0; 69 70 71 protected: 72 73 /// Find the length of a variable-length subfield. 74 virtual long findVariableSubfieldLength(char const* data, 75 long maxLength, 76 char delimiter) const; 77 78 }; // class sio_Converter 79 80 81 #endif // INCLUDED_SIO_CONVERTER_H 82