Tkrzw
Public Types | Public Member Functions | Friends | List of all members
tkrzw::FlatRecord Class Referencefinal

Flat record structure in the file. More...

#include <tkrzw_file_util.h>

Public Types

enum  RecordType : int32_t { RECORD_NORMAL = 0 , RECORD_METADATA = 1 }
 Enumeration of record types. More...
 

Public Member Functions

 FlatRecord (File *file)
 Constructor. More...
 
 ~FlatRecord ()
 Destructor. More...
 
Status Read (int64_t offset)
 Reads the next data. More...
 
std::string_view GetData () const
 Gets the data. More...
 
RecordType GetRecordType () const
 Gets the record type. More...
 
size_t GetOffset () const
 Gets the offset of the record. More...
 
size_t GetWholeSize () const
 Gets the whole size of the record. More...
 
Status Write (std::string_view data, RecordType rec_type=RECORD_NORMAL)
 Writes the record in the file. More...
 

Friends

class FlatRecordReader
 

Detailed Description

Flat record structure in the file.

Member Enumeration Documentation

◆ RecordType

Enumeration of record types.

Enumerator
RECORD_NORMAL 

For normal records.

RECORD_METADATA 

For metadata records.

Constructor & Destructor Documentation

◆ FlatRecord()

tkrzw::FlatRecord::FlatRecord ( File file)
explicit

Constructor.

Parameters
fileThe pointer to the file object. The ownership is not taken.

◆ ~FlatRecord()

tkrzw::FlatRecord::~FlatRecord ( )

Destructor.

Member Function Documentation

◆ Read()

Status tkrzw::FlatRecord::Read ( int64_t  offset)

Reads the next data.

Parameters
offsetThe offset of the record.
Returns
The result status.

◆ GetData()

std::string_view tkrzw::FlatRecord::GetData ( ) const

Gets the data.

Returns
The data.

◆ GetRecordType()

RecordType tkrzw::FlatRecord::GetRecordType ( ) const

Gets the record type.

Returns
The record type.

◆ GetOffset()

size_t tkrzw::FlatRecord::GetOffset ( ) const

Gets the offset of the record.

Returns
The offset of the record.

◆ GetWholeSize()

size_t tkrzw::FlatRecord::GetWholeSize ( ) const

Gets the whole size of the record.

Returns
The whole size of the record.

◆ Write()

Status tkrzw::FlatRecord::Write ( std::string_view  data,
RecordType  rec_type = RECORD_NORMAL 
)

Writes the record in the file.

Parameters
dataThe record data.
rec_typeThe record type.
Returns
The result status.