Hi,

First of all I am newby with xerces(-c).
I wrote a piece of code which I'd like to discuss about.

Problem is , that stringhandling is almost as complicated as assembler programming in xerces-c.
There are many many functions, that expect a XMLCh* as parameter, which has to be allocated first, then applied, and then released, which creates three times more code than one would expect:

I wrote a class XMLStringParameterHandler (the name could be some more depictive, I know), which creates an object, wich handles this transcoding/releasing.

you can say

XMLStringParameterHandler handler = XMLStringParameterHandler();

DOMDocument* doc = impl-> createDocument(handler.transcode("Range",0), 0);

The handler object holds 5 registers in the background (or more, if a number is specified with the constructor).
When you say handler.transcode("text",0), the transcode method returns "text" as a XMLCh* string, and as a side effect, it saves this string in the first register. If you call this method again with another string, the content of the old register is internally first released and than reassigned with the new string.

I implemented also some other useful methods:

handler.release_all() // releases all registers
handler.release(int reg) // releases register reg
handler.getRegisterContentAsChar(int reg) // returns the content as a char*
handler.getRegisterContentAsXMLCh(int reg) // returns the content as XMLCh*
handler.getNumRegisters() // returns the number of registers

It's not complete yet. It's just the first implementation of an idea and I'd like to hear your opinion.
You will have to adapt the Makefiles to you environment.

greets Boris

P.S. files are attached and are of course released under the GPL.

Attachment: XMLStringParameterHandler.tar.gz
Description: Unix tar archive

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to