]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added documentation for SBufIterator, fixed SBuf unit test, simplified SBufIterator
authorFrancesco Chemolli <kinkie@squid-cache.org>
Sun, 1 Feb 2015 17:15:32 +0000 (18:15 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Sun, 1 Feb 2015 17:15:32 +0000 (18:15 +0100)
src/SBuf.h
src/tests/testSBuf.cc

index 4d3b8f8f2ec1eae9ab67828d764a4b9f1e32ed9e..7434726126cf5a258dfd7726695d8c8372b950e2 100644 (file)
@@ -78,6 +78,11 @@ public:
 class CharacterSet;
 class SBuf;
 
+/** Forward input iterator for SBufs
+ *
+ * Please note that any operation on the underlying SBuf may invalidate
+ * all iterators over it, resulting in undefined behavior by them.
+ */
 class SBufIterator : public std::iterator<std::input_iterator_tag, char>
 {
 public:
@@ -92,10 +97,14 @@ public:
 protected:
     SBufIterator(const SBuf &, size_type);
 
-    const SBuf &sbuf;
     const char *iter;
 };
 
+/** Reverse input iterator for SBufs
+ *
+ * Please note that any operation on the underlying SBuf may invalidate
+ * all iterators over it, resulting in undefined behavior by them.
+ */
 class SBufReverseIterator : public SBufIterator
 {
     friend class SBuf;
@@ -669,21 +678,21 @@ ToLower(SBuf buf)
 
 inline
 SBufIterator::SBufIterator(const SBuf &s, size_type pos)
-    : sbuf(s), iter(s.rawContent()+pos)
+    : iter(s.rawContent()+pos)
 {}
 
 inline bool
 SBufIterator::operator==(const SBufIterator &s) const
 {
     // note: maybe the sbuf comparison is unnecessary?
-    return iter == s.iter && sbuf == s.sbuf;
+    return iter == s.iter;
 }
 
 inline bool
 SBufIterator::operator!=(const SBufIterator &s) const
 {
     // note: maybe the sbuf comparison is unnecessary?
-    return iter != s.iter || sbuf != s.sbuf;
+    return iter != s.iter;
 }
 
 #endif /* SQUID_SBUF_H */
index 44e1c285d147760f78ff7a7f8aecc5f2e9cab4e1..2a2343972169f47ddc70c061c290cbdad319383d 100644 (file)
@@ -924,7 +924,7 @@ testSBuf::testIterators()
     CPPUNIT_ASSERT(text.begin() != text2.begin());
     {
         auto i = text.begin();
-        auto e = text.end()
+        auto e = text.end();
         CPPUNIT_ASSERT_EQUAL('f', *i);
         CPPUNIT_ASSERT(i != e);
         ++i;