From: stephan b. <sg...@us...> - 2004-12-28 15:56:37
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3385/include/pclasses/Util Modified Files: LexT.h Log Message: - Moved the s11n proxy support to another file. - "Fixed" the istream>> to not skip newlines (but the impl is still very arguable). Index: LexT.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Util/LexT.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- LexT.h 26 Dec 2004 14:43:03 -0000 1.3 +++ LexT.h 28 Dec 2004 15:56:23 -0000 1.4 @@ -1,7 +1,9 @@ #ifndef p_UTIL_LEXT_HPP_INCLUDED #define p_UTIL_LEXT_HPP_INCLUDED 1 //////////////////////////////////////////////////////////////////////// -// LexT.h: the P::Util::LexT class +// LexT.h: the P::Util::LexT class, a simple class for lexically casting +// i/ostreamable types. +// // author: st...@s1... // License: Public Domain //////////////////////////////////////////////////////////////////////// @@ -15,6 +17,9 @@ /** The functions in the Private namespace should not be used by client code. + + TODO: get rid of this stuff and use P::Util::StringTool + instead. */ namespace Private { @@ -165,13 +170,22 @@ This software is released into the Public Domain by it's author, stephan beal (st...@s1...). + If you want this class to work with the SIO framework you + must include the following header: + + <pclasses/s11n/proxy/LexT_s11n.h> + + Change history: + 28 Dec 2004: + - Changed the impl of istream>>() to use getc() instead of getline(), + so newlines are preserved. + 25 Dec 2004: - Ported into the P::Classes tree. Renamed the class and some functions for P's naming conventions. - 25 Nov 2004: - Minor doc updates. - Changed multiple-include guard to allow inclusion of this file twice @@ -421,7 +435,12 @@ */ inline std::istream & operator>>( std::istream & is, LexT & a ) { - while( std::getline( is, a.str() ).good() ); + char c; + // while( std::getline( is, a.str() ).good() ); + // ^^^ eeek! strips newlines! + while( ! is.get(c).eof() ) { + a.str().append( &c ); + } return is; } @@ -467,22 +486,3 @@ #endif // p_UTIL_LEXT_HPP_INCLUDED - - -//////////////////////////////////////////////////////////////////////// -#ifdef PCLASSES_S11N_INCLUDED -# ifndef p_UTIL_LEXT_REGISTERED_WITH_S11N -# define p_UTIL_LEXT_REGISTERED_WITH_S11N 1 -// We have s11n! Let's use it! -// Plug in a proxy for LexT, to make it work like a Streamable... -# include <pclasses/s11n/data_node_functor.h> // <-- s11n::streamable_type_serialization_proxy class -# include <pclasses/s11n/pods_streamable.h> // <-- required for s11n 0.9.14+ -# define PS11N_TYPE ::P::Util::LexT // <-- type of object to be treated as a Serializable -# define PS11N_TYPE_NAME "LexT" // <-- class name (for the classloader) -# define PS11N_SERIALIZE_FUNCTOR ::P::s11n::streamable_type_serialization_proxy - // ^^^^ our de/s11n implementation (proxy functor) -# include <pclasses/s11n/reg_serializable_traits.h> // <-- register the above data with s11n -# endif // p_UTIL_LEXT_REGISTERED_WITH_S11N -#endif // PCLASSES_S11N_INCLUDED -//////////////////////////////////////////////////////////////////////// - |