Joedb 10.0.1
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
process_journal_pair.cpp
Go to the documentation of this file.
3
4#include <iostream>
5
6namespace joedb
7{
8 ////////////////////////////////////////////////////////////////////////////
10 ////////////////////////////////////////////////////////////////////////////
11 (
12 Arguments &arguments,
13 void (*process)(Readonly_Journal &, Writable_Journal &, int64_t checkpoint)
14 )
15 {
16 const bool ignore_header = arguments.has_flag("ignore_header");
17 const int64_t until = arguments.get_option<int64_t>
18 (
19 "until",
20 "checkpoint",
21 0
22 );
23 const std::string_view input = arguments.get_next("input.joedb");
24 const std::string_view output = arguments.get_next("output.joedb");
25
26 if (arguments.missing())
27 {
28 arguments.print_help(std::cerr);
29 return 1;
30 }
31
32 File input_file(input.data(), Open_Mode::read_existing);
33
34 Readonly_Journal input_journal
35 (
37 (
38 input_file,
40 )
41 );
42
43 File output_file(output.data(), Open_Mode::create_new);
44 Writable_Journal output_journal(output_file);
45
46 process(input_journal, output_journal, until);
47
48 return 0;
49 }
50}
Class for conveniently parsing command-line arguments.
Definition Arguments.h:19
@ create_new
fails if already exists, locks the file for writing
@ read_existing
fails if does not exist
@ none
default: fail if file size > checkpoint
@ ignore_header
use file size as checkpoint
int process_journal_pair(Arguments &arguments, void(*process)(Readonly_Journal &, Writable_Journal &, int64_t checkpoint))
Definition Blob.h:7
JOEDB_FILE File
Definition File.h:25