summaryrefslogtreecommitdiff
path: root/src/memory_file.h
blob: 0701f7637f17a551f757ea4deece9a0d6ed34da0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef MEMORY_FILE_H
#define MEMORY_FILE_H


#include "audiere.h"
#include "types.h"


namespace audiere {

  class MemoryFile : public RefImplementation<File> {
  public:
    MemoryFile(const void* buffer, int size);
    ~MemoryFile();

    int  ADR_CALL read(void* buffer, int size);
    int  ADR_CALL write(const void* buffer, int size);
    bool ADR_CALL seek(int position, SeekMode mode);
    int  ADR_CALL tell();

  private:
    void ensureSize(int min_size);

    u8* m_buffer;
    int m_position;
    int m_size;

    /// The actual size of m_buffer.  Always a power of two.
    int m_capacity;
  };

}


#endif