libept
Classes | Public Member Functions | Public Attributes | List of all members
ept::str::Split Struct Reference

Split a string where a given substring is found. More...

#include <string.h>

Classes

class  const_iterator
 

Public Member Functions

 Split (const std::string &str, const std::string &sep, bool skip_empty=false)
 
const_iterator begin ()
 Return the begin iterator to split a string on instances of sep. More...
 
const_iterator end ()
 Return the end iterator to string split. More...
 

Public Attributes

std::string str
 String to split. More...
 
std::string sep
 Separator. More...
 
bool skip_empty
 If true, skip empty tokens, effectively grouping consecutive separators as if they were a single one. More...
 

Detailed Description

Split a string where a given substring is found.

This does a similar work to the split functions of perl, python and ruby.

Example code:

str::Split splitter(my_string, "/");
vector<string> split;
std::copy(splitter.begin(), splitter.end(), back_inserter(split));

Constructor & Destructor Documentation

◆ Split()

ept::str::Split::Split ( const std::string &  str,
const std::string &  sep,
bool  skip_empty = false 
)
inline

Member Function Documentation

◆ begin()

const_iterator ept::str::Split::begin ( )
inline

Return the begin iterator to split a string on instances of sep.

References ept::str::Split::const_iterator::const_iterator().

◆ end()

const_iterator ept::str::Split::end ( )
inline

Member Data Documentation

◆ sep

std::string ept::str::Split::sep

◆ skip_empty

bool ept::str::Split::skip_empty

If true, skip empty tokens, effectively grouping consecutive separators as if they were a single one.

Referenced by ept::str::Split::const_iterator::const_iterator(), and ept::str::Split::const_iterator::operator++().

◆ str

std::string ept::str::Split::str

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