blob: e7f75654286fc053985be297d8f12a995a7b9f77 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*
* Copyright (C) 2007-2012 Xagasoft, All rights reserved.
*
* This file is part of the libbu++ library and is released under the
* terms of the license contained in the file LICENSE.
*/
#include "bu/sio.h"
Bu::StdStream Bu::sioRaw;
Bu::Formatter Bu::sio( Bu::sioRaw );
class PrintEndAction : public Bu::String::FormatProxyEndAction
{
public:
PrintEndAction( Bu::Stream &s, bool bEndLn ) :
s( s ),
bEndLn( bEndLn )
{
}
virtual void operator()( const Bu::String &sFinal )
{
s.write( sFinal.getStr(), sFinal.getSize() );
if( bEndLn )
{
s.write("\n", 1);
s.flush();
}
}
Bu::Stream &s;
bool bEndLn;
};
Bu::String::FormatProxy Bu::print( Bu::Stream &s, const Bu::String &str )
{
return str.format( new PrintEndAction( s, false ) );
}
Bu::String::FormatProxy Bu::print( const Bu::String &str )
{
return print( sioRaw, str );
}
Bu::String::FormatProxy Bu::println( Bu::Stream &s, const Bu::String &str )
{
return str.format( new PrintEndAction( s, true ) );
}
Bu::String::FormatProxy Bu::println( const Bu::String &str )
{
return println( sioRaw, str );
}
|