[libxml++] typedef string class



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;
}

#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".

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).






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]