aboutsummaryrefslogtreecommitdiff
path: root/src/stable/staticmembuf.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/stable/staticmembuf.h')
-rw-r--r--src/stable/staticmembuf.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/stable/staticmembuf.h b/src/stable/staticmembuf.h
new file mode 100644
index 0000000..f168de3
--- /dev/null
+++ b/src/stable/staticmembuf.h
@@ -0,0 +1,65 @@
1/*
2 * Copyright (C) 2007-2011 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_STATIC_MEM_BUF_H
9#define BU_STATIC_MEM_BUF_H
10
11#include <stdint.h>
12
13#include "bu/config.h"
14#include "bu/stream.h"
15
16namespace Bu
17{
18 /**
19 * An immutable, read-only memory buffer. Construct this buffer around a
20 * block of raw memory, provide the length of the block, and you can read
21 * from that block via this class as though it were a normal stream.
22 *
23 * Use this class instead of MemBuf when you have a string already, and
24 * don't need to change it. MemBuf will make a copy of your string for
25 * it's own use (often) and this will not (ever).
26 *@ingroup Streams
27 */
28 class StaticMemBuf : public Stream
29 {
30 public:
31 StaticMemBuf( const void *pData, size iSize );
32 virtual ~StaticMemBuf();
33
34 virtual void close();
35 virtual size read( void *pBuf, size iBytes );
36
37 virtual size write( const void *pBuf, size iBytes );
38 using Stream::write;
39 virtual size tell();
40 virtual void seek( size offset );
41 virtual void setPos( size pos );
42 virtual void setPosEnd( size pos );
43 virtual bool isEos();
44 virtual bool isOpen();
45 virtual void flush();
46 virtual bool canRead();
47 virtual bool canWrite();
48 virtual bool isReadable();
49 virtual bool isWritable();
50 virtual bool isSeekable();
51 virtual bool isBlocking();
52 virtual void setBlocking( bool bBlocking=true );
53 virtual void setSize( size iSize );
54 virtual size getSize() const;
55 virtual size getBlockSize() const;
56 virtual Bu::String getLocation() const;
57
58 private:
59 const void *pData;
60 size iSize;
61 size nPos;
62 };
63}
64
65#endif