diff options
Diffstat (limited to '')
-rw-r--r-- | src/stable/sio.cpp | 38 |
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 @@ | |||
10 | Bu::StdStream Bu::sioRaw; | 10 | Bu::StdStream Bu::sioRaw; |
11 | Bu::Formatter Bu::sio( Bu::sioRaw ); | 11 | Bu::Formatter Bu::sio( Bu::sioRaw ); |
12 | 12 | ||
13 | Bu::size Bu::print( Bu::Stream &s, const Bu::String &str ) | 13 | class PrintEndAction : public Bu::String::FormatProxyEndAction |
14 | { | 14 | { |
15 | return s.write( str.getStr(), str.getSize() ); | 15 | public: |
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 | |||
36 | Bu::String::FormatProxy Bu::print( Bu::Stream &s, const Bu::String &str ) | ||
37 | { | ||
38 | return str.format( new PrintEndAction( s, false ) ); | ||
16 | } | 39 | } |
17 | 40 | ||
18 | Bu::size Bu::print( const Bu::String &str ) | 41 | Bu::String::FormatProxy Bu::print( const Bu::String &str ) |
19 | { | 42 | { |
20 | return print( sioRaw, str ); | 43 | return print( sioRaw, str ); |
21 | } | 44 | } |
22 | 45 | ||
23 | Bu::size Bu::println( Bu::Stream &s, const Bu::String &str ) | 46 | Bu::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 | ||
31 | Bu::size Bu::println( const Bu::String &str ) | 51 | Bu::String::FormatProxy Bu::println( const Bu::String &str ) |
32 | { | 52 | { |
33 | return println( sioRaw, str ); | 53 | return println( sioRaw, str ); |
34 | } | 54 | } |