diff --git a/include/loki/SafeFormat.h b/include/loki/SafeFormat.h index 7fd211b..5c4919e 100644 --- a/include/loki/SafeFormat.h +++ b/include/loki/SafeFormat.h @@ -605,6 +605,14 @@ namespace Loki LOKI_EXPORT PrintfState FPrintf(std::FILE* f, const std::string& format); + /// Prints to cout. + LOKI_EXPORT + PrintfState FPrintf( const char * format ); + + /// Prints to cout. + LOKI_EXPORT + PrintfState FPrintf( const std::string & format ); + LOKI_EXPORT PrintfState FPrintf(std::ostream& f, const char* format); diff --git a/src/SafeFormat.cpp b/src/SafeFormat.cpp index 5c26acf..865b9a4 100644 --- a/src/SafeFormat.cpp +++ b/src/SafeFormat.cpp @@ -99,6 +99,22 @@ namespace Loki return printState2; } + PrintfState< std::ostream &, char > FPrintf( const char * format ) { + ::std::string buffer; + const PrintfState< ::std::string &, char > state1( buffer, format ); + ::std::cout << buffer.c_str(); + PrintfState< ::std::ostream &, char > printState2 = state1.ChangeDevice< ::std::ostream & >( ::std::cout ); + return printState2; + } + + PrintfState< std::ostream &, char > FPrintf( const std::string & format ) { + ::std::string buffer; + const PrintfState< ::std::string &, char > state1( buffer, format.c_str() ); + ::std::cout << buffer.c_str(); + PrintfState< std::ostream &, char > printState2 = state1.ChangeDevice< ::std::ostream & >( ::std::cout ); + return printState2; + } + PrintfState FPrintf(std::ostream& f, const char* format) { ::std::string buffer; const PrintfState< ::std::string &, char > state1( buffer, format );