StrList.h File Reference
#include "sbuf/forward.h"
#include <iterator>
Include dependency graph for StrList.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void strListAdd (String *str, const char *item, char del)
 Appends the given item to a delimiter-separated list in str. More...
 
void strListAdd (String &str, const char *item, const size_t itemSize, const char del=',')
 Appends the given item of a given size to a delimiter-separated list in str. More...
 
void strListAdd (String &str, const SBuf &item, char delimiter=',')
 
int strListIsMember (const String *str, const SBuf &item, char del)
 
int strListIsSubstr (const String *list, const char *s, char del)
 
int strListGetItem (const String *str, char del, const char **item, int *ilen, const char **pos)
 
SBuf getListMember (const String &list, const char *key, const char delimiter)
 

Function Documentation

◆ getListMember()

SBuf getListMember ( const String list,
const char *  key,
const char  delimiter 
)

Searches for the first matching key=value pair within a delimiter-separated list of items.

Returns
the value of the found pair or an empty string.

Definition at line 144 of file StrList.cc.

References delimiter, and strListGetItem().

Referenced by HttpHeader::getByNameListMember(), ProxyProtocol::Header::getElem(), and HttpHeader::getListMember().

◆ strListAdd() [1/3]

void strListAdd ( String str,
const char *  item,
const size_t  itemSize,
const char  del = ',' 
)

◆ strListAdd() [2/3]

void strListAdd ( String str,
const SBuf item,
char  delimiter = ',' 
)

Appends the given item to a delimiter-separated list in str. Use strListAdd(c-string) for c-string items with unknown length.

Definition at line 39 of file StrList.cc.

References delimiter, SBuf::length(), SBuf::rawContent(), and strListAdd().

◆ strListAdd() [3/3]

void strListAdd ( String str,
const char *  item,
char  del 
)

Definition at line 31 of file StrList.cc.

References assert, delimiter, and strListAdd().

◆ strListGetItem()

int strListGetItem ( const String str,
char  del,
const char **  item,
int ilen,
const char **  pos 
)

Iterates through delimiter-separated and optionally "quoted" list members. Follows HTTP #rule, including skipping OWS and empty members.

iterates through a 0-terminated string of items separated by 'del's. white space around 'del' is considered to be a part of 'del' like strtok, but preserves the source, and can iterate several strings at once

returns true if next item is found. init pos with NULL to start iteration.

Definition at line 86 of file StrList.cc.

References assert, len, String::termedBuf(), and xisspace.

Referenced by assembleVaryKey(), HttpStateData::blockSwitchingProtocols(), Http::ContentLengthInterpreter::checkList(), HttpStateData::forwardUpgrade(), getListMember(), HttpHeader::hasByNameListMember(), HttpHeader::hasListMember(), StoreEntry::hasOneOfEtags(), HttpHdrSc::parse(), HttpHdrCc::parse(), Adaptation::Icap::Options::TransferList::parse(), HttpHdrRange::parseInit(), HttpReply::removeStaleWarningValues(), Adaptation::DynamicServiceChain::Split(), and strListIsMember().

◆ strListIsMember()

int strListIsMember ( const String list,
const SBuf m,
char  del 
)

◆ strListIsSubstr()

int strListIsSubstr ( const String list,
const char *  s,
char  del 
)

returns true iff "s" is a substring of a member of the list

Note
Note: the original code with a loop is broken because it uses strstr() instead of strnstr(). If 's' contains a 'del', strListIsSubstr() may return true when it should not. If 's' does not contain a 'del', the implementation is equavalent to strstr()! Thus, we replace the loop with strstr() above until strnstr() is available.

Definition at line 63 of file StrList.cc.

References assert, String::find(), and String::npos.

Referenced by clientInterpretRequestHeaders().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors