lib: improve printability for some types

A little fmt pixie dust
This commit is contained in:
Dirk-Jan C. Binnema
2023-09-09 11:59:00 +03:00
parent 264bb092f0
commit 89ed21e0c5
4 changed files with 44 additions and 16 deletions

View File

@ -192,6 +192,16 @@ public:
*/
const std::string& path() const;
/**
* Get a description of the Xapian database
*
* @return description
*/
const std::string description() const {
return db().get_description();
}
/**
* Get the number of documents (messages) in the database
*
@ -399,6 +409,27 @@ private:
DbType db_;
};
constexpr std::string_view
format_as(XapianDb::Flavor flavor)
{
switch(flavor) {
case XapianDb::Flavor::CreateOverwrite:
return "create-overwrite";
case XapianDb::Flavor::Open:
return "open";
case XapianDb::Flavor::ReadOnly:
return "read-only";
default:
return "??";
}
}
static inline std::string
format_as(const XapianDb& db)
{
return mu_format("{} @ {}", db.description(), db.path());
}
} // namespace Mu
#endif /* MU_XAPIAN_DB_HH__ */