Falcon
Toggle main menu visibility
Loading...
Searching...
No Matches
dummy_data.cpp
1
#pragma once
2
#include <string>
3
#include "idata.hpp"
4
5
namespace
nsDummyType {
6
using
ParentType = AnyType;
7
using
Capabilities = ParentType::Capabilities;
8
using
Parameters = ParentType::Parameters;
9
10
class
Data :
public
IData
<Data, ParentType> {
11
private
:
12
std::string value_;
13
size_t
hash_;
14
15
public
:
16
using
BaseClass =
IData<Data, ParentType>
;
17
Data() : Data(
"hello"
) {}
18
Data(
const
std::string& value) { set_value(value); }
19
Data(
const
Parameters _) : Data(
"hello"
) {}
20
21
size_t
hash()
const
{
return
hash_; }
22
size_t
size()
const
{
return
value_.size(); }
23
std::string value()
const
{
return
value_; }
24
void
set_value(
const
std::string& val) {
25
value_ = val;
26
hash_ = std::hash<std::string>()(value_);
27
}
28
};
29
30
}
// namespace nsDummyType
31
32
using
DummyType =
DefineType
<
nsDummyType::Data
, AnyType,
true
, nsDummyType::Capabilities,
33
nsDummyType::Parameters>;
34
35
namespace
YAML {
36
template
<>
37
struct
convert<DummyType::Data> {
38
static
Node encode(
const
DummyType::Data& rhs) {
39
Node node;
40
node = rhs.value();
41
return
node;
42
}
43
44
static
bool
decode(
const
Node& node, DummyType::Data& rhs) {
45
rhs.set_value(node.as<std::string>());
46
return
true
;
47
}
48
};
49
}
// namespace YAML
DefineType
Convenient template class to define data types.
Definition
idata.hpp:75
IData
Base class of all data object classes.
Definition
idata.hpp:95
nsDummyType::Data
Definition
dummy_data.cpp:10
extensions
template_extension
src
dummy_data.cpp
Generated by
1.18.0