From: Christian P. <cp...@us...> - 2005-07-06 13:01:31
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27612/include/pclasses/IO Modified Files: TextStream.h Log Message: - More work on TextStream Index: TextStream.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/TextStream.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- TextStream.h 4 Jul 2005 23:36:13 -0000 1.1 +++ TextStream.h 6 Jul 2005 13:01:05 -0000 1.2 @@ -28,6 +28,7 @@ #include <pclasses/IO/StreamBuffer.h> #include <pclasses/Unicode/String.h> #include <pclasses/Unicode/Converter.h> +#include <pclasses/Unicode/NumberFormat.h> namespace P { @@ -35,6 +36,8 @@ class PIO_EXPORT TextStream: public StreamBase { public: + typedef Unicode::NumberFormat::Style NumberFormat; + TextStream(IODevice& dev, size_t outBufferSize = 1024, size_t inBufferSize = 1024); @@ -42,26 +45,45 @@ ~TextStream() throw(); - //! Number format - enum Format { - Hex, /*!< Print numbers in hexadecimal format */ - Dec, /*!< Print numbers in decimal format */ - Oct /*!< Print numbers in octal fomat */ - }; + //! Set the codepage + /*! + Sets the codepage for the output- and input-conversion. + */ + void setCodePage(const char* cp) throw(Unicode::UnicodeError); + const char* codePage() const throw(); + + //! Set the locale + /*! + Sets the locale for formatting numbers, date and time + values. + */ + void setLocale(const char* loc) throw(Unicode::UnicodeError); + const char* locale() const throw(); //! Set number-format - void setFormat(Format fmt) throw(); + void setNumberFormat(NumberFormat fmt) throw(Unicode::UnicodeError); + NumberFormat numberFormat() const throw(); - //! Set width of numbers + //! Set width of output fields void setWidth(unsigned int width) throw(); + unsigned int width() const throw(); - //! Set floating-point precision - void setPrecision(unsigned int prec) throw(); + enum PadPosition { + BeforePrefix, + AfterPrefix, + BeforeSuffix, + AfterSuffix, + Before = BeforePrefix, + After = AfterSuffix + }; - //! Set fill-character - void setFill(Unicode::Char ch) throw(); + //! Set padding position + void setPadPosition(PadPosition pos) throw(); + PadPosition padPosition() const throw(); - void setCodepage(const char* cp); + //! Set padding character + void setPadChar(Unicode::Char ch) throw(); + Unicode::Char padChar() const throw(); TextStream& operator<<(Int8 val); TextStream& operator<<(UInt8 val); @@ -92,6 +114,8 @@ TextStream& operator<<(const char* str); TextStream& operator<<(const std::string& str); + TextStream& write(const Unicode::String& str); + TextStream& operator>>(Int8& val); TextStream& operator>>(UInt8& val); @@ -119,16 +143,32 @@ TextStream& operator>>(std::string& str); private: - Format _fmt; - unsigned int _width, _prec; - Unicode::Char _fillCh; - Unicode::Converter* _converter; + Unicode::NumberFormat* createNumFormater(NumberFormat fmt, + const char* locale) throw(Unicode::UnicodeError); + + NumberFormat _numFormat; + unsigned int _width; + PadPosition _padPos; + Unicode::Char _padChar; + char* _locale; + char* _codePage; + Unicode::Converter* _converter; + Unicode::NumberFormat* _numFormater; }; -PUNICODE_EXPORT TextStream& endl(TextStream& strm); -PUNICODE_EXPORT TextStream& dec(TextStream& strm); +PIO_EXPORT TextStream& endl(TextStream& strm); + +PIO_EXPORT TextStream& decimal(TextStream& strm); +PIO_EXPORT TextStream& currency(TextStream& strm); +PIO_EXPORT TextStream& percent(TextStream& strm); +PIO_EXPORT TextStream& scientific(TextStream& strm); +PIO_EXPORT TextStream& spellout(TextStream& strm); +PIO_EXPORT TextStream& ordinal(TextStream& strm); + + +/*PUNICODE_EXPORT TextStream& dec(TextStream& strm); PUNICODE_EXPORT TextStream& hex(TextStream& strm); -PUNICODE_EXPORT TextStream& oct(TextStream& strm); +PUNICODE_EXPORT TextStream& oct(TextStream& strm);*/ } // !namespace IO |