lumiera_documentation/src/common/basic-setup.cpp
Ichthyostega 1c5ceaef15 Boost filesystem Ver 2/3 transition
This is kind of a workaround to avoid having to maintain two variants.
Explanation: between Boost 1.42 and 1.52 there was the transition to a
reworked version of the filesystem library, itroducing some breaking changes
The new version distinguishes much clearer between the native and the
generic representation of paths -- which becomes relevant when porting
to non-POXIX operating systems.

Actually the intention was to use the generic path representation in all
configuration; currently this distinction is moot, since we're caring
only for POSIX systems.

So the workaround is to use the fsys::path::string() function, which
is available in both versions, but changed meaning to yield the native
string. Later, when able to deprecate older Boost versions, we should
switch to generic_string()

Note: an alternative solution was found by Mike Fisher in 3b39f35
using the compiletime define BOOST_FILESYSTEM_VERSION=2

See also ticket #896
2013-01-05 04:50:29 +01:00

113 lines
3.9 KiB
C++

/*
BasicSetup - elementary self-configuration of the application
Copyright (C) Lumiera.org
2011, Hermann Vosseler <Ichthyostega@web.de>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *****************************************************/
#include "common/basic-setup.hpp"
#include "lib/searchpath.hpp"
#include "lib/error.hpp"
#include "lib/util.hpp"
extern "C" {
#include <unistd.h>
}
#include <boost/filesystem.hpp>
#include <iostream>
#include <fstream>
namespace lumiera {
using std::string;
using std::ifstream;
namespace fsys = boost::filesystem;
namespace opt = boost::program_options;
namespace { // details of the bootstrap process...
// Helper to locate a module using a search path spec
using lib::resolveModulePath;
/** use the general mechanism for resolving a search path
* to get the absolute path of the \c setup.ini */
string
resolve (fsys::path iniSpec)
{
string searchpath = iniSpec.parent_path().string(); ///////////TICKET #896
return resolveModulePath (iniSpec.filename(), searchpath);
}
}//(End) implementation details
/**
* Creating the BasicSetup object performs the
* initial self-configuration of the Lumiera Application.
* For this, the \c setup.ini file is located relative to the
* current application executable, read in and parsed into a
* map of setup variables.
*/
BasicSetup::BasicSetup (string bootstrapIni)
: syntax("Lumiera installation and platform configuration")
, settings()
{
syntax.add_options()
("Lumiera.gui", opt::value<string>(),
"name of the Lumiera GUI plugin to load")
("Lumiera.modulepath", opt::value<string>(),
"search path for loadable modules. "
"May us $ORIGIN to refer to the EXE location")
("Lumiera.configpath", opt::value<string>(),
"search path for extended configuration. "
"Extended Config system not yet implemented "
"Ignored as of 2/2011")
("Lumiera.title", opt::value<string>(),
"title of the Lumiera Application, e.g. for windows")
("Lumiera.version", opt::value<string>(),
"Application version string")
("Lumiera.website", opt::value<string>(),
"URL of the Lumiera website")
("Lumiera.authors", opt::value<string>(),
"names of Lumiera authors, for 'about' dialog. Separated by '|'")
("Gui.stylesheet", opt::value<string>(),
"name of the GTK stylesheet to use. Will be searched in resource path")
("Gui.iconpath", opt::value<string>(),
"search path for icons")
("Gui.resourcepath", opt::value<string>(),
"general search path for UI resources")
;
ifstream configIn (resolve(bootstrapIni).c_str());
opt::parsed_options parsed = opt::parse_config_file (configIn, syntax);
opt::store (parsed, settings);
opt::notify(settings);
}
} // namespace lumiera