1 /* Copyright (c) 2009, 2010, 2011 Nicira, Inc.
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 *);
76 char *ovsdb_column_set_to_string(const struct ovsdb_column_set *);
78 void ovsdb_column_set_add(struct ovsdb_column_set *,
79 const struct ovsdb_column *);
80 void ovsdb_column_set_add_all(struct ovsdb_column_set *,
81 const struct ovsdb_table *);
82 bool ovsdb_column_set_contains(const struct ovsdb_column_set *,
83 unsigned int column_index);
84 bool ovsdb_column_set_equals(const struct ovsdb_column_set *,
85 const struct ovsdb_column_set *);