From: Christian P. <cp...@us...> - 2005-07-06 12:59:20
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25949/include/pclasses/Unicode Modified Files: Converter.h Char.h Makefile.am Added Files: NumberFormat.h Log Message: - Renamed Unicode::Char::nl() to Unicode::Char::lf() - Added some documentation and methods to Unicode::Converter - Added Unicode::NumberFormat Index: Char.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Unicode/Char.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Char.h 24 May 2005 02:32:59 -0000 1.7 +++ Char.h 6 Jul 2005 12:59:09 -0000 1.8 @@ -80,7 +80,7 @@ bool operator>=(const Char& ch) const throw(); static const Char& eof() throw(); - static const Char& nl() throw(); + static const Char& lf() throw(); static const Char& cr() throw(); private: Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Unicode/Makefile.am,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Makefile.am 4 Jul 2005 23:36:14 -0000 1.6 +++ Makefile.am 6 Jul 2005 12:59:09 -0000 1.7 @@ -2,4 +2,5 @@ INCLUDES = METASOURCES = AUTO -pclasses_unicode_include_HEADERS = Char.h String.h Converter.h UnicodeError.h +pclasses_unicode_include_HEADERS = Char.h String.h Converter.h UnicodeError.h \ + NumberFormat.h Index: Converter.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Unicode/Converter.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Converter.h 24 May 2005 02:32:59 -0000 1.1 +++ Converter.h 6 Jul 2005 12:59:09 -0000 1.2 @@ -26,22 +26,77 @@ #include <pclasses/Unicode/UnicodeError.h> #include <string> +#include <vector> namespace P { namespace Unicode { +//! UNICODE Charset converter +/*! + The converter class is used to convert UNICODE strings + to and from different charsets. + + This class is utilizes the ICU character conversion library, + for more information see http://icu.sourceforge.net. + + @todo add streaming conversion methods ... +*/ class PUNICODE_EXPORT Converter { public: + typedef std::vector<std::string> StringVector; + + //! Creates a Converter object with the name specified as a C string + /*! + The actual name will be resolved with the alias file using a + case-insensitive string comparison that ignores the delimiters + '-', '_', and ' ' (dash, underscore, and space). E.g., the names + "UTF8", "utf-8", and "Utf 8" are all equivalent. If NULL is passed + for the converter name, it will create one with the systems default + converter name. + + Options are appended to the converter name string, with a ',' between + the name and the first option and also between adjacent options. + + \param name Name of the uconv table, may have options appended + \throw UnicodeError + */ Converter(const char* name) throw(UnicodeError); ~Converter() throw(); + //! Returns the internal, canonical name of the converter + std::string name() const throw(UnicodeError); + + //! Returns the display name of the converter + /*! + Returns the display name of the converter based on the locale passed + that was passid in. + If the locale contains no display name, the internal ASCII name will + be filled in. + \param locale the locale the name should be localised for + \throw UnicodeError + */ + String displayName(const char* locale) const throw(UnicodeError); + + //! Converts a string in the converters charset to UNICODE String toUnicode(const std::string& str) throw(UnicodeError); + + //! Converts a string in the converters charset to UNICODE String toUnicode(const char* str, size_t count = String::npos) throw(UnicodeError); + //! Converts a UNICODE string to the converters charset std::string fromUnicode(const String& str) throw(UnicodeError); + //! Converts a UNICODE character to the converters charset + std::string fromUnicode(Char ch) throw(UnicodeError); + + //! Returns the canonical names of all known converters + static StringVector availableNames() throw(UnicodeError); + + //! Returns the aliases for a given converter or alias name + static StringVector aliasNames(const std::string& name) throw(UnicodeError); + private: void* _private; }; --- NEW FILE: NumberFormat.h --- /*************************************************************************** * Copyright (C) 2005 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef P_Unicode_NumberFormat_h #define P_Unicode_NumberFormat_h #include <pclasses/Export.h> #include <pclasses/Unicode/UnicodeError.h> #include <pclasses/Unicode/Char.h> #include <pclasses/Unicode/String.h> namespace P { namespace Unicode { class PUNICODE_EXPORT NumberFormat { public: enum Style { Decimal, Currency, Percent, Scientific, Spellout, Ordinal }; NumberFormat(Style s, const char* locale); ~NumberFormat() throw(); void setWidth(unsigned int width); unsigned int width() const throw(); enum PadPosition { BeforePrefix, AfterPrefix, BeforeSuffix, AfterSuffix }; void setPadPosition(PadPosition p); PadPosition padPosition() const throw(); void setPadChar(Char ch); Char padChar() const throw(); void setPositivePrefix(Char ch); Char positivePrefix(); void setPositiveSuffix(Char ch); Char positiveSuffix(); void setNegativePrefix(Char ch); Char negativePrefix(); void setNegativeSuffix(Char ch); Char negativeSuffix(); String format(Int32 val) throw(UnicodeError); String format(Int64 val) throw(UnicodeError); String format(double val) throw(UnicodeError); private: void* _private; }; } // !namespace Unicode } // !namespace P #endif |