a file of records of a trivially copyable type on the disk
More...
#include <ADS/external/RecordFile.h>
|
| using | value_type = T |
| | the type of the records
|
| using | size_type = std::size_t |
| | the type of the sizes
|
|
| | RecordFile (std::filesystem::path path) |
| | the file at path, whose records are those already there, if any
|
| const std::filesystem::path & | path (void) const |
| | the path of the file
|
| std::size_t | size (void) const |
| | the number of whole records of the file, 0 if it does not exist
|
| bool | empty (void) const |
| | whether the file has no record
|
| void | append (const T *src, std::size_t n) |
| | the \( n \) records of src appended at the end of the file, which is made if it does not exist, after its last whole record (the bytes of a record left partial by a write interrupted, which size() and the scans do not count, are dropped)
|
| template<class F> |
| void | forEach (F &&f, std::size_t buffer=defaultBuffer) const |
| | \( f( x ) \) for each record \( x \) of the file, in order, read through a buffer of buffer records
|
| std::vector< T > | readAll (void) const |
| | all the records of the file, in order
|
| void | clear (void) |
| | the file emptied, and made if it does not exist
|
| void | remove (void) |
| | the file deleted from the disk, if it is there
|
|
| static constexpr std::size_t | defaultBuffer |
| | the records of a buffer of 1 MB, the default of the scans and of the writers
|
template<class T>
requires std::is_trivially_copyable_v< T >
class ADS::RecordFile< T >
a file of records of a trivially copyable type on the disk
◆ size_type
◆ value_type
◆ RecordFile()
the file at path, whose records are those already there, if any
◆ append()
the \( n \) records of src appended at the end of the file, which is made if it does not exist, after its last whole record (the bytes of a record left partial by a write interrupted, which size() and the scans do not count, are dropped)
- Precondition
- src is not null unless \( n = 0 \)
- Postcondition
- size() grows by \( n \)
◆ clear()
the file emptied, and made if it does not exist
- Postcondition
- empty()
◆ empty()
whether the file has no record
◆ forEach()
template<class T>
template<class F>
\( f( x ) \) for each record \( x \) of the file, in order, read through a buffer of buffer records
- Precondition
- buffer \( \ge 1 \)
◆ path()
◆ readAll()
all the records of the file, in order
◆ remove()
the file deleted from the disk, if it is there
- Postcondition
- empty()
◆ size()
the number of whole records of the file, 0 if it does not exist
◆ defaultBuffer
Initial value: =
sizeof( T ) >= ( std::size_t( 1 ) << 20 )
? 1
: ( std::size_t( 1 ) << 20 ) / sizeof( T )
the records of a buffer of 1 MB, the default of the scans and of the writers
The documentation for this class was generated from the following file: