Skip to content

Commit

Permalink
Update README.md (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasy-peak authored Dec 22, 2023
1 parent b84e61f commit 9724ab3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ account_info:
vec: ["fantasy-001", "fantasy-002"]
set_vec: [9, 5, 7]
account_type: "Personal"
ips: ["127.0.0.1"]
```
```cpp
Expand Down Expand Up @@ -77,13 +78,16 @@ struct AccountInfo {
std::tuple<std::string, uint8_t> tuple;
std::unordered_map<std::string, std::tuple<std::string, int32_t>> map_tuple;
std::string default_str{"hello default"};
std::vector<std::string> ips;
};
YCS_ADD_STRUCT(AccountInfo, flag, name, address, num, msec, tuple, map_tuple, default_str)
YCS_ADD_STRUCT(AccountInfo, flag, name, address, num, msec, tuple, map_tuple, default_str, ips)

int main(int, char** argv) {
auto [cfg, error] = yaml_cpp_struct::from_yaml<Config>(argv[1]);
auto [str, e] = yaml_cpp_struct::to_yaml(cfg.value());
// Load values from environment variables
// export YCS_ENV_IPS=["Google","Runoob","Taobao"]
// auto [cfg, error] = yaml_cpp_struct::from_yaml_env<Config>(argv[1], "YCS_ENV_");
return 0;
}

```

0 comments on commit 9724ab3

Please sign in to comment.