Panda3D
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  */
17 INLINE SubfileInfo::
18 SubfileInfo() :
19  _start(0),
20  _size(0)
21 {
22 }
23 
24 /**
25  *
26  */
27 INLINE SubfileInfo::
28 SubfileInfo(const FileReference *file, std::streampos start, std::streamsize size) :
29  _file(file),
30  _start(start),
31  _size(size)
32 {
33 }
34 
35 /**
36  *
37  */
38 INLINE SubfileInfo::
39 SubfileInfo(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  */
49 INLINE SubfileInfo::
50 SubfileInfo(const SubfileInfo &copy) :
51  _file(copy._file),
52  _start(copy._start),
53  _size(copy._size)
54 {
55 }
56 
57 /**
58  *
59  */
60 INLINE void SubfileInfo::
61 operator = (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  */
71 INLINE bool SubfileInfo::
72 is_empty() const {
73  return _file == nullptr;
74 }
75 
76 /**
77  * Returns the FileReference that represents this file.
78  */
79 INLINE const FileReference *SubfileInfo::
80 get_file() const {
81  return _file;
82 }
83 
84 /**
85  * A shortcut to the filename.
86  */
87 INLINE const Filename &SubfileInfo::
88 get_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  */
99 INLINE std::streampos SubfileInfo::
100 get_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  */
108 INLINE std::streamsize SubfileInfo::
109 get_size() const {
110  return _size;
111 }
112 
113 INLINE std::ostream &
114 operator << (std::ostream &out, const SubfileInfo &info) {
115  info.output(out);
116  return out;
117 }
std::streamsize get_size() const
Returns the number of consecutive bytes, beginning at get_start(), that correspond to this file data.
Definition: subfileInfo.I:109
Keeps a reference-counted pointer to a file on disk.
Definition: fileReference.h:26
const FileReference * get_file() const
Returns the FileReference that represents this file.
Definition: subfileInfo.I:80
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
bool is_empty() const
Returns true if this SubfileInfo doesn't define any file, false if it has real data.
Definition: subfileInfo.I:72
const Filename & get_filename() const
A shortcut to the filename.
Definition: subfileInfo.I:88
This class records a particular byte sub-range within an existing file on disk.
Definition: subfileInfo.h:26
std::streampos get_start() const
Returns the offset within the file at which this file data begins.
Definition: subfileInfo.I:100