2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef XWALK_COMMON_COMMAND_LINE_H_
18 #define XWALK_COMMON_COMMAND_LINE_H_
28 // CommandLine only uses long options
29 typedef std::map<std::string, std::string> OptionMap;
30 // Arguments which except for option strings
31 typedef std::vector<std::string> Arguments;
33 static void Init(int argc, char* argv[]);
34 static CommandLine* ForCurrentProcess();
37 // Test if options_ has 'option_name'
38 bool HasOptionName(const std::string& option_name);
39 // Get the option's value
40 std::string GetOptionValue(const std::string& option_name);
41 // Get command string include options and arguments
42 std::string GetCommandString();
44 std::string GetAppIdFromCommandLine(const std::string& program);
46 std::string program() const { return program_; }
47 const OptionMap& options() const { return options_; }
48 const Arguments& arguments() const { return arguments_; }
49 char** argv() const { return argv_; }
50 int argc() const { return argc_; }
53 CommandLine(int argc, char* argv[]);
54 virtual ~CommandLine();
56 void AppendOption(const char* value);
58 // The singleton CommandLine instance of current process
59 static CommandLine* current_process_commandline_;
70 #endif // XWALK_COMMON_COMMAND_LINE_H_