]> 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 bb35b0b43528ca4eba14dc66682f43ae26bca651..e8b172eb5af068004d6ad051642ced663a2b9608 100644 (file)
@@ -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