1 //===-- SBFormat.cpp ------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBFormat.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>
17 using namespace lldb_private
;
19 SBFormat::SBFormat() : m_opaque_sp() {}
21 SBFormat::SBFormat(const SBFormat
&rhs
) {
22 m_opaque_sp
= clone(rhs
.m_opaque_sp
);
25 SBFormat::~SBFormat() = default;
27 SBFormat
&SBFormat::operator=(const SBFormat
&rhs
) {
29 m_opaque_sp
= clone(rhs
.m_opaque_sp
);
33 SBFormat::operator bool() const { return (bool)m_opaque_sp
; }
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
);
39 error
.SetError(std::move(status
));
41 m_opaque_sp
= format_entry_sp
;
44 lldb::FormatEntrySP
SBFormat::GetFormatEntrySP() const { return m_opaque_sp
; }