MongoDB  2.7.0
options_parser.h
1 /* Copyright 2013 10gen Inc.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #pragma once
17 
18 #include <map>
19 #include <string>
20 #include <vector>
21 
22 #include "mongo/base/status.h"
23 
24 namespace mongo {
25 namespace optionenvironment {
26 
27  class Environment;
28  class OptionSection;
29  class Value;
30 
73  class OptionsParser {
74  public:
75  OptionsParser() { }
76  virtual ~OptionsParser() { }
77 
88  Status run(const OptionSection&,
89  const std::vector<std::string>& argv,
90  const std::map<std::string, std::string>& env,
91  Environment*);
92 
93  private:
95  Status parseCommandLine(const OptionSection&,
96  const std::vector<std::string>& argv, Environment*);
97 
99  Status parseINIConfigFile(const OptionSection&, const std::string& config, Environment*);
100 
102  Status addDefaultValues(const OptionSection&, Environment*);
103 
106  virtual Status readConfigFile(const std::string& filename, std::string*);
107  };
108 
109 } // namespace optionenvironment
110 } // namespace mongo
Status run(const OptionSection &, const std::vector< std::string > &argv, const std::map< std::string, std::string > &env, Environment *)
Handles parsing of the command line as well as YAML and INI config files.
Definition: options_parser.cpp:851
A container for OptionDescription instances as well as other OptionSection instances.
Definition: option_section.h:67
An Environment is a map of values that can be validated according to a set of registered constraints...
Definition: environment.h:98
Handles parsing of the command line as well as YAML and INI config files.
Definition: options_parser.h:73