Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
ETag.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
6
7 /*
8 ********************************************************************************
9 ************************************ HTTP::ETag ********************************
10 ********************************************************************************
11 */
12 inline ETag::ETag (const String& value, bool weak)
13 : fValue{value}
14 , fWeak{weak}
15 {
16 }
17 inline optional<ETag> ETag::Parse (const String& wireFormat)
18 {
19 if (not wireFormat.EndsWith ('\"')) {
20 return nullopt;
21 }
22 if (wireFormat.StartsWith ('\"')) {
23 return ETag{wireFormat.SubString (1, -1)};
24 }
25 if (wireFormat.StartsWith ("\\W\""sv)) {
26 return ETag{wireFormat.SubString (3, -1), true};
27 }
28 return nullopt;
29 }
30 template <>
31 inline Characters::String ETag::As () const
32 {
33 return (fWeak ? "\\W\""sv : "\""sv) + fValue + "\""sv;
34 }
35 inline Characters::String ETag::ToString () const
36 {
37 return As<String> ();
38 }
39
40}
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
nonvirtual bool EndsWith(const Character &c, CompareOptions co=eWithCase) const
Definition String.cpp:1088
nonvirtual String SubString(SZ from) const
nonvirtual bool StartsWith(const Character &c, CompareOptions co=eWithCase) const
Definition String.cpp:1059