]> www.ginac.de Git - ginac.git/blobdiff - ginac/utils.h
* Zapped header dependency from <strstream>.
[ginac.git] / ginac / utils.h
index c2a5f232336f3576ee9d72f75bd5b6e2f2c18f2e..6edea866c16f22c2e0d533f0a42f2513b88d31df 100644 (file)
 #ifndef __GINAC_UTILS_H__
 #define __GINAC_UTILS_H__
 
-#include <strstream>
+#include "config.h"
+
 #include <string>
 #include <stdexcept>
-#include "config.h"
+#if defined(HAVE_SSTREAM)
+#include <sstream>
+#elif defined(HAVE_STRSTREAM)
+#include <strstream>
+#else
+#error Need either sstream or strstream
+#endif
 #include "assertion.h"
 
 namespace GiNaC {
@@ -36,9 +43,15 @@ namespace GiNaC {
 template<class T>
 std::string ToString(const T & t)
 {
+#if defined(HAVE_SSTREAM)
+       std::ostringstream buf;
+       buf << t << std::ends;
+       return buf.str();
+#else
        char buf[256];
        std::ostrstream(buf,sizeof(buf)) << t << std::ends;
        return buf;
+#endif
 }
 
 /** Exception class thrown by classes which provide their own series expansion
@@ -301,6 +314,18 @@ void classname::print(const print_context & c, unsigned level) const \
                c.s << text; \
 }
 
+#define DEFAULT_PRINT_LATEX(classname, text, latex) \
+void classname::print(const print_context & c, unsigned level) const \
+{ \
+       debugmsg(#classname " print", LOGLEVEL_PRINT); \
+       if (is_of_type(c, print_tree)) \
+               inherited::print(c, level); \
+       else if (is_of_type(c, print_latex)) \
+               c.s << latex; \
+       else \
+               c.s << text; \
+}
+
 } // namespace GiNaC
 
 #endif // ndef __GINAC_UTILS_H__