1//===-- OptionDefinition.h --------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_UTILITY_OPTIONDEFINITION_H
10#define LLDB_UTILITY_OPTIONDEFINITION_H
11
12#include "lldb/lldb-enumerations.h"
13#include "lldb/lldb-private-types.h"
14#include "llvm/ADT/StringExtras.h"
15#include "llvm/Support/MathExtras.h"
16#include <climits>
17#include <cstdint>
18
19namespace lldb_private {
20struct OptionDefinition {
21  /// Used to mark options that can be used together.  If
22  /// `(1 << n & usage_mask) != 0` then this option belongs to option set n.
23  uint32_t usage_mask;
24  /// This option is required (in the current usage level).
25  bool required;
26  /// Full name for this option.
27  const char *long_option;
28  /// Single character for this option. If the option doesn't use a short
29  /// option character, this has to be a integer value that is not a printable
30  /// ASCII code point and also unique in the used set of options.
31  /// @see OptionDefinition::HasShortOption
32  int short_option;
33  /// no_argument, required_argument or optional_argument
34  int option_has_arg;
35  /// If non-NULL, option is valid iff |validator->IsValid()|, otherwise
36  /// always valid.
37  OptionValidator *validator;
38  /// If not empty, an array of enum values.
39  OptionEnumValues enum_values;
40  /// The kind of completion for this option.
41  /// Contains values of the lldb::CompletionType enum.
42  uint32_t completion_type;
43  /// Type of argument this option takes.
44  lldb::CommandArgumentType argument_type;
45  /// Full text explaining what this options does and what (if any) argument to
46  /// pass it.
47  const char *usage_text;
48
49  /// Whether this has a short option character.
50  bool HasShortOption() const {
51    // See the short_option documentation for more.
52    return llvm::isUInt<CHAR_BIT>(short_option) &&
53           llvm::isPrint(short_option);
54  }
55};
56} // namespace lldb_private
57
58#endif // LLDB_UTILITY_OPTIONDEFINITION_H
59