From: Francesco Chemolli Date: Thu, 5 Dec 2013 15:26:22 +0000 (+0100) Subject: Fixed formatting X-Git-Tag: SQUID_3_5_0_1~463^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=514fc315b50f58424a0c5e363315efc6f7de141a;p=thirdparty%2Fsquid.git Fixed formatting Moved ToSBufList from SBufList.h/cc to wordlist.h/cc Fixed some misnamed parameters in SBufAlgos.h --- diff --git a/src/Makefile.am b/src/Makefile.am index 9e6e9d280c..191c6de5a2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2540,6 +2540,8 @@ tests_testHttpParser_SOURCES = \ String.cc \ cache_cf.h \ YesNoNone.h \ + $(SBUF_SOURCE) \ + tests/stub_SBufDetailedStats.cc \ tests/stub_cache_cf.cc \ tests/stub_cache_manager.cc \ tests/stub_debug.cc \ @@ -2989,6 +2991,9 @@ tests_testString_SOURCES = \ tests/stub_mem.cc \ MemBuf.cc \ String.cc \ + $(SBUF_SOURCE) \ + SBufDetailedStats.h \ + tests/stub_SBufDetailedStats.cc \ tests/testMain.cc \ tests/testString.cc \ tests/testString.h \ @@ -3714,6 +3719,9 @@ tests_testConfigParser_SOURCES = \ tests/stub_mem.cc \ tests/stub_MemBuf.cc \ tests/stub_time.cc \ + $(SBUF_SOURCE) \ + SBufDetailedStats.h \ + tests/stub_SBufDetailedStats.cc \ String.cc \ ConfigParser.cc \ fatal.h \ diff --git a/src/SBufAlgos.h b/src/SBufAlgos.h index 988361091b..ae43c03682 100644 --- a/src/SBufAlgos.h +++ b/src/SBufAlgos.h @@ -6,32 +6,35 @@ #include /// 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()) {} @@ -48,8 +51,7 @@ SBuf 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) diff --git a/src/SBufList.cc b/src/SBufList.cc index adbf5767a2..80827ae423 100644 --- a/src/SBufList.cc +++ b/src/SBufList.cc @@ -8,14 +8,3 @@ IsMember(const SBufList & sl, const SBuf &S, const SBufCaseSensitive case_sensit { return std::find_if(sl.begin(), sl.end(), SBufEqual(S,case_sensitive)) != sl.end(); } - -SBufList -ToSBufList(wordlist *wl) -{ - SBufList rv; - while (wl != NULL) { - rv.push_back(SBuf(wl->key)); - wl = wl->next; - } - return rv; -} diff --git a/src/SBufList.h b/src/SBufList.h index d95815b860..5dec76bb23 100644 --- a/src/SBufList.h +++ b/src/SBufList.h @@ -14,9 +14,4 @@ typedef std::list SBufList; */ bool IsMember(const SBufList &, const SBuf &, const SBufCaseSensitive isCaseSensitive = caseSensitive); -class wordlist; - -/// convert a wordlist to a SBufList -SBufList ToSBufList(wordlist *); - #endif /* SQUID_SBUFLIST_H */ diff --git a/src/wordlist.cc b/src/wordlist.cc index 8a9bdc09d7..7df0087a9e 100644 --- a/src/wordlist.cc +++ b/src/wordlist.cc @@ -109,3 +109,14 @@ wordlistDup(const wordlist * w) return D; } + +SBufList +ToSBufList(wordlist *wl) +{ + SBufList rv; + while (wl != NULL) { + rv.push_back(SBuf(wl->key)); + wl = wl->next; + } + return rv; +} diff --git a/src/wordlist.h b/src/wordlist.h index 497a2ab6d5..fafdb63c47 100644 --- a/src/wordlist.h +++ b/src/wordlist.h @@ -33,6 +33,7 @@ #include "globals.h" #include "MemPool.h" #include "profiler/Profiler.h" +#include "SBufList.h" /** A list of C-strings * @@ -49,29 +50,38 @@ public: 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 */