12#ifndef tutorial_rpc_population_Database_declared
13#define tutorial_rpc_population_Database_declared
40 class container_of_city;
41 class container_of_data;
50 size_t size()
const {
return freedom_keeper.
size();}
52 void resize(
size_t new_size)
54 freedom_keeper.
resize(new_size);
60 std::vector<std::string> field_value_of_city_name;
61 std::vector<id_of_city> field_value_of_city;
62 std::vector<int64_t> field_value_of_population;
66 size_t size()
const {
return freedom_keeper.
size();}
68 void resize(
size_t new_size)
70 field_value_of_city_name.resize(new_size);
71 field_value_of_city.resize(new_size);
72 field_value_of_population.resize(new_size);
73 freedom_keeper.
resize(new_size);
87 template<
typename E = joedb::Exception>
90 throw E(
"tutorial::rpc::population: " + message);
110 storage_of_data.field_value_of_city_name[to_underlying(record_id)].clear();
112 storage_of_data.field_value_of_population[to_underlying(record_id)] = 0;
140 const std::string& field_value_of_city_name
144 storage_of_data.field_value_of_city_name[to_underlying(record_id)] = field_value_of_city_name;
151 const std::string *value
155 std::string *target = &
storage_of_data.field_value_of_city_name.data()[to_underlying(record_id)];
157 std::copy_n(value, size, target);
167 storage_of_data.field_value_of_city[to_underlying(record_id)] = field_value_of_city;
180 std::copy_n(value, size, target);
186 int64_t field_value_of_population
190 storage_of_data.field_value_of_population[to_underlying(record_id)] = field_value_of_population;
201 int64_t *target = &
storage_of_data.field_value_of_population.data()[to_underlying(record_id)];
203 std::copy_n(value, size, target);
225 template<
class Comparator>
226 std::vector<id_of_city>
sorted_city(Comparator comparator)
const;
251 template<
class Comparator>
252 std::vector<id_of_data>
sorted_data(Comparator comparator)
const;
293 iterator(
const detail::data_of_city &data): fk(&data.freedom_keeper), index(
joedb::Freedom_Keeper_Constants::used_list) {}
326 template<
class Comparator>
329 std::vector<id_of_city> result;
331 result.emplace_back(x);
332 std::sort(result.begin(), result.end(), comparator);
351 iterator(
const detail::data_of_data &data): fk(&data.freedom_keeper), index(
joedb::Freedom_Keeper_Constants::used_list) {}
384 template<
class Comparator>
387 std::vector<id_of_data> result;
389 result.emplace_back(x);
390 std::sort(result.begin(), result.end(), comparator);
void resize(Record_Id new_size)
Record_Id get_previous(Record_Id index) const
Record_Id get_next(Record_Id index) const
static const Record_Id null
Strongly-typed wrapper around an integer representing a row of the city table.
Store all the tables of the database.
detail::data_of_data storage_of_data
friend class container_of_city
detail::data_of_city storage_of_city
void internal_update_vector_data__city_name(Record_Id record_id, size_t size, const std::string *value)
void internal_update_vector_data__city(Record_Id record_id, size_t size, const id_of_city *value)
void internal_vector_insert_city(Record_Id record_id, size_t size)
id_of_data previous(id_of_data id) const
void internal_update_data__population(Record_Id record_id, int64_t field_value_of_population)
void internal_delete_city(Record_Id record_id)
static id_of_data null_data()
std::vector< id_of_city > sorted_city(Comparator comparator) const
void internal_update_data__city(Record_Id record_id, id_of_city field_value_of_city)
std::vector< id_of_data > sorted_data(Comparator comparator) const
id_of_data next(id_of_data id) const
void internal_delete_data(Record_Id record_id)
bool is_valid(id_of_city id) const
void internal_update_data__city_name(Record_Id record_id, const std::string &field_value_of_city_name)
container_of_data get_data_table() const
friend class container_of_data
bool is_valid_record_id_for_data(Record_Id record_id) const
const std::string & get_city_name(id_of_data record) const
bool is_valid_record_id_for_city(Record_Id record_id) const
bool is_valid(id_of_data id) const
void internal_insert_data(Record_Id record_id)
static id_of_city null_city()
int64_t get_population(id_of_data record) const
id_of_city get_city(id_of_data record) const
id_of_city previous(id_of_city id) const
void internal_update_vector_data__population(Record_Id record_id, size_t size, const int64_t *value)
static void throw_exception(const std::string &message)
container_of_city get_city_table() const
void internal_vector_insert_data(Record_Id record_id, size_t size)
void internal_insert_city(Record_Id record_id)
id_of_city next(id_of_city id) const
Implement the joedb::Readable interface for a compiled database.
id_of_city operator*() const
bool operator!=(const iterator &i) const
std::forward_iterator_tag iterator_category
bool operator==(const iterator &i) const
std::ptrdiff_t difference_type
returned by Database::get_city_table
joedb::index_t get_size() const
bool is_valid_at(size_t i)
static id_of_city get_at(size_t i)
id_of_city get_end() const
std::ptrdiff_t difference_type
bool operator!=(const iterator &i) const
std::forward_iterator_tag iterator_category
bool operator==(const iterator &i) const
id_of_data operator*() const
returned by Database::get_data_table
bool is_valid_at(size_t i)
static id_of_data get_at(size_t i)
joedb::index_t get_size() const
id_of_data get_end() const
Strongly-typed wrapper around an integer representing a row of the data table.
constexpr auto get_id() const
constexpr Record_Id get_record_id() const
#define JOEDB_RELEASE_ASSERT(x)
always-tested assertion (release and debug mode)
constexpr const char * get_version()
Automatically generated by joedbc.
tutorial::id_of_city id_of_city