36 #ifdef YAMLCPP_OLD_API 38 #endif // YAMLCPP_OLD_API 40 #ifndef YAMLCPP_OLD_API 45 value = node.as<
float>();
50 value = node.as<
double>();
55 value = node.as<
bool>();
60 value = node.as<int16_t>();
65 value = node.as<uint16_t>();
70 value = node.as<int32_t>();
75 value = node.as<uint32_t>();
80 value = node.as<int64_t>();
85 value = node.as<uint64_t>();
90 value = node.as<std::string>();
93 #endif // YAMLCPP_OLD_API 97 bool LoadFile(
const std::string& path, YAML::Node& yaml)
101 #ifndef YAMLCPP_OLD_API 104 std::ifstream fin(path.c_str());
110 YAML::Parser parser(fin);
111 parser.GetNextDocument(yaml);
112 #endif // YAMLCPP_OLD_API 126 #ifndef YAMLCPP_OLD_API 127 yaml = YAML::Load(input);
129 std::stringstream stream(input);
130 YAML::Parser parser(stream);
131 parser.GetNextDocument(yaml);
132 #endif // YAMLCPP_OLD_API 142 bool LoadMap(
const std::map<std::string,std::string>& dict, YAML::Node& yaml)
144 std::vector<std::string> items;
146 for (std::map<std::string,std::string>::const_iterator iter = dict.begin();
150 if (!iter->first.empty()) {
151 items.push_back(
"\"" + iter->first +
"\": \"" + iter->second +
"\"");
155 std::string input =
"{ ";
156 for (
size_t i = 0; i < items.size(); ++i) {
158 if (i+1 < items.size()) {
164 printf(
"stringified: %s", input.c_str());
169 bool FindValue(
const YAML::Node& node,
const std::string& name)
171 #ifndef YAMLCPP_OLD_API 172 return static_cast<bool>(node[name]);
174 return node.FindValue(name);
175 #endif // YAMLCPP_OLD_API 180 #ifndef YAMLCPP_OLD_API 184 #endif // YAMLCPP_OLD_API 187 std::string
ToString(
double value, int32_t precision)
189 std::stringstream ss;
190 ss << std::setprecision(precision) << value;
bool LoadFile(const std::string &path, YAML::Node &yaml)
std::string ToString(double value, int32_t precision)
void operator>>(const YAML::Node &node, float &value)
bool LoadString(const std::string &input, YAML::Node &yaml)
bool LoadMap(const std::map< std::string, std::string > &dict, YAML::Node &yaml)
std::unique_ptr< YAML::Node > YamlNodePtr
bool FindValue(const YAML::Node &node, const std::string &name)
YamlNodePtr Clone(const YAML::Node &node)