WvStreams
Public Member Functions | List of all members
WvStringList Class Reference

This is a WvList of WvStrings, and is a really handy way to parse strings. More...

#include <wvstringlist.h>

Inheritance diagram for WvStringList:
Inheritance graph
[legend]

Public Member Functions

 WvStringList ()
 Instatiate a new WvStringList() More...
 
WvString join (const char *joinchars=" ") const
 concatenates all elements of the list seperating on joinchars More...
 
void split (WvStringParm s, const char *splitchars=" \t\r\n", int limit=0)
 split s and form a list ignoring splitchars (except at beginning and end) ie. More...
 
void splitstrict (WvStringParm s, const char *splitchars=" \t\r\n", int limit=0)
 split s and form a list creating null entries when there are multiple splitchars ie " happy birthday to you" split on " " will populate the list with "" "happy" "birthday" "" "to" "" "you" More...
 
void split (WvStringParm s, const WvRegex &regex, int limit=0)
 split s and form a list ignoring regex (except at beginning and end) Note that there is no splitstrict for regexes, since the differece is taken care of through the regex (...)+ syntax More...
 
void fill (const char *const *array)
 
void append (WvStringParm str)
 
void append (WVSTRING_FORMAT_DECL)
 
void append (WvString *strp, bool autofree, char *id=NULL)
 
WvString popstr ()
 get the first string in the list, or an empty string if the list is empty. More...
 

Detailed Description

This is a WvList of WvStrings, and is a really handy way to parse strings.

If you ever find yourself using strtok(3) or strpbrk(3), or find yourself needing to parse a line of input, WvStringList, WvStringList::split(), and WvStringList::popstr() are probably what you want, and avoid all sorts of nasty security bugs caused by doing it any other way.

Definition at line 27 of file wvstringlist.h.

Constructor & Destructor Documentation

◆ WvStringList()

WvStringList::WvStringList ( )
inline

Instatiate a new WvStringList()

Definition at line 35 of file wvstringlist.h.

Member Function Documentation

◆ join()

WvString WvStringList::join ( const char *  joinchars = " ") const

concatenates all elements of the list seperating on joinchars

Definition at line 14 of file wvstringlist.cc.

References strcoll_join().

Referenced by WvDBusMsg::Iter::get_all().

◆ split() [1/2]

void WvStringList::split ( WvStringParm  s,
const char *  splitchars = " \t\r\n",
int  limit = 0 
)

split s and form a list ignoring splitchars (except at beginning and end) ie.

" happy birthday to you" split on " " will populate the list with "" "happy" "birthday" "to" "you"

Definition at line 19 of file wvstringlist.cc.

References strcoll_split().

Referenced by WvDBusServerAuth::authorize(), encode_hostname_as_DN(), and WvIPRouteList::get_kernel().

◆ splitstrict()

void WvStringList::splitstrict ( WvStringParm  s,
const char *  splitchars = " \t\r\n",
int  limit = 0 
)

split s and form a list creating null entries when there are multiple splitchars ie " happy birthday to you" split on " " will populate the list with "" "happy" "birthday" "" "to" "" "you"

Definition at line 25 of file wvstringlist.cc.

References strcoll_splitstrict().

◆ split() [2/2]

void WvStringList::split ( WvStringParm  s,
const WvRegex regex,
int  limit = 0 
)

split s and form a list ignoring regex (except at beginning and end) Note that there is no splitstrict for regexes, since the differece is taken care of through the regex (...)+ syntax

Definition at line 67 of file wvstringlist.cc.

References strcoll_split().

◆ fill()

void WvStringList::fill ( const char *const *  array)

Definition at line 31 of file wvstringlist.cc.

◆ append() [1/3]

void WvStringList::append ( WvStringParm  str)

Definition at line 41 of file wvstringlist.cc.

◆ append() [2/3]

void WvStringList::append ( WVSTRING_FORMAT_DECL  )
inline

Definition at line 84 of file wvstringlist.h.

◆ append() [3/3]

void WvStringList::append ( WvString strp,
bool  autofree,
char *  id = NULL 
)

Definition at line 47 of file wvstringlist.cc.

◆ popstr()

WvString WvStringList::popstr ( )

get the first string in the list, or an empty string if the list is empty.

Removes the returned string from the list.

Definition at line 55 of file wvstringlist.cc.

Referenced by WvDBusServerAuth::authorize(), and WvX509::get_aki().


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