diff options
author | Ben Pfaff <blp@nicira.com> | 2011-06-06 09:02:01 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2011-06-06 09:02:01 -0700 |
commit | 25d4983554f6cf8ce5e169f7c5bb5a08c981d27e (patch) | |
tree | ff6fc1082d1ea60a022c0b564d7d4666c14f44b6 /ovsdb/row.c | |
parent | 44b4d050d4a2c966ed6f4aef2e523f70b6463648 (diff) | |
download | openvswitch-25d4983554f6cf8ce5e169f7c5bb5a08c981d27e.tar.gz |
ovsdb: Add functions for formatting column sets and data in columns sets.
These will be used for formatting error messages in an upcoming commit.
Diffstat (limited to 'ovsdb/row.c')
-rw-r--r-- | ovsdb/row.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/ovsdb/row.c b/ovsdb/row.c index ba00bb9f3..dece90fd9 100644 --- a/ovsdb/row.c +++ b/ovsdb/row.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009, 2010 Nicira Networks +/* Copyright (c) 2009, 2010, 2011 Nicira Networks * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ #include <assert.h> #include <stddef.h> +#include "dynamic-string.h" #include "json.h" #include "ovsdb-error.h" #include "shash.h" @@ -173,6 +174,23 @@ ovsdb_row_update_columns(struct ovsdb_row *dst, } } +/* Appends the string form of the value in 'row' of each of the columns in + * 'columns' to 'out', e.g. "1, \"xyz\", and [1, 2, 3]". */ +void +ovsdb_row_columns_to_string(const struct ovsdb_row *row, + const struct ovsdb_column_set *columns, + struct ds *out) +{ + size_t i; + + for (i = 0; i < columns->n_columns; i++) { + const struct ovsdb_column *column = columns->columns[i]; + + ds_put_cstr(out, english_list_delimiter(i, columns->n_columns)); + ovsdb_datum_to_string(&row->fields[column->index], &column->type, out); + } +} + struct ovsdb_error * ovsdb_row_from_json(struct ovsdb_row *row, const struct json *json, struct ovsdb_symbol_table *symtab, |