id.h revision 299742
1/* id.h : interface to node ID functions, private to libsvn_fs_fs 2 * 3 * ==================================================================== 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 * ==================================================================== 21 */ 22 23#ifndef SVN_LIBSVN_FS_FS_ID_H 24#define SVN_LIBSVN_FS_FS_ID_H 25 26#include "svn_fs.h" 27#include "private/svn_fs_fs_private.h" 28 29#ifdef __cplusplus 30extern "C" { 31#endif /* __cplusplus */ 32 33 34/*** Operations on ID parts. ***/ 35 36/* Return TRUE, if both elements of the PART is 0, i.e. this is the default 37 * value if e.g. no copies were made of this node. */ 38svn_boolean_t svn_fs_fs__id_part_is_root(const svn_fs_fs__id_part_t *part); 39 40/* Return TRUE, if all element values of *LHS and *RHS match. */ 41svn_boolean_t svn_fs_fs__id_part_eq(const svn_fs_fs__id_part_t *lhs, 42 const svn_fs_fs__id_part_t *rhs); 43 44/* Return TRUE, if TXN_ID is used, i.e. doesn't contain just the defaults. */ 45svn_boolean_t svn_fs_fs__id_txn_used(const svn_fs_fs__id_part_t *txn_id); 46 47/* Reset TXN_ID to the defaults. */ 48void svn_fs_fs__id_txn_reset(svn_fs_fs__id_part_t *txn_id); 49 50/* Parse the transaction id in DATA and store the result in *TXN_ID */ 51svn_error_t *svn_fs_fs__id_txn_parse(svn_fs_fs__id_part_t *txn_id, 52 const char *data); 53 54/* Convert the transaction id in *TXN_ID into a textual representation 55 * allocated in POOL. */ 56const char *svn_fs_fs__id_txn_unparse(const svn_fs_fs__id_part_t *txn_id, 57 apr_pool_t *pool); 58 59 60/*** ID accessor functions. ***/ 61 62/* Get the "node id" portion of ID. */ 63const svn_fs_fs__id_part_t *svn_fs_fs__id_node_id(const svn_fs_id_t *id); 64 65/* Get the "copy id" portion of ID. */ 66const svn_fs_fs__id_part_t *svn_fs_fs__id_copy_id(const svn_fs_id_t *id); 67 68/* Get the "txn id" portion of ID, or NULL if it is a permanent ID. */ 69const svn_fs_fs__id_part_t *svn_fs_fs__id_txn_id(const svn_fs_id_t *id); 70 71/* Get the "rev,item" portion of ID. */ 72const svn_fs_fs__id_part_t *svn_fs_fs__id_rev_item(const svn_fs_id_t *id); 73 74/* Get the "rev" portion of ID, or SVN_INVALID_REVNUM if it is a 75 transaction ID. */ 76svn_revnum_t svn_fs_fs__id_rev(const svn_fs_id_t *id); 77 78/* Access the "item" portion of the ID, or 0 if it is a transaction 79 ID. */ 80apr_uint64_t svn_fs_fs__id_item(const svn_fs_id_t *id); 81 82/* Return TRUE, if this is a transaction ID. */ 83svn_boolean_t svn_fs_fs__id_is_txn(const svn_fs_id_t *id); 84 85/* Convert ID into string form, allocated in POOL. */ 86svn_string_t *svn_fs_fs__id_unparse(const svn_fs_id_t *id, 87 apr_pool_t *pool); 88 89/* Return true if A and B are equal. */ 90svn_boolean_t svn_fs_fs__id_eq(const svn_fs_id_t *a, 91 const svn_fs_id_t *b); 92 93/* Return true if A and B are related. */ 94svn_boolean_t svn_fs_fs__id_check_related(const svn_fs_id_t *a, 95 const svn_fs_id_t *b); 96 97/* Return the noderev relationship between A and B. */ 98svn_fs_node_relation_t svn_fs_fs__id_compare(const svn_fs_id_t *a, 99 const svn_fs_id_t *b); 100 101/* Return 0 if A and B are equal, 1 if A is "greater than" B, -1 otherwise. */ 102int svn_fs_fs__id_part_compare(const svn_fs_fs__id_part_t *a, 103 const svn_fs_fs__id_part_t *b); 104 105/* Create the txn root ID for transaction TXN_ID. Allocate it in POOL. */ 106svn_fs_id_t *svn_fs_fs__id_txn_create_root(const svn_fs_fs__id_part_t *txn_id, 107 apr_pool_t *pool); 108 109/* Create the root ID for REVISION (logical addressing node only). 110 Allocate it in POOL. */ 111svn_fs_id_t *svn_fs_fs__id_create_root(const svn_revnum_t revision, 112 apr_pool_t *pool); 113 114/* Create an ID within a transaction based on NODE_ID, COPY_ID, and 115 TXN_ID, allocated in POOL. */ 116svn_fs_id_t *svn_fs_fs__id_txn_create(const svn_fs_fs__id_part_t *node_id, 117 const svn_fs_fs__id_part_t *copy_id, 118 const svn_fs_fs__id_part_t *txn_id, 119 apr_pool_t *pool); 120 121/* Create a permanent ID based on NODE_ID, COPY_ID and REV_ITEM, 122 allocated in POOL. */ 123svn_fs_id_t *svn_fs_fs__id_rev_create(const svn_fs_fs__id_part_t *node_id, 124 const svn_fs_fs__id_part_t *copy_id, 125 const svn_fs_fs__id_part_t *rev_item, 126 apr_pool_t *pool); 127 128/* Return a copy of ID, allocated from POOL. */ 129svn_fs_id_t *svn_fs_fs__id_copy(const svn_fs_id_t *id, 130 apr_pool_t *pool); 131 132/* Return an ID in *ID_P resulting from parsing the string DATA, or an error 133 if DATA is an invalid ID string. *DATA will be modified / invalidated by 134 this call. */ 135svn_error_t * 136svn_fs_fs__id_parse(const svn_fs_id_t **id_p, 137 char *data, 138 apr_pool_t *pool); 139 140 141/* (de-)serialization support*/ 142 143struct svn_temp_serializer__context_t; 144 145/** 146 * Serialize an @a id within the serialization @a context. 147 */ 148void 149svn_fs_fs__id_serialize(struct svn_temp_serializer__context_t *context, 150 const svn_fs_id_t * const *id); 151 152/** 153 * Deserialize an @a id within the @a buffer. 154 */ 155void 156svn_fs_fs__id_deserialize(void *buffer, 157 svn_fs_id_t **id); 158 159#ifdef __cplusplus 160} 161#endif /* __cplusplus */ 162 163#endif /* SVN_LIBSVN_FS_FS_ID_H */ 164