Eliminate printf usage in macros.
authorScott Cantor <cantor.2@osu.edu>
Wed, 21 Dec 2011 19:33:16 +0000 (19:33 +0000)
committerScott Cantor <cantor.2@osu.edu>
Wed, 21 Dec 2011 19:33:16 +0000 (19:33 +0000)
xmltooling/base.h
xmltooling/encryption/Encryption.h

index ff96588..4e80091 100644 (file)
             m_##proper = prepareForAssignment(m_##proper,proper); \
         } \
         void set##proper(int proper) { \
             m_##proper = prepareForAssignment(m_##proper,proper); \
         } \
         void set##proper(int proper) { \
-            char buf##proper[64]; \
-            std::sprintf(buf##proper,"%d",proper); \
-            xmltooling::auto_ptr_XMLCh wide##proper(buf##proper); \
-            set##proper(wide##proper.get()); \
+            try { \
+                xmltooling::xstring buf = boost::lexical_cast<xmltooling::xstring>(proper); \
+                set##proper(buf.c_str()); \
+            } \
+            catch (boost::bad_lexical_cast&) { \
+            } \
         }
 
 /**
         }
 
 /**
     } \
     XMLTOOLING_DOXYGEN(Sets proper.) \
     void set##proper(int proper) { \
     } \
     XMLTOOLING_DOXYGEN(Sets proper.) \
     void set##proper(int proper) { \
-        char buf[64]; \
-        std::sprintf(buf,"%d",proper); \
-        xmltooling::auto_ptr_XMLCh widebuf(buf); \
-        setTextContent(widebuf.get()); \
+        try { \
+            xmltooling::xstring buf = boost::lexical_cast<xmltooling::xstring>(proper); \
+            setTextContent(buf.c_str()); \
+        } \
+        catch (boost::bad_lexical_cast&) { \
+        } \
     } \
     XMLTOOLING_DOXYGEN(Sets or clears proper.) \
     void set##proper(const XMLCh* proper) { \
     } \
     XMLTOOLING_DOXYGEN(Sets or clears proper.) \
     void set##proper(const XMLCh* proper) { \
index e7e3329..934088b 100644 (file)
@@ -32,6 +32,7 @@
 #include <xmltooling/util/XMLConstants.h>
 
 #include <cstdio>
 #include <xmltooling/util/XMLConstants.h>
 
 #include <cstdio>
+#include <boost/lexical_cast.hpp>
 
 namespace xmlsignature {
     class XMLTOOL_API KeyInfo;
 
 namespace xmlsignature {
     class XMLTOOL_API KeyInfo;