From 6546c05428bb4820a337b079aa728b62adaaab5e Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 6 Jan 2016 12:46:06 +0100 Subject: [PATCH] Move Fallback map to components/ --- apps/openmw/main.cpp | 34 +------------ apps/openmw/mwbase/world.hpp | 8 +++- apps/openmw/mwgui/charactercreation.cpp | 5 +- apps/openmw/mwgui/levelupdialog.cpp | 3 +- apps/openmw/mwrender/animation.cpp | 5 +- apps/openmw/mwrender/renderingmanager.cpp | 4 +- apps/openmw/mwrender/renderingmanager.hpp | 6 +-- apps/openmw/mwrender/ripplesimulation.cpp | 7 ++- apps/openmw/mwrender/ripplesimulation.hpp | 6 +-- apps/openmw/mwrender/sky.cpp | 7 ++- apps/openmw/mwrender/water.cpp | 5 +- apps/openmw/mwrender/water.hpp | 10 ++-- apps/openmw/mwworld/weather.cpp | 10 ++-- apps/openmw/mwworld/weather.hpp | 14 ++++-- apps/openmw/mwworld/worldimp.cpp | 2 +- apps/openmw/mwworld/worldimp.hpp | 15 +++--- components/CMakeLists.txt | 4 ++ .../fallback}/fallback.cpp | 14 +++--- .../fallback}/fallback.hpp | 11 +++-- components/fallback/validate.hpp | 48 +++++++++++++++++++ 20 files changed, 127 insertions(+), 91 deletions(-) rename {apps/openmw/mwworld => components/fallback}/fallback.cpp (75%) rename {apps/openmw/mwworld => components/fallback}/fallback.hpp (67%) create mode 100644 components/fallback/validate.hpp diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index c3f0f8688e..a4bf1fe5ba 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -52,39 +53,8 @@ inline boost::filesystem::path lexical_cast mMap; -}; - -void validate(boost::any &v, std::vector const &tokens, FallbackMap*, int) -{ - if(v.empty()) - { - v = boost::any(FallbackMap()); - } - - FallbackMap *map = boost::any_cast(&v); - - for(std::vector::const_iterator it=tokens.begin(); it != tokens.end(); ++it) - { - int sep = it->find(","); - if(sep < 1 || sep == (int)it->length()-1) -#if (BOOST_VERSION < 104200) - throw boost::program_options::validation_error("invalid value"); -#else - throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value); -#endif - - std::string key(it->substr(0,sep)); - std::string value(it->substr(sep+1)); - - if(map->mMap.find(key) == map->mMap.end()) - { - map->mMap.insert(std::make_pair (key,value)); - } - } -} +using namespace Fallback; /** * \brief Parses application command line and calls \ref Cfg::ConfigurationManager diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index ebce2e1bf8..801016e068 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -56,7 +56,6 @@ namespace MWMechanics namespace MWWorld { - class Fallback; class CellStore; class Player; class LocalScripts; @@ -67,6 +66,11 @@ namespace MWWorld typedef std::vector > PtrMovementList; } +namespace Fallback +{ + class Map; +} + namespace MWBase { /// \brief Interface for the World (implemented in MWWorld) @@ -119,7 +123,7 @@ namespace MWBase virtual void adjustSky() = 0; - virtual const MWWorld::Fallback *getFallback () const = 0; + virtual const Fallback::Map *getFallback () const = 0; virtual MWWorld::Player& getPlayer() = 0; virtual MWWorld::Ptr getPlayerPtr() = 0; diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index d2ce35509d..8c2ec68813 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -1,5 +1,7 @@ #include "charactercreation.hpp" +#include + #include "../mwbase/environment.hpp" #include "../mwbase/soundmanager.hpp" #include "../mwbase/mechanicsmanager.hpp" @@ -10,7 +12,6 @@ #include "../mwmechanics/actorutil.hpp" #include "../mwworld/class.hpp" -#include "../mwworld/fallback.hpp" #include "../mwworld/esmstore.hpp" #include "textinput.hpp" @@ -32,7 +33,7 @@ namespace const ESM::Class::Specialization mSpecializations[3]={ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth}; // The specialization for each answer Step sGenerateClassSteps(int number) { number++; - const MWWorld::Fallback* fallback=MWBase::Environment::get().getWorld()->getFallback(); + const Fallback::Map* fallback=MWBase::Environment::get().getWorld()->getFallback(); Step step = {fallback->getFallbackString("Question_"+MyGUI::utility::toString(number)+"_Question"), {fallback->getFallbackString("Question_"+MyGUI::utility::toString(number)+"_AnswerOne"), fallback->getFallbackString("Question_"+MyGUI::utility::toString(number)+"_AnswerTwo"), diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index c832a78792..4e8d0a02c4 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -4,13 +4,14 @@ #include #include +#include + #include "../mwbase/windowmanager.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/soundmanager.hpp" #include "../mwworld/class.hpp" -#include "../mwworld/fallback.hpp" #include "../mwworld/esmstore.hpp" #include "../mwworld/cellstore.hpp" diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 68a073731d..c2fc82881f 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -35,11 +35,12 @@ #include #include +#include + #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwworld/esmstore.hpp" #include "../mwworld/class.hpp" -#include "../mwworld/fallback.hpp" #include "../mwworld/cellstore.hpp" #include "../mwmechanics/character.hpp" // FIXME: for MWMechanics::Priority @@ -1113,7 +1114,7 @@ namespace MWRender osg::ref_ptr light (new osg::Light); lightSource->setNodeMask(Mask_Lighting); - const MWWorld::Fallback* fallback = MWBase::Environment::get().getWorld()->getFallback(); + const Fallback::Map* fallback = MWBase::Environment::get().getWorld()->getFallback(); float radius = esmLight->mData.mRadius; lightSource->setRadius(radius); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index ee9d93c0f2..61ce626fde 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -30,8 +30,8 @@ #include #include +#include -#include "../mwworld/fallback.hpp" #include "../mwworld/cellstore.hpp" #include "sky.hpp" @@ -126,7 +126,7 @@ namespace MWRender }; RenderingManager::RenderingManager(osgViewer::Viewer* viewer, osg::ref_ptr rootNode, Resource::ResourceSystem* resourceSystem, - const MWWorld::Fallback* fallback, const std::string& resourcePath) + const Fallback::Map* fallback, const std::string& resourcePath) : mViewer(viewer) , mRootNode(rootNode) , mResourceSystem(resourceSystem) diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 58012078c4..3b583af89c 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -37,9 +37,9 @@ namespace Terrain class World; } -namespace MWWorld +namespace Fallback { - class Fallback; + class Map; } namespace MWRender @@ -58,7 +58,7 @@ namespace MWRender { public: RenderingManager(osgViewer::Viewer* viewer, osg::ref_ptr rootNode, Resource::ResourceSystem* resourceSystem, - const MWWorld::Fallback* fallback, const std::string& resourcePath); + const Fallback::Map* fallback, const std::string& resourcePath); ~RenderingManager(); MWRender::Objects& getObjects(); diff --git a/apps/openmw/mwrender/ripplesimulation.cpp b/apps/openmw/mwrender/ripplesimulation.cpp index f232ea475d..f74631c4a2 100644 --- a/apps/openmw/mwrender/ripplesimulation.cpp +++ b/apps/openmw/mwrender/ripplesimulation.cpp @@ -15,19 +15,18 @@ #include #include #include +#include #include "vismask.hpp" #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" -#include "../mwworld/fallback.hpp" - #include "../mwmechanics/actorutil.hpp" namespace { - void createWaterRippleStateSet(Resource::ResourceSystem* resourceSystem, const MWWorld::Fallback* fallback, osg::Node* node) + void createWaterRippleStateSet(Resource::ResourceSystem* resourceSystem, const Fallback::Map* fallback, osg::Node* node) { int rippleFrameCount = fallback->getFallbackInt("Water_RippleFrameCount"); if (rippleFrameCount <= 0) @@ -78,7 +77,7 @@ namespace namespace MWRender { -RippleSimulation::RippleSimulation(osg::Group *parent, Resource::ResourceSystem* resourceSystem, const MWWorld::Fallback* fallback) +RippleSimulation::RippleSimulation(osg::Group *parent, Resource::ResourceSystem* resourceSystem, const Fallback::Map* fallback) : mParent(parent) { osg::ref_ptr geode (new osg::Geode); diff --git a/apps/openmw/mwrender/ripplesimulation.hpp b/apps/openmw/mwrender/ripplesimulation.hpp index a4e12f2756..bca81c59b4 100644 --- a/apps/openmw/mwrender/ripplesimulation.hpp +++ b/apps/openmw/mwrender/ripplesimulation.hpp @@ -21,9 +21,9 @@ namespace Resource class ResourceSystem; } -namespace MWWorld +namespace Fallback { - class Fallback; + class Map; } namespace MWRender @@ -40,7 +40,7 @@ namespace MWRender class RippleSimulation { public: - RippleSimulation(osg::Group* parent, Resource::ResourceSystem* resourceSystem, const MWWorld::Fallback* fallback); + RippleSimulation(osg::Group* parent, Resource::ResourceSystem* resourceSystem, const Fallback::Map* fallback); ~RippleSimulation(); /// @param dt Time since the last frame diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 635116db0a..efe797336d 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -42,8 +43,6 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" -#include "../mwworld/fallback.hpp" - #include "vismask.hpp" #include "renderbin.hpp" @@ -827,7 +826,7 @@ private: , mTimeOfDayFade(1.f) , mGlareView(1.f) { - const MWWorld::Fallback* fallback = MWBase::Environment::get().getWorld()->getFallback(); + const Fallback::Map* fallback = MWBase::Environment::get().getWorld()->getFallback(); mColor = fallback->getFallbackColour("Weather_Sun_Glare_Fader_Color"); mSunGlareFaderMax = fallback->getFallbackFloat("Weather_Sun_Glare_Fader_Max"); mSunGlareFaderAngleMax = fallback->getFallbackFloat("Weather_Sun_Glare_Fader_Angle_Max"); @@ -1161,7 +1160,7 @@ void SkyManager::create() mSun.reset(new Sun(mEarlyRenderBinRoot, *mSceneManager->getTextureManager())); - const MWWorld::Fallback* fallback=MWBase::Environment::get().getWorld()->getFallback(); + const Fallback::Map* fallback=MWBase::Environment::get().getWorld()->getFallback(); mMasser.reset(new Moon(mEarlyRenderBinRoot, *mSceneManager->getTextureManager(), fallback->getFallbackFloat("Moons_Masser_Size")/125, Moon::Type_Masser)); mSecunda.reset(new Moon(mEarlyRenderBinRoot, *mSceneManager->getTextureManager(), fallback->getFallbackFloat("Moons_Secunda_Size")/125, Moon::Type_Secunda)); diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index cd1f4c5113..1b19246f5b 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -34,8 +34,9 @@ #include +#include + #include "../mwworld/cellstore.hpp" -#include "../mwworld/fallback.hpp" #include "vismask.hpp" #include "ripplesimulation.hpp" @@ -457,7 +458,7 @@ public: }; Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem *resourceSystem, osgUtil::IncrementalCompileOperation *ico, - const MWWorld::Fallback* fallback, const std::string& resourcePath) + const Fallback::Map* fallback, const std::string& resourcePath) : mParent(parent) , mSceneRoot(sceneRoot) , mResourceSystem(resourceSystem) diff --git a/apps/openmw/mwrender/water.hpp b/apps/openmw/mwrender/water.hpp index b26782873f..b02ee392c5 100644 --- a/apps/openmw/mwrender/water.hpp +++ b/apps/openmw/mwrender/water.hpp @@ -28,11 +28,15 @@ namespace Resource namespace MWWorld { - class Fallback; class CellStore; class Ptr; } +namespace Fallback +{ + class Map; +} + namespace MWRender { @@ -50,7 +54,7 @@ namespace MWRender osg::ref_ptr mWaterNode; osg::ref_ptr mWaterGeode; Resource::ResourceSystem* mResourceSystem; - const MWWorld::Fallback* mFallback; + const Fallback::Map* mFallback; osg::ref_ptr mIncrementalCompileOperation; std::auto_ptr mSimulation; @@ -77,7 +81,7 @@ namespace MWRender public: Water(osg::Group* parent, osg::Group* sceneRoot, - Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, const MWWorld::Fallback* fallback, + Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, const Fallback::Map* fallback, const std::string& resourcePath); ~Water(); diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 5ce3d5c2fe..c40913ff1b 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -20,7 +21,6 @@ #include "player.hpp" #include "esmstore.hpp" -#include "fallback.hpp" #include "cellstore.hpp" #include @@ -100,7 +100,7 @@ template class TimeOfDayInterpolator; template class TimeOfDayInterpolator; Weather::Weather(const std::string& name, - const MWWorld::Fallback& fallback, + const Fallback::Map& fallback, float stormWindSpeed, float rainSpeed, const std::string& particleEffect) @@ -327,7 +327,7 @@ void RegionWeather::chooseNewWeather() mWeather = i; } -MoonModel::MoonModel(const std::string& name, const MWWorld::Fallback& fallback) +MoonModel::MoonModel(const std::string& name, const Fallback::Map& fallback) : mFadeInStart(fallback.getFallbackFloat("Moons_" + name + "_Fade_In_Start")) , mFadeInFinish(fallback.getFallbackFloat("Moons_" + name + "_Fade_In_Finish")) , mFadeOutStart(fallback.getFallbackFloat("Moons_" + name + "_Fade_Out_Start")) @@ -496,7 +496,7 @@ inline float MoonModel::earlyMoonShadowAlpha(float angle) const return 0.0f; } -WeatherManager::WeatherManager(MWRender::RenderingManager& rendering, const MWWorld::Fallback& fallback, MWWorld::ESMStore& store) +WeatherManager::WeatherManager(MWRender::RenderingManager& rendering, const Fallback::Map& fallback, MWWorld::ESMStore& store) : mStore(store) , mRendering(rendering) , mSunriseTime(fallback.getFallbackFloat("Weather_Sunrise_Time")) @@ -862,7 +862,7 @@ void WeatherManager::clear() } inline void WeatherManager::addWeather(const std::string& name, - const MWWorld::Fallback& fallback, + const Fallback::Map& fallback, const std::string& particleEffect) { static const float fStromWindSpeed = mStore.get().find("fStromWindSpeed")->getFloat(); diff --git a/apps/openmw/mwworld/weather.hpp b/apps/openmw/mwworld/weather.hpp index a5627a507c..0442007570 100644 --- a/apps/openmw/mwworld/weather.hpp +++ b/apps/openmw/mwworld/weather.hpp @@ -29,9 +29,13 @@ namespace Loading class Listener; } +namespace Fallback +{ + class Map; +} + namespace MWWorld { - class Fallback; class TimeStamp; @@ -66,7 +70,7 @@ namespace MWWorld { public: Weather(const std::string& name, - const MWWorld::Fallback& fallback, + const Fallback::Map& fallback, float stormWindSpeed, float rainSpeed, const std::string& particleEffect); @@ -172,7 +176,7 @@ namespace MWWorld class MoonModel { public: - MoonModel(const std::string& name, const MWWorld::Fallback& fallback); + MoonModel(const std::string& name, const Fallback::Map& fallback); MWRender::MoonState calculateState(const TimeStamp& gameTime) const; @@ -203,7 +207,7 @@ namespace MWWorld public: // Have to pass fallback and Store, can't use singleton since World isn't fully constructed yet at the time WeatherManager(MWRender::RenderingManager& rendering, - const MWWorld::Fallback& fallback, + const Fallback::Map& fallback, MWWorld::ESMStore& store); ~WeatherManager(); @@ -288,7 +292,7 @@ namespace MWWorld std::string mPlayingSoundID; void addWeather(const std::string& name, - const MWWorld::Fallback& fallback, + const Fallback::Map& fallback, const std::string& particleEffect = ""); void importRegions(); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 15826009d6..789b1b64fa 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -511,7 +511,7 @@ namespace MWWorld return 0; } - const MWWorld::Fallback *World::getFallback() const + const Fallback::Map *World::getFallback() const { return &mFallback; } diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 4ed97759ef..53d640871e 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -5,21 +5,20 @@ #include +#include +#include + +#include "../mwbase/world.hpp" + #include "ptr.hpp" #include "scene.hpp" #include "esmstore.hpp" #include "cells.hpp" #include "localscripts.hpp" #include "timestamp.hpp" -#include "fallback.hpp" #include "globals.hpp" - -#include "../mwbase/world.hpp" - #include "contentloader.hpp" -#include - namespace osg { class Group; @@ -71,7 +70,7 @@ namespace MWWorld { Resource::ResourceSystem* mResourceSystem; - MWWorld::Fallback mFallback; + Fallback::Map mFallback; MWRender::RenderingManager* mRendering; MWWorld::WeatherManager* mWeatherManager; @@ -210,7 +209,7 @@ namespace MWWorld virtual void adjustSky(); - virtual const Fallback *getFallback() const; + virtual const Fallback::Map *getFallback() const; virtual Player& getPlayer(); virtual MWWorld::Ptr getPlayerPtr(); diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index bbbff234c4..af26fc9989 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -138,6 +138,10 @@ add_component_dir (version version ) +add_component_dir (fallback + fallback validate + ) + set (ESM_UI ${CMAKE_SOURCE_DIR}/files/ui/contentselector.ui ) diff --git a/apps/openmw/mwworld/fallback.cpp b/components/fallback/fallback.cpp similarity index 75% rename from apps/openmw/mwworld/fallback.cpp rename to components/fallback/fallback.cpp index e810f8241b..3545956606 100644 --- a/apps/openmw/mwworld/fallback.cpp +++ b/components/fallback/fallback.cpp @@ -2,12 +2,12 @@ #include -namespace MWWorld +namespace Fallback { - Fallback::Fallback(const std::map& fallback):mFallbackMap(fallback) + Map::Map(const std::map& fallback):mFallbackMap(fallback) {} - std::string Fallback::getFallbackString(const std::string& fall) const + std::string Map::getFallbackString(const std::string& fall) const { std::map::const_iterator it; if((it = mFallbackMap.find(fall)) == mFallbackMap.end()) @@ -16,7 +16,7 @@ namespace MWWorld } return it->second; } - float Fallback::getFallbackFloat(const std::string& fall) const + float Map::getFallbackFloat(const std::string& fall) const { std::string fallback=getFallbackString(fall); if(fallback.empty()) @@ -24,7 +24,7 @@ namespace MWWorld else return boost::lexical_cast(fallback); } - int Fallback::getFallbackInt(const std::string& fall) const + int Map::getFallbackInt(const std::string& fall) const { std::string fallback=getFallbackString(fall); if(fallback.empty()) @@ -33,7 +33,7 @@ namespace MWWorld return boost::lexical_cast(fallback); } - bool Fallback::getFallbackBool(const std::string& fall) const + bool Map::getFallbackBool(const std::string& fall) const { std::string fallback=getFallbackString(fall); if(fallback.empty()) @@ -41,7 +41,7 @@ namespace MWWorld else return boost::lexical_cast(fallback); } - osg::Vec4f Fallback::getFallbackColour(const std::string& fall) const + osg::Vec4f Map::getFallbackColour(const std::string& fall) const { std::string sum=getFallbackString(fall); if(sum.empty()) diff --git a/apps/openmw/mwworld/fallback.hpp b/components/fallback/fallback.hpp similarity index 67% rename from apps/openmw/mwworld/fallback.hpp rename to components/fallback/fallback.hpp index af47063ee8..b44483fbc1 100644 --- a/apps/openmw/mwworld/fallback.hpp +++ b/components/fallback/fallback.hpp @@ -1,18 +1,19 @@ -#ifndef GAME_MWWORLD_FALLBACK_H -#define GAME_MWWORLD_FALLBACK_H +#ifndef OPENMW_COMPONENTS_FALLBACK_H +#define OPENMW_COMPONENTS_FALLBACK_H #include #include #include -namespace MWWorld +namespace Fallback { - class Fallback + /// @brief contains settings imported from the Morrowind INI file. + class Map { const std::map mFallbackMap; public: - Fallback(const std::map& fallback); + Map(const std::map& fallback); std::string getFallbackString(const std::string& fall) const; float getFallbackFloat(const std::string& fall) const; int getFallbackInt(const std::string& fall) const; diff --git a/components/fallback/validate.hpp b/components/fallback/validate.hpp new file mode 100644 index 0000000000..3b6398d6a2 --- /dev/null +++ b/components/fallback/validate.hpp @@ -0,0 +1,48 @@ +#ifndef OPENMW_COMPONENTS_FALLBACK_VALIDATE_H +#define OPENMW_COMPONENTS_FALLBACK_VALIDATE_H + +#include + +// Parses and validates a fallback map from boost program_options. +// Note: for boost to pick up the validate function, you need to pull in the namespace e.g. +// by using namespace Fallback; + +namespace Fallback +{ + + struct FallbackMap { + std::map mMap; + }; + + void validate(boost::any &v, std::vector const &tokens, FallbackMap*, int) + { + if(v.empty()) + { + v = boost::any(FallbackMap()); + } + + FallbackMap *map = boost::any_cast(&v); + + for(std::vector::const_iterator it=tokens.begin(); it != tokens.end(); ++it) + { + int sep = it->find(","); + if(sep < 1 || sep == (int)it->length()-1) + #if (BOOST_VERSION < 104200) + throw boost::program_options::validation_error("invalid value"); + #else + throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value); + #endif + + std::string key(it->substr(0,sep)); + std::string value(it->substr(sep+1)); + + if(map->mMap.find(key) == map->mMap.end()) + { + map->mMap.insert(std::make_pair (key,value)); + } + } + } + +} + +#endif