| 209 | // Enforces the FlagRequirements are met for a given flag. |
| 210 | template <typename T> |
| 211 | void EnforceFlagRequirement(const T& flag, const string& flag_name, |
| 212 | FlagRequirement requirement) { |
| 213 | if (requirement == FlagRequirement::kMustBeSpecified) { |
| 214 | QCHECK(flag.specified()) << "Missing required flag " << flag_name; |
| 215 | } |
| 216 | if (requirement == FlagRequirement::kMustNotBeSpecified) { |
| 217 | QCHECK(!flag.specified()) |
| 218 | << "Given other flags, this flag should not have been specified: " |
| 219 | << flag_name; |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | // Gets the value from the flag if specified. Returns default if the |
| 224 | // FlagRequirement is kUseDefault. |