#ifndef __JEEP__JPRINT__ #define __JEEP__JPRINT__ #include #include #include #include /** * \file * I/O formatting auxiliaries. * \author mdejong */ namespace JEEP {} namespace JPP { using namespace JEEP; } namespace JEEP { /** * Get output stream for conversion to std::string. * * Note that the stream is emptied before use. * * \return output stream */ inline std::ostream& getOstream() { static std::ostringstream buffer; buffer.str(""); return buffer; } /** * Get output C-string. * * Note that this method is needed to guarentee livetime of underlying std::string. * * \param input input * \return C-string */ inline const char* getCString(const std::string& input) { static std::string buffer; buffer = input; return buffer.c_str(); } } /** * Make string. * * \param A std::ostream compatible construct * \return std::string */ #define MAKE_STRING(A) (static_cast(JEEP::getOstream() << A << std::flush)).str() /** * Make C-string. * * \param A std::ostream compatible construct * \return C-string */ #define MAKE_CSTRING(A) JEEP::getCString(MAKE_STRING(A)) #endif