Joedb 10.2.3
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
rpc_client.cpp
Go to the documentation of this file.
6
7#include <iostream>
8
9namespace joedb
10{
11 static int rpc_client(Arguments &arguments)
12 {
13 const std::string_view endpoint_path = arguments.get_next("<endpoint_path>");
14
15 if (arguments.missing())
16 {
17 arguments.print_help(std::cerr);
18 return 1;
19 }
20
21 Local_Channel channel((std::string(endpoint_path)));
22 tutorial::rpc::Client rpc_client(channel);
23
24 {
26 city.set_name("Tombouctou");
27 rpc_client.insert_city(city);
28
29 try
30 {
31 rpc_client.insert_city(city);
32 }
33 catch (std::exception &e)
34 {
35 std::cout << "Caught exception: " << e.what() << '\n';
36 }
37
38 rpc_client.delete_city(city);
39 }
40
41 {
43 population.set_city_name(population.new_data(), "Tokyo");
44 population.set_city_name(population.new_data(), "Tombouctou");
45 population.set_city_name(population.new_data(), "Lille");
46 rpc_client.get_population(population);
48 }
49
50 {
52 db.set_name(db.new_city(), "Lille");
53 rpc_client.get_inhabitants(db);
54 tutorial::print_person_table(std::cout, db);
55 }
56
57 return 0;
58 }
59}
60
61int main(int argc, char **argv)
62{
63 return joedb::main_wrapper(joedb::rpc_client, argc, argv);
64}
Shortcut to directly build a Writable_Database with a Memory_File.
void set_name(id_of_city record, const std::string &field_value_of_name)
Specialization of joedb::rpc::Client.
Definition Client.h:22
Shortcut to directly build a Writable_Database with a Memory_File.
void set_name(id_of_city record, const std::string &field_value_of_name)
Shortcut to directly build a Writable_Database with a Memory_File.
void set_city_name(id_of_data record, const std::string &field_value_of_city_name)
int main()
int main_wrapper(int(*main)(Arguments &), int argc, char **argv)
Process command-line arguments and catch exceptions from main.
void print_data_table(std::ostream &out, const Database &db, size_t max_column_width=0, Record_Id start=Record_Id::null, size_t length=0)
Definition print_table.h:42
void print_person_table(std::ostream &out, const Database &db, size_t max_column_width=0, Record_Id start=Record_Id::null, size_t length=0)
Definition print_table.h:42