// Boost.Sqlite review // Copyright (c) 2024 Barend Gehrels, Amsterdam, the Netherlands. // #include #include #include #include #include struct query_result { std::int64_t fid; boost::sqlite::string_view geom; std::int64_t blob_size; boost::sqlite::string_view reg_name; }; int main(int argc, char *argv[]) { boost::sqlite::connection conn{"italy.db"}; const auto meta = table_column_meta_data(conn, "limits_IT_regions", "geom"); std::cout << "Column: " << meta.data_type << " " << meta.collation << " " << meta.not_null << " " << meta.primary_key << " " << meta.auto_increment << std::endl; boost::sqlite::create_scalar_function(conn, "my_blob_size", [](boost::sqlite::context ctx, boost::span args) -> std::size_t { return args[0].get_blob().size(); }); std::string const query_string = "select fid,geom,my_blob_size(geom) as blob_size,reg_name from limits_IT_regions"; for (auto const& row : conn.query(query_string)) { std::cout << "Described " << row.fid << ": " << " " << row.reg_name << " " << row.blob_size << std::endl; } return 0; }