Add hidl_vec iterator and hidl_string ==

Add bidirectional iterator for hidl_vec
Add operator== and operator!= for hidl_string to hidl_string
comparision.

Test:  Added unit tests to libhidl_test
Change-Id: I908bc71fae4016f335e2342f28b351f63f22fa66
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index 0da0e37..c604f56 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -20,6 +20,7 @@
 #include <algorithm>
 #include <dirent.h>
 #include <dlfcn.h>
+#include <iterator>
 #include <cutils/properties.h>
 #include <functional>
 #include <hidl/Status.h>
@@ -158,6 +159,14 @@
     void moveFrom(hidl_string &&);
 };
 
+inline bool operator==(const hidl_string &hs1, const hidl_string &hs2) {
+    return strcmp(hs1.c_str(), hs2.c_str()) == 0;
+}
+
+inline bool operator!=(const hidl_string &hs1, const hidl_string &hs2) {
+    return !(hs1 == hs2);
+}
+
 inline bool operator==(const hidl_string &hs, const char *s) {
     return strcmp(hs.c_str(), s) == 0;
 }
@@ -319,6 +328,27 @@
 
     // offsetof(hidl_string, mBuffer) exposed since mBuffer is private.
     static const size_t kOffsetOfBuffer;
+
+    // Define std interator interface for walking the array contents
+    // TODO:  it might be nice to implement a full featured random access iterator...
+    class iterator : public std::iterator<std::bidirectional_iterator_tag, T>
+    {
+    public:
+        iterator(T* ptr) : mPtr(ptr) { }
+        iterator operator++()    { iterator i = *this; mPtr++; return i; }
+        iterator operator++(int) { mPtr++; return *this; }
+        iterator operator--()    { iterator i = *this; mPtr--; return i; }
+        iterator operator--(int) { mPtr--; return *this; }
+        T& operator*()  { return *mPtr; }
+        T* operator->() { return mPtr; }
+        bool operator==(const iterator& rhs) const { return mPtr == rhs.mPtr; }
+        bool operator!=(const iterator& rhs) const { return mPtr != rhs.mPtr; }
+    private:
+        T* mPtr;
+    };
+    iterator begin() { return data(); }
+    iterator end() { return data()+mSize; }
+
 private:
     details::hidl_pointer<T> mBuffer;
     uint32_t mSize;