aboutsummaryrefslogtreecommitdiff
path: root/src/stream.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-01-20 18:09:04 +0000
committerMike Buland <eichlan@xagasoft.com>2011-01-20 18:09:04 +0000
commit393f1b414746a7f1977971dd7659dd2b47092b11 (patch)
tree81d0ca1ee70ab86a7d79c1991abe5c387b655fb2 /src/stream.h
parentc259f95bd0e58b247940a339bb9b4b401b4e9438 (diff)
parent7e25a863325dc3e9762397e700030969e093b087 (diff)
downloadlibbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.gz
libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.bz2
libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.xz
libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.zip
Wow! Merged the branch, streams are updated, and there's no more FString, run
the fixstrings.sh script in the support directory to (hopefully) automatically update your projects.
Diffstat (limited to 'src/stream.h')
-rw-r--r--src/stream.h48
1 files changed, 36 insertions, 12 deletions
diff --git a/src/stream.h b/src/stream.h
index 0ea5560..fb70f21 100644
--- a/src/stream.h
+++ b/src/stream.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2007-2010 Xagasoft, All rights reserved. 2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 * 3 *
4 * This file is part of the libbu++ library and is released under the 4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE. 5 * terms of the license contained in the file LICENSE.
@@ -8,10 +8,12 @@
8#ifndef BU_STREAM_H 8#ifndef BU_STREAM_H
9#define BU_STREAM_H 9#define BU_STREAM_H
10 10
11#include "bu/config.h"
12
11#include <stdint.h> 13#include <stdint.h>
12#include <stdio.h> 14#include <stdio.h>
13 15
14#include "bu/fstring.h" 16#include "bu/string.h"
15 17
16namespace Bu 18namespace Bu
17{ 19{
@@ -43,7 +45,7 @@ namespace Bu
43 *@param nBytes (size_t) Max data to read. 45 *@param nBytes (size_t) Max data to read.
44 *@returns (size_t) Amount of data read. 46 *@returns (size_t) Amount of data read.
45 */ 47 */
46 virtual size_t read( void *pBuf, size_t nBytes ) = 0; 48 virtual size read( void *pBuf, size iBytes ) = 0;
47 49
48 /** 50 /**
49 * Attempts to read a complete line from the stream. This will stop 51 * Attempts to read a complete line from the stream. This will stop
@@ -51,7 +53,7 @@ namespace Bu
51 * data in a non-blocking stream. 53 * data in a non-blocking stream.
52 *@returns The line read, not including newline character. 54 *@returns The line read, not including newline character.
53 */ 55 */
54 virtual Bu::FString readLine(); 56 virtual Bu::String readLine();
55 57
56 /** 58 /**
57 * Write data to the stream. 59 * Write data to the stream.
@@ -59,33 +61,33 @@ namespace Bu
59 *@param nBytes (size_t) Amount of data to write from pBuf. 61 *@param nBytes (size_t) Amount of data to write from pBuf.
60 *@returns (size_t) Amount of data actually written. 62 *@returns (size_t) Amount of data actually written.
61 */ 63 */
62 virtual size_t write( const void *pBuf, size_t nBytes ) = 0; 64 virtual size write( const void *pBuf, size iBytes ) = 0;
63 65
64 virtual size_t write( const Bu::FString &sBuf ); 66 virtual size write( const Bu::String &sBuf );
65 67
66 /** 68 /**
67 * Get the current position in the stream. 69 * Get the current position in the stream.
68 *@returns (long) The current position in the stream. 70 *@returns (long) The current position in the stream.
69 */ 71 */
70 virtual long tell() = 0; 72 virtual size tell() = 0;
71 73
72 /** 74 /**
73 * Seek to a position in the stream relative to the current position. 75 * Seek to a position in the stream relative to the current position.
74 *@param offset (long) Offset from current position to seek to. 76 *@param offset (long) Offset from current position to seek to.
75 */ 77 */
76 virtual void seek( long offset ) = 0; 78 virtual void seek( size offset ) = 0;
77 79
78 /** 80 /**
79 * Set position in the stream relative to the start of the stream. 81 * Set position in the stream relative to the start of the stream.
80 *@param pos (long) The position. 82 *@param pos (long) The position.
81 */ 83 */
82 virtual void setPos( long pos ) = 0; 84 virtual void setPos( size pos ) = 0;
83 85
84 /** 86 /**
85 * Set position in the stream relative to the end of the stream. 87 * Set position in the stream relative to the end of the stream.
86 *@param pos (long) The position. 88 *@param pos (long) The position.
87 */ 89 */
88 virtual void setPosEnd( long pos ) = 0; 90 virtual void setPosEnd( size pos ) = 0;
89 91
90 /** 92 /**
91 * Are we at the end of the stream? 93 * Are we at the end of the stream?
@@ -158,10 +160,32 @@ namespace Bu
158 * removed from the end of the stream, but the content of the added 160 * removed from the end of the stream, but the content of the added
159 * data is undefined. 161 * data is undefined.
160 */ 162 */
161 virtual void setSize( long iSize ) = 0; 163 virtual void setSize( size iSize ) = 0;
164
165 /**
166 * Returns the size of the stream if the stream can have a size. For
167 * streams that do not (sockets, pipes, etc.) this should throw an
168 * unsupported exception.
169 */
170 virtual size getSize() const = 0;
162 171
163 public: // Filters 172 /**
173 * Returns the block-size of the stream, if it has one. This should
174 * throw an unsupported exception. In some cases the block size
175 * returned will not represent quite the same thing, for example,
176 * sockets will return their MTU, while files will return the
177 * filesystem's block size, and memory buffers will throw an exception.
178 */
179 virtual size getBlockSize() const = 0;
164 180
181 /**
182 * If possible, this returns a string that can be used to describe how
183 * to access the open stream. Not all streams support this, such as
184 * MemBuf, but for files it may give you a path to a file, for a socket
185 * it may give you an ip address, etc. If it isn't supported, an empty
186 * string may be returned.
187 */
188 virtual Bu::String getLocation() const = 0;
165 189
166 private: 190 private:
167 191