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