aboutsummaryrefslogtreecommitdiff
path: root/src/stable/sio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/stable/sio.cpp')
-rw-r--r--src/stable/sio.cpp38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/stable/sio.cpp b/src/stable/sio.cpp
index 02ba631..e7f7565 100644
--- a/src/stable/sio.cpp
+++ b/src/stable/sio.cpp
@@ -10,25 +10,45 @@
10Bu::StdStream Bu::sioRaw; 10Bu::StdStream Bu::sioRaw;
11Bu::Formatter Bu::sio( Bu::sioRaw ); 11Bu::Formatter Bu::sio( Bu::sioRaw );
12 12
13Bu::size Bu::print( Bu::Stream &s, const Bu::String &str ) 13class PrintEndAction : public Bu::String::FormatProxyEndAction
14{ 14{
15 return s.write( str.getStr(), str.getSize() ); 15public:
16 PrintEndAction( Bu::Stream &s, bool bEndLn ) :
17 s( s ),
18 bEndLn( bEndLn )
19 {
20 }
21
22 virtual void operator()( const Bu::String &sFinal )
23 {
24 s.write( sFinal.getStr(), sFinal.getSize() );
25 if( bEndLn )
26 {
27 s.write("\n", 1);
28 s.flush();
29 }
30 }
31
32 Bu::Stream &s;
33 bool bEndLn;
34};
35
36Bu::String::FormatProxy Bu::print( Bu::Stream &s, const Bu::String &str )
37{
38 return str.format( new PrintEndAction( s, false ) );
16} 39}
17 40
18Bu::size Bu::print( const Bu::String &str ) 41Bu::String::FormatProxy Bu::print( const Bu::String &str )
19{ 42{
20 return print( sioRaw, str ); 43 return print( sioRaw, str );
21} 44}
22 45
23Bu::size Bu::println( Bu::Stream &s, const Bu::String &str ) 46Bu::String::FormatProxy Bu::println( Bu::Stream &s, const Bu::String &str )
24{ 47{
25 Bu::size sRet = s.write( str.getStr(), str.getSize() ); 48 return str.format( new PrintEndAction( s, true ) );
26 sRet += s.write("\n", 1 );
27 s.flush();
28 return sRet;
29} 49}
30 50
31Bu::size Bu::println( const Bu::String &str ) 51Bu::String::FormatProxy Bu::println( const Bu::String &str )
32{ 52{
33 return println( sioRaw, str ); 53 return println( sioRaw, str );
34} 54}