https://github.com/fregate/termlib
Erlang binary term parser/builder
https://github.com/fregate/termlib
Last synced: over 1 year ago
JSON representation
Erlang binary term parser/builder
- Host: GitHub
- URL: https://github.com/fregate/termlib
- Owner: fregate
- License: mit
- Created: 2023-04-06T08:16:22.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-11-01T08:08:45.000Z (over 1 year ago)
- Last Synced: 2024-11-01T09:18:57.779Z (over 1 year ago)
- Language: C++
- Size: 119 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# termlib
Erlang binary term parser/builder
Lightwieght library to parse Erlang binary representation of terms (after erlang:term_to_binary) and create binary to parse with erlang:binary_to_term.
Not all Erlang types are supprted at this moment.
# Roadmap
1. Support all erlang types. And make some C++ equivalents
2. Rewrite it for look more modern, like [glaze](https://github.com/stephenberry/glaze/). For example:
```
struct MyStruct {
int value;
std::string atom;
std::string str;
std::vector single_type_list;
std::tuple various_types_list;
};
// Define order of field in Term
template<>
struct erlterm::meta {
using T = MyStruct;
static constexpr auto value = term(
&T::value,
&T::str,
&T::atom,
&T::single_type_list,
&T::various_types_list
);
};
// usage
MyStruct s{};
auto ec = erlterm::read_term(data, s);
if (ec) {
// Handle error
}
// or
auto s = erlterm::read_term(data);
if (s) { // check std::expected
// use s.value()
// else - handle error
}
```