• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef HC_GEN_OPTION_H
10 #define HC_GEN_OPTION_H
11 
12 #include <memory>
13 #include <string>
14 
15 namespace OHOS {
16 namespace Hardware {
17 class Option {
18 public:
19     Option() = default;
20 
21     ~Option() = default;
22 
23     static Option &Instance();
24 
25     Option &Parse(int argc, char *argv[]);
26 
27     static void ShowUsage();
28 
29     static void ShowVersion();
30 
31     bool ShouldShowUsage() const;
32 
33     bool OptionError() const;
34 
35     bool ShouldShowVersion() const;
36 
37     bool ShouldAlign() const;
38 
39     bool ShouldGenTextConfig() const;
40 
41     bool ShouldGenMacroConfig() const;
42 
43     bool ShouldGenBinaryConfig() const;
44 
45     bool ShouldGenStartConfig() const;
46 
47     bool ShouldGenHexDump() const;
48 
49     bool ShouldDecompile() const;
50 
51     std::string GetSymbolPrefix() const;
52 
53     std::string GetSourceName() const;
54 
55     std::string GetSourceNameBase() const;
56 
57     std::string GetOutputName() const;
58 
59     static void GetVersion(uint32_t &minor, uint32_t &major);
60 
61     bool VerboseLog() const;
62 
63     std::string GetSourceDir() const;
64 
65     static std::string RealPathSourcePath(const char *path);
66 
67 private:
68     static void ShowOption(const std::string &option, const std::string &helpInfo);
69     bool ParseOptions(int argc, char *argv[]);
70     void SetOptionError(bool shouldShowUsage = true);
71     bool SetSourceOption(const char *srcName);
72 
73     bool showUsage_ = false;
74     bool showVersion_ = false;
75     bool shouldAlign_ = false;
76     bool shouldGenTextConfig_ = false;
77     bool shouldGenMacroConfig_ = false;
78     bool shouldGenByteCodeConfig_ = true;
79     bool genStartCfg_ = false;
80     bool showGenHexDump_ = false;
81     bool shouldDecompile_ = false;
82     bool verboseLog_ = false;
83     bool optionError_ = false;
84     std::string symbolNamePrefix_;
85     std::string sourceName_;
86     std::string sourceNameBase_;
87     std::string outputName_;
88     void SetOptionData(char op);
89 };
90 } // namespace Hardware
91 } // namespace OHOS
92 #endif // HC_GEN_OPTION_H
93