85 if (!left.m_value || !right.m_value)
88 return !left.m_value && !right.m_value;
91 switch (comparisonKind)
93 case ETagComparison::Strong:
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])
129 explicit ETag(std::string etag) : m_value(std::move(etag)) {}
144 return m_value.
Value();
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] ==
'"'));
Provide assert macros to use with pre-conditions.
#define AZURE_UNREACHABLE_CODE()
Indicate that the code cannot be reached.
Definition azure_assert.hpp:64
#define AZURE_ASSERT_MSG(exp, msg)
Azure specific assert macro with message.
Definition azure_assert.hpp:53
Represents an HTTP validator.
Definition etag.hpp:21
bool HasValue() const
Whether ETag is present.
Definition etag.hpp:135
ETag()=default
Constructs an empty (null) ETag.
bool IsWeak() const
Specifies whether the Azure::ETag is strong or weak.
Definition etag.hpp:167
bool operator!=(const ETag &other) const
Compare with other ETag for inequality.
Definition etag.hpp:161
static bool Equals(const ETag &left, const ETag &right, const ETagComparison comparisonKind=ETagComparison::Strong)
Indicates whether two Azure::ETag values are equal.
Definition etag.hpp:79
static const ETag & Any()
Azure::ETag representing everything.
const std::string & ToString() const
Returns the resource metadata represented as a string.
Definition etag.hpp:141
bool operator==(const ETag &other) const
Compare with other ETag for equality.
Definition etag.hpp:153
ETagComparison
The comparison type.
Definition etag.hpp:32
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.
Definition nullable.hpp:30
const T & Value() const &noexcept
Get the contained value.
Definition nullable.hpp:236
bool HasValue() const noexcept
Check whether a value is contained.
Definition nullable.hpp:230
Compute the hash value for the input binary data, using SHA256, SHA384 and SHA512.
Definition azure_assert.hpp:57
Manages an optional contained value, i.e. a value that may or may not be present.