PTLib  Version 2.14.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
memfile.h
Go to the documentation of this file.
1 /*
2  * memfile.h
3  *
4  * WAV file I/O channel class.
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 2002 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is
23  * Equivalence Pty Ltd
24  *
25  * All Rights Reserved.
26  *
27  * Contributor(s): ______________________________________.
28  *
29  * $Revision: 26950 $
30  * $Author: rjongbloed $
31  * $Date: 2012-02-08 13:37:08 +1100 (Wed, 08 Feb 2012) $
32  */
33 
34 #ifndef PTLIB_PMEMFILE_H
35 #define PTLIB_PMEMFILE_H
36 
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40 
41 
44 class PMemoryFile : public PFile
45 {
46  PCLASSINFO(PMemoryFile, PFile);
47  public:
52  PMemoryFile();
53 
57  const PBYTEArray & data
58  );
59 
62  ~PMemoryFile();
64 
65 
75  const PObject & obj
76  ) const;
78 
79 
93  virtual PBoolean Open(
94  OpenMode mode = ReadWrite, // Mode in which to open the file.
95  int opts = ModeDefault // Options for open operation.
96  );
97 
108  virtual PBoolean Open(
109  const PFilePath & name, // Name of file to open.
110  OpenMode mode = ReadWrite, // Mode in which to open the file.
111  int opts = ModeDefault // <code>OpenOptions</code> enum# for open operation.
112  );
113 
118  virtual PBoolean Close();
119 
131  virtual PBoolean Read(
132  void * buf,
133  PINDEX len
134  );
135 
145  virtual PBoolean Write(
146  const void * buf,
147  PINDEX len
148  );
150 
151 
160  virtual off_t GetLength() const;
161 
168  virtual PBoolean SetLength(
169  off_t len
170  );
171 
182  virtual PBoolean SetPosition(
183  off_t pos,
184  FilePositionOrigin origin = Start
185  );
186 
193  virtual off_t GetPosition() const;
195 
196 
201  const PBYTEArray & GetData() const { return m_data; }
203 
204 
205  protected:
207  off_t m_position;
208 };
209 
210 
211 #endif // PTLIB_PMEMFILE_H
212 
213 
214 // End of File ///////////////////////////////////////////////////////////////