1 /* Copyright (c) 2009, 2010, 2011 Nicira Networks
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef OVSDB_COLUMN_H
17 #define OVSDB_COLUMN_H 1
21 #include "ovsdb-types.h"
24 struct ovsdb_table_schema;
26 /* A column or a column schema (currently there is no distinction). */
33 struct ovsdb_type type;
36 /* A few columns appear in every table with standardized column indexes.
37 * These macros define those columns' indexes.
39 * Don't change these values, because ovsdb_query() depends on OVSDB_COL_UUID
42 OVSDB_COL_UUID = 0, /* UUID for the row. */
43 OVSDB_COL_VERSION = 1, /* Version number for the row. */
47 struct ovsdb_column *ovsdb_column_create(
48 const char *name, bool mutable, bool persistent,
49 const struct ovsdb_type *);
50 struct ovsdb_column *ovsdb_column_clone(const struct ovsdb_column *);
51 void ovsdb_column_destroy(struct ovsdb_column *);
53 struct ovsdb_error *ovsdb_column_from_json(const struct json *,
55 struct ovsdb_column **)
57 struct json *ovsdb_column_to_json(const struct ovsdb_column *);
59 /* An unordered set of distinct columns. */
61 struct ovsdb_column_set {
62 const struct ovsdb_column **columns;
63 size_t n_columns, allocated_columns;
66 #define OVSDB_COLUMN_SET_INITIALIZER { NULL, 0, 0 }
68 void ovsdb_column_set_init(struct ovsdb_column_set *);
69 void ovsdb_column_set_destroy(struct ovsdb_column_set *);
70 void ovsdb_column_set_clone(struct ovsdb_column_set *,
71 const struct ovsdb_column_set *);
72 struct ovsdb_error *ovsdb_column_set_from_json(
73 const struct json *, const struct ovsdb_table_schema *,
74 struct ovsdb_column_set *);
75 struct json *ovsdb_column_set_to_json(const struct ovsdb_column_set *);
77 void ovsdb_column_set_add(struct ovsdb_column_set *,
78 const struct ovsdb_column *);
79 void ovsdb_column_set_add_all(struct ovsdb_column_set *,
80 const struct ovsdb_table *);
81 bool ovsdb_column_set_contains(const struct ovsdb_column_set *,
82 unsigned int column_index);
83 bool ovsdb_column_set_equals(const struct ovsdb_column_set *,
84 const struct ovsdb_column_set *);