Skip to content

Commit b4053b8

Browse files
committed
Provide nonstd::string::npos, update Synopsis
1 parent 71be699 commit b4053b8

File tree

4 files changed

+56
-60
lines changed

4 files changed

+56
-60
lines changed

README.md

Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -92,55 +92,53 @@ Creating *string bare* I've had a look at the [C++ standard](https://eel.is/c++d
9292
<a id="syn-doc"></a>
9393
### Documentation of *string bare*
9494

95-
The following table presents simplified, short prototypes of the functions in _string-bare_.
96-
97-
| Kind | Type or function | Notes |
98-
| ------------- | ---------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
99-
| **Type** | **literal_delimiter** | a single string |
100-
| &nbsp; | **any_of_delimiter** | any of given characters |
101-
| &nbsp; | **fixed_delimiter** | fixed length |
102-
| &nbsp; | **limit_delimiter** | apply given delimiter a limited number of times (not implemented) |
103-
| &nbsp; | **regex_delimiter** | regular expression |
104-
| &nbsp; | **char_delimiter** | character position |
105-
| &nbsp; | &nbsp; | &nbsp; |
106-
| **Utilities** | char_t **nullchr**() | null char of template character type |
107-
| &nbsp; | char_t \* **nullstr**() | empty character string of template character type |
108-
| &nbsp; | &nbsp; | &nbsp; |
109-
| **Observers** | size_t **length**(string_view sv) | length of string |
110-
| &nbsp; | size_t **size**(string_view sv) | length of string |
111-
| &nbsp; | bool **is_empty**(string_view sv) | true if string is empty |
112-
| &nbsp; | bool **contains**(string_view sv, string_view what) | true if string contains given string |
113-
| &nbsp; | bool **starts_with**(string_view sv, string_view what) | true if string starts with given string |
114-
| &nbsp; | bool **ends_with**(string_view sv, string_view what) | true if string ends with given string |
115-
| &nbsp; | &nbsp; | &nbsp; |
116-
| **Searching** | size_t **find_first**(string_view sv, string_view what) | position of first occurrence of given string, or npos [Note 1](#note-1) |
117-
| &nbsp; | size_t **find_first_of**(string_view sv, string_view set) | position of first occurrence of character in set, or npos |
118-
| &nbsp; | size_t **find_first_not_of**(string_view sv, string_view set) | position of first occurrence of character not in set, or npos |
119-
| &nbsp; | size_t **find_last**(string_view sv, string_view what) | position of last occurrence of given string, or npos |
120-
| &nbsp; | size_t **find_last_of**(string_view sv, string_view set) | position of last occurrence of character in set, or npos |
121-
| &nbsp; | size_t **find_last_not_of**(string_view sv, string_view set) | position of last occurrence of character not in set, or npos |
122-
| &nbsp; | &nbsp; | &nbsp; |
123-
| **Modifiers** | char_t **to_lowercase**(char_t chr) | character transformed to lowercase |
124-
| &nbsp; | char_t **to_uppercase**(char_t chr) | character transformed to uppercase |
125-
| &nbsp; | string **to_lowercase**(string_view sv) | string transformed to lowercase |
126-
| &nbsp; | string **to_uppercase**(string_view sv) | string transformed to uppercase |
127-
| &nbsp; | string **substring**(string_view sv, size_t pos \[, size_t count\]); | substring starting at given position of given length, default up to end |
128-
| &nbsp; | string **strip**(string_view sv, string_view set) | string with characters given in set stripped from left and right |
129-
| &nbsp; | string **strip_left**(string_view sv, string_view set) | string with characters given in set stripped from left |
130-
| &nbsp; | string **strip_right**(string_view sv, string_view set) | string with characters given in set stripped from right |
131-
| &nbsp; | string **replace_all**(string_view sv, string_view what, string_view with) | string with all occurrences of 'what' replaced with 'with' |
132-
| &nbsp; | string **replace_first**(string_view sv, string_view what, string_view with) | string with first occurrence of 'what' replaced with 'with' |
133-
| &nbsp; | string **replace_last**(string_view sv, string_view what, string_view with) | string with last occurrence of 'what' replaced with 'with' |
134-
| &nbsp; | &nbsp; | &nbsp; |
135-
| **Combining** | string **append**(string_view head, string_view tail) | string with tail appended to head |
136-
| &nbsp; | string **join**(collection\<string_view\> vec, string_view sep) | string with elements of collection joined with given separator string |
137-
| &nbsp; | vector\<string_view\> **split**(string_view sv, string_view set) | vector of string_view with elements of string separated by characters from given set |
138-
| &nbsp; | tuple\<string_view, string_view\> **split_left**(string_view sv, Delimiter delim) | tuple with head and tail string_view on given string as split at left by given delimiter |
139-
| &nbsp; | tuple\<string_view, string_view\> **split_right**(string_view sv, Delimiter delim) | tuple with head and tail string_view on given string as split at right by given delimiter |
140-
| &nbsp; | tuple\<string_view, string_view\> **split_left**(string_view sv, string_view set) | tuple with head and tail string_view on given string as split at left by characters in given set |
141-
| &nbsp; | tuple\<string_view, string_view\> **split_right**(string_view sv, string_view set) | tuple with head and tail string_view on given string as split at right by characters in given set |
142-
143-
<a id="note-1"></a>Note 1: npos: `nonstd::string::std17::string_view::npos`; TODO: provide `nonstd::string::npos`.
95+
The following table presents types, values and simplified, short prototypes of the functions in _string-bare_'s `nonstd` namespace.
96+
97+
| Kind | Type or function | Notes |
98+
| -------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
99+
| **Type** | **literal_delimiter** | a string, `literal_delimiter("exact_text")` |
100+
| &nbsp; | **any_of_delimiter** | any of given characters, `any_of_delimiter("+-")` |
101+
| &nbsp; | **fixed_delimiter** | fixed length, `fixed_delimiter(length)` |
102+
| &nbsp; | **limit_delimiter** | apply given delimiter a limited number of times (not implemented) |
103+
| &nbsp; | **regex_delimiter** | regular expression, `regex_delimiter("regexp")` |
104+
| &nbsp; | **char_delimiter** | a character, `char_delimiter('&')` |
105+
| &nbsp; | &nbsp; | &nbsp; |
106+
| **Value** | size_t **string::npos** | not-found position value, in nonstd::string namespace |
107+
| &nbsp; | &nbsp; | &nbsp; |
108+
| **Observers** | size_t **length**(string_view sv) | length of string |
109+
| &nbsp; | size_t **size**(string_view sv) | length of string |
110+
| &nbsp; | bool **is_empty**(string_view sv) | true if string is empty |
111+
| &nbsp; | bool **contains**(string_view sv, string_view what) | true if string contains given string |
112+
| &nbsp; | bool **starts_with**(string_view sv, string_view what) | true if string starts with given string |
113+
| &nbsp; | bool **ends_with**(string_view sv, string_view what) | true if string ends with given string |
114+
| &nbsp; | &nbsp; | &nbsp; |
115+
| **Searching** | size_t **find_first**(string_view sv, string_view what) | position of first occurrence of given string, or npos |
116+
| &nbsp; | size_t **find_first_of**(string_view sv, string_view set) | position of first occurrence of character in set, or npos |
117+
| &nbsp; | size_t **find_first_not_of**(string_view sv, string_view set) | position of first occurrence of character not in set, or npos |
118+
| &nbsp; | size_t **find_last**(string_view sv, string_view what) | position of last occurrence of given string, or npos |
119+
| &nbsp; | size_t **find_last_of**(string_view sv, string_view set) | position of last occurrence of character in set, or npos |
120+
| &nbsp; | size_t **find_last_not_of**(string_view sv, string_view set) | position of last occurrence of character not in set, or npos |
121+
| &nbsp; | &nbsp; | &nbsp; |
122+
| **Modifiers** | char_t **to_lowercase**(char_t chr) | character transformed to lowercase |
123+
| &nbsp; | char_t **to_uppercase**(char_t chr) | character transformed to uppercase |
124+
| &nbsp; | string **to_lowercase**(string_view sv) | string transformed to lowercase |
125+
| &nbsp; | string **to_uppercase**(string_view sv) | string transformed to uppercase |
126+
| &nbsp; | string **substring**(string_view sv, size_t pos \[, size_t count\]); | substring starting at given position of given length, default up to end |
127+
| &nbsp; | string **strip**(string_view sv, string_view set) | string with characters given in set stripped from left and right |
128+
| &nbsp; | string **strip_left**(string_view sv, string_view set) | string with characters given in set stripped from left |
129+
| &nbsp; | string **strip_right**(string_view sv, string_view set) | string with characters given in set stripped from right |
130+
| &nbsp; | string **replace_all**(string_view sv, string_view what, string_view with) | string with all occurrences of 'what' replaced with 'with' |
131+
| &nbsp; | string **replace_first**(string_view sv, string_view what, string_view with) | string with first occurrence of 'what' replaced with 'with' |
132+
| &nbsp; | string **replace_last**(string_view sv, string_view what, string_view with) | string with last occurrence of 'what' replaced with 'with' |
133+
| &nbsp; | &nbsp; | &nbsp; |
134+
| **Combining** | string **append**(string_view head, string_view tail) | string with tail appended to head |
135+
| &nbsp; | string **join**(collection\<string_view\> vec, string_view sep) | string with elements of collection joined with given separator string |
136+
| &nbsp; | &nbsp; | &nbsp; |
137+
| **Separating** | vector\<string_view\> **split**(string_view sv, string_view set) | vector of string_view with elements of string separated by characters from given set |
138+
| &nbsp; | tuple\<string_view, string_view\> **split_left**(string_view sv, Delimiter delim) | tuple with head and tail string_view on given string as split at left by given delimiter |
139+
| &nbsp; | tuple\<string_view, string_view\> **split_right**(string_view sv, Delimiter delim) | tuple with head and tail string_view on given string as split at right by given delimiter |
140+
| &nbsp; | tuple\<string_view, string_view\> **split_left**(string_view sv, string_view set) | tuple with head and tail string_view on given string as split at left by characters in given set |
141+
| &nbsp; | tuple\<string_view, string_view\> **split_right**(string_view sv, string_view set) | tuple with head and tail string_view on given string as split at right by characters in given set |
144142

145143
### Configuration
146144

0 commit comments

Comments
 (0)