summaryrefslogtreecommitdiff
path: root/src/stable/sio.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-09-05 20:44:55 +0000
committerMike Buland <eichlan@xagasoft.com>2012-09-05 20:44:55 +0000
commite5f2e1ce7faeb8fb4609f7291e77d5b682685057 (patch)
treec00b5d47966aef916f8a2f055aedadade5fa95d3 /src/stable/sio.cpp
parent69d1606ac97547896a0ede8dee5e59fc4a5de7c2 (diff)
downloadlibbu++-e5f2e1ce7faeb8fb4609f7291e77d5b682685057.tar.gz
libbu++-e5f2e1ce7faeb8fb4609f7291e77d5b682685057.tar.bz2
libbu++-e5f2e1ce7faeb8fb4609f7291e77d5b682685057.tar.xz
libbu++-e5f2e1ce7faeb8fb4609f7291e77d5b682685057.zip
This'll make *everything* rebuild. String formatters now support the end()
call, which will force substitution and return a string. They now also support ending actions, which let us do great stuff like printing stuff out after formatting finished...and other stuff.
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}