xpcom/io/nsBinaryStream.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:bec549cdc522
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef nsBinaryStream_h___
7 #define nsBinaryStream_h___
8
9 #include "nsCOMPtr.h"
10 #include "nsAString.h"
11 #include "nsIObjectInputStream.h"
12 #include "nsIObjectOutputStream.h"
13 #include "nsIStreamBufferAccess.h"
14
15 #define NS_BINARYOUTPUTSTREAM_CID \
16 { /* 86c37b9a-74e7-4672-844e-6e7dd83ba484 */ \
17 0x86c37b9a, \
18 0x74e7, \
19 0x4672, \
20 {0x84, 0x4e, 0x6e, 0x7d, 0xd8, 0x3b, 0xa4, 0x84} \
21 }
22
23 #define NS_BINARYOUTPUTSTREAM_CONTRACTID "@mozilla.org/binaryoutputstream;1"
24
25 // Derive from nsIObjectOutputStream so this class can be used as a superclass
26 // by nsObjectOutputStream.
27 class nsBinaryOutputStream : public nsIObjectOutputStream
28 {
29 public:
30 nsBinaryOutputStream() {}
31 // virtual dtor since subclasses call our Release()
32 virtual ~nsBinaryOutputStream() {}
33
34 protected:
35 // nsISupports methods
36 NS_DECL_ISUPPORTS
37
38 // nsIOutputStream methods
39 NS_DECL_NSIOUTPUTSTREAM
40
41 // nsIBinaryOutputStream methods
42 NS_DECL_NSIBINARYOUTPUTSTREAM
43
44 // nsIObjectOutputStream methods
45 NS_DECL_NSIOBJECTOUTPUTSTREAM
46
47 // Call Write(), ensuring that all proffered data is written
48 nsresult WriteFully(const char *aBuf, uint32_t aCount);
49
50 nsCOMPtr<nsIOutputStream> mOutputStream;
51 nsCOMPtr<nsIStreamBufferAccess> mBufferAccess;
52 };
53
54 #define NS_BINARYINPUTSTREAM_CID \
55 { /* c521a612-2aad-46db-b6ab-3b821fb150b1 */ \
56 0xc521a612, \
57 0x2aad, \
58 0x46db, \
59 {0xb6, 0xab, 0x3b, 0x82, 0x1f, 0xb1, 0x50, 0xb1} \
60 }
61
62 #define NS_BINARYINPUTSTREAM_CONTRACTID "@mozilla.org/binaryinputstream;1"
63
64 // Derive from nsIObjectInputStream so this class can be used as a superclass
65 // by nsObjectInputStream.
66 class nsBinaryInputStream : public nsIObjectInputStream
67 {
68 public:
69 nsBinaryInputStream() {}
70 // virtual dtor since subclasses call our Release()
71 virtual ~nsBinaryInputStream() {}
72
73 protected:
74 // nsISupports methods
75 NS_DECL_ISUPPORTS
76
77 // nsIInputStream methods
78 NS_DECL_NSIINPUTSTREAM
79
80 // nsIBinaryInputStream methods
81 NS_DECL_NSIBINARYINPUTSTREAM
82
83 // nsIObjectInputStream methods
84 NS_DECL_NSIOBJECTINPUTSTREAM
85
86 nsCOMPtr<nsIInputStream> mInputStream;
87 nsCOMPtr<nsIStreamBufferAccess> mBufferAccess;
88 };
89
90 #endif // nsBinaryStream_h___

mercurial