CatapultServer  v0.5.0.1 (Elephant)
IndexFile.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "RawFile.h"
23 #include <string>
24 
25 namespace catapult { namespace io {
26 
28  class IndexFile {
29  public:
31  explicit IndexFile(const std::string& filename, LockMode lockMode = LockMode::File);
32 
33  public:
35  bool exists() const;
36 
38  uint64_t get() const;
39 
40  public:
42  void set(uint64_t value);
43 
45  uint64_t increment();
46 
47  private:
48  RawFile open(OpenMode mode) const;
49 
50  private:
51  std::string m_filename;
53  };
54 }}
catapult::io::IndexFile::get
uint64_t get() const
Gets the index value.
Definition: IndexFile.cpp:36
catapult::io::IndexFile::open
RawFile open(OpenMode mode) const
Definition: IndexFile.cpp:62
catapult::io::RawFile
Wrapper for low-level i/o operations on files.
Definition: RawFile.h:49
catapult::io::IndexFile::m_filename
std::string m_filename
Definition: IndexFile.h:51
catapult::io::IndexFile
Index file containing a uint64_t value.
Definition: IndexFile.h:28
catapult::io::IndexFile::m_lockMode
LockMode m_lockMode
Definition: IndexFile.h:52
catapult::io::OpenMode::Read_Only
Open file in read-only mode.
catapult::io::LockMode
LockMode
Defines locking mode for the file.
Definition: RawFile.h:40
catapult::io::OpenMode
OpenMode
Defines mode of opening the file.
Definition: RawFile.h:28
RawFile.h
IndexFile.h
catapult::io::LockMode::File
Use file-based locking.
catapult::io::Write64
void Write64(TIo &output, uint64_t value)
Writes value into output.
Definition: PodIoUtils.h:36
catapult::io::IndexFile::set
void set(uint64_t value)
Sets the index value to value.
Definition: IndexFile.cpp:41
catapult::io::IndexFile::IndexFile
IndexFile(const std::string &filename, LockMode lockMode=LockMode::File)
Creates an index file with name filename and file locking specified by lockMode.
Definition: IndexFile.cpp:27
catapult::io::IndexFile::exists
bool exists() const
true if the index file exists.
Definition: IndexFile.cpp:32
catapult::io::OpenMode::Read_Append
Open file for both reading and writing.
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::io::Read64
auto Read64(TIo &input)
Reads value from input.
Definition: PodIoUtils.h:66
PodIoUtils.h
catapult::io::IndexFile::increment
uint64_t increment()
Increments the index value by one and returns the new value.
Definition: IndexFile.cpp:47