Add filename() and parent_path() methods to object_path

In practice, one very common operation done on a dbus path is to get the
final member name in the dbus path, to use as unique IDs, or to pass
items to public interfaces.  This tends to lead to something like:

size_t pos = object_path.str.rfind('/');
if(pos == std::string::npos){
   // handle error
}
pos++;
if (pos >= object_path.str.size()){
   // handle error
}

std::string name = object_path.str.substr(pos);

As an aside, what I've written above is one of several "right" ways to
do it, and is among many other wrong ways that I've seen people try to
check in.  The goal of this patchset is to add the above code as a
method within object_path, to help people to use it, and to avoid using
object_path.str, which ideally would be a private member of that class.

Functionally, accomplishing the above this requires splitting
string_wrapper into two separate classes, as we continue to need the
string_wrapper instance to handle the signature type, but filename() and
parent_path() on signature are non-sensical.  Therefore, this splits the
functionality into string_wrapper and string_path_wrapper, each of which
no longer need to be a template, given there is only one use.  We could
also get rid of the using, and move these classes out of details, but
that seemed better reserved for a later patch.

Tested:
Unit tests written and passing.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I242d1965875ba1fe76a32fd78e381e90796706fc
diff --git a/test/message/types.cpp b/test/message/types.cpp
index 89cab14..9f82f0a 100644
--- a/test/message/types.cpp
+++ b/test/message/types.cpp
@@ -41,6 +41,28 @@
     ASSERT_EQ(dbus_string(sdbusplus::message::object_path("/asdf")), "o");
 }
 
+TEST(MessageTypes, ObjectPathLeaf)
+{
+    ASSERT_EQ(sdbusplus::message::object_path("/abc/def").filename(), "def");
+    ASSERT_EQ(sdbusplus::message::object_path("/abc/").filename(), "");
+    ASSERT_EQ(sdbusplus::message::object_path("/abc").filename(), "abc");
+    ASSERT_EQ(sdbusplus::message::object_path("/").filename(), "");
+    ASSERT_EQ(sdbusplus::message::object_path("").filename(), "");
+    ASSERT_EQ(sdbusplus::message::object_path("abc").filename(), "");
+}
+
+TEST(MessageTypes, ObjectPathParent)
+{
+    ASSERT_EQ(sdbusplus::message::object_path("/abc/def").parent_path(),
+              sdbusplus::message::object_path("/abc"));
+    ASSERT_EQ(sdbusplus::message::object_path("/abc/").parent_path(),
+              sdbusplus::message::object_path("/abc"));
+    ASSERT_EQ(sdbusplus::message::object_path("/abc").parent_path(),
+              sdbusplus::message::object_path("/"));
+    ASSERT_EQ(sdbusplus::message::object_path("/").parent_path(),
+              sdbusplus::message::object_path("/"));
+}
+
 TEST(MessageTypes, Signature)
 {
     ASSERT_EQ(dbus_string(sdbusplus::message::signature("sss")), "g");