/dbpp

Generic C++14 Database Construction Library

Primary LanguageC++BSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

dbpp

About

A generic, header-only C++14 database library. Store any values that are default-initializable, copy-assignable and move-assignable.

Makes heavy use of compile-time strings so records/fields are easily accessible at compile-time.

All the code is documented for doxygen, so running doxygen on the include directory should be sufficent if you want better documentation.

Credit where due

I'm using this great compile-time string library from George Makrydakis to achieve compile-time string identifiers.

Example

Here is an example of a user information database

#include "dbpp/dbpp.hpp"

int main(){
	using user_record = dbpp::record<
		// the id of the record is "users"
		dbpp_id("users"),
		
		// the type used to identify individual instances of this record
		std::string,
		
		// some fields
		dbpp::field<dbpp_id("email"), std::string>,
		dbpp::field<dbpp_id("dob"), std::string>
	>;
	
	// database with one type of record
	dbpp::database<user_record> db;
	
	// get record category by id
	auto &&users = db.get<dbpp_id("users")>();
	
	// create a user record
	auto &&coolUserName420 = users.make_record("coolUserName420", "skuxx_muffin70@gmail.com");
	
	// we need to modify the users email
	coolUserName420.get<dbpp_id("email")>() = "skuxx_muffin69@gmail.com";
}