LLDB  mainline
OptionGroupPythonClassWithDict.h
Go to the documentation of this file.
1 //===-- OptionGroupPythonClassWithDict.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_INTERPRETER_OPTIONGROUPPYTHONCLASSWITHDICT_H
10 #define LLDB_INTERPRETER_OPTIONGROUPPYTHONCLASSWITHDICT_H
11 
13 #include "lldb/Utility/Flags.h"
15 #include "lldb/lldb-types.h"
16 
17 namespace lldb_private {
18 
19 // Use this Option group if you have a python class that implements some
20 // Python extension point, and you pass a SBStructuredData to the class
21 // __init__ method.
22 // class_option specifies the class name
23 // the key and value options are read in in pairs, and a
24 // StructuredData::Dictionary is constructed with those pairs.
26 public:
27  enum OptionKind {
28  eScriptClass = 1 << 0,
29  eDictKey = 1 << 1,
30  eDictValue = 1 << 2,
31  ePythonFunction = 1 << 3,
33  };
34 
35  OptionGroupPythonClassWithDict(const char *class_use, bool is_class = true,
36  int class_option = 'C', int key_option = 'k',
37  int value_option = 'v',
38  uint16_t required_options = eScriptClass |
40 
41  ~OptionGroupPythonClassWithDict() override = default;
42 
43  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
44  return llvm::ArrayRef<OptionDefinition>(m_option_definition);
45  }
46 
47  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
48  ExecutionContext *execution_context) override;
49 
50  void OptionParsingStarting(ExecutionContext *execution_context) override;
51  Status OptionParsingFinished(ExecutionContext *execution_context) override;
52 
54  return m_dict_sp;
55  }
56  const std::string &GetName() {
57  return m_name;
58  }
59 
60 protected:
65  bool m_is_class;
68 };
69 
70 } // namespace lldb_private
71 
72 #endif // LLDB_INTERPRETER_OPTIONGROUPPYTHONCLASSWITHDICT_H
lldb_private::OptionGroupPythonClassWithDict
Definition: OptionGroupPythonClassWithDict.h:25
lldb_private::ExecutionContext
Definition: ExecutionContext.h:291
lldb_private::OptionGroupPythonClassWithDict::ePythonFunction
@ ePythonFunction
Definition: OptionGroupPythonClassWithDict.h:31
StructuredData.h
lldb_private::OptionGroupPythonClassWithDict::m_key_usage_text
std::string m_key_usage_text
Definition: OptionGroupPythonClassWithDict.h:64
lldb_private::OptionGroup
Definition: Options.h:233
lldb_private::Flags
Definition: Flags.h:22
lldb_private::OptionGroupPythonClassWithDict::GetName
const std::string & GetName()
Definition: OptionGroupPythonClassWithDict.h:56
lldb_private::OptionGroupPythonClassWithDict::m_dict_sp
StructuredData::DictionarySP m_dict_sp
Definition: OptionGroupPythonClassWithDict.h:63
lldb_private::OptionGroupPythonClassWithDict::m_name
std::string m_name
Definition: OptionGroupPythonClassWithDict.h:61
lldb_private::OptionGroupPythonClassWithDict::OptionParsingFinished
Status OptionParsingFinished(ExecutionContext *execution_context) override
Definition: OptionGroupPythonClassWithDict.cpp:128
lldb_private::OptionGroupPythonClassWithDict::OptionGroupPythonClassWithDict
OptionGroupPythonClassWithDict(const char *class_use, bool is_class=true, int class_option='C', int key_option='k', int value_option='v', uint16_t required_options=eScriptClass|ePythonFunction)
Definition: OptionGroupPythonClassWithDict.cpp:16
lldb_private::OptionGroupPythonClassWithDict::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
Definition: OptionGroupPythonClassWithDict.cpp:81
lldb_private::OptionGroupPythonClassWithDict::~OptionGroupPythonClassWithDict
~OptionGroupPythonClassWithDict() override=default
lldb_private::OptionGroupPythonClassWithDict::eDictValue
@ eDictValue
Definition: OptionGroupPythonClassWithDict.h:30
lldb_private::OptionGroupPythonClassWithDict::eAllOptions
@ eAllOptions
Definition: OptionGroupPythonClassWithDict.h:32
Options.h
lldb_private::OptionGroupPythonClassWithDict::m_option_definition
OptionDefinition m_option_definition[4]
Definition: OptionGroupPythonClassWithDict.h:66
lldb_private::OptionGroupPythonClassWithDict::m_required_options
Flags m_required_options
Definition: OptionGroupPythonClassWithDict.h:67
lldb_private::OptionGroupPythonClassWithDict::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: OptionGroupPythonClassWithDict.h:43
lldb_private::StructuredData::DictionarySP
std::shared_ptr< Dictionary > DictionarySP
Definition: StructuredData.h:67
lldb_private::OptionGroupPythonClassWithDict::eDictKey
@ eDictKey
Definition: OptionGroupPythonClassWithDict.h:29
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:38
lldb-types.h
lldb_private::OptionGroupPythonClassWithDict::eScriptClass
@ eScriptClass
Definition: OptionGroupPythonClassWithDict.h:28
lldb_private::OptionGroupPythonClassWithDict::m_class_usage_text
std::string m_class_usage_text
Definition: OptionGroupPythonClassWithDict.h:64
lldb_private::Status
Definition: Status.h:44
uint32_t
uint16_t
lldb_private::OptionGroupPythonClassWithDict::m_value_usage_text
std::string m_value_usage_text
Definition: OptionGroupPythonClassWithDict.h:64
lldb_private::OptionGroupPythonClassWithDict::OptionKind
OptionKind
Definition: OptionGroupPythonClassWithDict.h:27
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::OptionGroupPythonClassWithDict::m_is_class
bool m_is_class
Definition: OptionGroupPythonClassWithDict.h:65
lldb_private::OptionGroupPythonClassWithDict::GetStructuredData
const StructuredData::DictionarySP GetStructuredData()
Definition: OptionGroupPythonClassWithDict.h:53
lldb_private::OptionGroupPythonClassWithDict::m_current_key
std::string m_current_key
Definition: OptionGroupPythonClassWithDict.h:62
lldb_private::OptionDefinition
Definition: OptionDefinition.h:20
lldb_private::OptionGroupPythonClassWithDict::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: OptionGroupPythonClassWithDict.cpp:118
Flags.h