libfilezilla
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
strtokenizer< String, Delims > Class Template Reference

Container-like class that can be used to iterate over tokens in a string. More...

#include <string.hpp>

Classes

struct  iterator
 
struct  sentinel
 

Public Types

using value_type = const view_type
 
using pointer = value_type *
 
using reference = value_type &
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 
using const_value_type = value_type
 
using const_pointer = pointer
 
using const_reference = reference
 
using const_iterator = iterator
 

Public Member Functions

constexpr strtokenizer (String &&string, Delims &&delims, bool ignore_empty)
 strtokenizer class constructor. More...
 
constexpr iterator begin () const
 
constexpr sentinel end () const
 
constexpr const_iterator cbegin () const
 
constexpr sentinel cend () const
 

Public Attributes

String string_
 
Delims delims_
 
bool ignore_empty_
 

Detailed Description

template<typename String, typename Delims>
class fz::strtokenizer< String, Delims >

Container-like class that can be used to iterate over tokens in a string.

The class will keep a copy of any temporary constructor's parameter. strtokenizer must live longer than the iterators created from it.

Access through the iterators returns views, make sure non-temporary arguments to strtokenizer constructur live longer than the iterators.

Do not modify a string for which there is an strtokenizer instance.

Always use the construction guide for this class, never explictly use the template parameters.

Usage example:

for (auto t : fz::strtokenizer("foo,baz,,bar", ",", true)) {
std::cout << t << "\n";
}
// Will print the following:
// foo
// baz
// bar
Container-like class that can be used to iterate over tokens in a string.
Definition: string.hpp:339

Constructor & Destructor Documentation

◆ strtokenizer()

constexpr strtokenizer ( String &&  string,
Delims &&  delims,
bool  ignore_empty 
)
inlineconstexpr

strtokenizer class constructor.

Parameters
delimsthe delimiters to look for
ignore_emptyIf true, empty tokens are omitted in the output

The documentation for this class was generated from the following file: