From b011b17393069d86790b2291a759280e15c75a0f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 2 Jun 2011 18:15:13 +0300 Subject: [PATCH] Rewrite string codec utility functions more compactly --- source/stringcodec/codec.h | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/source/stringcodec/codec.h b/source/stringcodec/codec.h index ab2a3ea..a307e2e 100644 --- a/source/stringcodec/codec.h +++ b/source/stringcodec/codec.h @@ -154,9 +154,7 @@ template ustring decode(const std::string &s) { typename C::Decoder dec; - ustring result; - dec.decode(s, result); - return result; + return dec.decode(s); } /** Convenience function that encodes a string. */ @@ -164,24 +162,14 @@ template std::string encode(const ustring &s) { typename C::Encoder enc; - std::string result; - enc.encode(s, result); - enc.sync(result); - return result; + return enc.encode(s); } /** Convenience function that transcodes a string from one codec to another. */ template std::string transcode(const std::string &s) { - typename F::Decoder from; - typename T::Encoder to; - ustring temp; - from.decode(s, temp); - std::string result; - to.encode(temp, result); - to.sync(result); - return result; + return encode(decode(s)); } /** Creates a codec for an encoding by name. The caller is responsible for -- 2.45.2