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/Interpreter/Options.h"
13#include "lldb/Utility/Flags.h"
14#include "lldb/Utility/StructuredData.h"
15#include "lldb/lldb-types.h"
16
17namespace 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.
25class OptionGroupPythonClassWithDict : public OptionGroup {
26public:
27 enum OptionKind {
28 eScriptClass = 1 << 0,
29 eDictKey = 1 << 1,
30 eDictValue = 1 << 2,
31 ePythonFunction = 1 << 3,
32 eAllOptions = (eScriptClass | eDictKey | eDictValue | ePythonFunction)
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 |
39 ePythonFunction);
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
53 const StructuredData::DictionarySP GetStructuredData() {
54 return m_dict_sp;
55 }
56 const std::string &GetName() {
57 return m_name;
58 }
59
60protected:
61 std::string m_name;
62 std::string m_current_key;
63 StructuredData::DictionarySP m_dict_sp;
64 std::string m_class_usage_text, m_key_usage_text, m_value_usage_text;
65 bool m_is_class;
66 OptionDefinition m_option_definition[4];
67 Flags m_required_options;
68};
69
70} // namespace lldb_private
71
72#endif // LLDB_INTERPRETER_OPTIONGROUPPYTHONCLASSWITHDICT_H
73

source code of lldb/include/lldb/Interpreter/OptionGroupPythonClassWithDict.h