24 #ifndef PXR_BASE_TF_UNICODE_UTILS_H
25 #define PXR_BASE_TF_UNICODE_UTILS_H
37 #include <string_view>
65 static constexpr std::pair<uint32_t, uint32_t>
79 constexpr uint32_t
AsUInt32()
const {
return _value; }
83 return left._value == right._value;
87 return left._value != right._value;
104 return static_cast<unsigned char>(
value) < 128 ?
106 TfUtf8InvalidCodePoint;
136 const std::string_view::const_iterator& it,
137 const std::string_view::const_iterator&
end) : _it(it), _end(end) {
153 std::string_view::const_iterator
GetBase()
const
164 return (this->_it == rhs._it);
173 return (this->_it != rhs._it);
187 _EncodingLength increment = _GetEncodingLength();
196 auto isContinuation = [](
const char c) {
197 const auto uc =
static_cast<unsigned char>(
c);
198 return (uc >= static_cast<unsigned char>(
'\x80')) &&
199 (uc < static_cast<unsigned char>(
'\xc0'));
201 while ((increment > 1) && !_IsPastTheEnd() && isContinuation(*_it)) {
225 return lhs._IsPastTheEnd();
237 return !(lhs == rhs);
242 return !(lhs == rhs);
246 using _EncodingLength =
unsigned char;
252 _EncodingLength _GetEncodingLength()
const
264 unsigned char x =
static_cast<unsigned char>(*_it);
269 else if ((x >= 0xc0) && (x < 0xe0))
273 else if ((x >= 0xe0) && (x < 0xf0))
277 else if ((x >= 0xf0) && (x < 0xf8))
293 TF_API uint32_t _GetCodePoint()
const;
297 bool _IsPastTheEnd()
const
302 std::string_view::const_iterator _it;
303 std::string_view::const_iterator _end;
372 return _view.empty();
438 #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)
#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