aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llbufferstream.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llmessage/llbufferstream.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llmessage/llbufferstream.h')
-rw-r--r--linden/indra/llmessage/llbufferstream.h153
1 files changed, 153 insertions, 0 deletions
diff --git a/linden/indra/llmessage/llbufferstream.h b/linden/indra/llmessage/llbufferstream.h
new file mode 100644
index 0000000..0a4ad40
--- /dev/null
+++ b/linden/indra/llmessage/llbufferstream.h
@@ -0,0 +1,153 @@
1/**
2 * @file llbufferstream.h
3 * @author Phoenix
4 * @date 2005-10-10
5 * @brief Classes to treat an LLBufferArray as a c++ iostream.
6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 *
9 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement
12 * ("Other License"), formally executed by you and Linden Lab. Terms of
13 * the GPL can be found in doc/GPL-license.txt in this distribution, or
14 * online at http://secondlife.com/developers/opensource/gplv2
15 *
16 * There are special exceptions to the terms and conditions of the GPL as
17 * it is applied to this Source Code. View the full text of the exception
18 * in the file doc/FLOSS-exception.txt in this software distribution, or
19 * online at http://secondlife.com/developers/opensource/flossexception
20 *
21 * By copying, modifying or distributing this software, you acknowledge
22 * that you have read and understood your obligations described above,
23 * and agree to abide by those obligations.
24 *
25 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
26 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
27 * COMPLETENESS OR PERFORMANCE.
28 */
29
30#ifndef LL_LLBUFFERSTREAM_H
31#define LL_LLBUFFERSTREAM_H
32
33#include <iosfwd>
34#include <iostream>
35#include "llbuffer.h"
36
37/**
38 * @class LLBufferStreamBuf
39 * @brief This implements the buffer wrapper for an istream
40 *
41 * The buffer array passed in is not owned by the stream buf object.
42 */
43class LLBufferStreamBuf : public std::streambuf
44{
45public:
46 LLBufferStreamBuf(
47 const LLChannelDescriptors& channels,
48 LLBufferArray* buffer);
49 virtual ~LLBufferStreamBuf();
50
51protected:
52#if( LL_WINDOWS || __GNUC__ > 2 )
53 typedef std::streambuf::pos_type pos_type;
54 typedef std::streambuf::off_type off_type;
55#endif
56
57 /* @name streambuf vrtual implementations
58 */
59 //@{
60 /*
61 * @brief called when we hit the end of input
62 *
63 * @return Returns the character at the current position or EOF.
64 */
65 virtual int underflow();
66
67 /*
68 * @brief called when we hit the end of output
69 *
70 * @param c The character to store at the current put position
71 * @return Returns EOF if the function failed. Any other value on success.
72 */
73 virtual int overflow(int c);
74
75 /*
76 * @brief synchronize the buffer
77 *
78 * @return Returns 0 on success or -1 on failure.
79 */
80 virtual int sync();
81
82 /*
83 * @brief Seek to an offset position in a stream.
84 *
85 * @param off Offset value relative to way paramter
86 * @param way The seek direction. One of ios::beg, ios::cur, and ios::end.
87 * @param which Which pointer to modify. One of ios::in, ios::out,
88 * or both masked together.
89 * @return Returns the new position or an invalid position on failure.
90 */
91#if( LL_WINDOWS || __GNUC__ > 2)
92 virtual pos_type seekoff(
93 off_type off,
94 std::ios::seekdir way,
95 std::ios::openmode which);
96#else
97 virtual streampos seekoff(
98 streamoff off,
99 std::ios::seekdir way,
100 std::ios::openmode which);
101#endif
102
103 /*
104 * @brief Get s sequence of characters from the input
105 *
106 * @param dst Pointer to a block of memory to accept the characters
107 * @param length Number of characters to be read
108 * @return Returns the number of characters read
109 */
110 //virtual streamsize xsgetn(char* dst, streamsize length);
111
112 /*
113 * @brief Write some characters to output
114 *
115 * @param src Pointer to a sequence of characters to be output
116 * @param length Number of characters to be put
117 * @return Returns the number of characters written
118 */
119 //virtual streamsize xsputn(char* src, streamsize length);
120 //@}
121
122protected:
123 // This channels we are working on.
124 LLChannelDescriptors mChannels;
125
126 // The buffer we work on
127 LLBufferArray* mBuffer;
128};
129
130
131/**
132 * @class LLBufferStream
133 * @brief This implements an istream based wrapper around an LLBufferArray.
134 *
135 * This class does not own the buffer array, and does not hold a
136 * shared pointer to it. Since the class itself is fairly ligthweight,
137 * just make one on the stack when needed and let it fall out of
138 * scope.
139 */
140class LLBufferStream : public std::iostream
141{
142public:
143 LLBufferStream(
144 const LLChannelDescriptors& channels,
145 LLBufferArray* buffer);
146 ~LLBufferStream();
147
148protected:
149 LLBufferStreamBuf mStreamBuf;
150};
151
152
153#endif // LL_LLBUFFERSTREAM_H