Inherits tpie::file_base_crtp< file_base >.
Inherited by tpie::file< T >.
|
| struct | block_t |
| | This is the type of our block buffers. More...
|
| |
| class | stream |
| | Stream in file. We support multiple streams per file. More...
|
| |
|
| static memory_size_type | block_size (double blockFactor) throw () |
| | Calculate the block size in bytes used by a stream. More...
|
| |
| static double | calculate_block_factor (memory_size_type blockSize) throw () |
| | Find the block factor that would result in the given block size measured in bytes. More...
|
| |
| static memory_size_type | block_memory_usage (double blockFactor) |
| | Amount of memory used by a single block given the block factor. More...
|
| |
|
|
void | update_size (stream_size_type size) |
| |
|
| file_base (memory_size_type item_size, double blockFactor=1.0, file_accessor::file_accessor *fileAccessor=NULL) |
| |
|
void | create_block () |
| |
|
void | delete_block () |
| |
|
block_t * | get_block (stream_size_type block) |
| |
|
void | free_block (block_t *block) |
| |
|
void | open_inner (const std::string &path, access_type accessType, memory_size_type userDataSize, cache_hint cacheHint) |
| |
|
void | read_block (BT &b, stream_size_type block) |
| |
|
void | get_block_check (stream_size_type block) |
| |
Definition at line 48 of file file_base.h.
◆ ~file_base()
| tpie::file_base::~file_base |
( |
| ) |
|
◆ block_items()
◆ block_memory_usage()
Amount of memory used by a single block given the block factor.
Definition at line 99 of file file_base_crtp.h.
◆ block_size() [1/2]
◆ block_size() [2/2]
Calculate the block size in bytes used by a stream.
We have block_size(calculate_block_factor(b)) ~= b.
- Parameters
-
| blockFactor | Factor of the global block size to use. |
- Returns
- Size in bytes.
Definition at line 79 of file file_base_crtp.h.
80 return static_cast<memory_size_type
>(
get_block_size() * blockFactor);
◆ calculate_block_factor()
Find the block factor that would result in the given block size measured in bytes.
We have calculate_block_factor(block_size(f)) ~= f.
- Parameters
-
| blockSize | The sought block size. |
- Returns
- The block factor needed to achieve this block size.
Definition at line 92 of file file_base_crtp.h.
93 return (
double)blockSize / (double)
block_size(1.0);
◆ file_size()
Get the size of the file measured in items.
If there are streams of this file that have extended the stream length but have not yet flushed these writes, we might report an incorrect size.
- Returns
- The number of items in the file.
Definition at line 269 of file file_base_crtp.h.
◆ is_open()
◆ is_readable()
Check if we can read from the file.
- Returns
- True if we can read from the file.
Definition at line 57 of file file_base_crtp.h.
◆ is_writable()
Check if we can write to the file.
- Returns
- True if we can write to the file.
Definition at line 66 of file file_base_crtp.h.
◆ max_user_data_size()
◆ open() [1/3]
Open a file.
- Parameters
-
| path | The path of the file to open. |
| accessType | The mode of operation. |
| userDataSize | The size of the user data we want to store in the file. |
Definition at line 208 of file file_base_crtp.h.
213 self().open_inner(
path, accessType, userDataSize, cacheHint);
◆ open() [2/3]
Open an anonymous temporary file.
The temporary file is deleted when this file is closed.
Definition at line 220 of file file_base_crtp.h.
223 m_ownedTempFile.reset(tpie_new<temp_file>());
224 m_tempFile=m_ownedTempFile.get();
◆ open() [3/3]
Open a temporary file.
The temporary file is not deleted when this file is closed, so several tpie::file objects may use the same temporary file consecutively.
Definition at line 233 of file file_base_crtp.h.
239 self().open_inner(m_tempFile->
path(), accessType, userDataSize, cacheHint);
◆ path()
The path of the file opened or the empty string.
- Returns
- The path of the currently opened file.
Definition at line 195 of file file_base_crtp.h.
197 return m_fileAccessor->
path();
◆ read_user_data() [1/2]
Read the user data associated with the file.
- Parameters
-
| data | Where to store the user data. |
- Template Parameters
-
| TT | The type of user data. sizeof(TT) must be less than or equal to the maximum user data size of the stream. TT must be trivially copyable. |
Definition at line 126 of file file_base_crtp.h.
128 if (
sizeof(TT) !=
user_data_size())
throw io_exception(
"Wrong user data size");
129 m_fileAccessor->
read_user_data(
reinterpret_cast<void*
>(&data),
sizeof(TT));
◆ read_user_data() [2/2]
Read variable length user data associated with the file.
- Parameters
-
| data | The buffer in which to write data. |
| count | The size of the buffer. |
- Returns
- Number of bytes of user data actually read.
Definition at line 139 of file file_base_crtp.h.
◆ truncate()
| void tpie::file_base::truncate |
( |
stream_size_type |
s | ) |
|
|
inline |
Truncate file to given size.
May only be used when no streams are opened to this file.
Definition at line 181 of file file_base.h.
183 if (!m_used.empty()) {
184 throw io_exception(
"Tried to truncate a file with one or more open streams");
187 m_fileAccessor->truncate(s);
189 m_tempFile->update_recorded_size(m_fileAccessor->
byte_size());
◆ user_data_size()
◆ write_user_data() [1/2]
Write user data to the stream.
- Parameters
-
| data | The user data to store in the stream. |
- Template Parameters
-
| TT | The type of user data. sizeof(TT) must be less than or equal to the maximum user data size of the stream. TT must be trivially copyable. |
Definition at line 153 of file file_base_crtp.h.
156 m_fileAccessor->
write_user_data(
reinterpret_cast<const void*
>(&data),
sizeof(TT));
◆ write_user_data() [2/2]
Write variable length user data associated with the file.
Throws a stream_exception if the size of the user data exceeds the maximum user data size of the stream.
- Parameters
-
| data | The buffer from which to read data. |
| count | The size of the user data. |
Definition at line 168 of file file_base_crtp.h.
The documentation for this class was generated from the following file: