7 #ifndef PXR_BASE_TF_UNICODE_UTILS_H
8 #define PXR_BASE_TF_UNICODE_UTILS_H
20 #include <string_view>
48 static constexpr std::pair<uint32_t, uint32_t>
62 constexpr uint32_t
AsUInt32()
const {
return _value; }
66 return left._value == right._value;
70 return left._value != right._value;
87 return static_cast<unsigned char>(
value) < 128 ?
89 TfUtf8InvalidCodePoint;
147 return (this->_it == rhs._it);
156 return (this->_it != rhs._it);
170 _EncodingLength increment = _GetEncodingLength();
179 auto isContinuation = [](
const char c) {
180 const auto uc =
static_cast<unsigned char>(
c);
181 return (uc >= static_cast<unsigned char>(
'\x80')) &&
182 (uc < static_cast<unsigned char>(
'\xc0'));
184 while ((increment > 1) && !_IsPastTheEnd() && isContinuation(*_it)) {
208 return lhs._IsPastTheEnd();
220 return !(lhs == rhs);
225 return !(lhs == rhs);
229 using _EncodingLength =
unsigned char;
235 _EncodingLength _GetEncodingLength()
const
247 unsigned char x =
static_cast<unsigned char>(*_it);
252 else if ((x >= 0xc0) && (x < 0xe0))
256 else if ((x >= 0xe0) && (x < 0xf0))
260 else if ((x >= 0xf0) && (x < 0xf8))
276 TF_API uint32_t _GetCodePoint()
const;
280 bool _IsPastTheEnd()
const
355 return _view.empty();
421 #endif // PXR_BASE_TF_UNICODE_UTILS_H_
value_type operator*() const
static constexpr uint32_t MaximumValue
TfUtf8CodePointView(const std::string_view &view)
static constexpr uint32_t ReplacementValue
const_iterator cbegin() const
TfUtf8CodePointView()=default
GLsizei const GLfloat * value
std::ptrdiff_t difference_type
bool empty() const
Returns true if the underlying view is empty.
TfUtf8CodePointIterator const_iterator
TfUtf8CodePointIterator::PastTheEndSentinel cend() const
TfUtf8CodePointIterator::PastTheEndSentinel end() const
friend constexpr bool operator==(const TfUtf8CodePoint left, const TfUtf8CodePoint right)
basic_string_view< char > string_view
friend bool operator==(PastTheEndSentinel lhs, const TfUtf8CodePointIterator &rhs)
#define TF_DEV_AXIOM(cond)
constexpr TfUtf8CodePoint(uint32_t value)
friend bool operator==(const TfUtf8CodePointIterator &lhs, PastTheEndSentinel)
std::forward_iterator_tag iterator_category
const_iterator EndAsIterator() const
TF_API std::ostream & operator<<(std::ostream &, const TfUtf8CodePoint)
TF_API bool TfIsUtf8CodePointXidContinue(uint32_t codePoint)
std::string_view::const_iterator GetBase() const
Retrieves the wrapped string iterator.
constexpr TfUtf8CodePoint()=default
Construct a code point initialized to the replacement value.
TfUtf8CodePointIterator & operator++()
const_iterator begin() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
friend bool operator!=(PastTheEndSentinel lhs, const TfUtf8CodePointIterator &rhs)
const_pointer const_iterator
#define PXR_NAMESPACE_CLOSE_SCOPE
TfUtf8CodePointIterator(const std::string_view::const_iterator &it, const std::string_view::const_iterator &end)
static constexpr std::pair< uint32_t, uint32_t > SurrogateRange
constexpr TfUtf8CodePoint TfUtf8CodePointFromAscii(const char value)
Constructs a TfUtf8CodePoint from an ASCII charcter (0-127).
bool operator==(const TfUtf8CodePointIterator &rhs) const
friend bool operator!=(const TfUtf8CodePointIterator &lhs, PastTheEndSentinel rhs)
TF_API bool TfIsUtf8CodePointXidStart(uint32_t codePoint)
friend constexpr bool operator!=(const TfUtf8CodePoint left, const TfUtf8CodePoint right)
bool operator!=(const TfUtf8CodePointIterator &rhs) const
constexpr uint32_t AsUInt32() const