]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - include/idatastream.h
transfer from internal tree r5311 branches/1.4-gpl
[xonotic/netradiant.git] / include / idatastream.h
1 /*\r
2 Copyright (c) 2001, Loki software, inc.\r
3 modifications (c) 2001, Id software, inc.\r
4 All rights reserved.\r
5 \r
6 Redistribution and use in source and binary forms, with or without modification, \r
7 are permitted provided that the following conditions are met:\r
8 \r
9 Redistributions of source code must retain the above copyright notice, this list \r
10 of conditions and the following disclaimer.\r
11 \r
12 Redistributions in binary form must reproduce the above copyright notice, this\r
13 list of conditions and the following disclaimer in the documentation and/or\r
14 other materials provided with the distribution.\r
15 \r
16 Neither the name of Loki software nor the names of its contributors may be used \r
17 to endorse or promote products derived from this software without specific prior \r
18 written permission. \r
19 \r
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' \r
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \r
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE \r
23 DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY \r
24 DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \r
25 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
26 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
27 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
28 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS \r
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \r
30 */\r
31 \r
32 #ifndef _ISTREAM_H_\r
33 #define _ISTREAM_H_\r
34 \r
35 /*!\r
36 API for data streams\r
37 \r
38 Based on an initial implementation by Loki software\r
39 modified to be abstracted and shared across modules\r
40 \r
41 NOTE: why IDataStream and not IStream? because IStream is defined in windows IDL headers\r
42 */\r
43 \r
44 class IDataStream\r
45 {\r
46 public:  \r
47   IDataStream();\r
48   virtual ~IDataStream();\r
49 \r
50         virtual void IncRef () = 0;     ///< Increment the number of references to this object\r
51         virtual void DecRef () = 0; ///< Decrement the reference count\r
52 \r
53         virtual unsigned long GetPosition() const = 0;\r
54         virtual unsigned long Seek(long lOff, int nFrom) = 0;\r
55         virtual void SetLength(unsigned long nNewLen) = 0;\r
56         virtual unsigned long GetLength() const = 0;\r
57 \r
58         virtual char* ReadString(char* pBuf, unsigned long nMax)=0;\r
59         virtual unsigned long Read(void* pBuf, unsigned long nCount)=0;\r
60         virtual unsigned long Write(const void* pBuf, unsigned long nCount)=0;\r
61         virtual int GetChar()=0;\r
62         virtual int PutChar(int c)=0;\r
63 \r
64   virtual void printf(const char*, ...) = 0; ///< completely matches the usual printf behaviour\r
65 \r
66         virtual void Abort()=0;\r
67         virtual void Flush()=0;\r
68         virtual void Close()=0;\r
69 };\r
70 \r
71 #endif // _ISTREAM_H_\r