1 /* string_table.h : interface to string tables, private to libsvn_fs_x
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
20 * ====================================================================
23 #ifndef SVN_LIBSVN_FS_X_STRING_TABLE_H
24 #define SVN_LIBSVN_FS_X_STRING_TABLE_H
27 #include "private/svn_temp_serializer.h"
31 #endif /* __cplusplus */
33 /* A string table is a very space efficient, read-only representation for
34 * a set of strings with high degreed of prefix and postfix overhead.
36 * Creating a string table is a two-stage process: Use a builder class,
37 * stuff all the strings in there and let it then do the heavy lifting of
38 * classification and compression to create the actual string table object.
40 * We will use this for the various path values in FSX change lists and
41 * node revision items.
44 /* the string table builder */
45 typedef struct string_table_builder_t string_table_builder_t;
47 /* the string table */
48 typedef struct string_table_t string_table_t;
50 /* Returns a new string table builder object, allocated in RESULT_POOL.
52 string_table_builder_t *
53 svn_fs_x__string_table_builder_create(apr_pool_t *result_pool);
55 /* Add an arbitrary NUL-terminated C-string STRING of the given length LEN
56 * to BUILDER. Return the index of that string in the future string table.
57 * If LEN is 0, determine the length of the C-string internally.
60 svn_fs_x__string_table_builder_add(string_table_builder_t *builder,
64 /* Return an estimate for the on-disk size of the resulting string table.
65 * The estimate may err in both directions but tends to overestimate the
66 * space requirements for larger tables.
69 svn_fs_x__string_table_builder_estimate_size(string_table_builder_t *builder);
71 /* From the given BUILDER object, create a string table object allocated
72 * in RESULT_POOL that contains all strings previously added to BUILDER.
75 svn_fs_x__string_table_create(const string_table_builder_t *builder,
76 apr_pool_t *result_pool);
78 /* Extract string number INDEX from TABLE and return a copy of it allocated
79 * in RESULT_POOL. If LENGTH is not NULL, set *LENGTH to strlen() of the
80 * result string. Returns an empty string for invalid indexes.
83 svn_fs_x__string_table_get(const string_table_t *table,
86 apr_pool_t *result_pool);
88 /* Write a serialized representation of the string table TABLE to STREAM.
89 * Use SCRATCH_POOL for temporary allocations.
92 svn_fs_x__write_string_table(svn_stream_t *stream,
93 const string_table_t *table,
94 apr_pool_t *scratch_pool);
96 /* Read the serialized string table representation from STREAM and return
97 * the resulting runtime representation in *TABLE_P. Allocate it in
98 * RESULT_POOL and use SCRATCH_POOL for temporary allocations.
101 svn_fs_x__read_string_table(string_table_t **table_p,
102 svn_stream_t *stream,
103 apr_pool_t *result_pool,
104 apr_pool_t *scratch_pool);
106 /* Serialize string table *ST within the serialization CONTEXT.
109 svn_fs_x__serialize_string_table(svn_temp_serializer__context_t *context,
110 string_table_t **st);
112 /* Deserialize string table *TABLE within the BUFFER.
115 svn_fs_x__deserialize_string_table(void *buffer,
116 string_table_t **table);
118 /* Extract string number INDEX from the cache serialized representation at
119 * TABLE and return a copy of it allocated in RESULT_POOL. If LENGTH is not
120 * NULL, set *LENGTH to strlen() of the result string. Returns an empty
121 * string for invalid indexes.
124 svn_fs_x__string_table_get_func(const string_table_t *table,
127 apr_pool_t *result_pool);
131 #endif /* __cplusplus */
133 #endif /* SVN_LIBSVN_FS_X_STRING_TABLE_H */