Brad King | 86578ec | 2016-09-27 15:01:08 -0400 | [diff] [blame] | 1 | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
| 2 | file Copyright.txt or https://cmake.org/licensing for details. */ |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 3 | #include "cmIDEOptions.h" |
| 4 | |
NAKAMURA Takumi | 0e58a5e | 2021-11-14 19:58:11 +0900 | [diff] [blame] | 5 | #include <algorithm> |
Rose | 6f4727a | 2021-10-23 11:27:46 -0400 | [diff] [blame] | 6 | #include <cstring> |
Daniel Pfeifer | 66a7099 | 2016-11-25 22:54:58 +0100 | [diff] [blame] | 7 | #include <iterator> |
NAKAMURA Takumi | 0e58a5e | 2021-11-14 19:58:11 +0900 | [diff] [blame] | 8 | #include <utility> |
Kitware Robot | ed98209 | 2019-09-30 10:46:28 -0400 | [diff] [blame] | 9 | |
Marc Chevrier | f7d1260 | 2019-12-09 17:39:29 +0100 | [diff] [blame] | 10 | #include <cmext/algorithm> |
| 11 | |
Kitware Robot | ed98209 | 2019-09-30 10:46:28 -0400 | [diff] [blame] | 12 | #include "cmsys/String.h" |
| 13 | |
Daniel Pfeifer | 66a7099 | 2016-11-25 22:54:58 +0100 | [diff] [blame] | 14 | #include "cmIDEFlagTable.h" |
Sebastian Holtermann | f4f3c68 | 2019-08-11 11:56:59 +0200 | [diff] [blame] | 15 | #include "cmStringAlgorithms.h" |
Brad King | 4ca9df8 | 2016-01-08 14:30:06 -0500 | [diff] [blame] | 16 | |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 17 | cmIDEOptions::cmIDEOptions() |
| 18 | { |
| 19 | this->DoingDefine = false; |
| 20 | this->AllowDefine = true; |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 21 | this->DoingInclude = false; |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 22 | this->AllowSlash = false; |
Ben Boeckel | 1b929ba | 2022-11-22 13:51:48 -0500 | [diff] [blame^] | 23 | this->DoingFollowing = nullptr; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 24 | for (int i = 0; i < FlagTableCount; ++i) { |
Ben Boeckel | 1b929ba | 2022-11-22 13:51:48 -0500 | [diff] [blame^] | 25 | this->FlagTable[i] = nullptr; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 26 | } |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 27 | } |
| 28 | |
Ben Boeckel | 83d685e | 2022-11-22 13:39:20 -0500 | [diff] [blame] | 29 | cmIDEOptions::~cmIDEOptions() = default; |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 30 | |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 31 | void cmIDEOptions::HandleFlag(std::string const& flag) |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 32 | { |
| 33 | // If the last option was -D then this option is the definition. |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 34 | if (this->DoingDefine) { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 35 | this->DoingDefine = false; |
| 36 | this->Defines.push_back(flag); |
| 37 | return; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 38 | } |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 39 | |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 40 | // If the last option was -I then this option is the include directory. |
| 41 | if (this->DoingInclude) { |
| 42 | this->DoingInclude = false; |
| 43 | this->Includes.push_back(flag); |
| 44 | return; |
| 45 | } |
| 46 | |
Brad King | 650199e | 2014-04-01 14:56:08 -0400 | [diff] [blame] | 47 | // If the last option expected a following value, this is it. |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 48 | if (this->DoingFollowing) { |
Brad King | 650199e | 2014-04-01 14:56:08 -0400 | [diff] [blame] | 49 | this->FlagMapUpdate(this->DoingFollowing, flag); |
Ben Boeckel | 1b929ba | 2022-11-22 13:51:48 -0500 | [diff] [blame^] | 50 | this->DoingFollowing = nullptr; |
Brad King | 650199e | 2014-04-01 14:56:08 -0400 | [diff] [blame] | 51 | return; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 52 | } |
Brad King | 650199e | 2014-04-01 14:56:08 -0400 | [diff] [blame] | 53 | |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 54 | // Look for known arguments. |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 55 | size_t len = flag.length(); |
| 56 | if (len > 0 && (flag[0] == '-' || (this->AllowSlash && flag[0] == '/'))) { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 57 | // Look for preprocessor definitions. |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 58 | if (this->AllowDefine && len > 1 && flag[1] == 'D') { |
| 59 | if (len <= 2) { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 60 | // The next argument will have the definition. |
| 61 | this->DoingDefine = true; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 62 | } else { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 63 | // Store this definition. |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 64 | this->Defines.push_back(flag.substr(2)); |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 65 | } |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 66 | return; |
| 67 | } |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 68 | // Look for include directory. |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 69 | if (this->AllowInclude && len > 1 && flag[1] == 'I') { |
| 70 | if (len <= 2) { |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 71 | // The next argument will have the include directory. |
| 72 | this->DoingInclude = true; |
| 73 | } else { |
| 74 | // Store this include directory. |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 75 | this->Includes.push_back(flag.substr(2)); |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 76 | } |
| 77 | return; |
| 78 | } |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 79 | |
| 80 | // Look through the available flag tables. |
| 81 | bool flag_handled = false; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 82 | for (int i = 0; i < FlagTableCount && this->FlagTable[i]; ++i) { |
| 83 | if (this->CheckFlagTable(this->FlagTable[i], flag, flag_handled)) { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 84 | return; |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 85 | } |
| 86 | } |
| 87 | |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 88 | // If any map entry handled the flag we are done. |
| 89 | if (flag_handled) { |
| 90 | return; |
| 91 | } |
| 92 | } |
| 93 | |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 94 | // This option is not known. Store it in the output flags. |
| 95 | this->StoreUnknownFlag(flag); |
| 96 | } |
| 97 | |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 98 | bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table, |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 99 | std::string const& flag, bool& flag_handled) |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 100 | { |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 101 | const char* pf = flag.c_str() + 1; |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 102 | // Look for an entry in the flag table matching this flag. |
Stephan Szabo | 8279302 | 2018-11-20 10:09:57 -0800 | [diff] [blame] | 103 | for (cmIDEFlagTable const* entry = table; !entry->IDEName.empty(); ++entry) { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 104 | bool entry_found = false; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 105 | if (entry->special & cmIDEFlagTable::UserValue) { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 106 | // This flag table entry accepts a user-specified value. If |
| 107 | // the entry specifies UserRequired we must match only if a |
| 108 | // non-empty value is given. |
Stephan Szabo | 8279302 | 2018-11-20 10:09:57 -0800 | [diff] [blame] | 109 | int n = static_cast<int>(entry->commandFlag.length()); |
| 110 | if ((strncmp(pf, entry->commandFlag.c_str(), n) == 0 || |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 111 | (entry->special & cmIDEFlagTable::CaseInsensitive && |
Stephan Szabo | 8279302 | 2018-11-20 10:09:57 -0800 | [diff] [blame] | 112 | cmsysString_strncasecmp(pf, entry->commandFlag.c_str(), n))) && |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 113 | (!(entry->special & cmIDEFlagTable::UserRequired) || |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 114 | static_cast<int>(strlen(pf)) > n)) { |
| 115 | this->FlagMapUpdate(entry, std::string(pf + n)); |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 116 | entry_found = true; |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 117 | } |
Stephan Szabo | 8279302 | 2018-11-20 10:09:57 -0800 | [diff] [blame] | 118 | } else if (strcmp(pf, entry->commandFlag.c_str()) == 0 || |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 119 | (entry->special & cmIDEFlagTable::CaseInsensitive && |
Stephan Szabo | 8279302 | 2018-11-20 10:09:57 -0800 | [diff] [blame] | 120 | cmsysString_strcasecmp(pf, entry->commandFlag.c_str()) == 0)) { |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 121 | if (entry->special & cmIDEFlagTable::UserFollowing) { |
Brad King | 650199e | 2014-04-01 14:56:08 -0400 | [diff] [blame] | 122 | // This flag expects a value in the following argument. |
| 123 | this->DoingFollowing = entry; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 124 | } else { |
Brad King | 650199e | 2014-04-01 14:56:08 -0400 | [diff] [blame] | 125 | // This flag table entry provides a fixed value. |
| 126 | this->FlagMap[entry->IDEName] = entry->value; |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 127 | } |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 128 | entry_found = true; |
| 129 | } |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 130 | |
| 131 | // If the flag has been handled by an entry not requesting a |
| 132 | // search continuation we are done. |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 133 | if (entry_found && !(entry->special & cmIDEFlagTable::Continue)) { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 134 | return true; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 135 | } |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 136 | |
| 137 | // If the entry was found the flag has been handled. |
| 138 | flag_handled = flag_handled || entry_found; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 139 | } |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 140 | |
| 141 | return false; |
| 142 | } |
| 143 | |
Brad King | f2a3dd9 | 2014-04-01 14:54:28 -0400 | [diff] [blame] | 144 | void cmIDEOptions::FlagMapUpdate(cmIDEFlagTable const* entry, |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 145 | std::string const& new_value) |
Brad King | f2a3dd9 | 2014-04-01 14:54:28 -0400 | [diff] [blame] | 146 | { |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 147 | if (entry->special & cmIDEFlagTable::UserIgnored) { |
Brad King | f2a3dd9 | 2014-04-01 14:54:28 -0400 | [diff] [blame] | 148 | // Ignore the user-specified value. |
| 149 | this->FlagMap[entry->IDEName] = entry->value; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 150 | } else if (entry->special & cmIDEFlagTable::SemicolonAppendable) { |
Brad King | 1c209ac | 2014-07-23 11:13:13 -0400 | [diff] [blame] | 151 | this->FlagMap[entry->IDEName].push_back(new_value); |
Brad King | 3936a28 | 2017-02-15 09:35:36 -0500 | [diff] [blame] | 152 | } else if (entry->special & cmIDEFlagTable::SpaceAppendable) { |
| 153 | this->FlagMap[entry->IDEName].append_with_space(new_value); |
Wil Stark | 8226979 | 2019-02-05 15:12:38 -0800 | [diff] [blame] | 154 | } else if (entry->special & cmIDEFlagTable::CommaAppendable) { |
| 155 | this->FlagMap[entry->IDEName].append_with_comma(new_value); |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 156 | } else { |
Brad King | f2a3dd9 | 2014-04-01 14:54:28 -0400 | [diff] [blame] | 157 | // Use the user-specified value. |
| 158 | this->FlagMap[entry->IDEName] = new_value; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 159 | } |
Brad King | f2a3dd9 | 2014-04-01 14:54:28 -0400 | [diff] [blame] | 160 | } |
| 161 | |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 162 | void cmIDEOptions::AddDefine(const std::string& def) |
| 163 | { |
| 164 | this->Defines.push_back(def); |
| 165 | } |
| 166 | |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 167 | void cmIDEOptions::AddDefines(std::string const& defines) |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 168 | { |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 169 | if (!defines.empty()) { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 170 | // Expand the list of definitions. |
Sebastian Holtermann | f4f3c68 | 2019-08-11 11:56:59 +0200 | [diff] [blame] | 171 | cmExpandList(defines, this->Defines); |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 172 | } |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 173 | } |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 174 | void cmIDEOptions::AddDefines(const std::vector<std::string>& defines) |
Stephen Kelly | afc9243c | 2013-07-10 15:22:59 +0200 | [diff] [blame] | 175 | { |
Marc Chevrier | f7d1260 | 2019-12-09 17:39:29 +0100 | [diff] [blame] | 176 | cm::append(this->Defines, defines); |
Stephen Kelly | afc9243c | 2013-07-10 15:22:59 +0200 | [diff] [blame] | 177 | } |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 178 | |
Brad King | 8a619e8 | 2017-03-28 12:55:14 -0400 | [diff] [blame] | 179 | std::vector<std::string> const& cmIDEOptions::GetDefines() const |
| 180 | { |
| 181 | return this->Defines; |
| 182 | } |
| 183 | |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 184 | void cmIDEOptions::AddInclude(const std::string& include) |
| 185 | { |
| 186 | this->Includes.push_back(include); |
| 187 | } |
| 188 | |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 189 | void cmIDEOptions::AddIncludes(std::string const& includes) |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 190 | { |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 191 | if (!includes.empty()) { |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 192 | // Expand the list of includes. |
Sebastian Holtermann | f4f3c68 | 2019-08-11 11:56:59 +0200 | [diff] [blame] | 193 | cmExpandList(includes, this->Includes); |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 194 | } |
| 195 | } |
| 196 | void cmIDEOptions::AddIncludes(const std::vector<std::string>& includes) |
| 197 | { |
Marc Chevrier | f7d1260 | 2019-12-09 17:39:29 +0100 | [diff] [blame] | 198 | cm::append(this->Includes, includes); |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | std::vector<std::string> const& cmIDEOptions::GetIncludes() const |
| 202 | { |
| 203 | return this->Includes; |
| 204 | } |
| 205 | |
Vitaly Stakhovsky | c62ffdc | 2017-12-08 22:30:16 -0500 | [diff] [blame] | 206 | void cmIDEOptions::AddFlag(std::string const& flag, std::string const& value) |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 207 | { |
| 208 | this->FlagMap[flag] = value; |
| 209 | } |
David Cole | 98b448e | 2011-02-09 12:59:09 -0500 | [diff] [blame] | 210 | |
Vitaly Stakhovsky | c62ffdc | 2017-12-08 22:30:16 -0500 | [diff] [blame] | 211 | void cmIDEOptions::AddFlag(std::string const& flag, |
Brad King | 1c209ac | 2014-07-23 11:13:13 -0400 | [diff] [blame] | 212 | std::vector<std::string> const& value) |
| 213 | { |
| 214 | this->FlagMap[flag] = value; |
| 215 | } |
| 216 | |
Brad King | 29410df | 2014-07-31 14:02:03 -0400 | [diff] [blame] | 217 | void cmIDEOptions::AppendFlag(std::string const& flag, |
| 218 | std::string const& value) |
| 219 | { |
| 220 | this->FlagMap[flag].push_back(value); |
| 221 | } |
| 222 | |
Brad King | 8410010 | 2014-08-13 13:39:35 -0400 | [diff] [blame] | 223 | void cmIDEOptions::AppendFlag(std::string const& flag, |
| 224 | std::vector<std::string> const& value) |
| 225 | { |
| 226 | FlagValue& fv = this->FlagMap[flag]; |
| 227 | std::copy(value.begin(), value.end(), std::back_inserter(fv)); |
| 228 | } |
| 229 | |
Brad King | 3936a28 | 2017-02-15 09:35:36 -0500 | [diff] [blame] | 230 | void cmIDEOptions::AppendFlagString(std::string const& flag, |
| 231 | std::string const& value) |
| 232 | { |
| 233 | this->FlagMap[flag].append_with_space(value); |
| 234 | } |
| 235 | |
Vitaly Stakhovsky | c62ffdc | 2017-12-08 22:30:16 -0500 | [diff] [blame] | 236 | void cmIDEOptions::RemoveFlag(std::string const& flag) |
David Cole | 98b448e | 2011-02-09 12:59:09 -0500 | [diff] [blame] | 237 | { |
| 238 | this->FlagMap.erase(flag); |
| 239 | } |
Brad King | c65a2ea | 2012-10-26 10:16:45 -0400 | [diff] [blame] | 240 | |
Brad King | 9633d11 | 2014-08-13 14:07:07 -0400 | [diff] [blame] | 241 | bool cmIDEOptions::HasFlag(std::string const& flag) const |
| 242 | { |
| 243 | return this->FlagMap.find(flag) != this->FlagMap.end(); |
| 244 | } |
| 245 | |
Vitaly Stakhovsky | c62ffdc | 2017-12-08 22:30:16 -0500 | [diff] [blame] | 246 | const char* cmIDEOptions::GetFlag(std::string const& flag) const |
Brad King | c65a2ea | 2012-10-26 10:16:45 -0400 | [diff] [blame] | 247 | { |
Brad King | 1c209ac | 2014-07-23 11:13:13 -0400 | [diff] [blame] | 248 | // This method works only for single-valued flags! |
Vitaly Stakhovsky | c62ffdc | 2017-12-08 22:30:16 -0500 | [diff] [blame] | 249 | std::map<std::string, FlagValue>::const_iterator i = |
| 250 | this->FlagMap.find(flag); |
| 251 | if (i != this->FlagMap.cend() && i->second.size() == 1) { |
Brad King | 1c209ac | 2014-07-23 11:13:13 -0400 | [diff] [blame] | 252 | return i->second[0].c_str(); |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 253 | } |
Vitaly Stakhovsky | c62ffdc | 2017-12-08 22:30:16 -0500 | [diff] [blame] | 254 | return nullptr; |
Brad King | c65a2ea | 2012-10-26 10:16:45 -0400 | [diff] [blame] | 255 | } |