Boost logo

Boost :

From: Stefan Seefeld (seefeld_at_[hidden])
Date: 2005-11-08 11:13:26


Anthony,

thinking more about the involved issues, and especially taking into account
one comment regarding the need to pass 'internalized' strings around to avoid
duplicate conversions, I'm tempted by a radically different option:

Let the XML API provide a 'string_type' (or may be 'cdata_type'), and exclusively
operate on that. This type would be self-descriptive such that it could vary with
the backend, but always provide the same (compile-time) interface to users
(with tags for encoding, etc.).

Users then explicitely convert their strings back and forth on each call:

document_ptr doc(new document());
element_ptr root = doc->set_root(cdata_type("book"));

my_unicode_type name = ...;

root->apped_element(internalize(name));

Here, 'internalize' is a user-provided converter that generates dom::cdata_type
from my_unicode_type. Thus you can write as many converters as you have unicode
types, and have explicit control over when and where to convert. (Well, and if
you prefer implicit conversion, say, because you want to operate on a lot of
ASCII data, just add implicit cast and non-explicit constructors to your unicode
type.)

What about that ?

Regards,
                Stefan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk