xref: /freebsd/contrib/llvm-project/lldb/include/lldb/Utility/ScriptedMetadata.h (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
1*06c3fb27SDimitry Andric //===-- ScriptedMetadata.h ------------------------------------ -*- C++ -*-===//
2*06c3fb27SDimitry Andric //
3*06c3fb27SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*06c3fb27SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*06c3fb27SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*06c3fb27SDimitry Andric //
7*06c3fb27SDimitry Andric //===----------------------------------------------------------------------===//
8*06c3fb27SDimitry Andric 
9*06c3fb27SDimitry Andric #ifndef LLDB_INTERPRETER_SCRIPTEDMETADATA_H
10*06c3fb27SDimitry Andric #define LLDB_INTERPRETER_SCRIPTEDMETADATA_H
11*06c3fb27SDimitry Andric 
12*06c3fb27SDimitry Andric #include "lldb/Utility/ProcessInfo.h"
13*06c3fb27SDimitry Andric #include "lldb/Utility/StructuredData.h"
14*06c3fb27SDimitry Andric 
15*06c3fb27SDimitry Andric namespace lldb_private {
16*06c3fb27SDimitry Andric class ScriptedMetadata {
17*06c3fb27SDimitry Andric public:
ScriptedMetadata(llvm::StringRef class_name,StructuredData::DictionarySP dict_sp)18*06c3fb27SDimitry Andric   ScriptedMetadata(llvm::StringRef class_name,
19*06c3fb27SDimitry Andric                    StructuredData::DictionarySP dict_sp)
20*06c3fb27SDimitry Andric       : m_class_name(class_name.data()), m_args_sp(dict_sp) {}
21*06c3fb27SDimitry Andric 
ScriptedMetadata(const ProcessInfo & process_info)22*06c3fb27SDimitry Andric   ScriptedMetadata(const ProcessInfo &process_info) {
23*06c3fb27SDimitry Andric     lldb::ScriptedMetadataSP metadata_sp = process_info.GetScriptedMetadata();
24*06c3fb27SDimitry Andric     if (metadata_sp) {
25*06c3fb27SDimitry Andric       m_class_name = metadata_sp->GetClassName();
26*06c3fb27SDimitry Andric       m_args_sp = metadata_sp->GetArgsSP();
27*06c3fb27SDimitry Andric     }
28*06c3fb27SDimitry Andric   }
29*06c3fb27SDimitry Andric 
30*06c3fb27SDimitry Andric   explicit operator bool() const { return !m_class_name.empty(); }
31*06c3fb27SDimitry Andric 
GetClassName()32*06c3fb27SDimitry Andric   llvm::StringRef GetClassName() const { return m_class_name; }
GetArgsSP()33*06c3fb27SDimitry Andric   StructuredData::DictionarySP GetArgsSP() const { return m_args_sp; }
34*06c3fb27SDimitry Andric 
35*06c3fb27SDimitry Andric private:
36*06c3fb27SDimitry Andric   std::string m_class_name;
37*06c3fb27SDimitry Andric   StructuredData::DictionarySP m_args_sp;
38*06c3fb27SDimitry Andric };
39*06c3fb27SDimitry Andric } // namespace lldb_private
40*06c3fb27SDimitry Andric 
41*06c3fb27SDimitry Andric #endif // LLDB_INTERPRETER_SCRIPTEDMETADATA_H
42