-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasic.cpp
More file actions
25 lines (20 loc) · 701 Bytes
/
Copy pathbasic.cpp
File metadata and controls
25 lines (20 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <ripstop/Codec.h>
#include <iostream>
#include <span>
#include <vector>
int main() {
constexpr auto project =
ripstop::codec::make_project_options("example:replace-with-your-project");
const std::vector<float> input{1.0f, 2.0f, 3.0f};
const auto encoded = ripstop::codec::encode(std::span{input}, project);
if (!encoded) {
std::cerr << ripstop::codec::to_string(encoded.error) << '\n';
return 1;
}
const auto decoded = ripstop::codec::decode_to_vector<float>(*encoded, project);
if (!decoded) {
std::cerr << ripstop::codec::to_string(decoded.error) << '\n';
return 1;
}
return decoded.value == input ? 0 : 1;
}