Boost logo

Boost Users :

From: Rupert Bruce (rupert_at_[hidden])
Date: 2008-05-23 18:32:24


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chris Ross wrote:
> I have a project that's currently doing manual command-line
> parsing, then using a suite of classes I developed to read from
> multiple formats of configuration files. In looking at boost
> libraries, I see that boost::program_options might be something worth
> using.
>
> The first question I have is "what config file formats does it use/
> want" ? I'm still reading all of the docs, so this may become clear,
> but.
>
> The next question is, since this is one of the non-header-only
> libraries, how hard would it be to pull segments out of the boost
> distribution to ship with my suite of programs and build it along-
> side? Just to get the program_options component.
>
> (Though, as a side note, I'm also using Loki::SharedPtr in my
> project, so if that could be converted to boost::shared_ptr it might
> be less complicated. Then again, I'm using some of the more
> complicated features of SharedPtr, so it's not clear to me that
> boost::shared_ptr is adequate, which is why I didn't choose it in the
> first place.)
>
> Thanks... Any advice on taking portions of the boost code and
> bundling it into another source package would be appreciated.
>
> - Chris
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
I use the boost::program_options as it is halfway there to providing
something I've written from scratch in most other languages - a reusable
PropertyCatalog. My C++ implementation is wrapped around
boost::program_options which provides functions like the following:

bool PropertyCatalog::getBooleanProperty(string key, bool defaultValue)
    {
    bool retval = defaultValue;

    if (vm.count(key))
        {
        try
            {
            retval = vm[key].as<bool>();
            }
        catch (...)
            {
            retval = defaultValue;
            }
        }
    return retval;
    }

So anywhere in my code I can do, for example:
    if (PropertyCatalog::getBooleanProperty("testapp.profile",false))
        {
        profile.append(currentStatus);
        }

The actual command-line or INI file parsing is done by the
boost::program_options library - I have merely wrapped it in something I
am used to...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFIN0X4/X5Z5iyVCbERArmdAJsFoogqdFuLD+bFc55E0uIZcr0wtACfUJq6
HO1HUYpMX63mWGwv1cq5xmw=
=dlGM
-----END PGP SIGNATURE-----


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net