Add wrbuf.c_str() and wrbuf.c_str_null()
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 11 Apr 2014 08:49:03 +0000 (10:49 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 11 Apr 2014 08:49:03 +0000 (10:49 +0200)
include/metaproxy/util.hpp
src/util.cpp

index 26b9c1e..2377f5f 100644 (file)
@@ -169,6 +169,8 @@ namespace metaproxy_1 {
         operator WRBUF() const;
         size_t len();
         const char *buf();
+        const char *c_str();
+        const char *c_str_null();
     private:
         WRBUF m_wrbuf;
     };
index 514553f..732e552 100644 (file)
@@ -727,6 +727,17 @@ const char *mp::wrbuf::buf()
     return wrbuf_buf(m_wrbuf);
 }
 
+const char *mp::wrbuf::c_str()
+{
+    return wrbuf_cstr(m_wrbuf);
+}
+
+const char *mp::wrbuf::c_str_null()
+{
+    if (wrbuf_len(m_wrbuf))
+        return wrbuf_cstr(m_wrbuf);
+    return 0;
+}
 
 /*
  * Local variables: