3 * ====================================================================
4 * Copyright (c) 2007 CollabNet. All rights reserved.
6 * This software is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at http://subversion.tigris.org/license-1.html.
9 * If newer versions of this license are posted there, you may use a
10 * newer version instead, at your option.
12 * This software consists of voluntary contributions made by many
13 * individuals. For exact contribution history, see the revision
14 * history and logs, available at http://subversion.tigris.org/.
15 * ====================================================================
19 * @brief The Subversion Iteration drivers helper routines
25 #include "svn_types.h"
26 #include "svn_error.h"
27 #include "svn_pools.h"
30 /** Callback function for use with svn_iter_apr_hash().
31 * Use @a pool for temporary allocation, it's cleared between invocations.
33 * @a key, @a klen and @a val are the values normally retrieved with
36 * @a baton is the baton passed into svn_iter_apr_hash().
40 typedef svn_error_t
*(*svn_iter_apr_hash_cb_t
)(void *baton
,
43 void *val
, apr_pool_t
*pool
);
45 /** Iterate over the elements in @a hash, calling @a func for each one until
46 * there are no more elements or @a func returns an error.
48 * Uses @a pool for temporary allocations.
50 * If @a completed is not NULL, then on return - if @a func returns no
51 * errors - @a *completed will be set to @c TRUE.
53 * If @a func returns an error other than @c SVN_ERR_ITER_BREAK, that
54 * error is returned. When @a func returns @c SVN_ERR_ITER_BREAK,
55 * iteration is interrupted, but no error is returned and @a *completed is
61 svn_iter_apr_hash(svn_boolean_t
*completed
,
63 svn_iter_apr_hash_cb_t func
,
67 /** Iteration callback used in conjuction with svn_iter_apr_array().
69 * Use @a pool for temporary allocation, it's cleared between invocations.
71 * @a baton is the baton passed to svn_iter_apr_array(). @a item
72 * is a pointer to the item written to the array with the APR_ARRAY_PUSH()
77 typedef svn_error_t
*(*svn_iter_apr_array_cb_t
)(void *baton
,
81 /** Iterate over the elements in @a array calling @a func for each one until
82 * there are no more elements or @a func returns an error.
84 * Uses @a pool for temporary allocations.
86 * If @a completed is not NULL, then on return - if @a func returns no
87 * errors - @a *completed will be set to @c TRUE.
89 * If @a func returns an error other than @c SVN_ERR_ITER_BREAK, that
90 * error is returned. When @a func returns @c SVN_ERR_ITER_BREAK,
91 * iteration is interrupted, but no error is returned and @a *completed is
97 svn_iter_apr_array(svn_boolean_t
*completed
,
98 const apr_array_header_t
*array
,
99 svn_iter_apr_array_cb_t func
,
104 /** Internal routine used by svn_iter_break() macro.
107 svn_iter__break(void);
109 /** Helper macro to break looping in svn_iter_apr_array() and
110 * svn_iter_apr_hash() driven loops.
112 * @note The error is just a means of communicating between
113 * driver and callback. There is no need for it to exist
114 * past the lifetime of the iterpool.
118 #define svn_iter_break(pool) return svn_iter__break()