encoding: In OID, make toString, operator== and operator!= const. Refs #1091.
diff --git a/include/ndn-cpp/encoding/oid.hpp b/include/ndn-cpp/encoding/oid.hpp
index bc0dd25..f217889 100644
--- a/include/ndn-cpp/encoding/oid.hpp
+++ b/include/ndn-cpp/encoding/oid.hpp
@@ -39,20 +39,20 @@
}
std::string
- toString();
+ toString() const;
- bool operator == (const OID& oid)
+ bool operator == (const OID& oid) const
{
return equal(oid);
}
- bool operator != (const OID& oid)
+ bool operator != (const OID& oid) const
{
return !equal(oid);
}
private:
- bool equal(const OID& oid);
+ bool equal(const OID& oid) const;
std::vector<int> oid_;
};
diff --git a/src/encoding/oid.cpp b/src/encoding/oid.cpp
index db1fbc3..633d1cf 100644
--- a/src/encoding/oid.cpp
+++ b/src/encoding/oid.cpp
@@ -34,11 +34,11 @@
}
}
-string OID::toString()
+string OID::toString() const
{
ostringstream convert;
- vector<int>::iterator it = oid_.begin();
+ vector<int>::const_iterator it = oid_.begin();
for(; it < oid_.end(); it++){
if(it != oid_.begin())
convert << ".";
@@ -48,7 +48,7 @@
return convert.str();
}
-bool OID::equal(const OID& oid)
+bool OID::equal(const OID& oid) const
{
vector<int>::const_iterator i = oid_.begin();
vector<int>::const_iterator j = oid.oid_.begin();