|
Str View
|
The SV_Str_view Interface.
More...
#include <stdbool.h>#include <stddef.h>
Go to the source code of this file.
The SV_Str_view Interface.
A SV_Str_view is a read only view of null terminated C strings. It's purpose is to provide robust read only string construction, tokenizing, and matching. This introduces tremendous flexibility to string handling in C programming from low-level kernel code to application layer programming.
Read only string handling offers many safety benefits as well. All functions in the interface are either constant or pure functions. This means that given the same inputs, they will provide the same outputs. And because no functions can modify the underlying string, compilers can often help use these guarantees to produce faster code. This also means that all string view functions are inherently safe to be used from multiple threads over the same string data.
This interface also aims to provide robust read only tokenization without any of the concerns that come with functions like strtok versus strtok_r. Tokenization can occur simultaneously from multiple threads and a natural iteration abstraction is provided.
Finally, all major string matching functions are provided and run in linear time, using constant space. There are also variants of the substring matching algorithms that run in reverse providing the optimal time complexity for reverse string matching. Constant space complexity is an important component of maintaining the pure attributes of the searching function. Regardless of the underlying string matching algorithm, no side effects occur and no auxiliary global or static global storage is needed.
Data Structures | |
| struct | SV_Str_view |
| A read-only view of string data in C. More... | |
Construction | |
A macro and functions for constructing a | |
| #define | SV_from(str_literal) ((SV_Str_view){SV_STR_LITERAL(str_literal), sizeof(str_literal) - 1}) |
| A macro to reduce the chance for errors in repeating oneself when constructing an inline or const SV_Str_view. The input must be a string literal. | |
| SV_API SV_Str_view | SV_from_terminated (char const *str) SV_ATTRIB_NULLTERM(1) SV_ATTRIB_PURE |
| Constructs and returns a string view from a null terminated string. | |
| SV_API SV_Str_view | SV_from_view (size_t n, char const *str) SV_ATTRIB_NULLTERM(2) SV_ATTRIB_PURE |
| Constructs and returns a string view from a sequence of valid n bytes or string length, whichever comes first. | |
| SV_API SV_Str_view | SV_from_delimiter (char const *str, char const *delim) SV_ATTRIB_NULLTERM(1) SV_ATTRIB_NULLTERM(2) SV_ATTRIB_PURE |
| Constructs and returns a string view from a null terminated string broken on the first occurrence of delimiter if found or null terminator if delim cannot be found. | |
| SV_API SV_Str_view | SV_substr (SV_Str_view sv, size_t pos, size_t count) SV_ATTRIB_PURE |
Creates the substring from position pos for count length. The count is the minimum value between count and (length - pos). | |
| SV_API size_t | SV_str_bytes (char const *str) SV_ATTRIB_NULLTERM(1) SV_ATTRIB_PURE |
| Returns the bytes of the string pointer to, null terminator included. | |
| SV_API SV_Str_view | SV_copy (size_t str_bytes, char const *src_str) SV_ATTRIB_NULLTERM(2) SV_ATTRIB_PURE |
| Copies the max of string bytes or input string length into a view, whichever ends first. | |
| SV_API size_t | SV_fill (size_t dest_bytes, char *dest_buf, SV_Str_view src) |
| Fills the destination buffer with the minimum between destination size and source view size, null terminating the string. | |
| SV_API SV_Str_view | SV_extend (SV_Str_view sv) SV_ATTRIB_PURE |
| Returns a SV_Str_view of the entirety of the underlying string, starting at the current view pointer position. | |
Types | |
The types of the | |
| enum | SV_Order { SV_ORDER_LESSER = -1 , SV_ORDER_EQUAL , SV_ORDER_GREATER , SV_ORDER_ERROR } |
| Standard three way comparison type in C. More... | |
Comparison | |
Comparing a | |
| SV_API SV_Order | SV_compare (SV_Str_view lhs, SV_Str_view rhs) SV_ATTRIB_PURE |
| Returns the standard C threeway comparison between cmp(lhs, rhs) between two string views. | |
| SV_API SV_Order | SV_terminated_compare (SV_Str_view lhs, char const *rhs) SV_ATTRIB_NULLTERM(2) SV_ATTRIB_PURE |
| Returns the standard C threeway comparison between cmp(lhs, rhs) between a SV_Str_view and a C string. | |
| SV_API SV_Order | SV_view_compare (SV_Str_view lhs, char const *rhs, size_t n) SV_ATTRIB_NULLTERM(2) SV_ATTRIB_PURE |
Returns the standard C threeway comparison between cmp(lhs, rhs) between a SV_Str_view and a C string, bounded by n bytes of the right hand side. If n is shorter than the right hand side string the nth byte is compared. | |
Tokenization and Iteration | |
Tokenize a | |
| SV_API SV_Str_view | SV_token_begin (SV_Str_view src, SV_Str_view delim) SV_ATTRIB_PURE |
| Finds the first tokenized position in the string view given any length delim SV_Str_view. | |
| SV_API bool | SV_token_end (SV_Str_view src, SV_Str_view token) SV_ATTRIB_PURE |
| Provides the status of the current tokenization for use in conditions such as loops. | |
| SV_API SV_Str_view | SV_token_next (SV_Str_view src, SV_Str_view token, SV_Str_view delim) SV_ATTRIB_PURE |
| Advances to the next token in the remaining view separated by the delim. | |
| SV_API SV_Str_view | SV_token_reverse_begin (SV_Str_view src, SV_Str_view delim) SV_ATTRIB_PURE |
| SV_API bool | SV_token_reverse_end (SV_Str_view src, SV_Str_view token) SV_ATTRIB_PURE |
| Provides the status of the current tokenization for use in conditions such as loops. | |
| SV_API SV_Str_view | SV_token_reverse_next (SV_Str_view src, SV_Str_view token, SV_Str_view delim) SV_ATTRIB_PURE |
| Advances the token in src to the next token between two delimiters provided by delim. | |
| SV_API char const * | SV_begin (SV_Str_view sv) SV_ATTRIB_PURE |
| Returns a read only pointer to the beginning of the string view, the first valid character in the view. | |
| SV_API char const * | SV_reverse_begin (SV_Str_view sv) SV_ATTRIB_PURE |
| Returns the reverse iterator beginning, the last character of the current view. | |
| SV_API char const * | SV_next (char const *c) SV_ATTRIB_NULLTERM(1) SV_ATTRIB_PURE |
| Advances the null terminated string pointer from its previous position. If NULL is provided SV_null() is returned. | |
| SV_API char const * | SV_reverse_next (char const *c) SV_ATTRIB_PURE |
| Advances the iterator to the next character in the SV_Str_view being iterated through in reverse. | |
| SV_API char const * | SV_end (SV_Str_view sv) SV_ATTRIB_PURE |
| Returns a read only pointer to the end of the string view. | |
| SV_API char const * | SV_reverse_end (SV_Str_view sv) SV_ATTRIB_PURE |
| The ending position of a reverse iteration. | |
String Matching | |
Search a | |
| SV_API size_t | SV_find (SV_Str_view haystack, size_t pos, SV_Str_view needle) SV_ATTRIB_PURE |
| Searches for needle in haystack starting from pos. | |
| SV_API size_t | SV_reverse_find (SV_Str_view haystack, size_t pos, SV_Str_view needle) SV_ATTRIB_PURE |
| Searches for the last occurrence of needle in haystack starting from pos from right to left. | |
| SV_API bool | SV_contains (SV_Str_view haystack, SV_Str_view needle) SV_ATTRIB_PURE |
| Tests membership of needle in haystack. | |
| SV_API SV_Str_view | SV_match (SV_Str_view haystack, SV_Str_view needle) SV_ATTRIB_PURE |
| Search for a substring within a source string view. | |
| SV_API SV_Str_view | SV_reverse_match (SV_Str_view haystack, SV_Str_view needle) SV_ATTRIB_PURE |
| Search for a substring within a source string in reverse. | |
| SV_API bool | SV_starts_with (SV_Str_view sv, SV_Str_view prefix) SV_ATTRIB_PURE |
| Confirms the presence of a prefix within a string view. | |
| SV_API SV_Str_view | SV_remove_prefix (SV_Str_view sv, size_t n) SV_ATTRIB_PURE |
| SV_API bool | SV_ends_with (SV_Str_view sv, SV_Str_view suffix) SV_ATTRIB_PURE |
| Confirms the presence of a suffix within a string view. | |
| SV_API SV_Str_view | SV_remove_suffix (SV_Str_view sv, size_t n) SV_ATTRIB_PURE |
| SV_API size_t | SV_find_first_of (SV_Str_view haystack, SV_Str_view set) SV_ATTRIB_PURE |
| SV_API size_t | SV_find_first_not_of (SV_Str_view haystack, SV_Str_view set) SV_ATTRIB_PURE |
| SV_API size_t | SV_find_last_of (SV_Str_view haystack, SV_Str_view set) SV_ATTRIB_PURE |
| SV_API size_t | SV_find_last_not_of (SV_Str_view haystack, SV_Str_view set) SV_ATTRIB_PURE |
State | |
Obtain current state of an | |
| SV_API size_t | SV_min_len (char const *str, size_t n) SV_ATTRIB_NULLTERM(1) SV_ATTRIB_PURE |
| Returns the minimum between the string size vs n bytes. | |
| SV_API char const * | SV_null (void) SV_ATTRIB_PURE |
| A sentinel empty string. Safely dereference to view a null terminator. This may be returned from various functions when bad input is given such as NULL pointers as the underlying SV_Str_view string pointer. | |
| SV_API size_t | SV_npos (SV_Str_view sv) SV_ATTRIB_CONST |
| The end of a SV_Str_view guaranteed to be greater than or equal to size. | |
| SV_API bool | SV_is_empty (SV_Str_view sv) SV_ATTRIB_CONST |
| Returns true if the provided SV_Str_view is empty, false otherwise. | |
| SV_API size_t | SV_len (SV_Str_view sv) SV_ATTRIB_CONST |
| Returns the length of the SV_Str_view in O(1) time. | |
| SV_API size_t | SV_bytes (SV_Str_view sv) SV_ATTRIB_CONST |
| SV_API char const * | SV_pointer (SV_Str_view sv, size_t i) SV_ATTRIB_PURE |
| Returns the character pointer at the minimum between the indicated position and the end of the string view. | |
| SV_API char | SV_at (SV_Str_view sv, size_t i) SV_ATTRIB_PURE |
| Obtain a character at a position in the string view. | |
| SV_API char | SV_front (SV_Str_view sv) SV_ATTRIB_PURE |
| Obtain the character at the first position of SV_Str_view. | |
| SV_API char | SV_back (SV_Str_view sv) SV_ATTRIB_PURE |
| Obtain the character at the last position of SV_Str_view. | |
| #define SV_from | ( | str_literal | ) | ((SV_Str_view){SV_STR_LITERAL(str_literal), sizeof(str_literal) - 1}) |
A macro to reduce the chance for errors in repeating oneself when constructing an inline or const SV_Str_view. The input must be a string literal.
| [in] | str_literal | a C string literal |
One can even use this in code when string literals are used rather than saved constants to avoid errors in SV_Str_view constructions.
However saving the SV_Str_view in a constant may be more convenient.
| enum SV_Order |
Standard three way comparison type in C.
Orders the result of a comparison between left and right hand side elements, describing the order of the left hand side element compared to the right.
| SV_API char SV_at | ( | SV_Str_view | sv, |
| size_t | i | ||
| ) |
Obtain a character at a position in the string view.
| [in] | sv | the input string view. |
| [in] | i | the index within [0, string view length - 1) |
| SV_API char SV_back | ( | SV_Str_view | sv | ) |
Obtain the character at the last position of SV_Str_view.
| [in] | sv | the input string view. |
| SV_API char const * SV_begin | ( | SV_Str_view | sv | ) |
Returns a read only pointer to the beginning of the string view, the first valid character in the view.
| [in] | sv | the input string view. |
| SV_API size_t SV_bytes | ( | SV_Str_view | sv | ) |
Returns the bytes of SV_Str_view including null terminator.
| [in] | sv | the string view to check. |
| SV_API SV_Order SV_compare | ( | SV_Str_view | lhs, |
| SV_Str_view | rhs | ||
| ) |
Returns the standard C threeway comparison between cmp(lhs, rhs) between two string views.
| [in] | lhs | the string view left hand side. |
| [in] | rhs | the string view right hand side. |
Comparison is bounded by the shorter SV_Str_view length. ERR is returned if bad input is provided such as a SV_Str_view with a NULL pointer field.
| SV_API bool SV_contains | ( | SV_Str_view | haystack, |
| SV_Str_view | needle | ||
| ) |
Tests membership of needle in haystack.
| [in] | haystack | the source string view to search. |
| [in] | needle | the substring to match within haystack. |
| SV_API SV_Str_view SV_copy | ( | size_t | str_bytes, |
| char const * | src_str | ||
| ) |
Copies the max of string bytes or input string length into a view, whichever ends first.
| [in] | str_bytes | the number of bytes to scan, at most. |
| [in] | src_str | the null terminated string to scan. |
\0 character is encountered, the character found at byte str_bytes of the input string is conceptually at the position of the null terminator of the view. | SV_API char const * SV_end | ( | SV_Str_view | sv | ) |
Returns a read only pointer to the end of the string view.
| [in] | sv | the view being iterated over. |
| SV_API bool SV_ends_with | ( | SV_Str_view | sv, |
| SV_Str_view | suffix | ||
| ) |
Confirms the presence of a suffix within a string view.
| [in] | sv | the string view to search. |
| [in] | suffix | the substring suffix to match with the input view. |
| SV_API SV_Str_view SV_extend | ( | SV_Str_view | sv | ) |
Returns a SV_Str_view of the entirety of the underlying string, starting at the current view pointer position.
| [in] | sv | the string view to extend. |
This guarantees that the SV_Str_view returned ends at the null terminator of the underlying string as all strings used with SV_Str_views are assumed to be null terminated. It is undefined behavior to provide non null terminated strings to any SV_Str_view code.
| SV_API size_t SV_fill | ( | size_t | dest_bytes, |
| char * | dest_buf, | ||
| SV_Str_view | src | ||
| ) |
Fills the destination buffer with the minimum between destination size and source view size, null terminating the string.
| [in] | dest_bytes | the bytes available in the destination. |
| [in] | dest_buf | the character buffer destination. |
| [in] | src | the string view to copy into the buffer. |
destination bytes < source length. Returns how many bytes were written to the buffer. | SV_API size_t SV_find | ( | SV_Str_view | haystack, |
| size_t | pos, | ||
| SV_Str_view | needle | ||
| ) |
Searches for needle in haystack starting from pos.
| [in] | haystack | the string view to search. |
| [in] | pos | the position from which to start the search. |
| [in] | needle | the substring to match within haystack. |
| SV_API size_t SV_find_first_not_of | ( | SV_Str_view | haystack, |
| SV_Str_view | set | ||
| ) |
Finds the first position at which no characters in set can be found.
| [in] | haystack | the input view to search. |
| [in] | set | the set of characters banned in the search for of haystack. Each character in the input set is considered a valid match if encountered in haystack. |
| SV_API size_t SV_find_first_of | ( | SV_Str_view | haystack, |
| SV_Str_view | set | ||
| ) |
Finds the first position of an occurrence of any character in set.
| [in] | haystack | the input view to search. |
| [in] | set | the set of characters to search for in the haystack. Each character in the input set is considered a valid match if encountered in haystack. |
| SV_API size_t SV_find_last_not_of | ( | SV_Str_view | haystack, |
| SV_Str_view | set | ||
| ) |
Finds the last position at which no characters in set can be found.
| [in] | haystack | the input view to search. |
| [in] | set | the set of characters banned in the search for of haystack. Each character in the input set is considered a valid match if encountered in haystack. |
| SV_API size_t SV_find_last_of | ( | SV_Str_view | haystack, |
| SV_Str_view | set | ||
| ) |
Finds the last position of an occurrence of any character in set.
| [in] | haystack | the input view to search. |
| [in] | set | the set of characters to search for in the haystack. Each character in the input set is considered a valid match if encountered in haystack. |
| SV_API SV_Str_view SV_from_delimiter | ( | char const * | str, |
| char const * | delim | ||
| ) |
Constructs and returns a string view from a null terminated string broken on the first occurrence of delimiter if found or null terminator if delim cannot be found.
| [in] | str | the null terminated input string. |
| [in] | delim | the null terminated delimiter on which to break. |
This constructor will also skip the delimiter if that delimiter starts the string. This is similar to the tokenizing function in the iteration section.
| SV_API SV_Str_view SV_from_terminated | ( | char const * | str | ) |
Constructs and returns a string view from a null terminated string.
| [in] | str | a pointer to the null terminated string. |
| SV_API SV_Str_view SV_from_view | ( | size_t | n, |
| char const * | str | ||
| ) |
Constructs and returns a string view from a sequence of valid n bytes or string length, whichever comes first.
| [in] | n | the number of bytes to scan, at most. |
| [in] | str | the null terminated string to scan. |
\0 character is encountered, the character found at byte n of the input string is conceptually at the position of the null terminator of the view. | SV_API char SV_front | ( | SV_Str_view | sv | ) |
Obtain the character at the first position of SV_Str_view.
| [in] | sv | the input string view. |
| SV_API bool SV_is_empty | ( | SV_Str_view | sv | ) |
Returns true if the provided SV_Str_view is empty, false otherwise.
| [in] | sv | the string view to check. |
This is a useful function to check for SV_Str_view searches that yield an empty view at the end of a SV_Str_view when an element cannot be found.
| SV_API size_t SV_len | ( | SV_Str_view | sv | ) |
Returns the length of the SV_Str_view in O(1) time.
| [in] | sv | the string view to check. |
The position at SV_Str_view size is interpreted as the null terminator and not counted toward length of a SV_Str_view.
| SV_API SV_Str_view SV_match | ( | SV_Str_view | haystack, |
| SV_Str_view | needle | ||
| ) |
Search for a substring within a source string view.
| [in] | haystack | the source string view to search. |
| [in] | needle | the substring to match within haystack. |
| SV_API size_t SV_min_len | ( | char const * | str, |
| size_t | n | ||
| ) |
Returns the minimum between the string size vs n bytes.
| [in] | str | the null terminated input string. |
| [in] | n | the limiting byte count to compare. |
| SV_API char const * SV_next | ( | char const * | c | ) |
Advances the null terminated string pointer from its previous position. If NULL is provided SV_null() is returned.
| [in] | c | the pointer to a null terminated string iterator. |
| SV_API size_t SV_npos | ( | SV_Str_view | sv | ) |
The end of a SV_Str_view guaranteed to be greater than or equal to size.
| [in] | sv | the string view. |
This value may be used for the idiomatic check for most string searching function return values when something is not found. If a size is returned from a searching function it is possible to check it against this value.
| SV_API char const * SV_null | ( | void | ) |
A sentinel empty string. Safely dereference to view a null terminator. This may be returned from various functions when bad input is given such as NULL pointers as the underlying SV_Str_view string pointer.
| SV_API char const * SV_pointer | ( | SV_Str_view | sv, |
| size_t | i | ||
| ) |
Returns the character pointer at the minimum between the indicated position and the end of the string view.
| [in] | sv | the string view input. |
| [in] | i | the index within range of [0, string view length - 1). |
| SV_API SV_Str_view SV_remove_prefix | ( | SV_Str_view | sv, |
| size_t | n | ||
| ) |
Removes the minimum between SV_Str_view length and n from the start of the SV_Str_view.
| [in] | sv | the input string view. |
| [in] | n | the bytes to remove from the start of the input view. |
It is safe to provide n larger than SV_Str_view size as that will result in a size 0 view to the end of the current view which may or may not be the null terminator.
| SV_API SV_Str_view SV_remove_suffix | ( | SV_Str_view | sv, |
| size_t | n | ||
| ) |
Removes the minimum between SV_Str_view length and n from the end of the SV_Str_view.
| [in] | sv | the input string view. |
| [in] | n | the bytes to remove from the end of the input view. |
It is safe to provide n larger than SV_Str_view size as that will result in a size 0 view to the end of the current view which may or may not be the null terminator.
| SV_API char const * SV_reverse_begin | ( | SV_Str_view | sv | ) |
Returns the reverse iterator beginning, the last character of the current view.
| [in] | sv | the input string view. |
| SV_API char const * SV_reverse_end | ( | SV_Str_view | sv | ) |
The ending position of a reverse iteration.
| [in] | sv | the view being iterated over in reverse. |
| SV_API size_t SV_reverse_find | ( | SV_Str_view | haystack, |
| size_t | pos, | ||
| SV_Str_view | needle | ||
| ) |
Searches for the last occurrence of needle in haystack starting from pos from right to left.
| [in] | haystack | the string view to search. |
| [in] | pos | the position from which to start the search. |
| [in] | needle | the substring to match within haystack. |
If the position is larger than the haystack, the entire haystack is searched.
| SV_API SV_Str_view SV_reverse_match | ( | SV_Str_view | haystack, |
| SV_Str_view | needle | ||
| ) |
Search for a substring within a source string in reverse.
| [in] | haystack | the source string view to reverse search. |
| [in] | needle | the substring to match within haystack. |
| SV_API char const * SV_reverse_next | ( | char const * | c | ) |
Advances the iterator to the next character in the SV_Str_view being iterated through in reverse.
| [in] | c | the pointer to the null terminated string iterator. |
| SV_API bool SV_starts_with | ( | SV_Str_view | sv, |
| SV_Str_view | prefix | ||
| ) |
Confirms the presence of a prefix within a string view.
| [in] | sv | the string view to search. |
| [in] | prefix | the substring prefix to match with the input view. |
| SV_API size_t SV_str_bytes | ( | char const * | str | ) |
Returns the bytes of the string pointer to, null terminator included.
| [in] | str | the null terminated input string. |
| SV_API SV_Str_view SV_substr | ( | SV_Str_view | sv, |
| size_t | pos, | ||
| size_t | count | ||
| ) |
Creates the substring from position pos for count length. The count is the minimum value between count and (length - pos).
| [in] | sv | the string view. |
| [in] | pos | the position from which to start the substring. |
| [in] | count | the new string length of the substring. |
| SV_API SV_Order SV_terminated_compare | ( | SV_Str_view | lhs, |
| char const * | rhs | ||
| ) |
Returns the standard C threeway comparison between cmp(lhs, rhs) between a SV_Str_view and a C string.
| [in] | lhs | the string view that serves as the left hand side of the order. |
| [in] | rhs | the null terminated string to compare against. |
SV_ORDER_LESSER, SV_ORDER_EQUAL, or SV_ORDER_GREATER.Comparison is bounded by the shorter SV_Str_view length. An error value is returned if bad input is provided such as a SV_Str_view with a NULL pointer field.
| SV_API SV_Str_view SV_token_begin | ( | SV_Str_view | src, |
| SV_Str_view | delim | ||
| ) |
Finds the first tokenized position in the string view given any length delim SV_Str_view.
| [in] | src | the source string view to tokenize. |
| [in] | delim | the delimiter that separates tokens. |
| SV_API bool SV_token_end | ( | SV_Str_view | src, |
| SV_Str_view | token | ||
| ) |
Provides the status of the current tokenization for use in conditions such as loops.
| [in] | src | the source view being tokenized. |
| [in] | token | the current token obtained from tokenization. |
| SV_API SV_Str_view SV_token_next | ( | SV_Str_view | src, |
| SV_Str_view | token, | ||
| SV_Str_view | delim | ||
| ) |
Advances to the next token in the remaining view separated by the delim.
| [in] | src | the source string view being tokenized. |
| [in] | token | the current token obtained from tokenizing. |
| [in] | delim | the delimeter that separates tokens. |
| SV_API SV_Str_view SV_token_reverse_begin | ( | SV_Str_view | src, |
| SV_Str_view | delim | ||
| ) |
Obtains the last token in a string in preparation for reverse tokenized iteration.
| [in] | src | the source view to tokenize in reverse. |
| [in] | delim | the delimiter that separates tokens. |
| SV_API bool SV_token_reverse_end | ( | SV_Str_view | src, |
| SV_Str_view | token | ||
| ) |
Provides the status of the current tokenization for use in conditions such as loops.
| [in] | src | the source view being tokenized. |
| [in] | token | the current token obtained from tokenization. |
| SV_API SV_Str_view SV_token_reverse_next | ( | SV_Str_view | src, |
| SV_Str_view | token, | ||
| SV_Str_view | delim | ||
| ) |
Advances the token in src to the next token between two delimiters provided by delim.
| [in] | src | the source string view being reverse tokenized. |
| [in] | token | the current token obtained from tokenization. |
| [in] | delim | the delimiter that separates tokens. |
| SV_API SV_Order SV_view_compare | ( | SV_Str_view | lhs, |
| char const * | rhs, | ||
| size_t | n | ||
| ) |
Returns the standard C threeway comparison between cmp(lhs, rhs) between a SV_Str_view and a C string, bounded by n bytes of the right hand side. If n is shorter than the right hand side string the nth byte is compared.
| [in] | lhs | the string view that serves as the left hand side of the order. |
| [in] | rhs | the null terminated string to compare against. |
| [in] | n | limit bytes of the comparison if less than right hand side length. |
SV_ORDER_LESSER, SV_ORDER_EQUAL, or SV_ORDER_GREATER.Comparison is bounded by the shortest length between left hand side, right hand side string length, and the byte limit n. An error value is returned if bad input is provided such as a SV_Str_view with a NULL pointer field.