[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

String type madness

From: Branko Čibej <brane_at_xbc.nu>
Date: 2001-07-25 23:43:32 CEST

I'm totally confused.

Can somebody remind me when we're supposed to use `const svn_string_t*'
vs. `const char*'? In the public interfaces, that is. I seem to remember
GregS saying something about why svn_string_t is good for scripting
language wrappers.

The reason I'm asking is this: I'm totally swamped, working on two
projects simultaneously at work, so I decided to postpone the delta
combiner until after M3 (more on that later), since it's not critical
for this milestone.

Instead, I decided to resurrect a config file parsing library -- which /
should/ be in M3, IMHO -- I have lying around (It's LGPL, but I'm the
author, got a loopohole :-). I'm banging it into shape for Subversion,
and want to get the public interfaces right. Here's an example of what
I'm talking about:

    /* Find the value of a (SECTION, OPTION) pair in CFG. Return
       DEFAULT_VALUE if the value doesn't exist. */
    const char *svn_config_get (svn_config_t *cfg,
                                const char *section, const char *option,
                                const char *default_value);

I really see no reason why the parameters should be anything but `const
char*'; but what about the return value? I was considering returning a
svn_string_t instead (IIRC, returning structs is even worse for
scripting wrappers, at least in my experiences with swig), or adding a
svn_string_t out parameter, like this:

    void svn_config_get (svn_config_t *cfg, svn_string_t *valuep,
                         const char *section, const char *option,
                         const char *default_value);

I'd appreciate some input here.


P.S.: I plan to tweak my library a bit so that it reads config files
that have the same format as Python's ConfigParser files. I think
interoperability is nice, don't you? Oh, and we'll be able to read the
config straight from the registry on Win32.

To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:33 2006

This is an archived mail posted to the Subversion Dev mailing list.