Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/braintwister/record
A heterogeneous data structure for C++
https://github.com/braintwister/record
cpp data-structures heterogeneous polymorphism
Last synced: 23 days ago
JSON representation
A heterogeneous data structure for C++
- Host: GitHub
- URL: https://github.com/braintwister/record
- Owner: BrainTwister
- License: mit
- Created: 2018-05-02T20:21:12.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-26T15:00:43.000Z (about 2 years ago)
- Last Synced: 2024-11-18T23:58:24.530Z (3 months ago)
- Topics: cpp, data-structures, heterogeneous, polymorphism
- Language: C++
- Homepage: https://braintwister.eu/posts/record.html
- Size: 74.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[![Build Status](https://github.com/BrainTwister/record/actions/workflows/cmake.yml/badge.svg)](https://github.com/BrainTwister/record/actions/workflows/cmake.yml)
BrainTwister record
===================A heterogeneous data structure for C++
Copyright (C) 2018 Bernd Doser,
All rights reserved.
BrainTwister record is free software made available under the
[MIT License](http://opensource.org/licenses/MIT). For details see [LICENSE](LICENSE.md).conan.io
--------C++ conan.io package is available at https://bintray.com/braintwister/conan
Description
-----------BrainTwister record is a linear, direct-accessible, heterogeneous
data structure, which is defined by```
BRAINTWISTER_RECORD( record_name, \
(( entry_type, entry_name, entry_default_value )) \
... \
)
```For instance, a database connection can be defined as
```
BRAINTWISTER_RECORD( Database, \
(( uint16_t, port, 3306 )) \
(( std::string, database, "" )) \
(( std::string, table, "" )) \
)
```The entries are statically typed and are directly accessible using the dot operator
```
Database db;
std::cout << db.database << std::endl;
```A record can be initialized with a build pattern
```
Database db.set_port(9876);
```or with JSON/XML
```
{
"port": 9876,
"database": "staff",
"table": "employees"
}
```Nested records and std::vector are supported.
Polymorphic record
------------------For a polymorphic record a macro for the base class and for
the derived classes have to be defined by```
BRAINTWISTER_RECORD_BASE( base_recor_name, \
(( base_entry_type, base_entry_name, base_entry_default_value )) \
..., \
virtual function \
)BRAINTWISTER_RECORD_DERIVED( derived_record_name, \
(( derived_entry_type, derived_entry_name, derived_entry_default_value )) \
..., \
virtual function \
)
```