VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/io/nsStorageStream.h@ 31232

最後變更 在這個檔案從31232是 1,由 vboxsync 提交於 55 年 前

import

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 4.0 KB
 
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is Mozilla Communicator client code, released
16 * March 31, 1998.
17 *
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998-1999
21 * the Initial Developer. All Rights Reserved.
22 *
23 * Contributor(s):
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38
39/*
40 * The storage stream provides an internal buffer that can be filled by a
41 * client using a single output stream. One or more independent input streams
42 * can be created to read the data out non-destructively. The implementation
43 * uses a segmented buffer internally to avoid realloc'ing of large buffers,
44 * with the attendant performance loss and heap fragmentation.
45 */
46
47#ifndef _nsStorageStream_h_
48#define _nsStorageStream_h_
49
50#include "nsIStorageStream.h"
51#include "nsIOutputStream.h"
52#include "nsMemory.h"
53
54#define NS_STORAGESTREAM_CID \
55{ /* 669a9795-6ff7-4ed4-9150-c34ce2971b63 */ \
56 0x669a9795, \
57 0x6ff7, \
58 0x4ed4, \
59 {0x91, 0x50, 0xc3, 0x4c, 0xe2, 0x97, 0x1b, 0x63} \
60}
61
62#define NS_STORAGESTREAM_CONTRACTID "@mozilla.org/storagestream;1"
63#define NS_STORAGESTREAM_CLASSNAME "Storage Stream"
64
65class nsSegmentedBuffer;
66
67class nsStorageStream : public nsIStorageStream,
68 public nsIOutputStream
69{
70public:
71 nsStorageStream();
72
73 NS_DECL_ISUPPORTS
74 NS_DECL_NSISTORAGESTREAM
75 NS_DECL_NSIOUTPUTSTREAM
76
77 friend class nsStorageInputStream;
78
79private:
80 ~nsStorageStream();
81
82 nsSegmentedBuffer* mSegmentedBuffer;
83 PRUint32 mSegmentSize; // All segments, except possibly the last, are of this size
84 // Must be power-of-2
85 PRUint32 mSegmentSizeLog2; // log2(mSegmentSize)
86 PRBool mWriteInProgress; // true, if an un-Close'ed output stream exists
87 PRInt32 mLastSegmentNum; // Last segment # in use, -1 initially
88 char* mWriteCursor; // Pointer to next byte to be written
89 char* mSegmentEnd; // Pointer to one byte after end of segment
90 // containing the write cursor
91 PRUint32 mLogicalLength; // Number of bytes written to stream
92
93 NS_METHOD Seek(PRInt32 aPosition);
94 PRUint32 SegNum(PRUint32 aPosition) {return aPosition >> mSegmentSizeLog2;}
95 PRUint32 SegOffset(PRUint32 aPosition) {return aPosition & (mSegmentSize - 1);}
96};
97
98#endif // _nsStorageStream_h_
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette