MCPcopy Create free account
hub / github.com/Kitware/CMake / HandleFlag

Method HandleFlag

Source/cmIDEOptions.cxx:32–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30cmIDEOptions::~cmIDEOptions() = default;
31
32void cmIDEOptions::HandleFlag(std::string const& flag)
33{
34 // If the last option was -D then this option is the definition.
35 if (this->DoingDefine) {
36 this->DoingDefine = false;
37 this->Defines.push_back(flag);
38 return;
39 }
40
41 // If the last option was -I then this option is the include directory.
42 if (this->DoingInclude) {
43 this->DoingInclude = false;
44 this->Includes.push_back(flag);
45 return;
46 }
47
48 // If the last option expected a following value, this is it.
49 if (this->DoingFollowing) {
50 this->FlagMapUpdate(this->DoingFollowing, flag);
51 this->DoingFollowing = nullptr;
52 return;
53 }
54
55 // Look for known arguments.
56 size_t len = flag.length();
57 if (len > 0 && (flag[0] == '-' || (this->AllowSlash && flag[0] == '/'))) {
58 // Look for preprocessor definitions.
59 if (this->AllowDefine && len > 1 && flag[1] == 'D') {
60 if (len <= 2) {
61 // The next argument will have the definition.
62 this->DoingDefine = true;
63 } else {
64 // Store this definition.
65 this->Defines.emplace_back(flag.substr(2));
66 }
67 return;
68 }
69 // Look for include directory.
70 if (this->AllowInclude && len > 1 && flag[1] == 'I') {
71 if (len <= 2) {
72 // The next argument will have the include directory.
73 this->DoingInclude = true;
74 } else {
75 // Store this include directory.
76 this->Includes.emplace_back(flag.substr(2));
77 }
78 return;
79 }
80
81 // Look through the available flag tables.
82 bool flag_handled = false;
83 for (int i = 0; i < FlagTableCount && this->FlagTable[i]; ++i) {
84 if (this->CheckFlagTable(this->FlagTable[i], flag, flag_handled)) {
85 return;
86 }
87 }
88
89 // If any map entry handled the flag we are done.

Callers 1

ParseMethod · 0.80

Calls 7

FlagMapUpdateMethod · 0.95
CheckFlagTableMethod · 0.95
push_backMethod · 0.80
lengthMethod · 0.80
emplace_backMethod · 0.80
StoreUnknownFlagMethod · 0.80
substrMethod · 0.45

Tested by

no test coverage detected