• 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 
18 class Option {
19 public:
20     Option() = default;
21 
22     ~Option() = default;
23 
24     static Option &Instance();
25 
26     Option &Parse(int argc, char *argv[]);
27 
28     void ShowUsage();
29 
30     void ShowVersion();
31 
32     bool ShouldShowUsage() const;
33 
34     bool OptionError() const;
35 
36     bool ShouldShowVersion() const;
37 
38     bool ShouldAlign() const;
39 
40     bool ShouldGenTextConfig() const;
41 
42     bool ShouldGenMacroConfig() const;
43 
44     bool ShouldGenBinaryConfig() const;
45 
46     bool ShouldGenHexDump() const;
47 
48     bool ShouldDecompile() const;
49 
50     std::string GetSymbolPrefix();
51 
52     std::string GetSourceName();
53 
54     std::string GetSourceNameBase();
55 
56     std::string GetOutputName();
57 
58     void GetVersion(uint32_t &minor, uint32_t &major);
59 
60     bool VerboseLog() const;
61 
62     std::string GetSourceDir();
63 
64     static std::string RealPathSourcePath(const char *path);
65 
66 private:
67     static void ShowOption(const std::string &option, const std::string &helpInfo);
68     bool ParseOptions(int argc, char *argv[]);
69     void SetOptionError(bool shouldShowUsage = true);
70     bool SetSourceOption(const char *srcName);
71 
72     bool showUsage_ = false;
73     bool showVersion_ = false;
74     bool shouldAlign_ = false;
75     bool shouldGenTextConfig_ = false;
76     bool shouldGenMacroConfig_ = false;
77     bool shouldGenByteCodeConfig_ = true;
78     bool showGenHexDump_ = false;
79     bool shouldDecompile_ = false;
80     bool verboseLog_ = false;
81     bool optionError_ = false;
82     std::string symbolNamePrefix_;
83     std::string sourceName_;
84     std::string sourceNameBase_;
85     std::string outputName_;
86     std::string sourceDir_;
87     void SetOptionData(char op);
88 };
89 } // namespace Hardware
90 } // namespace OHOS
91 #endif // HC_GEN_OPTION_H
92