From: Mikko Rasa Date: Tue, 4 Sep 2012 06:40:53 +0000 (+0300) Subject: Let the base classes decide the default error mode X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=017feade2799ddbecad62b9a7911bf4d3e229dad;p=libs%2Fcore.git Let the base classes decide the default error mode --- diff --git a/source/stringcodec/ascii.h b/source/stringcodec/ascii.h index b052727..6980494 100644 --- a/source/stringcodec/ascii.h +++ b/source/stringcodec/ascii.h @@ -12,7 +12,7 @@ public: class Encoder: public Codec::Encoder { public: - Encoder(ErrorMode em = THROW_ON_ERROR): Codec::Encoder(em) { } + Encoder(ErrorMode em = DEFAULT): Codec::Encoder(em) { } virtual void encode_char(unichar, std::string &); private: @@ -22,12 +22,12 @@ public: class Decoder: public Codec::Decoder { public: - Decoder(ErrorMode em = THROW_ON_ERROR): Codec::Decoder(em) { } + Decoder(ErrorMode em = DEFAULT): Codec::Decoder(em) { } virtual unichar decode_char(const std::string &, std::string::const_iterator &); }; - Ascii(ErrorMode em = THROW_ON_ERROR): StandardCodec(em) { } + Ascii(ErrorMode em = DEFAULT): StandardCodec(em) { } virtual const char *get_name() const { return "ASCII"; } }; diff --git a/source/stringcodec/codec.cpp b/source/stringcodec/codec.cpp index d1fc1df..865d9c7 100644 --- a/source/stringcodec/codec.cpp +++ b/source/stringcodec/codec.cpp @@ -74,7 +74,7 @@ Codec *create_codec(const string &n) name += *i; } - ErrorMode em = THROW_ON_ERROR; + ErrorMode em = DEFAULT; if(i!=n.end() && *i==':') { string em_str(i+1, n.end()); diff --git a/source/stringcodec/codec.h b/source/stringcodec/codec.h index e0e0a96..d0871ff 100644 --- a/source/stringcodec/codec.h +++ b/source/stringcodec/codec.h @@ -41,7 +41,7 @@ public: protected: ErrorMode err_mode; - Encoder(ErrorMode em): err_mode(em) { } + Encoder(ErrorMode em): err_mode(em==DEFAULT ? THROW_ON_ERROR : em) { } public: virtual ~Encoder() { } @@ -92,7 +92,7 @@ public: protected: ErrorMode err_mode; - Decoder(ErrorMode em): err_mode(em) { } + Decoder(ErrorMode em): err_mode(em==DEFAULT ? THROW_ON_ERROR : em) { } public: virtual ~Decoder() { } diff --git a/source/stringcodec/iso2022jp.h b/source/stringcodec/iso2022jp.h index a3f425a..aa5c78b 100644 --- a/source/stringcodec/iso2022jp.h +++ b/source/stringcodec/iso2022jp.h @@ -22,7 +22,7 @@ public: Mode mode; public: - Encoder(ErrorMode em = THROW_ON_ERROR): Codec::Encoder(em), mode(ASCII) { } + Encoder(ErrorMode em = DEFAULT): Codec::Encoder(em), mode(ASCII) { } virtual void encode_char(unichar, std::string &); virtual void sync(std::string &); @@ -39,7 +39,7 @@ public: Codec::Decoder *dec; public: - Decoder(ErrorMode =THROW_ON_ERROR); + Decoder(ErrorMode = DEFAULT); virtual unichar decode_char(const std::string &, std::string::const_iterator &); virtual void reset(); @@ -47,7 +47,7 @@ public: void switch_mode(Mode); }; - Iso2022Jp(ErrorMode em = THROW_ON_ERROR): StandardCodec(em) { } + Iso2022Jp(ErrorMode em = DEFAULT): StandardCodec(em) { } virtual const char *get_name() const { return "ISO-2022-JP"; } }; diff --git a/source/stringcodec/iso646fi.h b/source/stringcodec/iso646fi.h index 7ded23c..2266c2c 100644 --- a/source/stringcodec/iso646fi.h +++ b/source/stringcodec/iso646fi.h @@ -12,7 +12,7 @@ public: class Encoder: public Codec::Encoder { public: - Encoder(ErrorMode em = THROW_ON_ERROR): Codec::Encoder(em) { } + Encoder(ErrorMode em = DEFAULT): Codec::Encoder(em) { } virtual void encode_char(unichar, std::string &); private: @@ -22,12 +22,12 @@ public: class Decoder: public Codec::Decoder { public: - Decoder(ErrorMode em = THROW_ON_ERROR): Codec::Decoder(em) { } + Decoder(ErrorMode em = DEFAULT): Codec::Decoder(em) { } virtual unichar decode_char(const std::string &, std::string::const_iterator &); }; - Iso646Fi(ErrorMode em = THROW_ON_ERROR): StandardCodec(em) { } + Iso646Fi(ErrorMode em = DEFAULT): StandardCodec(em) { } virtual const char *get_name() const { return "ISO-646-FI"; } }; diff --git a/source/stringcodec/iso88591.h b/source/stringcodec/iso88591.h index 5c59fae..2b5a624 100644 --- a/source/stringcodec/iso88591.h +++ b/source/stringcodec/iso88591.h @@ -12,7 +12,7 @@ public: class Encoder: public Codec::Encoder { public: - Encoder(ErrorMode em = THROW_ON_ERROR): Codec::Encoder(em) { } + Encoder(ErrorMode em = DEFAULT): Codec::Encoder(em) { } virtual void encode_char(unichar, std::string &); private: @@ -22,12 +22,12 @@ public: class Decoder: public Codec::Decoder { public: - Decoder(ErrorMode em = THROW_ON_ERROR): Codec::Decoder(em) { } + Decoder(ErrorMode em = DEFAULT): Codec::Decoder(em) { } virtual unichar decode_char(const std::string &, std::string::const_iterator &); }; - Iso88591(ErrorMode em = THROW_ON_ERROR): StandardCodec(em) { } + Iso88591(ErrorMode em = DEFAULT): StandardCodec(em) { } virtual const char *get_name() const { return "ISO-8859-1"; } }; diff --git a/source/stringcodec/iso885915.h b/source/stringcodec/iso885915.h index 5d65730..ffb3c9a 100644 --- a/source/stringcodec/iso885915.h +++ b/source/stringcodec/iso885915.h @@ -12,7 +12,7 @@ public: class Encoder: public Codec::Encoder { public: - Encoder(ErrorMode em = THROW_ON_ERROR): Codec::Encoder(em) { } + Encoder(ErrorMode em = DEFAULT): Codec::Encoder(em) { } virtual void encode_char(unichar, std::string &); private: @@ -22,12 +22,12 @@ public: class Decoder: public Codec::Decoder { public: - Decoder(ErrorMode em = THROW_ON_ERROR): Codec::Decoder(em) { } + Decoder(ErrorMode em = DEFAULT): Codec::Decoder(em) { } virtual unichar decode_char(const std::string &, std::string::const_iterator &); }; - Iso885915(ErrorMode em = THROW_ON_ERROR): StandardCodec(em) { } + Iso885915(ErrorMode em = DEFAULT): StandardCodec(em) { } virtual const char *get_name() const { return "ISO-8859-15"; } }; diff --git a/source/stringcodec/jisx0201.h b/source/stringcodec/jisx0201.h index 5521d01..1e7c8ef 100644 --- a/source/stringcodec/jisx0201.h +++ b/source/stringcodec/jisx0201.h @@ -12,7 +12,7 @@ public: class Encoder: public Codec::Encoder { public: - Encoder(ErrorMode em = THROW_ON_ERROR): Codec::Encoder(em) { } + Encoder(ErrorMode em = DEFAULT): Codec::Encoder(em) { } virtual void encode_char(unichar, std::string &); private: @@ -22,12 +22,12 @@ public: class Decoder: public Codec::Decoder { public: - Decoder(ErrorMode em = THROW_ON_ERROR): Codec::Decoder(em) { } + Decoder(ErrorMode em = DEFAULT): Codec::Decoder(em) { } virtual unichar decode_char(const std::string &, std::string::const_iterator &); }; - JisX0201(ErrorMode em = THROW_ON_ERROR): StandardCodec(em) { } + JisX0201(ErrorMode em = DEFAULT): StandardCodec(em) { } virtual const char *get_name() const { return "JIS X 0201"; } }; diff --git a/source/stringcodec/jisx0208.h b/source/stringcodec/jisx0208.h index c8e6944..293d277 100644 --- a/source/stringcodec/jisx0208.h +++ b/source/stringcodec/jisx0208.h @@ -17,7 +17,7 @@ public: class Encoder: public Codec::Encoder { public: - Encoder(ErrorMode em = THROW_ON_ERROR): Codec::Encoder(em) { } + Encoder(ErrorMode em = DEFAULT): Codec::Encoder(em) { } virtual void encode_char(unichar, std::string &); private: @@ -27,12 +27,12 @@ public: class Decoder: public Codec::Decoder { public: - Decoder(ErrorMode em = THROW_ON_ERROR): Codec::Decoder(em) { } + Decoder(ErrorMode em = DEFAULT): Codec::Decoder(em) { } virtual unichar decode_char(const std::string &, std::string::const_iterator &); }; - JisX0208(ErrorMode em = THROW_ON_ERROR): StandardCodec(em) { } + JisX0208(ErrorMode em = DEFAULT): StandardCodec(em) { } virtual const char *get_name() const { return "JIS X 0208"; } }; diff --git a/source/stringcodec/utf8.h b/source/stringcodec/utf8.h index fcf23ef..94c627e 100644 --- a/source/stringcodec/utf8.h +++ b/source/stringcodec/utf8.h @@ -12,7 +12,7 @@ public: class Encoder: public Codec::Encoder { public: - Encoder(ErrorMode em = THROW_ON_ERROR): Codec::Encoder(em) { } + Encoder(ErrorMode em = DEFAULT): Codec::Encoder(em) { } virtual void encode_char(unichar, std::string &); private: @@ -22,12 +22,12 @@ public: class Decoder: public Codec::Decoder { public: - Decoder(ErrorMode em = THROW_ON_ERROR): Codec::Decoder(em) { } + Decoder(ErrorMode em = DEFAULT): Codec::Decoder(em) { } virtual unichar decode_char(const std::string &, std::string::const_iterator &); }; - Utf8(ErrorMode em = THROW_ON_ERROR): StandardCodec(em) { } + Utf8(ErrorMode em = DEFAULT): StandardCodec(em) { } virtual const char *get_name() const { return "UTF-8"; } }; diff --git a/source/stringcodec/windows1252.h b/source/stringcodec/windows1252.h index 44d97c9..c5d140f 100644 --- a/source/stringcodec/windows1252.h +++ b/source/stringcodec/windows1252.h @@ -12,7 +12,7 @@ public: class Encoder: public Codec::Encoder { public: - Encoder(ErrorMode em = THROW_ON_ERROR): Codec::Encoder(em) { } + Encoder(ErrorMode em = DEFAULT): Codec::Encoder(em) { } virtual void encode_char(unichar, std::string &); private: @@ -22,12 +22,12 @@ public: class Decoder: public Codec::Decoder { public: - Decoder(ErrorMode em = THROW_ON_ERROR): Codec::Decoder(em) { } + Decoder(ErrorMode em = DEFAULT): Codec::Decoder(em) { } virtual unichar decode_char(const std::string &, std::string::const_iterator &); }; - Windows1252(ErrorMode em = THROW_ON_ERROR): StandardCodec(em) { } + Windows1252(ErrorMode em = DEFAULT): StandardCodec(em) { } virtual const char *get_name() const { return "Windows-1252"; } };