forked from trpc-group/trpc-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_conf.h
More file actions
46 lines (35 loc) · 978 Bytes
/
Copy pathcustom_conf.h
File metadata and controls
46 lines (35 loc) · 978 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
//
// Tencent is pleased to support the open source community by making tRPC available.
//
// Copyright (C) 2023 THL A29 Limited, a Tencent company.
// All rights reserved.
//
// If you have downloaded a copy of the tRPC source code from Tencent,
// please note that tRPC source code is licensed under the Apache 2.0 License,
// A copy of the Apache 2.0 License is included in this file.
//
//
#pragma once
#include "yaml-cpp/yaml.h"
namespace examples::admin {
struct CustomConfig {
int value = 0;
};
} // namespace examples::admin
namespace YAML {
template <>
struct convert<examples::admin::CustomConfig> {
static YAML::Node encode(const examples::admin::CustomConfig& conf) {
YAML::Node node;
node["value"] = conf.value;
return node;
}
static bool decode(const YAML::Node& node, examples::admin::CustomConfig& conf) {
if (node["value"]) {
conf.value = node["value"].as<int>();
}
return true;
}
};
} // namespace YAML