xpcom/io/nsBinaryStream.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/io/nsBinaryStream.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,90 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsBinaryStream_h___
    1.10 +#define nsBinaryStream_h___
    1.11 +
    1.12 +#include "nsCOMPtr.h"
    1.13 +#include "nsAString.h"
    1.14 +#include "nsIObjectInputStream.h"
    1.15 +#include "nsIObjectOutputStream.h"
    1.16 +#include "nsIStreamBufferAccess.h"
    1.17 +
    1.18 +#define NS_BINARYOUTPUTSTREAM_CID        \
    1.19 +{ /* 86c37b9a-74e7-4672-844e-6e7dd83ba484 */         \
    1.20 +     0x86c37b9a,                                     \
    1.21 +     0x74e7,                                         \
    1.22 +     0x4672,                                         \
    1.23 +    {0x84, 0x4e, 0x6e, 0x7d, 0xd8, 0x3b, 0xa4, 0x84} \
    1.24 +}
    1.25 +
    1.26 +#define NS_BINARYOUTPUTSTREAM_CONTRACTID "@mozilla.org/binaryoutputstream;1"
    1.27 +
    1.28 +// Derive from nsIObjectOutputStream so this class can be used as a superclass
    1.29 +// by nsObjectOutputStream.
    1.30 +class nsBinaryOutputStream : public nsIObjectOutputStream
    1.31 +{
    1.32 +public:
    1.33 +    nsBinaryOutputStream() {}
    1.34 +    // virtual dtor since subclasses call our Release()
    1.35 +    virtual ~nsBinaryOutputStream() {}
    1.36 +
    1.37 +protected:
    1.38 +    // nsISupports methods
    1.39 +    NS_DECL_ISUPPORTS
    1.40 +
    1.41 +    // nsIOutputStream methods
    1.42 +    NS_DECL_NSIOUTPUTSTREAM
    1.43 +
    1.44 +    // nsIBinaryOutputStream methods
    1.45 +    NS_DECL_NSIBINARYOUTPUTSTREAM
    1.46 +
    1.47 +    // nsIObjectOutputStream methods
    1.48 +    NS_DECL_NSIOBJECTOUTPUTSTREAM
    1.49 +
    1.50 +    // Call Write(), ensuring that all proffered data is written
    1.51 +    nsresult WriteFully(const char *aBuf, uint32_t aCount);
    1.52 +
    1.53 +    nsCOMPtr<nsIOutputStream>       mOutputStream;
    1.54 +    nsCOMPtr<nsIStreamBufferAccess> mBufferAccess;
    1.55 +};
    1.56 +
    1.57 +#define NS_BINARYINPUTSTREAM_CID        \
    1.58 +{ /* c521a612-2aad-46db-b6ab-3b821fb150b1 */         \
    1.59 +     0xc521a612,                                     \
    1.60 +     0x2aad,                                         \
    1.61 +     0x46db,                                         \
    1.62 +    {0xb6, 0xab, 0x3b, 0x82, 0x1f, 0xb1, 0x50, 0xb1} \
    1.63 +}
    1.64 +
    1.65 +#define NS_BINARYINPUTSTREAM_CONTRACTID "@mozilla.org/binaryinputstream;1"
    1.66 +
    1.67 +// Derive from nsIObjectInputStream so this class can be used as a superclass
    1.68 +// by nsObjectInputStream.
    1.69 +class nsBinaryInputStream : public nsIObjectInputStream
    1.70 +{
    1.71 +public:
    1.72 +    nsBinaryInputStream() {}
    1.73 +    // virtual dtor since subclasses call our Release()
    1.74 +    virtual ~nsBinaryInputStream() {}
    1.75 +
    1.76 +protected:
    1.77 +    // nsISupports methods
    1.78 +    NS_DECL_ISUPPORTS
    1.79 +
    1.80 +    // nsIInputStream methods
    1.81 +    NS_DECL_NSIINPUTSTREAM
    1.82 +
    1.83 +    // nsIBinaryInputStream methods
    1.84 +    NS_DECL_NSIBINARYINPUTSTREAM
    1.85 +
    1.86 +    // nsIObjectInputStream methods
    1.87 +    NS_DECL_NSIOBJECTINPUTSTREAM
    1.88 +
    1.89 +    nsCOMPtr<nsIInputStream>        mInputStream;
    1.90 +    nsCOMPtr<nsIStreamBufferAccess> mBufferAccess;
    1.91 +};
    1.92 +
    1.93 +#endif // nsBinaryStream_h___

mercurial