svn_iter.h

Go to the documentation of this file.
00001 /**
00002  * @copyright
00003  * ====================================================================
00004  * Copyright (c) 2007 CollabNet.  All rights reserved.
00005  *
00006  * This software is licensed as described in the file COPYING, which
00007  * you should have received as part of this distribution.  The terms
00008  * are also available at http://subversion.tigris.org/license-1.html.
00009  * If newer versions of this license are posted there, you may use a
00010  * newer version instead, at your option.
00011  *
00012  * This software consists of voluntary contributions made by many
00013  * individuals.  For exact contribution history, see the revision
00014  * history and logs, available at http://subversion.tigris.org/.
00015  * ====================================================================
00016  * @endcopyright
00017  *
00018  * @file svn_iter.h
00019  * @brief The Subversion Iteration drivers helper routines
00020  *
00021  */
00022 
00023 #include <apr_hash.h>
00024 
00025 #include "svn_types.h"
00026 #include "svn_error.h"
00027 #include "svn_pools.h"
00028 
00029 
00030 /** Callback function for use with svn_iter_apr_hash().
00031  * Use @a pool for temporary allocation, it's cleared between invocations.
00032  *
00033  * @a key, @a klen and @a val are the values normally retrieved with
00034  * apr_hash_this().
00035  *
00036  * @a baton is the baton passed into svn_iter_apr_hash().
00037  *
00038  * @since New in 1.5.
00039  */
00040 typedef svn_error_t *(*svn_iter_apr_hash_cb_t)(void *baton,
00041                                                const void *key,
00042                                                apr_ssize_t klen,
00043                                                void *val, apr_pool_t *pool);
00044 
00045 /** Iterate over the elements in @a hash, calling @a func for each one until
00046  * there are no more elements or @a func returns an error.
00047  *
00048  * Uses @a pool for temporary allocations.
00049  *
00050  * On return - if @a func returns no errors - @a *completed will be set
00051  * to @c TRUE.
00052  *
00053  * If @a func returns an error other than @c SVN_ERR_ITER_BREAK, that
00054  * error is returned.  When @a func returns @c SVN_ERR_ITER_BREAK,
00055  * iteration is interrupted, but no error is returned and @a *completed is
00056  * set to @c FALSE.
00057  *
00058  * @since New in 1.5.
00059  */
00060 svn_error_t *
00061 svn_iter_apr_hash(svn_boolean_t *completed,
00062                   apr_hash_t *hash,
00063                   svn_iter_apr_hash_cb_t func,
00064                   void *baton,
00065                   apr_pool_t *pool);
00066 
00067 /** Iteration callback used in conjuction with svn_iter_apr_array().
00068  *
00069  * Use @a pool for temporary allocation, it's cleared between invocations.
00070  *
00071  * @a baton is the baton passed to svn_iter_apr_array().  @a item
00072  * is a pointer to the item written to the array with the APR_ARRAY_PUSH()
00073  * macro.
00074  *
00075  * @since New in 1.5.
00076  */
00077 typedef svn_error_t *(*svn_iter_apr_array_cb_t)(void *baton,
00078                                                 void *item,
00079                                                 apr_pool_t *pool);
00080 
00081 /** Iterate over the elements in @a array calling @a func for each one until
00082  * there are no more elements or @a func returns an error.
00083  *
00084  * Uses @a pool for temporary allocations.
00085  *
00086  * On return - if @a func returns no errors - @a *completed will be set
00087  * to @c TRUE.
00088  *
00089  * If @a func returns an error other than @c SVN_ERR_ITER_BREAK, that
00090  * error is returned.  When @a func returns @c SVN_ERR_ITER_BREAK,
00091  * iteration is interrupted, but no error is returned and @a *completed is
00092  * set to @c FALSE.
00093  *
00094  * @since New in 1.5.
00095  */
00096 svn_error_t *
00097 svn_iter_apr_array(svn_boolean_t *completed,
00098                    const apr_array_header_t *array,
00099                    svn_iter_apr_array_cb_t func,
00100                    void *baton,
00101                    apr_pool_t *pool);
00102 
00103 
00104 /** Internal routine used by svn_iter_break() macro.
00105  */
00106 svn_error_t *
00107 svn_iter__break(void);
00108 
00109 /** Helper macro to break looping in svn_iter_apr_array() and
00110  * svn_iter_apr_hash() driven loops.
00111  *
00112  * @note The error is just a means of communicating between
00113  *       driver and callback.  There is no need for it to exist
00114  *       past the lifetime of the iterpool.
00115  *
00116  * @since New in 1.5.
00117  */
00118 #define svn_iter_break(pool) return svn_iter__break()

Generated on Sun Dec 21 20:02:54 2008 for Subversion by doxygen 1.3.5