add writing to ostream, by Tom Browder
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@692 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
289bc55ba0
commit
ae9c9ecc22
2 changed files with 32 additions and 3 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include <loki/LokiExport.h>
|
#include <loki/LokiExport.h>
|
||||||
|
|
||||||
|
@ -52,6 +53,9 @@ namespace Loki
|
||||||
LOKI_EXPORT
|
LOKI_EXPORT
|
||||||
void write(std::FILE* f, const char* from, const char* to);
|
void write(std::FILE* f, const char* from, const char* to);
|
||||||
|
|
||||||
|
// Write to an ostream
|
||||||
|
LOKI_EXPORT
|
||||||
|
void write(std::ostream& f, const char* from, const char* to);
|
||||||
|
|
||||||
// Write to a string
|
// Write to a string
|
||||||
LOKI_EXPORT
|
LOKI_EXPORT
|
||||||
|
@ -539,7 +543,7 @@ namespace Loki
|
||||||
PrintfState<std::FILE*, char> Printf(const char* format);
|
PrintfState<std::FILE*, char> Printf(const char* format);
|
||||||
|
|
||||||
LOKI_EXPORT
|
LOKI_EXPORT
|
||||||
PrintfState<std::FILE*, char> Printf(const std::string format);
|
PrintfState<std::FILE*, char> Printf(const std::string& format);
|
||||||
|
|
||||||
LOKI_EXPORT
|
LOKI_EXPORT
|
||||||
PrintfState<std::FILE*, char> FPrintf(std::FILE* f, const char* format);
|
PrintfState<std::FILE*, char> FPrintf(std::FILE* f, const char* format);
|
||||||
|
@ -547,6 +551,12 @@ namespace Loki
|
||||||
LOKI_EXPORT
|
LOKI_EXPORT
|
||||||
PrintfState<std::FILE*, char> FPrintf(std::FILE* f, const std::string& format);
|
PrintfState<std::FILE*, char> FPrintf(std::FILE* f, const std::string& format);
|
||||||
|
|
||||||
|
LOKI_EXPORT
|
||||||
|
PrintfState<std::ostream&, char> FPrintf(std::ostream& f, const char* format);
|
||||||
|
|
||||||
|
LOKI_EXPORT
|
||||||
|
PrintfState<std::ostream&, char> FPrintf(std::ostream& f, const std::string& format);
|
||||||
|
|
||||||
LOKI_EXPORT
|
LOKI_EXPORT
|
||||||
PrintfState<std::string&, char> SPrintf(std::string& s, const char* format);
|
PrintfState<std::string&, char> SPrintf(std::string& s, const char* format);
|
||||||
|
|
||||||
|
@ -576,6 +586,9 @@ namespace Loki
|
||||||
#endif //SAFEFORMAT_H_
|
#endif //SAFEFORMAT_H_
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.28 2006/07/06 18:25:28 syntheticpp
|
||||||
|
// add writing to ostream, by Tom Browder
|
||||||
|
//
|
||||||
// Revision 1.27 2006/07/03 09:55:19 syntheticpp
|
// Revision 1.27 2006/07/03 09:55:19 syntheticpp
|
||||||
// fix wrong buffer size check
|
// fix wrong buffer size check
|
||||||
//
|
//
|
||||||
|
|
|
@ -32,8 +32,13 @@ namespace Loki
|
||||||
assert(from <= to);
|
assert(from <= to);
|
||||||
s.append(from, to);
|
s.append(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Write to a stream
|
||||||
|
|
||||||
|
void write(std::ostream& f, const char* from, const char* to) {
|
||||||
|
assert(from <= to);
|
||||||
|
f.write(from, to - from);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// PrintfState class template
|
// PrintfState class template
|
||||||
|
@ -46,7 +51,7 @@ namespace Loki
|
||||||
return PrintfState<std::FILE*, char>(stdout, format);
|
return PrintfState<std::FILE*, char>(stdout, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintfState<std::FILE*, char> Printf(const std::string format) {
|
PrintfState<std::FILE*, char> Printf(const std::string& format) {
|
||||||
return PrintfState<std::FILE*, char>(stdout, format.c_str());
|
return PrintfState<std::FILE*, char>(stdout, format.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +63,14 @@ namespace Loki
|
||||||
return PrintfState<std::FILE*, char>(f, format.c_str());
|
return PrintfState<std::FILE*, char>(f, format.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PrintfState<std::ostream&, char> FPrintf(std::ostream& f, const char* format) {
|
||||||
|
return PrintfState<std::ostream&, char>(f, format);
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintfState<std::ostream&, char> FPrintf(std::ostream& f, const std::string& format) {
|
||||||
|
return PrintfState<std::ostream&, char>(f, format.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
PrintfState<std::string&, char> SPrintf(std::string& s, const char* format) {
|
PrintfState<std::string&, char> SPrintf(std::string& s, const char* format) {
|
||||||
return PrintfState<std::string&, char>(s, format);
|
return PrintfState<std::string&, char>(s, format);
|
||||||
}
|
}
|
||||||
|
@ -70,6 +83,9 @@ namespace Loki
|
||||||
}// namespace Loki
|
}// namespace Loki
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.4 2006/07/06 18:25:28 syntheticpp
|
||||||
|
// add writing to ostream, by Tom Browder
|
||||||
|
//
|
||||||
// Revision 1.3 2006/06/28 08:04:21 syntheticpp
|
// Revision 1.3 2006/06/28 08:04:21 syntheticpp
|
||||||
// use standard conforming naming, SUN's compiler needs it
|
// use standard conforming naming, SUN's compiler needs it
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue