]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/subversion/subversion/libsvn_fs_x/temp_serializer.h
MFC r275385 (by bapt):
[FreeBSD/stable/10.git] / contrib / subversion / subversion / libsvn_fs_x / temp_serializer.h
1 /* temp_serializer.h : serialization functions for caching of FSX structures
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__TEMP_SERIALIZER_H
24 #define SVN_LIBSVN_FS__TEMP_SERIALIZER_H
25
26 #include "private/svn_temp_serializer.h"
27 #include "fs.h"
28
29 /**
30  * Prepend the @a number to the @a string in a space efficient way such that
31  * no other (number,string) combination can produce the same result.
32  * Allocate temporaries as well as the result from @a pool.
33  */
34 const char*
35 svn_fs_x__combine_number_and_string(apr_int64_t number,
36                                     const char *string,
37                                     apr_pool_t *pool);
38
39 /**
40  * Serialize a @a noderev_p within the serialization @a context.
41  */
42 void
43 svn_fs_x__noderev_serialize(struct svn_temp_serializer__context_t *context,
44                             svn_fs_x__noderev_t * const *noderev_p);
45
46 /**
47  * Deserialize a @a noderev_p within the @a buffer and associate it with
48  * @a pool.
49  */
50 void
51 svn_fs_x__noderev_deserialize(void *buffer,
52                               svn_fs_x__noderev_t **noderev_p,
53                               apr_pool_t *pool);
54
55 /**
56  * Serialize APR array @a *a within the serialization @a context.
57  * The elements within the array must not contain pointers.
58  */
59 void
60 svn_fs_x__serialize_apr_array(struct svn_temp_serializer__context_t *context,
61                               apr_array_header_t **a);
62
63 /**
64  * Deserialize APR @a *array within the @a buffer.  Set its pool member to
65  * @a pool.  The elements within the array must not contain pointers.
66  */
67 void
68 svn_fs_x__deserialize_apr_array(void *buffer,
69                                 apr_array_header_t **array,
70                                 apr_pool_t *pool);
71
72
73 /**
74  * #svn_txdelta_window_t is not sufficient for caching the data it
75  * represents because data read process needs auxiliary information.
76  */
77 typedef struct
78 {
79   /* the txdelta window information cached / to be cached */
80   svn_txdelta_window_t *window;
81
82   /* the revision file read pointer position before reading the window */
83   apr_off_t start_offset;
84
85   /* the revision file read pointer position right after reading the window */
86   apr_off_t end_offset;
87 } svn_fs_x__txdelta_cached_window_t;
88
89 /**
90  * Implements #svn_cache__serialize_func_t for
91  * #svn_fs_x__txdelta_cached_window_t.
92  */
93 svn_error_t *
94 svn_fs_x__serialize_txdelta_window(void **buffer,
95                                    apr_size_t *buffer_size,
96                                    void *item,
97                                    apr_pool_t *pool);
98
99 /**
100  * Implements #svn_cache__deserialize_func_t for
101  * #svn_fs_x__txdelta_cached_window_t.
102  */
103 svn_error_t *
104 svn_fs_x__deserialize_txdelta_window(void **item,
105                                      void *buffer,
106                                      apr_size_t buffer_size,
107                                      apr_pool_t *pool);
108
109 /**
110  * Implements #svn_cache__serialize_func_t for a manifest
111  * (@a in is an #apr_array_header_t of apr_off_t elements).
112  */
113 svn_error_t *
114 svn_fs_x__serialize_manifest(void **data,
115                              apr_size_t *data_len,
116                              void *in,
117                              apr_pool_t *pool);
118
119 /**
120  * Implements #svn_cache__deserialize_func_t for a manifest
121  * (@a *out is an #apr_array_header_t of apr_off_t elements).
122  */
123 svn_error_t *
124 svn_fs_x__deserialize_manifest(void **out,
125                                void *data,
126                                apr_size_t data_len,
127                                apr_pool_t *pool);
128
129 /**
130  * Implements #svn_cache__serialize_func_t for a properties hash
131  * (@a in is an #apr_hash_t of svn_string_t elements, keyed by const char*).
132  */
133 svn_error_t *
134 svn_fs_x__serialize_properties(void **data,
135                                apr_size_t *data_len,
136                                void *in,
137                                apr_pool_t *pool);
138
139 /**
140  * Implements #svn_cache__deserialize_func_t for a properties hash
141  * (@a *out is an #apr_hash_t of svn_string_t elements, keyed by const char*).
142  */
143 svn_error_t *
144 svn_fs_x__deserialize_properties(void **out,
145                                  void *data,
146                                  apr_size_t data_len,
147                                  apr_pool_t *pool);
148
149 /**
150  * Implements #svn_cache__serialize_func_t for #svn_fs_x__noderev_t
151  */
152 svn_error_t *
153 svn_fs_x__serialize_node_revision(void **buffer,
154                                   apr_size_t *buffer_size,
155                                   void *item,
156                                   apr_pool_t *pool);
157
158 /**
159  * Implements #svn_cache__deserialize_func_t for #svn_fs_x__noderev_t
160  */
161 svn_error_t *
162 svn_fs_x__deserialize_node_revision(void **item,
163                                     void *buffer,
164                                     apr_size_t buffer_size,
165                                     apr_pool_t *pool);
166
167 /**
168  * Implements #svn_cache__serialize_func_t for a directory contents array
169  */
170 svn_error_t *
171 svn_fs_x__serialize_dir_entries(void **data,
172                                 apr_size_t *data_len,
173                                 void *in,
174                                 apr_pool_t *pool);
175
176 /**
177  * Implements #svn_cache__deserialize_func_t for a directory contents array
178  */
179 svn_error_t *
180 svn_fs_x__deserialize_dir_entries(void **out,
181                                   void *data,
182                                   apr_size_t data_len,
183                                   apr_pool_t *pool);
184
185 /**
186  * Implements #svn_cache__partial_getter_func_t.  Set (apr_off_t) @a *out
187  * to the element indexed by (apr_int64_t) @a *baton within the
188  * serialized manifest array @a data and @a data_len. */
189 svn_error_t *
190 svn_fs_x__get_sharded_offset(void **out,
191                              const void *data,
192                              apr_size_t data_len,
193                              void *baton,
194                              apr_pool_t *pool);
195
196 /**
197  * Baton type to be used with svn_fs_x__extract_dir_entry. */
198 typedef struct svn_fs_x__ede_baton_t
199 {
200   /* Name of the directory entry to find. */
201   const char *name;
202
203   /* Lookup hint [in / out] */
204   apr_size_t hint;
205 } svn_fs_x__ede_baton_t;
206
207 /**
208  * Implements #svn_cache__partial_getter_func_t for a single
209  * #svn_fs_x__dirent_t within a serialized directory contents hash,
210  * identified by its name (given in @a svn_fs_x__ede_baton_t @a *baton).
211  */
212 svn_error_t *
213 svn_fs_x__extract_dir_entry(void **out,
214                             const void *data,
215                             apr_size_t data_len,
216                             void *baton,
217                             apr_pool_t *pool);
218
219 /**
220  * Describes the change to be done to a directory: Set the entry
221  * identify by @a name to the value @a new_entry. If the latter is
222  * @c NULL, the entry shall be removed if it exists. Otherwise it
223  * will be replaced or automatically added, respectively.
224  */
225 typedef struct replace_baton_t
226 {
227   /** name of the directory entry to modify */
228   const char *name;
229
230   /** directory entry to insert instead */
231   svn_fs_x__dirent_t *new_entry;
232 } replace_baton_t;
233
234 /**
235  * Implements #svn_cache__partial_setter_func_t for a single
236  * #svn_fs_x__dirent_t within a serialized directory contents hash,
237  * identified by its name in the #replace_baton_t in @a baton.
238  */
239 svn_error_t *
240 svn_fs_x__replace_dir_entry(void **data,
241                             apr_size_t *data_len,
242                             void *baton,
243                             apr_pool_t *pool);
244
245 /**
246  * Implements #svn_cache__serialize_func_t for a #svn_fs_x__rep_header_t.
247  */
248 svn_error_t *
249 svn_fs_x__serialize_rep_header(void **data,
250                                apr_size_t *data_len,
251                                void *in,
252                                apr_pool_t *pool);
253
254 /**
255  * Implements #svn_cache__deserialize_func_t for a #svn_fs_x__rep_header_t.
256  */
257 svn_error_t *
258 svn_fs_x__deserialize_rep_header(void **out,
259                                  void *data,
260                                  apr_size_t data_len,
261                                  apr_pool_t *pool);
262
263 /**
264  * Implements #svn_cache__serialize_func_t for an #apr_array_header_t of
265  * #svn_fs_x__change_t *.
266  */
267 svn_error_t *
268 svn_fs_x__serialize_changes(void **data,
269                             apr_size_t *data_len,
270                             void *in,
271                             apr_pool_t *pool);
272
273 /**
274  * Implements #svn_cache__deserialize_func_t for an #apr_array_header_t of
275  * #svn_fs_x__change_t *.
276  */
277 svn_error_t *
278 svn_fs_x__deserialize_changes(void **out,
279                               void *data,
280                               apr_size_t data_len,
281                               apr_pool_t *pool);
282
283 /**
284  * Implements #svn_cache__serialize_func_t for #svn_mergeinfo_t objects.
285  */
286 svn_error_t *
287 svn_fs_x__serialize_mergeinfo(void **data,
288                               apr_size_t *data_len,
289                               void *in,
290                               apr_pool_t *pool);
291
292 /**
293  * Implements #svn_cache__deserialize_func_t for #svn_mergeinfo_t objects.
294  */
295 svn_error_t *
296 svn_fs_x__deserialize_mergeinfo(void **out,
297                                 void *data,
298                                 apr_size_t data_len,
299                                 apr_pool_t *pool);
300
301 #endif