ISIS Core Library 0.7.2 (api 3.0.0)
|
Class to map files into memory. More...
#include <fileptr.hpp>
Data Structures | |
struct | Closer |
struct | GeneratorMap |
Public Member Functions | |
template<typename T > | |
ValueArray< T > | at (size_t offset, size_t len=0, bool swap_endianess=false) |
Get a ValueArray representing the data in the file. | |
data::ValueArrayReference | atByID (unsigned short ID, size_t offset, size_t len=0, bool swap_endianess=false) |
Get a ValueArrayReference to a ValueArray of the requested type. | |
FilePtr (const boost::filesystem::path &filename, size_t len=0, bool write=false) | |
Create a FilePtr, mapping the given file. | |
FilePtr () | |
empty creator - result will not be usefull until filled | |
bool | good () |
void | release () |
Class to map files into memory.
This can be used read only, or for read/write.
Writing to a FilePtr mapping a file read-only is valid. It will not change the mapped file.
This is inherting from ValueArray. Thus this, and all ValueArray created from it will be managed. The mapped file will automatically unmapped and closed after all pointers a deleted.
Definition at line 38 of file fileptr.hpp.
isis::data::FilePtr::FilePtr | ( | ) |
empty creator - result will not be usefull until filled
Definition at line 169 of file fileptr.cpp.
isis::data::FilePtr::FilePtr | ( | const boost::filesystem::path & | filename, |
size_t | len = 0 , |
||
bool | write = false |
||
) |
Create a FilePtr, mapping the given file.
if the write is true:
if write is false:
creation will fail (good()!=true afterwards) if:
filename | the file to map into memory |
len | the requested length of the resulting ValueArray in bytes (automatically set if 0) |
write | the file be opened for writing (writing to the mapped memory will write to the file, otherwise it will cause a copy-on-write) |
Definition at line 172 of file fileptr.cpp.
ValueArray<T> isis::data::FilePtr::at | ( | size_t | offset, |
size_t | len = 0 , |
||
bool | swap_endianess = false |
||
) | [inline] |
Get a ValueArray representing the data in the file.
The resulting ValueArray will use a proxy deleter to keep track of the mapped file. So the file will be unmapped and closed if, and only if all ValueArray created by this function and the FilePtr are closed.
If the FilePtr was opened writing, writing access to this ValueArray objects will result in writes to the file. Otherwise it will just write into memory.
Note that there is no conversion done, just reinterpretation of the raw data in the file.
offset | the position in the file to start from (in bytes) |
len | the requested length of the resulting ValueArray in elements (if that will go behind the end of the file, a warning will be issued). |
swap_endianess | if endianess should be swapped when reading data file (ignored when used on files opened for writing) |
Definition at line 103 of file fileptr.hpp.
ValueArrayReference isis::data::FilePtr::atByID | ( | unsigned short | ID, |
size_t | offset, | ||
size_t | len = 0 , |
||
bool | swap_endianess = false |
||
) |
Get a ValueArrayReference to a ValueArray of the requested type.
The resulting ValueArray will use a proxy deleter to keep track of the mapped file. So the file will be unmapped and closed if, and only if all ValueArray created by this function and the FilePtr are closed.
If the FilePtr was opened writing, writing access to this ValueArray objects will result in writes to the file. Otherwise it will just write into memory.
If the FilePtr was opened reading and the assumed endianess of the file (see parameter) does not fit the endianess of the system an (endianess-converted) deep copy is created.
ID | the requested type (note that there is no conversion done, just reinterpretation of the raw data in the file) |
offset | the position in the file to start from (in bytes) |
len | the requested length of the resulting ValueArray in elements (if that will go behind the end of the file, a warning will be issued). |
swap_endianess | if endianess should be swapped when reading data file (ignored when used on files opened for writing) |
Definition at line 214 of file fileptr.cpp.
bool isis::data::FilePtr::good | ( | ) |
Definition at line 206 of file fileptr.cpp.
void isis::data::FilePtr::release | ( | ) |
Definition at line 208 of file fileptr.cpp.