sbFileObjectStreams.h
Go to the documentation of this file.
1 /*
2 //
3 // Copyright(c) 2005-2009 POTI, Inc.
4 // http://songbirdnest.com
5 //
6 // This file may be licensed under the terms of of the
7 // GNU General Public License Version 2 (the "GPL").
8 //
9 // Software distributed under the License is distributed
10 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
11 // express or implied. See the GPL for the specific language
12 // governing rights and limitations.
13 //
14 // You should have received a copy of the GPL along with this
15 // program. If not, go to http://www.gnu.org/licenses/gpl.html
16 // or write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 //
19 // END SONGBIRD GPL
20 //
21 */
22 
23 #ifndef sbFileObjectStreams_h_
24 #define sbFileObjectStreams_h_
25 
26 #include <nsCOMPtr.h>
27 #include <nsIFile.h>
28 #include <nsIFileStreams.h>
29 #include <nsIBufferedStreams.h>
30 #include <nsIObjectOutputStream.h>
31 #include <nsIObjectInputStream.h>
32 
33 
34 //------------------------------------------------------------------------------
35 // Pure virtual class for file object streams.
36 
38 {
39 public:
41  virtual ~sbFileObjectStream();
42  //
43  // \brief Init a stream with a given file spec.
44  //
45  NS_IMETHOD InitWithFile(nsIFile *aStreamedFile) = 0;
46 
47  //
48  // \brief Close a file object stream.
49  //
50  NS_IMETHOD Close() = 0;
51 
52 protected:
55 };
56 
57 #define SB_DECL_SBFILEOBJECTSTREAM \
58  NS_IMETHOD InitWithFile(nsIFile *aStreamedFile); \
59  NS_IMETHOD Close();
60 
61 
62 //------------------------------------------------------------------------------
63 // File object output stream implementation.
64 
66  public nsISupports
67 {
68 public:
70  virtual ~sbFileObjectOutputStream();
71 
74 
75  nsresult WriteObject(nsISupports *aSupports, PRBool aIsStrongRef);
76 
77  // Warning: Do not pass a NULL string into this method.
78  nsresult WriteCString(const nsACString & aString);
79 
80  // Warning: Do not pass a NULL string into this method.
81  nsresult WriteString(const nsAString & aString);
82 
83  nsresult WriteUint32(PRUint32 aOutInt);
84 
85  nsresult WritePRBool(PRBool aBoolean);
86 
87  nsresult WriteBytes(const char *aData, PRUint32 aLength);
88 
89 private:
90  nsCOMPtr<nsIFileOutputStream> mFileOutputStream;
91  nsCOMPtr<nsIObjectOutputStream> mObjectOutputStream;
92 };
93 
94 
95 //------------------------------------------------------------------------------
96 // File object input stream implementation.
97 
99  public nsISupports
100 {
101 public:
103  virtual ~sbFileObjectInputStream();
104 
107 
108  nsresult ReadObject(PRBool aIsStrongRef, nsISupports **aOutObject);
109 
110  nsresult ReadCString(nsACString & aReadString);
111 
112  nsresult ReadString(nsAString & aReadString);
113 
114  nsresult ReadUint32(PRUint32 *aReadInt);
115 
116  nsresult ReadPRBool(PRBool *aReadBoolean);
117 
118  nsresult ReadBytes(PRUint32 aLength, char **aString);
119 
120 private:
121  nsCOMPtr<nsIFileInputStream> mFileInputStream;
122  nsCOMPtr<nsIBufferedInputStream> mBufferedInputStream;
123  nsCOMPtr<nsIObjectInputStream> mObjectInputStream;
124  PRBool mBufferedStreamIsActive;
125 };
126 
127 #endif // sbFileObjectStreams_h_
128 
nsresult ReadString(nsAString &aReadString)
nsresult ReadPRBool(PRBool *aReadBoolean)
NS_IMETHOD Close()=0
NS_IMETHOD InitWithFile(nsIFile *aStreamedFile)=0
nsresult WriteObject(nsISupports *aSupports, PRBool aIsStrongRef)
nsresult ReadBytes(PRUint32 aLength, char **aString)
nsresult WriteString(const nsAString &aString)
nsresult ReadUint32(PRUint32 *aReadInt)
nsresult WriteUint32(PRUint32 aOutInt)
nsresult WriteCString(const nsACString &aString)
#define SB_DECL_SBFILEOBJECTSTREAM
nsresult WriteBytes(const char *aData, PRUint32 aLength)
nsresult ReadObject(PRBool aIsStrongRef, nsISupports **aOutObject)
nsresult ReadCString(nsACString &aReadString)
_updateTextAndScrollDataForFrame aData
nsresult WritePRBool(PRBool aBoolean)