Go to the documentation of this file.
84 if (!left.m_value || !right.m_value)
87 return !left.m_value && !right.m_value;
90 switch (comparisonKind)
92 case ETagComparison::Strong:
97 && (left.m_value.
Value().compare(right.m_value.
Value()) == 0);
100 case ETagComparison::Weak:
102 auto leftStart = left.
IsWeak() ? 2 : 0;
103 auto rightStart = right.
IsWeak() ? 2 : 0;
105 auto leftVal = left.m_value.
Value();
106 auto rightVal = right.m_value.
Value();
110 return ((leftVal.length() - leftStart) == (rightVal.length() - rightStart))
111 && (leftVal.compare(leftStart, leftVal.length() - leftStart, &rightVal[rightStart])
116 AZURE_UNREACHABLE_CODE();
129 explicit ETag(std::string etag) : m_value(std::move(etag)) {}
143 AZURE_ASSERT_MSG(m_value.
HasValue(),
"Empty ETag, check HasValue() before calling ToString().");
144 return m_value.
Value();
153 bool operator==(
const ETag& other)
const {
return Equals(*
this, other, ETagComparison::Strong); }
174 const bool weak = m_value && (m_value.
Value().length() >= 4)
175 && ((m_value.
Value()[0] ==
'W') && (m_value.
Value()[1] ==
'/')
176 && (m_value.
Value()[2] ==
'"') && (m_value.
Value()[m_value.
Value().size() - 1] ==
'"'));
bool IsWeak() const
Specifies whether the #Azure::Core::ETag is strong or weak.
Definition: etag.hpp:167
bool HasValue() const noexcept
Check whether a value is contained.
Definition: nullable.hpp:229
const T & Value() const &noexcept
Get the contained value.
Definition: nullable.hpp:235
bool operator==(const ETag &other) const
Compare with other ETag for equality.
Definition: etag.hpp:153
const std::string & ToString() const
Returns the resource metadata represented as a string.
Definition: etag.hpp:141
static const ETag & Any()
#Azure::Core::ETag representing everything.
Definition: etag.cpp:8
Represents an HTTP validator.
Definition: etag.hpp:21
ETag()=default
Constructs an empty (null) ETag.
Azure SDK abstractions.
Definition: azure_assert.hpp:55
ETag(std::string etag)
Constructs an ETag with string representation.
Definition: etag.hpp:129
Manages an optional contained value, i.e. a value that may or may not be present.
bool HasValue() const
Whether ETag is present.
Definition: etag.hpp:135
Provide assert macros to use with pre-conditions.
ETagComparison
The comparison type.
Definition: etag.hpp:32
bool operator!=(const ETag &other) const
Compare with other ETag for inequality.
Definition: etag.hpp:161