From: Adam Dickmeiss Date: Fri, 11 Apr 2014 08:49:03 +0000 (+0200) Subject: Add wrbuf.c_str() and wrbuf.c_str_null() X-Git-Tag: v1.5.0~8 X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=commitdiff_plain;h=8b1aea41996929289581cd25091af0e528e0019d;hp=6b53d99d063b40491100575eeaa4996303ef21f1;p=metaproxy-moved-to-github.git Add wrbuf.c_str() and wrbuf.c_str_null() --- diff --git a/include/metaproxy/util.hpp b/include/metaproxy/util.hpp index 26b9c1e..2377f5f 100644 --- a/include/metaproxy/util.hpp +++ b/include/metaproxy/util.hpp @@ -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; }; diff --git a/src/util.cpp b/src/util.cpp index 514553f..732e552 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -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: