]> git.tdb.fi Git - libs/core.git/blobdiff - source/codec.h
Add convenience functions to Encoder and Decoder to process a string and return the...
[libs/core.git] / source / codec.h
index 3470ccc68e6c65ad4890f499a54b41c88fa91256..e8b172eb5af068004d6ad051642ced663a2b9608 100644 (file)
@@ -9,7 +9,7 @@ Distributed under the LGPL
 #define MSP_STRINGS_CODEC_H_
 
 #include <string>
-#include <msp/core/error.h>
+#include <msp/core/except.h>
 
 namespace Msp {
 namespace Codecs {
@@ -79,6 +79,8 @@ public:
                */
                virtual void encode(const ustring &str, std::string &buf);
 
+               std::string encode(const ustring &);
+
                /**
                Procuces a sequence of bytes that will bring the encoder back to the
                initial state.
@@ -143,6 +145,8 @@ public:
                */
                virtual void decode(const std::string &str, ustring &buf);
 
+               ustring decode(const std::string &);
+
                /**
                Resets the decoder to the initial state.
                */
@@ -160,6 +164,11 @@ public:
 
        virtual ~Codec() { }
 
+       /**
+       Returns the name of the encoding handled by this codec.
+       */
+       virtual const char *get_name() const =0;
+
        /**
        Creates an encoder for this codec.
        */
@@ -231,6 +240,12 @@ deleting the codec when it's no longer needed.
 */
 Codec *create_codec(const std::string &);
 
+/**
+Automatically detects the encoding of a string and creates a codec for it.
+The codec must be deleted when it's no longer needed.
+*/
+Codec *detect_codec(const std::string &);
+
 } // namespace Codecs
 } // namespace Msp