summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-08-28 20:45:06 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-08-28 20:45:06 +0100
commit9636fe20c5e2eda44b65d29c7b59f2cb69a5b47a (patch)
treeb0a7870a122acb81c3716fc932bf8e5f4d9e41ca
parentSupport std::string fragment storage, reduce copy overheads, better control (diff)
downloadlibadhocutil-9636fe20c5e2eda44b65d29c7b59f2cb69a5b47a.tar.bz2
libadhocutil-9636fe20c5e2eda44b65d29c7b59f2cb69a5b47a.tar.xz
libadhocutil-9636fe20c5e2eda44b65d29c7b59f2cb69a5b47a.zip
Migrate formatted string wrappers as macros into buffer.h
-rw-r--r--libadhocutil/buffer.h5
-rw-r--r--libadhocutil/unittests/testBuffer.cpp5
2 files changed, 10 insertions, 0 deletions
diff --git a/libadhocutil/buffer.h b/libadhocutil/buffer.h
index aa1560a..ff1e250 100644
--- a/libadhocutil/buffer.h
+++ b/libadhocutil/buffer.h
@@ -117,5 +117,10 @@ class DLL_PUBLIC Buffer : public virtual IntrusivePtrBase {
};
Buffer::FragmentBase::~FragmentBase() = default;
+// libmisc compat macros
+#define vstringf Buffer().vappendf
+#define stringf Buffer().appendf
+#define stringbf Buffer().appendbf
+
#endif
diff --git a/libadhocutil/unittests/testBuffer.cpp b/libadhocutil/unittests/testBuffer.cpp
index 9c1c956..dce9f66 100644
--- a/libadhocutil/unittests/testBuffer.cpp
+++ b/libadhocutil/unittests/testBuffer.cpp
@@ -115,5 +115,10 @@ BOOST_AUTO_TEST_CASE( replacesstringbf )
{
auto str = Buffer().appendbf("something %d", 1234).str();
BOOST_REQUIRE_EQUAL("something 1234", str);
+
+ std::string macrostringf = stringf("something %d", 1234);
+ BOOST_REQUIRE_EQUAL("something 1234", macrostringf);
+ std::string macrostringbf = stringbf("something %d", 1234);
+ BOOST_REQUIRE_EQUAL("something 1234", macrostringbf);
}