📄 tostr.h
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright (C) Yeico S. A. de C. V. * * $Source: /cvsroot/xlslib/xlslib/src/xlslib/tostr.h,v $ * $Revision: 1.1.1.1 $ * $Author: darioglz $ * $Date: 2004/08/27 16:31:54 $ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * File description: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */#ifndef TOSTR_H#define TOSTR_H#include <config.h>#include <string>#include <sstream>#include <iostream> // forward declarationstruct str_stream;// ... helper - allow explicit conversion to stringclass as_string {};inline std::ostream & operator<< ( std::ostream & streamOut, const as_string &){ return streamOut;}namespace Private{ // what should we return when calling write_to_stream ? template< class type> struct return_from_write_to_stream { typedef const str_stream & return_type; }; template<> struct return_from_write_to_stream< as_string> { typedef std::string return_type; }; // forward declaration template< class type> inline typename return_from_write_to_stream< type>::return_type write_to_stream ( const str_stream & streamOut, const type & value);} // forward declarationtemplate< class type>inline typename Private::return_from_write_to_stream< type>::return_type operator<< ( const str_stream & streamOut, const type & value);// str_stream - allow stream usage, and then conversion to stringstruct str_stream{ // default construction str_stream(){} // allow to_string like usage template< class type> str_stream( const type & value) { *this << value; } std::stringstream & underlying_stream() const { return m_streamOut; } operator std::string() const { return m_streamOut.str(); } private: mutable std::stringstream m_streamOut;#ifndef NDEBUG public: void recalculate_string() const { m_string = m_streamOut.str(); } private: mutable std::string m_string;#endif};namespace Private{ template< class type> inline typename return_from_write_to_stream< type>::return_type write_to_stream ( const str_stream & streamOut, const type & value) { streamOut.underlying_stream() << value;#ifndef NDEBUG streamOut.recalculate_string();#endif return streamOut; }}template< class type>inline typename Private::return_from_write_to_stream< type>::return_type operator<< ( const str_stream & streamOut, const type & value){ return Private::write_to_stream( streamOut, value) ;} // allow function IO manipulatorsinline const str_stream & operator<< ( const str_stream & streamOut, std::ios_base & (*func)( std::ios_base&) ){ func( streamOut.underlying_stream()); return streamOut;}inline const str_stream & operator<< ( const str_stream & streamOut, std::basic_ios< char> & (*func)( std::basic_ios< char> &) ){ func( streamOut.underlying_stream()); return streamOut;}inline const str_stream & operator<< ( const str_stream & streamOut, std::ostream & (*func)( std::ostream &) ){ func( streamOut.underlying_stream()); return streamOut;}#endif //TOSTR_H/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * $Log: tostr.h,v $ * Revision 1.1.1.1 2004/08/27 16:31:54 darioglz * Initial Import. * * Revision 1.2 2004/01/29 03:18:55 dgonzalez * + Using the config.h file * * Revision 1.1 2003/12/02 18:15:06 dgonzalez * + Initial version. Added to handle signatures of objects * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -