99 std::
string const &
toString() const noexcept {
return _mimeType; }
103 bool isAny() const noexcept {
return _mimeType.empty(); }
126 std::string _mimeType;
136struct std::formatter<
dfx::Core::MimeType> :
public formatter<std::string_view>
139 {
return formatter<std::string_view>::format(m.
toString(), ctx); }
Macro-based enum <-> string utilities for dfx.
#define DECLARE_ENUM_STRING_FUNCTIONS(E)
Declare the enum string API (and std::formatter) for enum type E.
Definition EnumString.hpp:327
MIME type value object.
Definition MimeType.hpp:44
std::string const & toString() const noexcept
Return the underlying MIME type string.
Definition MimeType.hpp:99
auto operator<=>(MimeType const &rhs) const noexcept=default
Three-way comparison.
bool operator==(MimeType const &rhs) const noexcept=default
Equality comparison.
MimeType(StandardMimeType mimeType)
Construct from a well-known MIME type enum.
StandardMimeType
Well-known MIME types understood by dfx.
Definition MimeType.hpp:48
@ DfxControl
"application/x-dfx-control"
Definition MimeType.hpp:64
@ PlainText
"text/plain"
Definition MimeType.hpp:59
@ Csv
"text/csv"
Definition MimeType.hpp:61
@ Xml
"application/xml"
Definition MimeType.hpp:53
@ Yaml
"application/x-yaml"
Definition MimeType.hpp:51
@ Markdown
"text/markdown"
Definition MimeType.hpp:60
@ Json
"application/json"
Definition MimeType.hpp:50
@ Toml
"application/toml"
Definition MimeType.hpp:52
@ Any
"" (empty string), meaning "accept anything"
Definition MimeType.hpp:67
@ OctetStream
"application/octet-stream"
Definition MimeType.hpp:56
static void validateMimeTypeName(std::string_view name)
Validate a MIME type string according to dfx rules.
std::optional< StandardMimeType > standardType() const noexcept
Try to map the stored string back to a StandardMimeType.
MimeType(std::string mimeType)
Construct from an explicit MIME type string.
MimeType()
Construct a MIME type with the default value. The default is OctetStream.
bool isAny() const noexcept
Whether this MIME type represents the wildcard "any".
Definition MimeType.hpp:103
Definition Channel.hpp:22
std::vector< MimeType > MimeTypes
Convenience alias for a list of MIME types.
Definition MimeType.hpp:130
Definition Message.hpp:21