/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx 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, or (at your option) any later version. ### File Specific: main-programmer: Christoph Renner co-programmer: ... */ //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ #include "cmd_line_prefs_reader.h" #include "preferences.h" using namespace std; /** * standard constructor */ CmdLinePrefsReader::CmdLinePrefsReader( ) { } /** * standard deconstructor */ CmdLinePrefsReader::~CmdLinePrefsReader () { } bool CmdLinePrefsReader::callBack( ArgTableEntry entry, void * data, const std::string & arg, const std::vector & argArgs ) { switch ( entry.id ) { case ID_SET_INI: { std::string section = arg; section.erase( 0, entry.longOption.length()+1 ); std::string key = section; section.erase( section.find(".") ); key.erase( 0, key.find(".")+1 ); //PRINTF(0)("SECTION '%s', KEY '%s'\n", section.c_str(), key.c_str()); if ( key == "" || section == "" || argArgs.size() != 1 ) { PRINTF(1)("usage: --set-section.key=value\n"); return false; } Preferences::getInstance()->setMultiType( section, key, argArgs[0], true ); break; } default: assert(false); } return true; } bool CmdLinePrefsReader::parse( int argc, char ** argv ) { CmdLineParser parser; parser.add( ID_SET_INI, "set-%", '\0', 1 ); parser.parse( &callBack, NULL, argc, argv ); }