message: make it easier to create heap-allocated messages

We need this for guile to coöperate with its garbage collector.
This commit is contained in:
Dirk-Jan C. Binnema
2022-05-21 17:41:21 +03:00
parent 4305f47b86
commit a3ad04f12f
5 changed files with 20 additions and 29 deletions

View File

@ -46,6 +46,8 @@ using namespace Mu;
struct Message::Private {
Private(Message::Options options): opts{options} {}
Private(Message::Options options, Xapian::Document&& xdoc):
opts{options}, doc{std::move(xdoc)} {}
Message::Options opts;
Document doc;
@ -154,11 +156,9 @@ Message::operator=(Message&& other) noexcept
return *this;
}
Message::Message(Document&& doc):
priv_{std::make_unique<Private>(Message::Options::None)}
{
priv_->doc = std::move(doc);
}
Message::Message(Xapian::Document&& doc):
priv_{std::make_unique<Private>(Message::Options::None, std::move(doc))}
{}
Message::~Message() = default;