MCPcopy Create free account
hub / github.com/HumbleNet/HumbleNet / write_enums

Function write_enums

src/api_builder/build_csharp.cpp:186–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186void 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
216static std::string function_template = (
217 "\n"

Callers 1

buildCSharpFunction · 0.85

Calls 3

jsonArrayIteratorClass · 0.85
get_object_string_keyFunction · 0.85
get_object_keyFunction · 0.85

Tested by

no test coverage detected