Panda3D
Loading...
Searching...
No Matches
ramfile.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file ramfile.h
10 * @author mike
11 * @date 1997-01-09
12 */
13
14#ifndef RAMFILE_H
15#define RAMFILE_H
16
17#include "pandabase.h"
18#include "typedef.h"
19#include "referenceCount.h"
20#include "extension.h"
21
22/**
23 * An in-memory buffer specifically designed for downloading files to memory.
24 */
25class EXPCL_PANDA_EXPRESS Ramfile {
26PUBLISHED:
27 INLINE Ramfile();
28
29 INLINE void seek(size_t pos);
30 INLINE size_t tell() const;
31 EXTENSION(PyObject *read(size_t length));
32 EXTENSION(PyObject *readline());
33 EXTENSION(PyObject *readlines());
34
35 EXTENSION(PyObject *get_data() const);
36 INLINE size_t get_data_size() const;
37 INLINE void clear();
38
39public:
40 std::string read(size_t length);
41 std::string readline();
42 INLINE const std::string &get_data() const;
43
44 size_t _pos;
45 std::string _data;
46
47 friend class Extension<Ramfile>;
48};
49
50#include "ramfile.I"
51
52#endif
The default class template does not define any methods.
Definition extension.h:34
void clear()
Empties the current buffer contents.
Definition ramfile.I:61
size_t tell() const
Returns the current data pointer position as a byte offset from the beginning of the stream.
Definition ramfile.I:36
void seek(size_t pos)
Moves the data pointer to the indicated byte position.
Definition ramfile.I:27
size_t get_data_size() const
Returns the size of the entire buffer contents.
Definition ramfile.I:53
std::string readline()
Assumes the stream represents a text file, and extracts one line up to and including the trailing new...
Definition ramfile.cxx:40
std::string read(size_t length)
Extracts and returns the indicated number of characters from the current data pointer,...
Definition ramfile.cxx:25
const std::string & get_data() const
Returns the entire buffer contents as a string, regardless of the current data pointer.
Definition ramfile.I:45
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.