2
gtstream.h C++ Stream Supporting gettext Usage
3
Copyright (c) 2000, 2001, 2002, 2004, 2005 Kriang Lerdsuwanakij
4
email: lerdsuwa@users.sourceforge.net
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
#ifndef __K_GTSTREAM_H
22
#define __K_GTSTREAM_H
31
typedef std::ostringstream gtstream;
36
std::vector<std::string> str_vec;
37
std::vector<bool> str_flag;
44
gtout(std::ostream &os_, const std::string &fmt);
45
gtout(std::ostream &os_, const char *fmt);
47
~gtout() { finish(); }
49
int opfx() { return 1; }
52
gtout& flush() { need_flush = true; return *this; }
54
gtout& put(char c) { return *this << c; }
55
gtout& write(const char *s, std::streamsize n) { return *this << std::string(s, n); }
57
template <class T> gtout& operator<<(T t);
59
gtout& operator<<(gtout& (*f)(gtout&)) {
62
gtout& operator<<(std::ios& (*f)(std::ios&)) {
63
(*f)(os); return *this;
67
template <class T> gtout& gtout::operator<<(T t)
71
// Do not copy locale for speed reason
72
// buffer.copyfmt(*this); // Transfer states to buffer
73
// buffer.clear(rdstate());
76
// copyfmt(buffer); // Transfer states from buffer
77
// clear(buffer.rdstate());
79
str_vec.push_back(buffer.str());
80
str_flag.push_back(false);
85
#endif /* __K_GTSTREAM_H */