Subversion
svn_iter.h
Go to the documentation of this file.
00001 /**
00002  * @copyright
00003  * ====================================================================
00004  *    Licensed to the Apache Software Foundation (ASF) under one
00005  *    or more contributor license agreements.  See the NOTICE file
00006  *    distributed with this work for additional information
00007  *    regarding copyright ownership.  The ASF licenses this file
00008  *    to you under the Apache License, Version 2.0 (the
00009  *    "License"); you may not use this file except in compliance
00010  *    with the License.  You may obtain a copy of the License at
00011  *
00012  *      http://www.apache.org/licenses/LICENSE-2.0
00013  *
00014  *    Unless required by applicable law or agreed to in writing,
00015  *    software distributed under the License is distributed on an
00016  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00017  *    KIND, either express or implied.  See the License for the
00018  *    specific language governing permissions and limitations
00019  *    under the License.
00020  * ====================================================================
00021  * @endcopyright
00022  *
00023  * @file svn_iter.h
00024  * @brief The Subversion Iteration drivers helper routines
00025  *
00026  */
00027 
00028 #ifndef SVN_ITER_H
00029 #define SVN_ITER_H
00030 
00031 #include <apr.h>         /* for apr_ssize_t */
00032 #include <apr_pools.h>   /* for apr_pool_t */
00033 #include <apr_hash.h>    /* for apr_hash_t */
00034 #include <apr_tables.h>  /* for apr_array_header_t */
00035 
00036 #include "svn_types.h"
00037 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif /* __cplusplus */
00041 
00042 
00043 /** Callback function for use with svn_iter_apr_hash().
00044  * Use @a pool for temporary allocation, it's cleared between invocations.
00045  *
00046  * @a key, @a klen and @a val are the values normally retrieved with
00047  * apr_hash_this().
00048  *
00049  * @a baton is the baton passed into svn_iter_apr_hash().
00050  *
00051  * @since New in 1.5.
00052  */
00053 typedef svn_error_t *(*svn_iter_apr_hash_cb_t)(void *baton,
00054                                                const void *key,
00055                                                apr_ssize_t klen,
00056                                                void *val, apr_pool_t *pool);
00057 
00058 /** Iterate over the elements in @a hash, calling @a func for each one until
00059  * there are no more elements or @a func returns an error.
00060  *
00061  * Uses @a pool for temporary allocations.
00062  *
00063  * If @a completed is not NULL, then on return - if @a func returns no
00064  * errors - @a *completed will be set to @c TRUE.
00065  *
00066  * If @a func returns an error other than @c SVN_ERR_ITER_BREAK, that
00067  * error is returned.  When @a func returns @c SVN_ERR_ITER_BREAK,
00068  * iteration is interrupted, but no error is returned and @a *completed is
00069  * set to @c FALSE (even if this iteration was the last one).
00070  *
00071  * @since New in 1.5.
00072  */
00073 svn_error_t *
00074 svn_iter_apr_hash(svn_boolean_t *completed,
00075                   apr_hash_t *hash,
00076                   svn_iter_apr_hash_cb_t func,
00077                   void *baton,
00078                   apr_pool_t *pool);
00079 
00080 /** Iteration callback used in conjuction with svn_iter_apr_array().
00081  *
00082  * Use @a pool for temporary allocation, it's cleared between invocations.
00083  *
00084  * @a baton is the baton passed to svn_iter_apr_array().  @a item
00085  * is a pointer to the item written to the array with the APR_ARRAY_PUSH()
00086  * macro.
00087  *
00088  * @since New in 1.5.
00089  */
00090 typedef svn_error_t *(*svn_iter_apr_array_cb_t)(void *baton,
00091                                                 void *item,
00092                                                 apr_pool_t *pool);
00093 
00094 /** Iterate over the elements in @a array calling @a func for each one until
00095  * there are no more elements or @a func returns an error.
00096  *
00097  * Uses @a pool for temporary allocations.
00098  *
00099  * If @a completed is not NULL, then on return - if @a func returns no
00100  * errors - @a *completed will be set to @c TRUE.
00101  *
00102  * If @a func returns an error other than @c SVN_ERR_ITER_BREAK, that
00103  * error is returned.  When @a func returns @c SVN_ERR_ITER_BREAK,
00104  * iteration is interrupted, but no error is returned and @a *completed is
00105  * set to @c FALSE (even if this iteration was the last one).
00106  *
00107  * @since New in 1.5.
00108  */
00109 svn_error_t *
00110 svn_iter_apr_array(svn_boolean_t *completed,
00111                    const apr_array_header_t *array,
00112                    svn_iter_apr_array_cb_t func,
00113                    void *baton,
00114                    apr_pool_t *pool);
00115 
00116 
00117 /** Internal routine used by svn_iter_break() macro.
00118  */
00119 svn_error_t *
00120 svn_iter__break(void);
00121 
00122 
00123 /** Helper macro to break looping in svn_iter_apr_array() and
00124  * svn_iter_apr_hash() driven loops.
00125  *
00126  * @note The error is just a means of communicating between
00127  *       driver and callback.  There is no need for it to exist
00128  *       past the lifetime of the iterpool.
00129  *
00130  * @since New in 1.5.
00131  */
00132 #define svn_iter_break(pool) return svn_iter__break()
00133 
00134 
00135 #ifdef __cplusplus
00136 }
00137 #endif /* __cplusplus */
00138 
00139 #endif /* SVN_ITER_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines