Han-Wen Nienhuys | 17df8db | 2021-10-07 20:25:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2020 Google LLC |
| 3 | |
| 4 | Use of this source code is governed by a BSD-style |
| 5 | license that can be found in the LICENSE file or at |
| 6 | https://developers.google.com/open-source/licenses/bsd |
| 7 | */ |
| 8 | |
| 9 | #ifndef REFTABLE_GENERIC_H |
| 10 | #define REFTABLE_GENERIC_H |
| 11 | |
| 12 | #include "reftable-iterator.h" |
| 13 | |
| 14 | struct reftable_table_vtable; |
| 15 | |
| 16 | /* |
| 17 | * Provides a unified API for reading tables, either merged tables, or single |
| 18 | * readers. */ |
| 19 | struct reftable_table { |
| 20 | struct reftable_table_vtable *ops; |
| 21 | void *table_arg; |
| 22 | }; |
| 23 | |
| 24 | int reftable_table_seek_log(struct reftable_table *tab, |
| 25 | struct reftable_iterator *it, const char *name); |
| 26 | |
| 27 | int reftable_table_seek_ref(struct reftable_table *tab, |
| 28 | struct reftable_iterator *it, const char *name); |
| 29 | |
| 30 | /* returns the hash ID from a generic reftable_table */ |
| 31 | uint32_t reftable_table_hash_id(struct reftable_table *tab); |
| 32 | |
| 33 | /* returns the max update_index covered by this table. */ |
| 34 | uint64_t reftable_table_max_update_index(struct reftable_table *tab); |
| 35 | |
| 36 | /* returns the min update_index covered by this table. */ |
| 37 | uint64_t reftable_table_min_update_index(struct reftable_table *tab); |
| 38 | |
| 39 | /* convenience function to read a single ref. Returns < 0 for error, 0 |
| 40 | for success, and 1 if ref not found. */ |
| 41 | int reftable_table_read_ref(struct reftable_table *tab, const char *name, |
| 42 | struct reftable_ref_record *ref); |
| 43 | |
| 44 | /* dump table contents onto stdout for debugging */ |
| 45 | int reftable_table_print(struct reftable_table *tab); |
| 46 | |
| 47 | #endif |