++cur;
}
debugs(24, 7, "not found");
- return length();
+ return npos;
}
/*
* \return npos if no character in the set could be found
* \param startPos if specified, ignore any occurrences before that position
* if npos, then npos is always returned
+ *
+ * TODO: rename to camelCase
*/
size_type find_first_of(const CharacterSet &set, size_type startPos = 0) const;
/** Find first occurrence character NOT in character set
*
- * \return length() if all characters in the SBuf are from set
+ * \return npos if all characters in the SBuf are from set
* \param startPos if specified, ignore any occurrences before that position
* if npos, then npos is always returned
+ *
+ * TODO: rename to camelCase
*/
size_type find_first_not_of(const CharacterSet &set, size_type startPos = 0) const;
--- /dev/null
+#include "squid.h"
+
+#include "CharacterSet.h"
+
+const CharacterSet &
+CharacterSet::operator +=(const CharacterSet &src)
+{
+ if (src.chars_.size() > chars_.size())
+ chars_.reserve(src.chars_.size());
+
+ vector_type::const_iterator s = src.chars_.begin();
+ const vector_type::const_iterator e = src.chars_.end();
+ vector_type::iterator d = chars_.begin();
+ while (s != e) {
+ if (*s)
+ *d = true;
+ ++s;
+ ++d;
+ }
+ return *this;
+}
CharacterSet & add(const unsigned char c) {chars_[static_cast<uint8_t>(c)] = true; return *this; }
/// add all characters from the given CharacterSet to this one
- const CharacterSet &operator +=(const CharacterSet &src) {
- //precondition: src.chars_.size() == chars_.size()
- vector_type::const_iterator s = src.chars_.begin();
- const vector_type::const_iterator e = src.chars_.end();
- vector_type::iterator d = chars_.begin();
- while (s != e) {
- if (*s)
- *d = true;
- ++s;
- ++d;
- }
- return *this;
- }
+ const CharacterSet &operator +=(const CharacterSet &src);
/// optional set label fdebugging (default: "anonymous")
const char * name;
AsyncCallQueue.cc \
AsyncCallQueue.h \
CharacterSet.h \
+ CharacterSet.cc \
TidyPointer.h \
CbcPointer.h \
InstanceId.h \
// all chars from the set
idx=haystack.find_first_not_of(CharacterSet("t1",literal.c_str()));
- CPPUNIT_ASSERT_EQUAL(haystack.length(),idx);
+ CPPUNIT_ASSERT_EQUAL(SBuf::npos,idx);
// found at beginning
idx=haystack.find_first_not_of(CharacterSet("t2","a"));