Re: [libxml++] typedef string class
- From: Murray Cumming <murrayc murrayc com>
- To: libxml++ <libxmlplusplus-general lists sourceforge net>
- Subject: Re: [libxml++] typedef string class
- Date: Sun, 29 Feb 2004 12:46:43 +0100
On Sat, 2004-02-28 at 19:46, Kurt M. Brown wrote:
> I would like to suggest the use of a typedef for the string class used
> in libxml++.
>
> A new file, string_type.h, could be added:
> -------------------------------------
> // $Id: $
> #ifndef __LIBXMLPP_STRING_TYPE_H
> #define __LIBXMLPP_STRING_TYPE_H
>
> #if defined(LIBXMLPP_STRING_TYPE_STD)
>
> #include <string>
> namespace xmlpp {
> typedef std::string string;
> }
>
> #elif defined(LIBXMLPP_STRING_TYPE_STDW)
>
> #include <string>
> namespace xmlpp {
> typedef std::wstring string;
> }
libxml, and therefore libxml++, use utf8. Neither std::string or
std::wstring use utf8.
> #elif defined(LIBXMLPP_STRING_TYPE_GLIB)
>
> #include <glibmm/ustring.h>
> namespace xmlpp {
> typedef Glib::ustring string;
> }
>
> #else
>
> #error "unsupported string type"
>
> #endif
>
> #endif // __LIBXMLPP_STRING_TYPE_H
> -------------------------------------
>
> The macro, LIBXMLPP_STRING_TYPE_XXX, could be set by the configuration
> process.
>
> So, instead of including <string> or <glibmm/ustring.h>, one would
> include <libxml++/string_type.h>. Inside the xmlpp namespace, the class
> would be just "string".
But the library is compiled and linked - you would need to rebuild the
whole library to use a different string.
There was previously a discussion about making the whole library a set
of templates instead of a library, to achieve this. But we decided that
it wasn't worth it.
What problem are you actually trying to solve?
> To avoid problems with when:
> -------------------------------
> using namespace std;
> using namespace xmlpp;
>
> string s; // which one?
> -------------------------------
>
> the typedef could be changed from making a "string" in xmlpp to
> "xstring", "DOMString", etc.. For example, in string_type.h:
> -------------------------------
> namespace xmlpp {
> typedef std::string xstring;
> }
> -------------------------------
>
> Also, if anyone ever did want to use std::wstring, there would be issues
> with stream classes (which could be resolved by adding more typedefs).
--
Murray Cumming
www.murrayc.com
murrayc murrayc com
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]