From ebd23ef7dde39a35e9ffdfb5be31934507cefaad Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 18 Mar 2007 16:47:23 +0000 Subject: [PATCH] Corrected style errors --- source/codec.h | 15 ++++++++------- source/iso2022jp.cpp | 2 +- source/jisx0208.cpp | 4 ++-- source/latin1.cpp | 2 +- source/utils.cpp | 8 ++++---- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/source/codec.h b/source/codec.h index 8ea9991..d5ba595 100644 --- a/source/codec.h +++ b/source/codec.h @@ -17,12 +17,13 @@ public: }; /** -Base class for string codecs. Mostly abstract. Use one of the derived classes -or the function create_codec to create a specific codec. +Base class for string codecs. Use one of the derived classes or the function +create_codec to create a specific codec. For the purposes of this class, an std::wstring is considered to contain Unicode characters and an std::string is considered to be an encoded sequence -of bytes. Codecs are able to determine if an encoded string could be +of bytes. A codec is able to determine if an encoded string could be decoded +with it. */ class StringCodec { @@ -39,13 +40,13 @@ public: function to put the result into the internal buffer. */ virtual void encode_char(wchar_t) =0; - + /** Encodes a string. */ virtual void encode(const std::wstring &s) { for(std::wstring::const_iterator i=s.begin(); i!=s.end(); ++i) encode_char(*i); } - + /** Brings the encoder back to its initial state. This allows the encoded sequence to be extracted or flushed without loss of integrity. @@ -62,7 +63,7 @@ public: Returns the number of bytes in the output buffer. */ unsigned size() const { return buffer_.size(); } - + /** Clears the encoded sequence. Encoder state is left intact. */ @@ -116,7 +117,7 @@ protected: }; /** -Convenience function that decodes a string using the given codec. +Convenience function that decodes a string using the given codec. */ template std::wstring decode(const std::string &s) diff --git a/source/iso2022jp.cpp b/source/iso2022jp.cpp index 6a6bd1d..806dca1 100644 --- a/source/iso2022jp.cpp +++ b/source/iso2022jp.cpp @@ -72,7 +72,7 @@ void Iso2022Jp::Decoder::decode_char(const string &str, string::const_iterator & { if(escape) { - escape=escape<<8 | (unsigned char)*i; + escape=escape<<8 | static_cast(*i); if(*i>='@' && *i<='Z') { switch(escape) diff --git a/source/jisx0208.cpp b/source/jisx0208.cpp index 0f0e73d..477ccd0 100644 --- a/source/jisx0208.cpp +++ b/source/jisx0208.cpp @@ -60,11 +60,11 @@ unsigned short ucs_to_jisx0208(wchar_t c) { if(i+bit>=ucs_to_jisx0208_table_size) continue; - if(ucs_to_jisx0208_table[i+bit].ucs<=(unsigned short)c) + if(ucs_to_jisx0208_table[i+bit].ucs<=static_cast(c)) i+=bit; } - if(ucs_to_jisx0208_table[i].ucs==(unsigned short)c) + if(ucs_to_jisx0208_table[i].ucs==static_cast(c)) return ucs_to_jisx0208_table[i].jis; return 0; } diff --git a/source/latin1.cpp b/source/latin1.cpp index b95b011..fe9e1a4 100644 --- a/source/latin1.cpp +++ b/source/latin1.cpp @@ -15,7 +15,7 @@ void Latin1::Decoder::decode_char(const string &str, string::const_iterator &i) { if(i==str.end()) return; - append((unsigned char)*i++); + append(static_cast(*i++)); } } // namespace Msp diff --git a/source/utils.cpp b/source/utils.cpp index 3ef7b79..55b191f 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -33,7 +33,7 @@ Returns a lowercase copy of the given string. */ string tolower(const string &str) { - string result(str); + string result(str); transform(result.begin(), result.end(), result.begin(), ::tolower); return result; } @@ -43,7 +43,7 @@ Returns an uppercase copy of the given string. */ string toupper(const string &str) { - string result(str); + string result(str); transform(result.begin(), result.end(), result.begin(), ::toupper); return result; } @@ -62,7 +62,7 @@ vector split(const string &str, const string &sep, bool allow_empty) unsigned start=str.find_first_not_of(sep); while(start split(const string &str, const string &sep, bool allow_empty) vector split(const string &str, char sep, bool allow_empty) { - return split(str, string(1,sep), allow_empty); + return split(str, string(1, sep), allow_empty); } /** -- 2.43.0