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