#include <numeric>
/// SBuf equality predicate for STL algorithms etc
-class SBufEqual {
+class SBufEqual
+{
public:
- explicit SBufEqual(const SBuf &reference, SBufCaseSensitive caseSensitivity_ = caseSensitive) :
- reference_(reference), sensitivity_(caseSensitivity_) {}
- inline bool operator() (const SBuf & checking) { return 0 == checking.compare(reference_,sensitivity_); }
+ explicit SBufEqual(const SBuf &reference, SBufCaseSensitive sensitivity = caseSensitive) :
+ reference_(reference), sensitivity_(sensitivity) {}
+ bool operator() (const SBuf & checking) { return checking.compare(reference_,sensitivity_) == 0; }
private:
SBuf reference_;
SBufCaseSensitive sensitivity_;
};
/// SBuf "starts with" predicate for STL algorithms etc
-class SBufStartsWith {
+class SBufStartsWith
+{
public:
- explicit SBufStartsWith(const SBuf &prefix, SBufCaseSensitive caseSensitive = caseSensitive) :
- prefix_(prefix), sensitive(caseSensitive) {}
- inline bool operator() (const SBuf & checking) { return checking.startsWith(prefix_,sensitive); }
+ explicit SBufStartsWith(const SBuf &prefix, SBufCaseSensitive sensitivity = caseSensitive) :
+ prefix_(prefix), sensitivity_(sensitivity) {}
+ bool operator() (const SBuf & checking) { return checking.startsWith(prefix_,sensitivity_); }
private:
SBuf prefix_;
- SBufCaseSensitive sensitive;
+ SBufCaseSensitive sensitivity_;
};
/** SBuf size addition accumulator for STL contaniners
*
* Equivalent to prefix_length + SBuf.length() + separator.length()
*/
-class SBufAddLength {
+class SBufAddLength
+{
public:
explicit SBufAddLength(const SBuf &separator) :
separator_len(separator.length()) {}
SBufContainerJoin(const Container &items, const SBuf& separator)
{
// optimization: pre-calculate needed storage
- SBuf::size_type sz;
- sz = std::accumulate(items.begin(), items.end(), 0, SBufAddLength(separator));
+ const SBuf::size_type sz = std::accumulate(items.begin(), items.end(), 0, SBufAddLength(separator));
// protect against blindly dereferencing items.begin() if items.size()==0
if (sz == 0)
#include "globals.h"
#include "MemPool.h"
#include "profiler/Profiler.h"
+#include "SBufList.h"
/** A list of C-strings
*
MEMPROXY_CLASS_INLINE(wordlist);
class MemBuf;
+
/** Add a null-terminated c-string to a wordlist
*
* \deprecated use SBufList.push_back(SBuf(word)) instead
*/
const char *wordlistAdd(wordlist **, const char *);
+
/** Concatenate a wordlist
*
* \deprecated use SBufListContainerJoin(SBuf()) from SBufAlgos.h instead
*/
void wordlistCat(const wordlist *, MemBuf *);
+
/** append a wordlist to another
*
* \deprecated use SBufList.merge(otherwordlist) instead
*/
void wordlistAddWl(wordlist **, wordlist *);
+
/** Concatenate the words in a wordlist
*
* \deprecated use SBufListContainerJoin(SBuf()) from SBufAlgos.h instead
*/
void wordlistJoin(wordlist **, wordlist **);
+
/// duplicate a wordlist
wordlist *wordlistDup(const wordlist *);
+
/// destroy a wordlist
void wordlistDestroy(wordlist **);
+/// convert a wordlist to a SBufList
+SBufList ToSBufList(wordlist *);
+
#endif /* SQUID_WORDLIST_H */