mirror of https://github.com/djcb/mu.git
message & friends: make formattable
So we can easily debug-print them.
This commit is contained in:
parent
4dcd457b7f
commit
04219b55f7
|
@ -594,5 +594,20 @@ Option<Field> field_from_number(size_t id)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a fmt-printable representation of Field for fmt
|
||||
*
|
||||
* @param field a Field
|
||||
*
|
||||
* @return a printable representation
|
||||
*/
|
||||
static inline constexpr auto format_as(const Field& field) {
|
||||
return field.name;
|
||||
}
|
||||
static inline constexpr auto format_as(const Field::Id id) {
|
||||
return format_as(field_from_id(id));
|
||||
}
|
||||
|
||||
|
||||
} // namespace Mu
|
||||
#endif /* MU_FIELDS_HH__ */
|
||||
|
|
|
@ -387,6 +387,18 @@ flags_keep_unmutable(Flags old_flags, Flags new_flags, Flags unmutable_flag)
|
|||
*/
|
||||
std::string to_string(Flags flags);
|
||||
|
||||
|
||||
/**
|
||||
* Get a string representation of Flags for fmt
|
||||
*
|
||||
* @param flags flags
|
||||
*
|
||||
* @return string as a sequence of message-flag shortcuts
|
||||
*/
|
||||
static inline auto format_as(const Flags& flags) {
|
||||
return to_string(flags);
|
||||
}
|
||||
|
||||
} // namespace Mu
|
||||
|
||||
#endif /* MU_FLAGS_HH__ */
|
||||
|
|
|
@ -460,15 +460,10 @@ private:
|
|||
}; // Message
|
||||
MU_ENABLE_BITOPS(Message::Options);
|
||||
|
||||
|
||||
|
||||
static inline std::ostream&
|
||||
operator<<(std::ostream& os, const Message& msg)
|
||||
{
|
||||
os << msg.sexp();
|
||||
return os;
|
||||
static inline auto
|
||||
format_as(const Message& msg) {
|
||||
return msg.path();
|
||||
}
|
||||
|
||||
|
||||
} // Mu
|
||||
#endif /* MU_MESSAGE_HH__ */
|
||||
|
|
|
@ -109,7 +109,7 @@ QueryMatch::has_flag(QueryMatch::Flags flag) const
|
|||
return any_of(flags & flag);
|
||||
}
|
||||
|
||||
inline std::ostream&
|
||||
static inline std::ostream&
|
||||
operator<<(std::ostream& os, QueryMatch::Flags mflags)
|
||||
{
|
||||
if (mflags == QueryMatch::Flags::None) {
|
||||
|
@ -348,6 +348,13 @@ private:
|
|||
QueryMatches& query_matches_;
|
||||
};
|
||||
|
||||
|
||||
static inline auto
|
||||
format_as(const QueryResultsIterator& it)
|
||||
{
|
||||
return it.path().value_or("<no path>");
|
||||
}
|
||||
|
||||
constexpr auto MaxQueryResultsSize = std::numeric_limits<size_t>::max();
|
||||
|
||||
class QueryResults {
|
||||
|
|
Loading…
Reference in New Issue