| 184 | } |
| 185 | |
| 186 | void write_enums( std::ostream& out, json_value* enum_root ) { |
| 187 | assert(enum_root->type == json_array); |
| 188 | |
| 189 | for (auto& it: jsonArrayIterator(enum_root)) |
| 190 | { |
| 191 | std::string enumname = get_object_string_key( it, "enumname"); |
| 192 | json_value* values = get_object_key( it, "values" ); |
| 193 | |
| 194 | if( enumname.empty() || !values || values->type != json_array ) |
| 195 | continue; |
| 196 | |
| 197 | out << "\n"; |
| 198 | out << " public enum " << enumname << "\n"; |
| 199 | out << " {\n"; |
| 200 | |
| 201 | for (auto& vit: jsonArrayIterator(values)) { |
| 202 | std::string doc = get_object_string_key( vit, "doc" ); |
| 203 | std::string name = get_object_string_key( vit, "name" ); |
| 204 | std::string value = get_object_string_key( vit, "value" ); |
| 205 | |
| 206 | if( ! doc.empty() ) |
| 207 | out << " // " << doc << "\n"; |
| 208 | |
| 209 | out << " " << name << " = " << value << ",\n"; |
| 210 | } |
| 211 | |
| 212 | out << " }\n"; |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | static std::string function_template = ( |
| 217 | "\n" |
no test coverage detected