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