A heads-up: I'm renaming svn_hash_get_bool() to
svn_config_hash_get_bool(), and svn_hash_get_cstring() to
svn_config_hash_get(), moving them from svn_hash.h to svn_config.h.
They are being used only for config hashes, and don't seem like
general-purpose hash functions.  In particular, _get_bool() looks for a
variety of human-oriented boolean-like strings (on, off, yes, no, etc.).

Note that we already have svn_config_get_bool() and svn_config_get(),
which are similar but operate on a structured config file object,
whereas the functions I'm renaming operate on a simple hash.


Current APIs:
[[[
# In svn_hash.h:

/** Find the value of a @a key in @a hash, return the value.
 *
 * If @a hash is @c NULL or if the @a key cannot be found, the
 * @a default_value will be returned. 
 * 
 * @since New in 1.7.
 */
const char *
svn_hash_get_cstring(apr_hash_t *hash,
                     const char *key,
                     const char *default_value);

/** Like svn_hash_get_cstring(), but for boolean values.
 *
 * Parses the value as a boolean value. The recognized representations
 * are 'TRUE'/'FALSE', 'yes'/'no', 'on'/'off', '1'/'0'; case does not
 * matter.
 * 
 * @since New in 1.7.
 */
svn_boolean_t 
svn_hash_get_bool(apr_hash_t *hash,
                  const char *key,
                  svn_boolean_t default_value);

# In svn_config.h:

/** Find the value of a (@a section, @a option) pair in @a cfg, set @a
 * *valuep to the value.
 *
 * If @a cfg is @c NULL, just sets @a *valuep to @a default_value. If
 * the value does not exist, expand and return @a default_value. @a
 * default_value can be NULL.
 *
 * The returned value will be valid at least until the next call to
 * svn_config_get(), or for the lifetime of @a default_value. It is
 * safest to consume the returned value immediately.
 *
 * This function may change @a cfg by expanding option values.
 */
void
svn_config_get(svn_config_t *cfg,
               const char **valuep,
               const char *section,
               const char *option,
               const char *default_value);

/** Like svn_config_get(), but for boolean values.
 *
 * Parses the option as a boolean value. The recognized representations
 * are 'TRUE'/'FALSE', 'yes'/'no', 'on'/'off', '1'/'0'; case does not
 * matter. Returns an error if the option doesn't contain a known string.
 */
svn_error_t *
svn_config_get_bool(svn_config_t *cfg,
                    svn_boolean_t *valuep,
                    const char *section,
                    const char *option,
                    svn_boolean_t default_value);
]]]

Let me know if you have any concerns.  As I don't anticipate any, I'll
probably make the change before waiting for replies.

- Julian


Reply via email to