|
tdslite latest
C++ API reference
|
Non-owning view of a UTF-16LE string stored in a byte buffer, such as a string in a server response. More...
#include <tdslite/util/tdsl_u16le_view.hpp>
Classes | |
| struct | const_iterator |
Public Types | |
| using | value_type = char16_t |
| using | size_type = tdsl::byte_view::size_type |
Public Member Functions | |
| constexpr | u16le_view () noexcept=default |
| constexpr | u16le_view (tdsl::byte_view bytes) noexcept |
| constexpr size_type | size () const noexcept |
| Number of UTF-16 code units. | |
| constexpr size_type | size_bytes () const noexcept |
| constexpr bool | empty () const noexcept |
| constexpr char16_t | operator[] (size_type index) const noexcept |
Code unit at index (must be less than size()) | |
| const_iterator | begin () const noexcept |
| const_iterator | end () const noexcept |
| constexpr tdsl::byte_view | bytes () const noexcept |
| The underlying UTF-16LE bytes. | |
| size_type | copy_to (char16_t *dst, size_type capacity) const noexcept |
Copy up to capacity code units to dst. | |
| template<typename T > | |
| bool | equals (const T &other) const noexcept |
| Compare with a char16_t string (e.g. | |
Non-owning view of a UTF-16LE string stored in a byte buffer, such as a string in a server response.
Strings in a TDS message are not aligned to 2 bytes, so they can't be read through a const char16_t * (a misaligned load is undefined behavior, and faults on some CPUs). This view keeps the bytes as they are and builds each code unit from two bytes when it is read, which also gives the right value on big-endian hosts.
Iterating yields char16_t values:
for (char16_t ch : token.msgtext) { ... }
Use copy_to() to get the string into a char16_t array.
| using tdsl::u16le_view::value_type = char16_t |
|
inlineconstexprdefaultnoexcept |
|
inlineexplicitconstexprnoexcept |
| [in] | bytes | UTF-16LE encoded string. A trailing odd byte is ignored. |
|
inlineconstexprnoexcept |
Number of UTF-16 code units.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Code unit at index (must be less than size())
|
inlinenoexcept |
|
inlinenoexcept |
|
inlineconstexprnoexcept |
The underlying UTF-16LE bytes.
Copy up to capacity code units to dst.
|
inlinenoexcept |
Compare with a char16_t string (e.g.
u"text")