string_maker.h

来自「这是一个银行系统的管理软件」· C头文件 代码 · 共 58 行

H
58
字号
/**********************************************************************************
*                                                                                 *
*  Copyright (c) 2003 - 2004 by Royal. All rights reserved.                       *
*                                                                                 *
*  Permission to use, copy, modify, and distribute this software for any purpose  *
*  is hereby granted without fee, provided that this copyright and permissions    *
*  notice appear in all copies and derivatives, and that no charge may be made    *
*  for the software and its documentation except to cover cost of distribution.   *
*                                                                                 *
*  This software is provided "as is" without express or implied warranty.         *
*                                                                                 *
**********************************************************************************/

/*
*  Description:
*
*    A helper class that implements function as "format" string.
*
*  History:
*
*    Initial version created by Royal, January 2003.
*
*  Notes:
*
*    This code has been written to conform to standard C++ and STL. It has been
*    compiled successfully using GNU C++ 3.2, Borland C++ 5.5, and Visual C++ 7.0.
*/

#ifndef STRING_MAKER_H
#define STRING_MAKER_H

#include <sstream>
#include <string>

namespace dragon
{

class String_maker
{
public:
    template <class T> 
    String_maker& operator << (const T& t) 
    { 
        osm_ << t; 
        return *this; 
    }        
    operator std::string () const 
    { 
        return osm_.str(); 
    }    
private:
    std::ostringstream osm_;
};

} // namespace dragon

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?