Panda3D
Loading...
Searching...
No Matches
subfileInfo.I
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 subfileInfo.I
10 * @author drose
11 * @date 2011-06-20
12 */
13
14/**
15 *
16 */
17INLINE SubfileInfo::
18SubfileInfo() :
19 _start(0),
20 _size(0)
21{
22}
23
24/**
25 *
26 */
27INLINE SubfileInfo::
28SubfileInfo(const FileReference *file, std::streampos start, std::streamsize size) :
29 _file(file),
30 _start(start),
31 _size(size)
32{
33}
34
35/**
36 *
37 */
38INLINE SubfileInfo::
39SubfileInfo(const Filename &filename, std::streampos start, std::streamsize size) :
40 _file(new FileReference(filename)),
41 _start(start),
42 _size(size)
43{
44}
45
46/**
47 *
48 */
49INLINE SubfileInfo::
50SubfileInfo(const SubfileInfo &copy) :
51 _file(copy._file),
52 _start(copy._start),
53 _size(copy._size)
54{
55}
56
57/**
58 *
59 */
60INLINE void SubfileInfo::
61operator = (const SubfileInfo &copy) {
62 _file = copy._file;
63 _start = copy._start;
64 _size = copy._size;
65}
66
67/**
68 * Returns true if this SubfileInfo doesn't define any file, false if it has
69 * real data.
70 */
71INLINE bool SubfileInfo::
72is_empty() const {
73 return _file == nullptr;
74}
75
76/**
77 * Returns the FileReference that represents this file.
78 */
80get_file() const {
81 return _file;
82}
83
84/**
85 * A shortcut to the filename.
86 */
88get_filename() const {
89 if (_file != nullptr) {
90 return _file->get_filename();
91 }
92 static const Filename empty_filename;
93 return empty_filename;
94}
95
96/**
97 * Returns the offset within the file at which this file data begins.
98 */
99INLINE std::streampos SubfileInfo::
100get_start() const {
101 return _start;
102}
103
104/**
105 * Returns the number of consecutive bytes, beginning at get_start(), that
106 * correspond to this file data.
107 */
108INLINE std::streamsize SubfileInfo::
109get_size() const {
110 return _size;
111}
112
113INLINE std::ostream &
114operator << (std::ostream &out, const SubfileInfo &info) {
115 info.output(out);
116 return out;
117}
Keeps a reference-counted pointer to a file on disk.
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
This class records a particular byte sub-range within an existing file on disk.
Definition subfileInfo.h:26
const Filename & get_filename() const
A shortcut to the filename.
Definition subfileInfo.I:88
const FileReference * get_file() const
Returns the FileReference that represents this file.
Definition subfileInfo.I:80
std::streampos get_start() const
Returns the offset within the file at which this file data begins.
bool is_empty() const
Returns true if this SubfileInfo doesn't define any file, false if it has real data.
Definition subfileInfo.I:72
std::streamsize get_size() const
Returns the number of consecutive bytes, beginning at get_start(), that correspond to this file data.