write in CSVRowReader.cpp

Let's look at how we create the Text Node and append it using MSXML from C++.

//  Text Node <- Call Document's createTextNode method
//    with text from ColumnArray[ColumnNumber]
//  MSXML createTextNode specifies a BSTR for the
//    argument. Visual C++ is usually happy to convert
//    a char * but wanted an explicit cast for this
//    array element.
IXMLDOMTextPtr spTexText = spDocOutput->createTextNode(
  (char *) cColumnArray[iColumnNumber]);

//  Column Element <- Call Column Element's appendChild
//    to add Text Node as child
spEleColumn->appendChild(spTexText);

Again, this is very similar to the Java implementation. A “gotcha” here, as noted in the code comments, is that createTextNode requires that the text argument be a BSTR type. The compiler is usually very happy to handle a char * for us, but in this case it wanted a specific cast as char *. cColumnArray is an array of char * pointers. We allocate memory for them when we read a new column and release it when we've created the Text Node. Visual C++ evidently couldn't handle that level of type conversion.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset