diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-11-19 09:39:24 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-11-19 09:39:24 +0000 |
commit | b5b68088f28b2593bfbf910a46fd52775007e8b3 (patch) | |
tree | 254a04b68ee1a8f8e2070fe10162d6ad0cea1620 /src | |
parent | 305d608fe508b8e2c31df9282cc6f987260a76b1 (diff) | |
download | libbu++-b5b68088f28b2593bfbf910a46fd52775007e8b3.tar.gz libbu++-b5b68088f28b2593bfbf910a46fd52775007e8b3.tar.bz2 libbu++-b5b68088f28b2593bfbf910a46fd52775007e8b3.tar.xz libbu++-b5b68088f28b2593bfbf910a46fd52775007e8b3.zip |
Added the Bu::StdStream Stream class, it's just a wrapper for writing to,
reading from standard output/input.
Diffstat (limited to 'src')
-rw-r--r-- | src/stdstream.cpp | 97 | ||||
-rw-r--r-- | src/stdstream.h | 43 |
2 files changed, 140 insertions, 0 deletions
diff --git a/src/stdstream.cpp b/src/stdstream.cpp new file mode 100644 index 0000000..1ddb3c1 --- /dev/null +++ b/src/stdstream.cpp | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "bu/stdstream.h" | ||
9 | |||
10 | Bu::StdStream::StdStream() | ||
11 | { | ||
12 | } | ||
13 | |||
14 | Bu::StdStream::~StdStream() | ||
15 | { | ||
16 | } | ||
17 | |||
18 | void Bu::StdStream::close() | ||
19 | { | ||
20 | } | ||
21 | |||
22 | size_t Bu::StdStream::read( void *pBuf, size_t nBytes ) | ||
23 | { | ||
24 | return fread( pBuf, 1, nBytes, stdin ); | ||
25 | } | ||
26 | |||
27 | size_t Bu::StdStream::write( const void *pBuf, size_t nBytes ) | ||
28 | { | ||
29 | return fwrite( pBuf, 1, nBytes, stdout ); | ||
30 | } | ||
31 | |||
32 | long Bu::StdStream::tell() | ||
33 | { | ||
34 | return 0; | ||
35 | } | ||
36 | |||
37 | void Bu::StdStream::seek( long offset ) | ||
38 | { | ||
39 | } | ||
40 | |||
41 | void Bu::StdStream::setPos( long pos ) | ||
42 | { | ||
43 | } | ||
44 | |||
45 | void Bu::StdStream::setPosEnd( long pos ) | ||
46 | { | ||
47 | } | ||
48 | |||
49 | bool Bu::StdStream::isEOS() | ||
50 | { | ||
51 | return false; | ||
52 | } | ||
53 | |||
54 | bool Bu::StdStream::isOpen() | ||
55 | { | ||
56 | return true; | ||
57 | } | ||
58 | |||
59 | void Bu::StdStream::flush() | ||
60 | { | ||
61 | fflush( stdout ); | ||
62 | } | ||
63 | |||
64 | bool Bu::StdStream::canRead() | ||
65 | { | ||
66 | return true; | ||
67 | } | ||
68 | |||
69 | bool Bu::StdStream::canWrite() | ||
70 | { | ||
71 | return true; | ||
72 | } | ||
73 | |||
74 | bool Bu::StdStream::isReadable() | ||
75 | { | ||
76 | return true; | ||
77 | } | ||
78 | |||
79 | bool Bu::StdStream::isWritable() | ||
80 | { | ||
81 | return true; | ||
82 | } | ||
83 | |||
84 | bool Bu::StdStream::isSeekable() | ||
85 | { | ||
86 | return false; | ||
87 | } | ||
88 | |||
89 | bool Bu::StdStream::isBlocking() | ||
90 | { | ||
91 | return true; | ||
92 | } | ||
93 | |||
94 | void Bu::StdStream::setBlocking( bool bBlocking ) | ||
95 | { | ||
96 | } | ||
97 | |||
diff --git a/src/stdstream.h b/src/stdstream.h new file mode 100644 index 0000000..ccfb28a --- /dev/null +++ b/src/stdstream.h | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #ifndef BU_STD_STREAM_H | ||
9 | #define BU_STD_STREAM_H | ||
10 | |||
11 | #include <stdint.h> | ||
12 | #include <stdio.h> | ||
13 | #include "stream.h" | ||
14 | |||
15 | namespace Bu | ||
16 | { | ||
17 | class StdStream : public Stream | ||
18 | { | ||
19 | public: | ||
20 | StdStream(); | ||
21 | virtual ~StdStream(); | ||
22 | |||
23 | virtual void close(); | ||
24 | virtual size_t read( void *pBuf, size_t nBytes ); | ||
25 | virtual size_t write( const void *pBuf, size_t nBytes ); | ||
26 | virtual long tell(); | ||
27 | virtual void seek( long offset ); | ||
28 | virtual void setPos( long pos ); | ||
29 | virtual void setPosEnd( long pos ); | ||
30 | virtual bool isEOS(); | ||
31 | virtual bool isOpen(); | ||
32 | virtual void flush(); | ||
33 | virtual bool canRead(); | ||
34 | virtual bool canWrite(); | ||
35 | virtual bool isReadable(); | ||
36 | virtual bool isWritable(); | ||
37 | virtual bool isSeekable(); | ||
38 | virtual bool isBlocking(); | ||
39 | virtual void setBlocking( bool bBlocking=true ); | ||
40 | }; | ||
41 | } | ||
42 | |||
43 | #endif | ||