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 12 #include "lldb/lldb-types.h" 13 #include "lldb/Interpreter/Options.h" 14 #include "lldb/Utility/StructuredData.h" 15 16 namespace lldb_private { 17 18 // Use this Option group if you have a python class that implements some 19 // Python extension point, and you pass a SBStructuredData to the class 20 // __init__ method. 21 // class_option specifies the class name 22 // the key and value options are read in in pairs, and a 23 // StructuredData::Dictionary is constructed with those pairs. 24 class OptionGroupPythonClassWithDict : public OptionGroup { 25 public: 26 OptionGroupPythonClassWithDict(const char *class_use, 27 bool is_class = true, 28 int class_option = 'C', 29 int key_option = 'k', 30 int value_option = 'v'); 31 32 ~OptionGroupPythonClassWithDict() override; 33 GetDefinitions()34 llvm::ArrayRef<OptionDefinition> GetDefinitions() override { 35 return llvm::ArrayRef<OptionDefinition>(m_option_definition); 36 } 37 38 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, 39 ExecutionContext *execution_context) override; 40 Status SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete; 41 42 void OptionParsingStarting(ExecutionContext *execution_context) override; 43 Status OptionParsingFinished(ExecutionContext *execution_context) override; 44 GetStructuredData()45 const StructuredData::DictionarySP GetStructuredData() { 46 return m_dict_sp; 47 } GetName()48 const std::string &GetName() { 49 return m_name; 50 } 51 52 protected: 53 std::string m_name; 54 std::string m_current_key; 55 StructuredData::DictionarySP m_dict_sp; 56 std::string m_class_usage_text, m_key_usage_text, m_value_usage_text; 57 bool m_is_class; 58 OptionDefinition m_option_definition[4]; 59 }; 60 61 } // namespace lldb_private 62 63 #endif // LLDB_INTERPRETER_OPTIONGROUPPYTHONCLASSWITHDICT_H 64