]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added new methods to String class:
authorwessels <>
Wed, 28 Sep 2005 02:37:42 +0000 (02:37 +0000)
committerwessels <>
Wed, 28 Sep 2005 02:37:42 +0000 (02:37 +0000)
    cmp(String)
    operator ==
    operator !=

These are not currently used in HEAD, but they are used in a sourceforge
branch and may be useful for others now or in the future.

src/SquidString.h
src/String.cc
src/String.cci

index f41ecbdff4e0f7afb9c2513f773b8f3455d27648..a99f652e21530d3c49aa076c253ce5f6bfce2529 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: SquidString.h,v 1.5 2003/03/10 04:56:36 robertc Exp $
+ * $Id: SquidString.h,v 1.6 2005/09/27 20:37:42 wessels Exp $
  *
  * DEBUG: section 67    String
  * AUTHOR: Duane Wessels
@@ -84,6 +84,8 @@ public:
 
     String &operator =(char const *);
     String &operator =(String const &);
+    bool operator ==(String const &) const;
+    bool operator !=(String const &) const;
 
     _SQUID_INLINE_ int size() const;
     _SQUID_INLINE_ char const * buf() const;
@@ -103,6 +105,7 @@ public:
     _SQUID_INLINE_ const char * rpos(char const ch) const;
     _SQUID_INLINE_ int cmp (char const *) const;
     _SQUID_INLINE_ int cmp (char const *, size_t count) const;
+    _SQUID_INLINE_ int cmp (String const &) const;
     _SQUID_INLINE_ int caseCmp (char const *) const;
     _SQUID_INLINE_ int caseCmp (char const *, size_t count) const;
 
index b6551459b2263d9f23e350fb2cf0cde7be36aa91..ee115e37d211ec0c49753ae64cdee855dabd252b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: String.cc,v 1.19 2005/01/03 16:08:25 robertc Exp $
+ * $Id: String.cc,v 1.20 2005/09/27 20:37:42 wessels Exp $
  *
  * DEBUG: section 67    String
  * AUTHOR: Duane Wessels
@@ -83,6 +83,24 @@ String::operator = (String const &old)
     return *this;
 }
 
+bool
+String::operator == (String const &that) const
+{
+    if (0 == this->cmp(that))
+        return true;
+
+    return false;
+}
+
+bool
+String::operator != (String const &that) const
+{
+    if (0 == this->cmp(that))
+        return false;
+
+    return true;
+}
+
 void
 String::limitInit(const char *str, int len)
 {
index 045821c5e6079a14aefe65345fd7fdd9630c7aef..4e6e1d77bca8bbb04bbf9aa2d1e1ad97be2a7384 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: String.cci,v 1.3 2003/03/06 11:51:55 robertc Exp $
+ * $Id: String.cci,v 1.4 2005/09/27 20:37:42 wessels Exp $
  *
  * DEBUG: section 67    String
  * AUTHOR: Duane Wessels
@@ -82,6 +82,12 @@ String::cmp (char const *aString, size_t count) const
     return strncmp(buf(), aString, count);
 }
 
+int
+String::cmp (String const &aString) const
+{
+    return strcmp(buf(), aString.buf());
+}
+
 int
 String::caseCmp (char const *aString) const
 {