1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | ### File Specific: |
---|
12 | main-programmer: Christoph Renner |
---|
13 | co-programmer: ... |
---|
14 | */ |
---|
15 | |
---|
16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ |
---|
17 | |
---|
18 | #include "cmd_line_prefs_reader.h" |
---|
19 | |
---|
20 | #include "preferences.h" |
---|
21 | |
---|
22 | using namespace std; |
---|
23 | |
---|
24 | /** |
---|
25 | * standard constructor |
---|
26 | */ |
---|
27 | CmdLinePrefsReader::CmdLinePrefsReader( ) |
---|
28 | { |
---|
29 | |
---|
30 | } |
---|
31 | |
---|
32 | |
---|
33 | /** |
---|
34 | * standard deconstructor |
---|
35 | */ |
---|
36 | CmdLinePrefsReader::~CmdLinePrefsReader () |
---|
37 | { |
---|
38 | } |
---|
39 | |
---|
40 | bool CmdLinePrefsReader::callBack( ArgTableEntry entry, void * data, const std::string & arg, const std::vector<MultiType> & argArgs ) |
---|
41 | { |
---|
42 | switch ( entry.id ) |
---|
43 | { |
---|
44 | case ID_SET_INI: |
---|
45 | { |
---|
46 | std::string section = arg; |
---|
47 | section.erase( 0, entry.longOption.length()+1 ); |
---|
48 | std::string key = section; |
---|
49 | section.erase( section.find(".") ); |
---|
50 | key.erase( 0, key.find(".")+1 ); |
---|
51 | //PRINTF(0)("SECTION '%s', KEY '%s'\n", section.c_str(), key.c_str()); |
---|
52 | |
---|
53 | if ( key == "" || section == "" || argArgs.size() != 1 ) |
---|
54 | { |
---|
55 | PRINTF(1)("usage: --set-section.key=value\n"); |
---|
56 | return false; |
---|
57 | } |
---|
58 | |
---|
59 | Preferences::getInstance()->setMultiType( section, key, argArgs[0], true ); |
---|
60 | break; |
---|
61 | } |
---|
62 | default: |
---|
63 | assert(false); |
---|
64 | } |
---|
65 | |
---|
66 | return true; |
---|
67 | } |
---|
68 | |
---|
69 | bool CmdLinePrefsReader::parse( int argc, char ** argv ) |
---|
70 | { |
---|
71 | CmdLineParser parser; |
---|
72 | |
---|
73 | parser.add( ID_SET_INI, "set-%", '\0', 1 ); |
---|
74 | |
---|
75 | parser.parse( &callBack, NULL, argc, argv ); |
---|
76 | } |
---|
77 | |
---|
78 | |
---|