|
From: Christophe de V. <cde...@al...> - 2003-01-27 20:37:37
|
Le Lundi 27 Janvier 2003 20:58, Stefan Seefeld a =E9crit :
> hi there,
>
> libxml2 uses some internal utf8 types to represent characters.
> libxml++ currently uses std::string, which only works for characters
> in the ASCII subset of utf8. It was suggested to use glibmm::ustring
> instead, but I'd like to propose a different solution:
>
<big snip>
>
> Hope this makes some sense to you.
>
A lot of. But the change you suggest in the way _TextNode would be implemen=
ted=20
is big : at this time, the libxml2 types (xmlNode in this case) are used on=
ly=20
are read/write time, not to store the datas while manipulating nodes.
But I like much the idea so I see two options :
=2D doing exactly the way you did, but this means rethink completely the wa=
y=20
Node is implemented
=2D Keep the idea of a templated class, but with no parent class, and=20
string_type as the content type.
template <typename string_type, typename string_traits>
class TextNode
{
public:
void set_content(const string_type &content)
{
_TextNode::set_content(string_traits::to_utf8(content));
}
void write(xmlDocPtr doc, xmlNodePtr parent) const;
private:
string_type content;
};
Then the write() member function would use the string adaptor to produce th=
e=20
libxml2 node.
void TextNode::write(xmlDocPtr doc, xmlNodePtr parent) const
{
xmlNodePtr node =3D xmlNewText( string_traits::to_utf8(_content) );
/* ... */
}
The read method would do the exact oposite.
This way we wouldn't have to modify too much the current implementation,=20
unless we decide that it's better to rely on libxml2 types to store datas.
Thanks for your suggestion,
Christophe
|