4#include "Stroika/Foundation/StroikaPreComp.h"
9#include "Stroika/Foundation/Containers/SortedMapping.h"
10#include "Stroika/Foundation/DataExchange/BadFormatException.h"
36 static const RegularExpression kTopLevelMatcher_ =
"(^[-\\w.]+)/([-\\w.]+)(\\+[a-z]*)?(.*)"_RegEx;
38 if (ct.
Matches (kTopLevelMatcher_, &matches) and matches.
length () >= 2) {
40 fSubType_ = matches[1];
41 if (matches.
length () >= 3 and matches[2].length () > 1) {
42 fSuffix_ = matches[2].SubString (1);
44 if (matches.
length () == 4) {
45 String moreParameters = matches[3];
46 while (not moreParameters.empty ()) {
47 static const RegularExpression kParameterMatcher_ =
"\\s*;\\s*([_\\-[:alnum:]]+)\\s*=\\s*(\\S+)(.*)"_RegEx;
49 if (moreParameters.
Matches (kParameterMatcher_, &matches)) {
51 String pValue = matches[1];
55 fParameters_.Add (pName, pValue);
56 if (matches.
length () == 3) {
57 moreParameters = matches[2];
70 static const auto kException_ =
BadFormatException{
"Badly formatted InternetMediaType"sv};
87 sb << fType_.GetPrintName () <<
"/"sv << fSubType_.GetPrintName ();
89 sb <<
"+"sv << fSuffix_->GetPrintName ();
91 for (
const auto& p : fParameters_) {
92 sb <<
"; "sv << p.fKey <<
": "sv << p.fValue;
97strong_ordering InternetMediaType::THREEWAYCOMPARE_ (
const InternetMediaType& rhs)
const
99 strong_ordering cmp = fType_ <=> rhs.fType_;
100 if (cmp != strong_ordering::equal) {
103 cmp = fSubType_ <=> rhs.fSubType_;
104 if (cmp != strong_ordering::equal) {
107 cmp = Common::StdCompat::compare_three_way{}(fSuffix_, rhs.fSuffix_);
108 if (cmp != strong_ordering::equal) {
111 if (fParameters_.empty () and rhs.fParameters_.empty ()) {
112 return strong_ordering::equal;
116 using namespace Containers;
117 using namespace Characters;
118 auto sortedMapping = [] (
auto m) {
return SortedMapping<String, String>{
String::LessComparer{eCaseInsensitive}, m}; };
119#if qCompilerAndStdLib_template_DefaultArgIgnoredWhenFailedDeduction_Buggy
134 return hash<wstring>{}(arg.
As<wstring> ());
RegularExpression is a compiled regular expression which can be used to match on a String class.
Similar to String, but intended to more efficiently construct a String. Mutable type (String is large...
String is like std::u32string, except it is much easier to use, often much more space efficient,...
nonvirtual bool Matches(const RegularExpression ®Ex) const
nonvirtual bool EndsWith(const Character &c, CompareOptions co=eWithCase) const
nonvirtual String SubString(SZ from) const
nonvirtual bool StartsWith(const Character &c, CompareOptions co=eWithCase) const
A generalization of a vector: a container whose elements are keyed by the natural numbers.
nonvirtual size_t length() const
STL-ish alias for size() - really in STL only used in string, I think, but still makes sense as an al...
String ToString(T &&t, ARGS... args)
Return a debug-friendly, display version of the argument: not guaranteed parsable or usable except fo...
void Throw(T &&e2Throw)
identical to builtin C++ 'throw' except that it does helpful, type dependent DbgTrace() messages firs...
very similar to ThreeWayComparer but returns true if less
function object which serializes type T to a BLOB (or BLOB like) object
Memory::BLOB operator()(const T &t) const