]>
Commit | Line | Data |
---|---|---|
e0edde6f | 1 | /* Copyright (c) 2009, 2010, 2011 Nicira, Inc. |
f85f8ebb BP |
2 | * |
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: | |
6 | * | |
7 | * http://www.apache.org/licenses/LICENSE-2.0 | |
8 | * | |
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. | |
14 | */ | |
15 | ||
16 | #ifndef OVSDB_COLUMN_H | |
17 | #define OVSDB_COLUMN_H 1 | |
18 | ||
19 | #include <stdbool.h> | |
20 | #include "compiler.h" | |
21 | #include "ovsdb-types.h" | |
22 | ||
23 | struct ovsdb_table; | |
1cb29ab0 | 24 | struct ovsdb_table_schema; |
f85f8ebb BP |
25 | |
26 | /* A column or a column schema (currently there is no distinction). */ | |
27 | struct ovsdb_column { | |
28 | unsigned int index; | |
29 | char *name; | |
30 | ||
f85f8ebb BP |
31 | bool mutable; |
32 | bool persistent; | |
33 | struct ovsdb_type type; | |
34 | }; | |
35 | ||
36 | /* A few columns appear in every table with standardized column indexes. | |
37 | * These macros define those columns' indexes. | |
38 | * | |
39 | * Don't change these values, because ovsdb_query() depends on OVSDB_COL_UUID | |
40 | * having value 0. */ | |
41 | enum { | |
42 | OVSDB_COL_UUID = 0, /* UUID for the row. */ | |
43 | OVSDB_COL_VERSION = 1, /* Version number for the row. */ | |
44 | OVSDB_N_STD_COLUMNS | |
45 | }; | |
46 | ||
47 | struct ovsdb_column *ovsdb_column_create( | |
2e57b537 | 48 | const char *name, bool mutable, bool persistent, |
f85f8ebb | 49 | const struct ovsdb_type *); |
58985e09 | 50 | struct ovsdb_column *ovsdb_column_clone(const struct ovsdb_column *); |
f85f8ebb BP |
51 | void ovsdb_column_destroy(struct ovsdb_column *); |
52 | ||
53 | struct ovsdb_error *ovsdb_column_from_json(const struct json *, | |
54 | const char *name, | |
55 | struct ovsdb_column **) | |
56 | WARN_UNUSED_RESULT; | |
57 | struct json *ovsdb_column_to_json(const struct ovsdb_column *); | |
58 | \f | |
59 | /* An unordered set of distinct columns. */ | |
60 | ||
61 | struct ovsdb_column_set { | |
62 | const struct ovsdb_column **columns; | |
63 | size_t n_columns, allocated_columns; | |
64 | }; | |
65 | ||
66 | #define OVSDB_COLUMN_SET_INITIALIZER { NULL, 0, 0 } | |
67 | ||
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 *); | |
1cb29ab0 BP |
72 | struct ovsdb_error *ovsdb_column_set_from_json( |
73 | const struct json *, const struct ovsdb_table_schema *, | |
74 | struct ovsdb_column_set *); | |
a8425c53 | 75 | struct json *ovsdb_column_set_to_json(const struct ovsdb_column_set *); |
25d49835 | 76 | char *ovsdb_column_set_to_string(const struct ovsdb_column_set *); |
f85f8ebb BP |
77 | |
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 *); | |
86 | ||
87 | #endif /* column.h */ |