C Implementation


C++ Implementation

The following C++ source and header files implement the base classes described in the chapter. As with the Java implementation, we'll also include our standard error handling routines as well as some standard header files.

  • Converter.cpp

  • Converter.h

  • SourceConverter.cpp

  • SourceConverter.h

  • TargetConverter.cpp

  • TargetConverter.h

  • DataCell.cpp

  • DataCell.h

  • RecordHandler.cpp

  • RecordHandler.h

  • RecordReader.cpp

  • RecordReader.h

  • RecordWriter.cpp

  • RecordWriter.h

  • handleCOMError.cpp

  • handleParseError.cpp

  • BlasterIncludes.h

  • BlasterPrototypes.h

  • TextConstants.h

A few words are in order about string handling beyond what I noted in Chapter 1. Since C++ handles bytes for I/O as character arrays, we won't have some of Java's complexities in converting to and from bytes and strings. However, C++ character arrays certainly have their own problems and peculiarities . In particular, the string functions don't always handle non-string data very well (for example, when it contains null characters ). When there's a future possibility of dealing with non-string data, such as numeric data coded in one of the EBCDIC or native IBM data types, we'll use memcpy rather than string copy operations. We'll also do binary reads and writes of our data files rather than assume that the data is all character string data. Another difference between Java String and C++ character arrays is that in C++ we (conventionally) must allocate space for the array at compile time, hard-coding an array size. To avoid buffer overflows several of the string-based data types in the file description documents have maxLength facets imposed on them. When dealing with XML as the conversion source, I also check the sizes of strings that are returned from the DOM API methods before copying them to the C++ character arrays.

We'll store text constants in the TextConstants.h header file, serving the same function in the C++ environment as the TextConstants class in Java.



Using XML with Legacy Business Applications
Using XML with Legacy Business Applications
ISBN: 0321154940
EAN: 2147483647
Year: 2003
Pages: 181

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net