1*c9157d92SDimitry Andric //===-- SBFormat.cpp ------------------------------------------------------===// 2*c9157d92SDimitry Andric // 3*c9157d92SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*c9157d92SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*c9157d92SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*c9157d92SDimitry Andric // 7*c9157d92SDimitry Andric //===----------------------------------------------------------------------===// 8*c9157d92SDimitry Andric 9*c9157d92SDimitry Andric #include "lldb/API/SBFormat.h" 10*c9157d92SDimitry Andric #include "Utils.h" 11*c9157d92SDimitry Andric #include "lldb/Core/FormatEntity.h" 12*c9157d92SDimitry Andric #include "lldb/lldb-types.h" 13*c9157d92SDimitry Andric #include <lldb/API/SBError.h> 14*c9157d92SDimitry Andric #include <lldb/Utility/Status.h> 15*c9157d92SDimitry Andric 16*c9157d92SDimitry Andric using namespace lldb; 17*c9157d92SDimitry Andric using namespace lldb_private; 18*c9157d92SDimitry Andric SBFormat()19*c9157d92SDimitry AndricSBFormat::SBFormat() : m_opaque_sp() {} 20*c9157d92SDimitry Andric SBFormat(const SBFormat & rhs)21*c9157d92SDimitry AndricSBFormat::SBFormat(const SBFormat &rhs) { 22*c9157d92SDimitry Andric m_opaque_sp = clone(rhs.m_opaque_sp); 23*c9157d92SDimitry Andric } 24*c9157d92SDimitry Andric 25*c9157d92SDimitry Andric SBFormat::~SBFormat() = default; 26*c9157d92SDimitry Andric operator =(const SBFormat & rhs)27*c9157d92SDimitry AndricSBFormat &SBFormat::operator=(const SBFormat &rhs) { 28*c9157d92SDimitry Andric if (this != &rhs) 29*c9157d92SDimitry Andric m_opaque_sp = clone(rhs.m_opaque_sp); 30*c9157d92SDimitry Andric return *this; 31*c9157d92SDimitry Andric } 32*c9157d92SDimitry Andric operator bool() const33*c9157d92SDimitry AndricSBFormat::operator bool() const { return (bool)m_opaque_sp; } 34*c9157d92SDimitry Andric SBFormat(const char * format,lldb::SBError & error)35*c9157d92SDimitry AndricSBFormat::SBFormat(const char *format, lldb::SBError &error) { 36*c9157d92SDimitry Andric FormatEntrySP format_entry_sp = std::make_shared<FormatEntity::Entry>(); 37*c9157d92SDimitry Andric Status status = FormatEntity::Parse(format, *format_entry_sp); 38*c9157d92SDimitry Andric 39*c9157d92SDimitry Andric error.SetError(status); 40*c9157d92SDimitry Andric if (error.Success()) 41*c9157d92SDimitry Andric m_opaque_sp = format_entry_sp; 42*c9157d92SDimitry Andric } 43*c9157d92SDimitry Andric GetFormatEntrySP() const44*c9157d92SDimitry Andriclldb::FormatEntrySP SBFormat::GetFormatEntrySP() const { return m_opaque_sp; } 45