Back to index

lightning-sunbird  0.9+nobinonly
nsBinaryStream.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  * ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code, released
00016  * March 31, 1998.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 1998-2001
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #ifndef nsBinaryStream_h___
00040 #define nsBinaryStream_h___
00041 
00042 #include "nsCOMPtr.h"
00043 #include "nsAString.h"
00044 #include "nsIObjectInputStream.h"
00045 #include "nsIObjectOutputStream.h"
00046 #include "nsIStreamBufferAccess.h"
00047 
00048 #define NS_BINARYOUTPUTSTREAM_CID        \
00049 { /* 86c37b9a-74e7-4672-844e-6e7dd83ba484 */         \
00050      0x86c37b9a,                                     \
00051      0x74e7,                                         \
00052      0x4672,                                         \
00053     {0x84, 0x4e, 0x6e, 0x7d, 0xd8, 0x3b, 0xa4, 0x84} \
00054 }
00055 
00056 #define NS_BINARYOUTPUTSTREAM_CONTRACTID "@mozilla.org/binaryoutputstream;1"
00057 #define NS_BINARYOUTPUTSTREAM_CLASSNAME "Binary Output Stream"
00058 
00059 // Derive from nsIObjectOutputStream so this class can be used as a superclass
00060 // by nsObjectOutputStream.
00061 class nsBinaryOutputStream : public nsIObjectOutputStream
00062 {
00063 public:
00064     nsBinaryOutputStream() {};
00065     // virtual dtor since subclasses call our Release()
00066     virtual ~nsBinaryOutputStream() {};
00067 
00068 protected:
00069     // nsISupports methods
00070     NS_DECL_ISUPPORTS
00071 
00072     // nsIOutputStream methods
00073     NS_DECL_NSIOUTPUTSTREAM
00074 
00075     // nsIBinaryOutputStream methods
00076     NS_DECL_NSIBINARYOUTPUTSTREAM
00077 
00078     // nsIObjectOutputStream methods
00079     NS_DECL_NSIOBJECTOUTPUTSTREAM
00080 
00081     // Call Write(), ensuring that all proffered data is written
00082     nsresult WriteFully(const char *aBuf, PRUint32 aCount);
00083 
00084     nsCOMPtr<nsIOutputStream>       mOutputStream;
00085     nsCOMPtr<nsIStreamBufferAccess> mBufferAccess;
00086 };
00087 
00088 #define NS_BINARYINPUTSTREAM_CID        \
00089 { /* c521a612-2aad-46db-b6ab-3b821fb150b1 */         \
00090      0xc521a612,                                     \
00091      0x2aad,                                         \
00092      0x46db,                                         \
00093     {0xb6, 0xab, 0x3b, 0x82, 0x1f, 0xb1, 0x50, 0xb1} \
00094 }
00095 
00096 #define NS_BINARYINPUTSTREAM_CONTRACTID "@mozilla.org/binaryinputstream;1"
00097 #define NS_BINARYINPUTSTREAM_CLASSNAME "Binary Input Stream"
00098 
00099 // Derive from nsIObjectInputStream so this class can be used as a superclass
00100 // by nsObjectInputStream.
00101 class nsBinaryInputStream : public nsIObjectInputStream
00102 {
00103 public:
00104     nsBinaryInputStream() {};
00105     // virtual dtor since subclasses call our Release()
00106     virtual ~nsBinaryInputStream() {};
00107 
00108 protected:
00109     // nsISupports methods
00110     NS_DECL_ISUPPORTS
00111 
00112     // nsIInputStream methods
00113     NS_DECL_NSIINPUTSTREAM
00114 
00115     // nsIBinaryInputStream methods
00116     NS_DECL_NSIBINARYINPUTSTREAM
00117 
00118     // nsIObjectInputStream methods
00119     NS_DECL_NSIOBJECTINPUTSTREAM
00120 
00121     nsCOMPtr<nsIInputStream>        mInputStream;
00122     nsCOMPtr<nsIStreamBufferAccess> mBufferAccess;
00123 };
00124 
00125 #endif // nsBinaryStream_h___