A non-owning, immutable view of device data that is a variable length char array representing a UTF-8 string. More...
#include <string_view.hpp>
Classes | |
class | const_iterator |
Handy iterator for navigating through encoded characters. More... | |
Public Member Functions | |
CUDF_HOST_DEVICE size_type | size_bytes () const |
Return the number of bytes in this string. More... | |
size_type | length () const |
Return the number of characters in this string. More... | |
CUDF_HOST_DEVICE char const * | data () const |
Return a pointer to the internal device array. More... | |
CUDF_HOST_DEVICE bool | empty () const |
Return true if string has no characters. More... | |
const_iterator | begin () const |
Return new iterator pointing to the beginning of this string. More... | |
const_iterator | end () const |
Return new iterator pointing past the end of this string. More... | |
char_utf8 | operator[] (size_type pos) const |
Return single UTF-8 character at the given character position. More... | |
size_type | byte_offset (size_type pos) const |
Return the byte offset from data() for a given character position. More... | |
int | compare (string_view const &str) const |
Comparing target string with this string. Each character is compared as a UTF-8 code-point value. More... | |
int | compare (char const *str, size_type bytes) const |
Comparing target string with this string. Each character is compared as a UTF-8 code-point value. More... | |
bool | operator== (string_view const &rhs) const |
Returns true if rhs matches this string exactly. More... | |
bool | operator!= (string_view const &rhs) const |
Returns true if rhs does not match this string. More... | |
bool | operator< (string_view const &rhs) const |
Returns true if this string is ordered before rhs. More... | |
bool | operator> (string_view const &rhs) const |
Returns true if rhs is ordered before this string. More... | |
bool | operator<= (string_view const &rhs) const |
Returns true if this string matches or is ordered before rhs. More... | |
bool | operator>= (string_view const &rhs) const |
Returns true if rhs matches or is ordered before this string. More... | |
size_type | find (string_view const &str, size_type pos=0, size_type count=-1) const |
Returns the character position of the first occurrence where the argument str is found in this string within the character range [pos,pos+n). More... | |
size_type | find (char const *str, size_type bytes, size_type pos=0, size_type count=-1) const |
Returns the character position of the first occurrence where the array str is found in this string within the character range [pos,pos+n). More... | |
size_type | find (char_utf8 character, size_type pos=0, size_type count=-1) const |
Returns the character position of the first occurrence where character is found in this string within the character range [pos,pos+n). More... | |
size_type | rfind (string_view const &str, size_type pos=0, size_type count=-1) const |
Returns the character position of the last occurrence where the argument str is found in this string within the character range [pos,pos+n). More... | |
size_type | rfind (char const *str, size_type bytes, size_type pos=0, size_type count=-1) const |
Returns the character position of the last occurrence where the array str is found in this string within the character range [pos,pos+n). More... | |
size_type | rfind (char_utf8 character, size_type pos=0, size_type count=-1) const |
Returns the character position of the last occurrence where character is found in this string within the character range [pos,pos+n). More... | |
string_view | substr (size_type start, size_type length) const |
Return a sub-string of this string. The original string and device memory must still be maintained for the lifetime of the returned instance. More... | |
CUDF_HOST_DEVICE | string_view () |
Default constructor represents an empty string. | |
CUDF_HOST_DEVICE | string_view (char const *data, size_type bytes) |
Create instance from existing device char array. More... | |
string_view (string_view const &)=default | |
Copy constructor. | |
string_view (string_view &&)=default | |
Move constructor. | |
string_view & | operator= (string_view const &)=default |
Copy assignment operator. More... | |
string_view & | operator= (string_view &&)=default |
Move assignment operator. More... | |
Static Public Member Functions | |
static CUDF_HOST_DEVICE string_view | min () |
Return minimum value associated with the string type. More... | |
static CUDF_HOST_DEVICE string_view | max () |
Return maximum value associated with the string type. More... | |
Static Public Attributes | |
static cudf::size_type const | npos {-1} |
No-position value. More... | |
A non-owning, immutable view of device data that is a variable length char array representing a UTF-8 string.
The caller must maintain the device memory for the lifetime of this instance.
This may be used to wrap a device pointer and size but any member function that requires accessing the device memory must be called from a kernel.
Definition at line 44 of file string_view.hpp.
|
inline |
Create instance from existing device char array.
data | Device char array encoded in UTF8. |
bytes | Number of bytes in data array. |
Definition at line 343 of file string_view.hpp.
|
inline |
Return new iterator pointing to the beginning of this string.
Return the byte offset from data() for a given character position.
pos | Character position |
Definition at line 305 of file string_view.cuh.
|
inline |
Comparing target string with this string. Each character is compared as a UTF-8 code-point value.
str | Target string to compare with this string. |
bytes | Number of bytes in str. |
Definition at line 316 of file string_view.cuh.
|
inline |
Comparing target string with this string. Each character is compared as a UTF-8 code-point value.
str | Target string to compare with this string. |
Definition at line 311 of file string_view.cuh.
|
inline |
Return a pointer to the internal device array.
Definition at line 63 of file string_view.hpp.
|
inline |
Return true if string has no characters.
Definition at line 70 of file string_view.hpp.
|
inline |
Return new iterator pointing past the end of this string.
|
inline |
Returns the character position of the first occurrence where the array str is found in this string within the character range [pos,pos+n).
str | Target array to search within this string. |
bytes | Number of bytes in str. |
pos | Character position to start search within this string. |
count | Number of characters from pos to include in the search. Specify -1 to indicate to the end of the string. |
Definition at line 402 of file string_view.cuh.
|
inline |
Returns the character position of the first occurrence where character is found in this string within the character range [pos,pos+n).
character | Single encoded character. |
pos | Character position to start search within this string. |
count | Number of characters from pos to include in the search. Specify -1 to indicate to the end of the string. |
Definition at line 410 of file string_view.cuh.
|
inline |
Returns the character position of the first occurrence where the argument str is found in this string within the character range [pos,pos+n).
str | Target string to search within this string. |
pos | Character position to start search within this string. |
count | Number of characters from pos to include in the search. Specify -1 to indicate to the end of the string. |
Definition at line 365 of file string_view.cuh.
|
inline |
Return the number of characters in this string.
Definition at line 139 of file string_view.cuh.
|
inlinestatic |
Return maximum value associated with the string type.
This function is needed to be host callable because it is called by a host callable function DeviceMin::identity<string_view>()
Definition at line 127 of file string_view.cuh.
|
inlinestatic |
Return minimum value associated with the string type.
This function is needed to be host callable because it is called by a host callable function DeviceMax::identity<string_view>()
Definition at line 116 of file string_view.cuh.
|
inline |
Returns true if rhs does not match this string.
rhs | Target string to compare with this string. |
Definition at line 338 of file string_view.cuh.
|
inline |
Returns true if this string is ordered before rhs.
rhs | Target string to compare with this string. |
Definition at line 343 of file string_view.cuh.
|
inline |
Returns true if this string matches or is ordered before rhs.
rhs | Target string to compare with this string. |
Definition at line 353 of file string_view.cuh.
|
default |
Move assignment operator.
|
default |
Copy assignment operator.
|
inline |
Returns true if rhs matches this string exactly.
rhs | Target string to compare with this string. |
Definition at line 333 of file string_view.cuh.
|
inline |
Returns true if rhs is ordered before this string.
rhs | Target string to compare with this string. |
Definition at line 348 of file string_view.cuh.
|
inline |
Returns true if rhs matches or is ordered before this string.
rhs | Target string to compare with this string. |
Definition at line 359 of file string_view.cuh.
Return single UTF-8 character at the given character position.
pos | Character position |
Definition at line 296 of file string_view.cuh.
|
inline |
Returns the character position of the last occurrence where the array str is found in this string within the character range [pos,pos+n).
str | Target string to search with this string. |
bytes | Number of bytes in str. |
pos | Character position to start search within this string. |
count | Number of characters from pos to include in the search. Specify -1 to indicate to the end of the string. |
Definition at line 424 of file string_view.cuh.
|
inline |
Returns the character position of the last occurrence where character is found in this string within the character range [pos,pos+n).
character | Single encoded character. |
pos | Character position to start search within this string. |
count | Number of characters from pos to include in the search. Specify -1 to indicate to the end of the string. |
Definition at line 432 of file string_view.cuh.
|
inline |
Returns the character position of the last occurrence where the argument str is found in this string within the character range [pos,pos+n).
str | Target string to search within this string. |
pos | Character position to start search within this string. |
count | Number of characters from pos to include in the search. Specify -1 to indicate to the end of the string. |
Definition at line 417 of file string_view.cuh.
|
inline |
Return the number of bytes in this string.
Definition at line 51 of file string_view.hpp.
|
inline |
Return a sub-string of this string. The original string and device memory must still be maintained for the lifetime of the returned instance.
start | Character position to start the sub-string. |
length | Number of characters from start to include in the sub-string. |
Definition at line 440 of file string_view.cuh.
|
inlinestatic |
No-position value.
Used when specifying or returning an invalid or unknown character position value.
Definition at line 369 of file string_view.hpp.