Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joeyates/cpp-active-record
A C++ Implementation of the Active Record Pattern
https://github.com/joeyates/cpp-active-record
Last synced: 29 days ago
JSON representation
A C++ Implementation of the Active Record Pattern
- Host: GitHub
- URL: https://github.com/joeyates/cpp-active-record
- Owner: joeyates
- License: gpl-3.0
- Created: 2010-08-09T22:57:21.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2018-12-04T18:29:33.000Z (almost 6 years ago)
- Last Synced: 2024-07-31T22:57:48.058Z (3 months ago)
- Language: C++
- Homepage:
- Size: 672 KB
- Stars: 34
- Watchers: 10
- Forks: 14
- Open Issues: 1
-
Metadata Files:
- Readme: README
- Changelog: ChangeLog
- License: COPYING
Awesome Lists containing this project
README
[![Build Status](https://secure.travis-ci.org/joeyates/cpp-active-record.png)][Continuous Integration]
ActiveRecord - a C++ implementation of the Active Record pattern.
* [Source][Source Code]
* [Continuous Integration][Continuous Integration][Source Code]: https://github.com/joeyates/cpp-active-record "Source code at GitHub"
[Continuous Integration]: http://travis-ci.org/joeyates/cpp-active-record "Build status by Travis-CI"Databases supported:
* PostgreSQL
* SQLite# Installation
See the file INSTALL.md.
# Quick Start Guide
Here's a Hello World! example, that saves a record to the database, and retrieves
it:```c++
#include
#include
#include
#include
#includeclass Greeting: public ActiveRecord::Base {
public:
AR_CONSTRUCTORS(Greeting)
static ActiveRecord::Table table(ActiveRecord::Connection* connection) {
ActiveRecord::Table td(connection, "greetings");
td.fields() =
ActiveRecord::fields
("salute", ActiveRecord::Type::text)
("thing", ActiveRecord::Type::text)
("language", ActiveRecord::Type::text);
return td;
}
};AR_DECLARE(Greeting)
int main(int argc, const char *argv[]) {
Connection connection;
connection.connect(
ActiveRecord::options
("adapter", "sqlite")
("database", "greetings.sqlite3")
);
Greeting::setup(&connection);
connection.update_database();
Greeting greeting(
ActiveRecord::attributes
("salute", "Hello")
("thing", "World")
("language", "English")
);
greeting.save();Greeting greeting1(1);
std::cout << "In " << greeting1["language"] << " you say:" << std::endl;
std::cout << "'" << greeting1["salute"] << " " << greeting1["thing"] << "!'" << std::endl;return 0;
}
```# Development and Tests
See the file DEVELOPMENT.md.
# Other information
* Usage
* See the `examples` directory
* Documentation
* See the `doc` directory