13 const Containers::Mapping<String, String>& parameters)
17 , fParameters_{String::EqualsComparer{Characters::eCaseInsensitive}, parameters}
20 Require (subType.empty () or not type.empty ());
21 Require (not type.empty () or parameters.empty ());
22 Require (not type.empty () or suffix == nullopt);
24 inline InternetMediaType::InternetMediaType (AtomType type, AtomType subType,
const Containers::Mapping<String, String>& parameters)
25 : InternetMediaType{type, subType, nullopt, parameters}
28 inline InternetMediaType::InternetMediaType (
const String& type,
const String& subType,
const Containers::Mapping<String, String>& parameters)
29 : InternetMediaType{static_cast<AtomType> (type), static_cast<AtomType> (subType), parameters}
32 inline InternetMediaType::InternetMediaType (
const String& type,
const String& subType,
const optional<String>& suffix,
33 const Containers::Mapping<String, String>& parameters)
34 : InternetMediaType{static_cast<AtomType> (type), static_cast<AtomType> (subType),
35 suffix == nullopt ? nullopt : optional<AtomType>{
static_cast<AtomType
> (*suffix)}, parameters}
37 Require (suffix == nullopt or not suffix->empty ());
38 Require (suffix == nullopt or not suffix->StartsWith (
'+'));
39 Require (suffix == nullopt or not suffix->StartsWith (
'.'));
41 inline bool InternetMediaType::empty ()
const
44 Assert (not fType_.empty () or fSubType_.empty ());
45 Assert (not fType_.empty () or fParameters_.empty ());
46 Assert (not fType_.empty () or fSuffix_ == nullopt);
47 return fType_.empty ();
49 inline void InternetMediaType::clear ()
54 fParameters_.clear ();
57 inline auto InternetMediaType::GetType () const -> AtomType
62 inline auto InternetMediaType::GetType () const -> String
64 return fType_.GetPrintName ();
67 inline auto InternetMediaType::GetSubType () const -> AtomType
72 inline auto InternetMediaType::GetSubType () const -> String
74 return fSubType_.GetPrintName ();
77 inline auto InternetMediaType::GetSuffix () const -> optional<AtomType>
82 inline auto InternetMediaType::GetSuffix () const -> optional<String>
84 return fSuffix_ ? optional<String>{fSuffix_->GetPrintName ()} : nullopt;
86 inline Containers::Mapping<String, String> InternetMediaType::GetParameters ()
const
91 inline wstring InternetMediaType::As ()
const
93 return As<String> ().As<wstring> ();
95 inline strong_ordering InternetMediaType::operator<=> (
const InternetMediaType& rhs)
const
97 return THREEWAYCOMPARE_ (rhs);
101 return THREEWAYCOMPARE_ (rhs) == 0;