Implement operator /= for object_path

This probably should've been implemented as part of
fa0fa3b0fa5a9d59c37b6edbc53cc21b7c2a16b0 Implement path encoding and
decoding but alas, it was not.  This commit adds the relatively simple
operator/= overloads to object_path.  This allows calling code to do
operations like:

object_path myPath("/foo");
myPath /= "bar";

Which would result in the object path /foo/bar.

In the implementation, this actually just calls into operator/, and does
a relatively naive replace of the content in the new object.  Given how
the sd_bus_path_encode API is organized, there doesn't appear to be a
way to call into it and "append" to an existing thing, so constructing a
new string and assigning it to the current object was the best I could
come up with in terms of efficiency.

This includes overloads for both const char* and const std::string&,
both of which have essentially the same behavior.

Tested:
New unit tests included in commit, and pass.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Idfb7f7f2dc94ea3773841c9ae62cd671327db2cd
diff --git a/include/sdbusplus/message/native_types.hpp b/include/sdbusplus/message/native_types.hpp
index f93d775..4d41879 100644
--- a/include/sdbusplus/message/native_types.hpp
+++ b/include/sdbusplus/message/native_types.hpp
@@ -189,6 +189,20 @@
         out.str = encOut;
         return out;
     }
+
+    string_path_wrapper& operator/=(const char* extId)
+    {
+        string_path_wrapper out = this->operator/(extId);
+        this->str = std::move(out.str);
+        return *this;
+    }
+
+    string_path_wrapper& operator/=(const std::string& extId)
+    {
+        string_path_wrapper out = this->operator/(extId);
+        this->str = std::move(out.str);
+        return *this;
+    }
 };
 
 /** Typename for sdbus SIGNATURE types. */
diff --git a/test/message/types.cpp b/test/message/types.cpp
index b47d39b..530fbc3 100644
--- a/test/message/types.cpp
+++ b/test/message/types.cpp
@@ -84,6 +84,17 @@
               sdbusplus::message::object_path("/abc"));
 }
 
+TEST(MessageTypes, ObjectPathOperatorSlashEqual)
+{
+    sdbusplus::message::object_path path("/");
+    path /= "abc";
+    ASSERT_EQ(path, sdbusplus::message::object_path("/abc"));
+
+    sdbusplus::message::object_path path2("/");
+    path2 /= std::string("def");
+    ASSERT_EQ(path2, sdbusplus::message::object_path("/def"));
+}
+
 TEST(MessageTypes, Signature)
 {
     ASSERT_EQ(dbus_string(sdbusplus::message::signature("sss")), "g");