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