Add some new conversions.
[libcxml.git] / src / cxml.cc
index 78f75eeef24254365887c395ba8de78dfa6d9126..667da5515851b6a8ea8fd109f92cee71457fbc15 100644 (file)
 
 */
 
+#include "cxml.h"
+#include <libxml++/libxml++.h>
 #include <boost/filesystem.hpp>
 #include <boost/algorithm/string.hpp>
-#include <libxml++/libxml++.h>
-#include "cxml.h"
+#include <cstdio>
 
 using std::string;
 using std::list;
@@ -330,6 +331,15 @@ locale_convert (string x)
        return y;
 }
 
+template<>
+unsigned int
+locale_convert (string x)
+{
+       unsigned int y = 0;
+       sscanf (x.c_str(), "%u", &y);
+       return y;
+}
+
 template<>
 long int
 locale_convert (string x)
@@ -339,6 +349,45 @@ locale_convert (string x)
        return y;
 }
 
+template<>
+long unsigned int
+locale_convert (string x)
+{
+        long unsigned int y = 0;
+#ifdef LIBCXML_WINDOWS
+        __mingw_sscanf (x.c_str(), "%lud", &y);
+#else
+        sscanf (x.c_str(), "%lud", &y);
+#endif
+        return y;
+}
+
+template<>
+long long
+locale_convert (string x)
+{
+       long long y = 0;
+#ifdef LIBCXML_WINDOWS
+       __mingw_sscanf (x.c_str(), "%lld", &y);
+#else
+       sscanf (x.c_str(), "%lld", &y);
+#endif
+       return y;
+}
+
+template<>
+long long unsigned
+locale_convert (string x)
+{
+       long long unsigned y = 0;
+#ifdef LIBCXML_WINDOWS
+        __mingw_sscanf (x.c_str(), "%llud", &y);
+#else
+        sscanf (x.c_str(), "%llud", &y);
+#endif
+        return y;
+}
+
 template<>
 float
 locale_convert (string x)
@@ -364,6 +413,13 @@ cxml::raw_convert (string v)
        return locale_convert<int> (make_local(v));
 }
 
+template <>
+unsigned int
+cxml::raw_convert (string v)
+{
+       return locale_convert<unsigned int> (make_local(v));
+}
+
 template <>
 long int
 cxml::raw_convert (string v)
@@ -371,6 +427,27 @@ cxml::raw_convert (string v)
        return locale_convert<long int> (make_local(v));
 }
 
+template <>
+long unsigned int
+cxml::raw_convert (string v)
+{
+       return locale_convert<long unsigned int> (make_local(v));
+}
+
+template <>
+long long
+cxml::raw_convert (string v)
+{
+       return locale_convert<long long> (make_local(v));
+}
+
+template <>
+long long unsigned
+cxml::raw_convert (string v)
+{
+       return locale_convert<long long unsigned> (make_local(v));
+}
+
 template <>
 float
 cxml::raw_convert (string v)