623d4471160b7201544f23f2d0583859d3cb2827
[platform/framework/web/crosswalk-tizen.git] / src / common / command_line.h
1 // Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef WRT_COMMON_COMMAND_LINE_H_
6 #define WRT_COMMON_COMMAND_LINE_H_
7
8 #include <string>
9 #include <map>
10 #include <vector>
11
12 namespace wrt {
13
14 class CommandLine {
15  public:
16   // CommandLine only uses long options
17   typedef std::map<std::string, std::string> OptionMap;
18   // Arguments which except for option strings
19   typedef std::vector<std::string> Arguments;
20
21   static void Init(int argc, char* argv[]);
22   static CommandLine* ForCurrentProcess();
23   static void Reset();
24
25   // Test if options_ has 'option_name'
26   bool HasOptionName(const std::string& option_name);
27   // Get the option's value
28   std::string GetOptionValue(const std::string& option_name);
29   // Get command string include options and arguments
30   std::string GetCommandString();
31
32   std::string appid() const { return appid_; }
33   std::string program() const { return program_; }
34   const OptionMap& options() const { return options_; }
35   const Arguments& arguments() const { return arguments_; }
36   char** argv() const { return argv_; }
37   int argc() const { return argc_; }
38
39  private:
40   CommandLine(int argc, char* argv[]);
41   virtual ~CommandLine();
42
43   void AppendOption(const char* value);
44
45   // The singleton CommandLine instance of current process
46   static CommandLine* current_process_commandline_;
47
48   std::string appid_;
49   std::string program_;
50   OptionMap options_;
51   Arguments arguments_;
52   int argc_;
53   char** argv_;
54 };
55
56 }  // namespace wrt
57
58 #endif  // WRT_COMMON_COMMAND_LINE_H_