34 lines
893 B
C++
34 lines
893 B
C++
#include "guid.h"
|
|
#include "yaml/yaml.h"
|
|
#include <iostream>
|
|
#include <cassert>
|
|
using namespace refl;
|
|
using namespace std;
|
|
int main() {
|
|
int x = 123;
|
|
Guid g1 = Guid::Make();
|
|
YAML::TextArchive::Register<Guid>();
|
|
string rx = YAML::Text_Serialize(x);
|
|
string rg1 = YAML::Text_Serialize(g1);
|
|
YAML::Node rg2 = YAML::Load(rg1);
|
|
auto res1 = YAML::Text_Unserialize<Guid>(rg1);
|
|
Guid g2 = res1.value();
|
|
assert(g1 == g2);
|
|
auto res2 = YAML::Text_Unserialize<MetaBundle>(rg1);
|
|
if (res2) {
|
|
MetaBundle aa = res2.value();
|
|
}
|
|
std::cout << rg1 << std::endl;
|
|
YAML::Node primes = YAML::Load("[2, 3, 5, 7, 11]");
|
|
for (std::size_t i = 0; i < primes.size(); i++) {
|
|
std::cout << primes[i].as<int>() << "\n";
|
|
}
|
|
// or:
|
|
for (YAML::const_iterator it = primes.begin(); it != primes.end(); ++it) {
|
|
std::cout << it->as<int>() << "\n";
|
|
}
|
|
|
|
primes.push_back(13);
|
|
assert(primes.size() == 6);
|
|
return 0;
|
|
} |