|
LibSWOC++ 1.5.14
Solid Wall of C++
|
#include <TextView.h>

Public Types | |
| using | transform_type = X |
| Export transform functor type. | |
| using | source_view_type = V |
| Export source view type. | |
| using | source_value_type = std::remove_reference_t<decltype(*source_iterator{})> |
| using | value_type = std::invoke_result_t<transform_type, source_value_type> |
| Result type of calling the transform on an element of the source view. | |
| using | iterator = self_type |
| This class serves as its own iterator. | |
Public Member Functions | |
| TransformView (transform_type &&xf, source_view_type const &v) | |
| TransformView (transform_type const &xf, source_view_type const &v) | |
| TransformView (self_type const &that)=default | |
| Copy constructor. | |
| TransformView (self_type &&that)=default | |
| Move constructor. | |
| self_type & | operator= (self_type const &that)=default |
| Copy assignment. | |
| self_type & | operator= (self_type &&that)=default |
| Move assignment. | |
| bool | operator== (self_type const &that) const |
| Equality. | |
| bool | operator!= (self_type const &that) const |
| Inequality. | |
| value_type | operator* () const |
| Get the current element. | |
| self_type & | operator++ () |
| Move to next element. | |
| self_type | operator++ (int) |
| Move to next element. | |
| bool | empty () const |
| Check if view is empty. | |
| operator bool () const | |
| Check if bool is not empty. | |
| iterator | begin () const |
| Iterator to first transformed character. | |
| iterator | end () const |
| Iterator past last transformed character. | |
Protected Member Functions | |
| TransformView (transform_type &&xf, source_iterator &&limit) | |
Special constructor for making an empty instance to serve as the end iterator. | |
Protected Attributes | |
| transform_type | _xf |
| Per character transform functor. | |
| source_iterator | _spot |
| Current location in the source view. | |
| source_iterator | _limit |
| End of source view. | |
A transform view.
| X | Transform functor type. |
| V | Source view type. |
A transform view acts like a view on the original source view V with each element transformed by X.
This is used most commonly with std::string_view. For example, if the goal is to handle a piece of text as if it were lower case without changing the actual text, the following would make that possible.
To avoid having to figure out the exact signature of the transform, the convenience function transform_view_of is provide.
This class supports iterators but those should be avoided as use of them makes extra copies of the instance which may be expensive if the functor is expensive. In cases where the functor is a function pointer or a lambda this isn't an issue.
Definition at line 1799 of file TextView.h.
| using swoc::TransformView< X, V >::iterator = self_type |
This class serves as its own iterator.
Definition at line 1810 of file TextView.h.
| using swoc::TransformView< X, V >::source_value_type = std::remove_reference_t<decltype(*source_iterator{})> |
Definition at line 1806 of file TextView.h.
| using swoc::TransformView< X, V >::source_view_type = V |
Export source view type.
Definition at line 1805 of file TextView.h.
| using swoc::TransformView< X, V >::transform_type = X |
Export transform functor type.
Definition at line 1804 of file TextView.h.
| using swoc::TransformView< X, V >::value_type = std::invoke_result_t<transform_type, source_value_type> |
Result type of calling the transform on an element of the source view.
Definition at line 1808 of file TextView.h.
| swoc::TransformView< X, V >::TransformView | ( | transform_type && | xf, |
| source_view_type const & | v ) |
Construct a transform view using transform xf on source view v.
| xf | Transform instance. |
| v | Source view. |
Definition at line 1874 of file TextView.h.
| swoc::TransformView< X, V >::TransformView | ( | transform_type const & | xf, |
| source_view_type const & | v ) |
Construct a transform view using transform xf on source view v.
| xf | Transform instance. |
| v | Source view. |
Definition at line 1877 of file TextView.h.
|
inlineprotected |
Special constructor for making an empty instance to serve as the end iterator.
Definition at line 1870 of file TextView.h.
|
inline |
Iterator to first transformed character.
Definition at line 1855 of file TextView.h.
| bool swoc::TransformView< X, V >::empty | ( | ) | const |
Check if view is empty.
Definition at line 1903 of file TextView.h.
|
inline |
Iterator past last transformed character.
Definition at line 1860 of file TextView.h.
|
explicit |
Check if bool is not empty.
Definition at line 1907 of file TextView.h.
| bool swoc::TransformView< X, V >::operator!= | ( | self_type const & | that | ) | const |
Inequality.
Definition at line 1919 of file TextView.h.
| auto swoc::TransformView< X, V >::operator* | ( | ) | const |
Get the current element.
Definition at line 1882 of file TextView.h.
| auto swoc::TransformView< X, V >::operator++ | ( | ) |
Move to next element.
Definition at line 1888 of file TextView.h.
| auto swoc::TransformView< X, V >::operator++ | ( | int | ) |
Move to next element.
Definition at line 1895 of file TextView.h.
| bool swoc::TransformView< X, V >::operator== | ( | self_type const & | that | ) | const |
Equality.
Definition at line 1913 of file TextView.h.
|
protected |
End of source view.
Definition at line 1867 of file TextView.h.
|
protected |
Current location in the source view.
Definition at line 1866 of file TextView.h.
|
protected |
Per character transform functor.
Definition at line 1865 of file TextView.h.