lib/message-flags: update whitespace & clang++ appeasement
This commit is contained in:
@ -23,6 +23,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
#include <array>
|
||||||
#include "utils/mu-utils.hh"
|
#include "utils/mu-utils.hh"
|
||||||
|
|
||||||
namespace Mu {
|
namespace Mu {
|
||||||
@ -55,10 +56,9 @@ enum struct MessageFlags {
|
|||||||
Encrypted = 1 << 8, /**< Encrypted */
|
Encrypted = 1 << 8, /**< Encrypted */
|
||||||
HasAttachment = 1 << 9, /**< Has an attachment */
|
HasAttachment = 1 << 9, /**< Has an attachment */
|
||||||
|
|
||||||
Unread = 1 << 10, /**< Unread; pseudo-flag, only for queries, so
|
Unread = 1 << 10, /**< Unread; pseudo-flag, only for queries, so we can
|
||||||
* we can search for flag:unread, which is
|
* search for flag:unread, which is equivalent to
|
||||||
* equivalent to 'flag:new OR NOT
|
* 'flag:new OR NOT flag:seen' */
|
||||||
* flag:seen' */
|
|
||||||
/**
|
/**
|
||||||
* other content flags
|
* other content flags
|
||||||
*/
|
*/
|
||||||
@ -83,7 +83,6 @@ enum struct MessageFlagCategory {
|
|||||||
Pseudo /**< Pseuodo flag */
|
Pseudo /**< Pseuodo flag */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Info about invidual message flags
|
* Info about invidual message flags
|
||||||
*
|
*
|
||||||
@ -98,24 +97,25 @@ struct MessageFlagInfo {
|
|||||||
/**
|
/**
|
||||||
* Array of all flag information.
|
* Array of all flag information.
|
||||||
*/
|
*/
|
||||||
constexpr std::array<MessageFlagInfo, 12>
|
constexpr std::array<MessageFlagInfo, 12> AllMessageFlagInfos = {{
|
||||||
AllMessageFlagInfos = {{
|
MessageFlagInfo{MessageFlags::Draft, 'D', "draft", MessageFlagCategory::Mailfile},
|
||||||
{MessageFlags::Draft, 'D', "draft", MessageFlagCategory::Mailfile},
|
MessageFlagInfo{MessageFlags::Flagged, 'F', "flagged", MessageFlagCategory::Mailfile},
|
||||||
{MessageFlags::Flagged, 'F', "flagged", MessageFlagCategory::Mailfile},
|
MessageFlagInfo{MessageFlags::Passed, 'P', "passed", MessageFlagCategory::Mailfile},
|
||||||
{MessageFlags::Passed, 'P', "passed", MessageFlagCategory::Mailfile},
|
MessageFlagInfo{MessageFlags::Replied, 'R', "replied", MessageFlagCategory::Mailfile},
|
||||||
{MessageFlags::Replied, 'R', "replied", MessageFlagCategory::Mailfile},
|
MessageFlagInfo{MessageFlags::Seen, 'S', "seen", MessageFlagCategory::Mailfile},
|
||||||
{MessageFlags::Seen, 'S', "seen", MessageFlagCategory::Mailfile},
|
MessageFlagInfo{MessageFlags::Trashed, 'T', "trashed", MessageFlagCategory::Mailfile},
|
||||||
{MessageFlags::Trashed, 'T', "trashed", MessageFlagCategory::Mailfile},
|
|
||||||
|
|
||||||
{MessageFlags::New, 'N', "new", MessageFlagCategory::Maildir},
|
MessageFlagInfo{MessageFlags::New, 'N', "new", MessageFlagCategory::Maildir},
|
||||||
|
|
||||||
{MessageFlags::Signed, 'z', "signed", MessageFlagCategory::Content},
|
MessageFlagInfo{MessageFlags::Signed, 'z', "signed", MessageFlagCategory::Content},
|
||||||
{MessageFlags::Encrypted, 'x', "encrypted", MessageFlagCategory::Content},
|
MessageFlagInfo{MessageFlags::Encrypted, 'x', "encrypted",
|
||||||
{MessageFlags::HasAttachment, 'a', "attach", MessageFlagCategory::Content},
|
MessageFlagCategory::Content},
|
||||||
|
MessageFlagInfo{MessageFlags::HasAttachment, 'a', "attach",
|
||||||
|
MessageFlagCategory::Content},
|
||||||
|
|
||||||
{MessageFlags::Unread, 'u', "unread", MessageFlagCategory::Pseudo},
|
MessageFlagInfo{MessageFlags::Unread, 'u', "unread", MessageFlagCategory::Pseudo},
|
||||||
|
|
||||||
{MessageFlags::MailingList, 'l', "list", MessageFlagCategory::Content},
|
MessageFlagInfo{MessageFlags::MailingList, 'l', "list", MessageFlagCategory::Content},
|
||||||
}};
|
}};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,7 +137,6 @@ message_flag_info(MessageFlags flag)
|
|||||||
return AllMessageFlagInfos[static_cast<unsigned>(__builtin_ctz(val))];
|
return AllMessageFlagInfos[static_cast<unsigned>(__builtin_ctz(val))];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get flag info for some flag
|
* Get flag info for some flag
|
||||||
*
|
*
|
||||||
@ -172,7 +171,6 @@ message_flag_info(std::string_view name)
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* There are two string-based expression types for flags:
|
* There are two string-based expression types for flags:
|
||||||
* 1) 'absolute': replace the existing flags
|
* 1) 'absolute': replace the existing flags
|
||||||
@ -189,8 +187,7 @@ message_flag_info(std::string_view name)
|
|||||||
* @return the (OR'ed) flags or MessageFlags::None
|
* @return the (OR'ed) flags or MessageFlags::None
|
||||||
*/
|
*/
|
||||||
constexpr std::optional<MessageFlags>
|
constexpr std::optional<MessageFlags>
|
||||||
message_flags_from_absolute_expr(std::string_view expr,
|
message_flags_from_absolute_expr(std::string_view expr, bool ignore_invalid = false)
|
||||||
bool ignore_invalid=false)
|
|
||||||
{
|
{
|
||||||
MessageFlags flags{MessageFlags::None};
|
MessageFlags flags{MessageFlags::None};
|
||||||
|
|
||||||
@ -230,18 +227,13 @@ message_flags_from_delta_expr(std::string_view expr, MessageFlags flags,
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
for (auto u = 0U; u != expr.size(); u += 2) {
|
for (auto u = 0U; u != expr.size(); u += 2) {
|
||||||
|
|
||||||
if (const auto& info{message_flag_info(expr[u + 1])}; !info) {
|
if (const auto& info{message_flag_info(expr[u + 1])}; !info) {
|
||||||
if (!ignore_invalid)
|
if (!ignore_invalid)
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
} else {
|
} else {
|
||||||
switch (expr[u]) {
|
switch (expr[u]) {
|
||||||
case '+':
|
case '+': flags |= info->flag; break;
|
||||||
flags |= info->flag;
|
case '-': flags &= ~info->flag; break;
|
||||||
break;
|
|
||||||
case '-':
|
|
||||||
flags &= ~info->flag;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
if (!ignore_invalid)
|
if (!ignore_invalid)
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
@ -253,8 +245,6 @@ message_flags_from_delta_expr(std::string_view expr, MessageFlags flags,
|
|||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the flags from either 'absolute' or 'delta' expressions
|
* Calculate the flags from either 'absolute' or 'delta' expressions
|
||||||
*
|
*
|
||||||
@ -303,6 +293,6 @@ message_flags_filter(MessageFlags flags, MessageFlagCategory cat)
|
|||||||
*/
|
*/
|
||||||
std::string message_flags_to_string(MessageFlags flags);
|
std::string message_flags_to_string(MessageFlags flags);
|
||||||
|
|
||||||
} // namepace Mu
|
} // namespace Mu
|
||||||
|
|
||||||
#endif /* MU_MESSAGE_FLAGS_HH__ */
|
#endif /* MU_MESSAGE_FLAGS_HH__ */
|
||||||
|
|||||||
Reference in New Issue
Block a user