1 //===-- SBFormat.cpp ------------------------------------------------------===// 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 #include "lldb/API/SBFormat.h" 10 #include "Utils.h" 11 #include "lldb/Core/FormatEntity.h" 12 #include "lldb/lldb-types.h" 13 #include <lldb/API/SBError.h> 14 #include <lldb/Utility/Status.h> 15 16 using namespace lldb; 17 using namespace lldb_private; 18 19 SBFormat::SBFormat() : m_opaque_sp() {} 20 21 SBFormat::SBFormat(const SBFormat &rhs) { 22 m_opaque_sp = clone(rhs.m_opaque_sp); 23 } 24 25 SBFormat::~SBFormat() = default; 26 27 SBFormat &SBFormat::operator=(const SBFormat &rhs) { 28 if (this != &rhs) 29 m_opaque_sp = clone(rhs.m_opaque_sp); 30 return *this; 31 } 32 33 SBFormat::operator bool() const { return (bool)m_opaque_sp; } 34 35 SBFormat::SBFormat(const char *format, lldb::SBError &error) { 36 FormatEntrySP format_entry_sp = std::make_shared<FormatEntity::Entry>(); 37 Status status = FormatEntity::Parse(format, *format_entry_sp); 38 39 error.SetError(status); 40 if (error.Success()) 41 m_opaque_sp = format_entry_sp; 42 } 43 44 lldb::FormatEntrySP SBFormat::GetFormatEntrySP() const { return m_opaque_sp; } 45