>
> + # String Map Helpers.
> + for columnName, column in sorted(table.columns.iteritems()):
> + if not is_string_map(column):
> + continue
> +
> + print
> + print "const char *"
> + print "%(s)s_get_%(c)s_value(const struct %(s)s *row," \
> + " const char *key, const char *default_value)" \
> + % {'s': structName, 'c': columnName}
> + print "{"
> + print " char **keys = row->key_%s;" % columnName
> + print " char **values = row->value_%s;" % columnName
> + print " size_t n = row->n_%s;" % columnName
> + print " size_t i;"
> + print
> + print " assert(inited);"
> + print " for (i = 0; i < n; i++) {"
> + print " if (!strcmp(keys[i], key)) {"
> + print " return values[i];"
> + print " }"
> + print " }"
> + print " return default_value;"
> + print "}"
> +
>
You could do this as a single long string and apply a dict formatting at
the end of it, don't know whether there is an existing standard you've been
doing for printing the generated code.
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev