00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef H_LIBTHROWABLE_UTIL
00021 #define H_LIBTHROWABLE_UTIL
00022 #include <string>
00023 #include <sstream>
00024 #include "libthrowable/system.h"
00025 namespace libthrowable {
00029 namespace util {
00030
00035 template<class OStreamableT>
00036 std::string LIBTHROWABLE_API stringify(const OStreamableT& arg) throw();
00037
00041 int LIBTHROWABLE_API getTerminalWidth() throw();
00042
00045 std::string LIBTHROWABLE_API addIndent(const std::string& str, unsigned indent) throw();
00046
00050 std::string LIBTHROWABLE_API optimizeForLineWidth(const std::string& str, int width) throw();
00051
00056 inline std::string LIBTHROWABLE_API
00057 optimizeForTerminalWidth(const std::string& str) throw()
00058 { return optimizeForLineWidth(str, getTerminalWidth()); }
00059
00060 template<class OStreamableT>
00061 std::string stringify(const OStreamableT& arg) throw()
00062 {
00063 std::ostringstream os;
00064 os << arg;
00065 return os.str();
00066 }
00067
00068 inline std::string stringify(bool arg) throw()
00069 {
00070 return (arg ? "true" : "false");
00071 }
00072
00073 }}
00074 #endif
00075