当前位置: 首页>>代码示例>>C++>>正文


C++ std::stringstream类代码示例

本文整理汇总了C++中std::stringstream的典型用法代码示例。如果您正苦于以下问题:C++ stringstream类的具体用法?C++ stringstream怎么用?C++ stringstream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了stringstream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Print

static std::string Print(std::stringstream &os, const T &first, Ts... args) {
    os << first;
    Print(os, args...);
    return os.str();
}
开发者ID:gyuu,项目名称:image-retrieval,代码行数:5,代码来源:util.hpp

示例2: XML_RPC_METHOD_IMPLEMENT

#include "XmlRpcMethods.h"
#include "Log.h"
#include "TapiConn.h"

using namespace XmlRpc;

XmlRpc::MultithreadXmlRpcServer *theServer = NULL;


XML_RPC_METHOD_IMPLEMENT(Logging_ON, "1st arg string line_extension, 2nd arg string user_extension")
{
	xBEGIN
	std::string line_extension;
	std::string user_extension;
	
	std::stringstream ss;
	params.write(ss);
	theLog->Debug(ss.str());
	
	if(params.getType() == XmlRpcValue::TypeArray && params[0].getType() == XmlRpcValue::TypeStruct)
	{
		line_extension = std::string(params[0]["line_extension"]);
		user_extension = std::string(params[0]["user_extension"]);
	}
	else
	{
		line_extension = std::string(params[0]);
		user_extension = std::string(params[1]);
	}
	theLog->Default(std::string("Received command: Logging_ON, ") + line_extension + ", " + user_extension);
	theTapiConn->Logging_ON(line_extension, user_extension);
开发者ID:aaam,项目名称:TapiAdapter,代码行数:31,代码来源:XmlRpcMethods.cpp

示例3:

  #if WRITE_TEC
  std::stringstream file_name_tec;
  file_name_tec <<result_file_name << "_"<< t_step<< ".tec" ;
  tec.write_equation_systems (file_name_tec.str(),equation_systems);
  std::cout<<"Wrote "<< file_name_tec.str() <<std::endl;
  #endif

    std::stringstream file_name;
    file_name << equation_systems.parameters.get<std::string>("result_file_name");
    file_name << std::setw(2) << std::setfill('0') << t_step;
    file_name << ".e-s.";
    file_name << std::setw(3) << std::setfill('0') << t_step;
		//exo.write_timestep(file_name.str(), equation_systems,t_step+1,time); 
		exo.write_timestep(file_name.str(), equation_systems,t_step+1,t_step); 
    std::cout<<"exodus "<< file_name.str() <<std::endl;
		exo.write_element_data(equation_systems);
   
  tree.write_tree(equation_systems);
开发者ID:loztop,项目名称:large_deformation_lung,代码行数:18,代码来源:write_variable_results_and_mesh.cpp

示例4: PostWriteIntegralType

	void Emitter::PostWriteIntegralType(const std::stringstream& str)
	{
		m_stream << str.str();
		PostAtomicWrite();
	}
开发者ID:Gustavroot,项目名称:HERWIG,代码行数:5,代码来源:emitter.cpp

示例5:

 *
*/
/**
 * @file printf_verilog_generator_n.cpp
 * @brief Snippet for the printf dynamimc generator when a multiple bus architecture is considered.
 *
 * @author Fabrizio Ferrandi <[email protected]>
 * $Revision$
 * $Date$
 * Last modified by $Author$
 *
*/
std::string fsm;
std::string case_statement;

std::stringstream _npString;
_npString<<(std::max(_np,2));
std::string selector_dimension=_npString.str();

std::stringstream _np1String;
_np1String<<(std::max(_np-1, 1));
std::string selector_left=_np1String.str();

int selector=1;
for(int i=0;i<_np;i++){
   std::stringstream _selector_string;
   _selector_string<<selector;
   std::stringstream _index_string;
   _index_string<<(i+1);
   case_statement+="            "+selector_dimension+"'d"+_selector_string.str()+":\n             begin\n               data1="+_p[i].name+";\n               data1_size=BITSIZE_in"+_index_string.str()+";\n             end\n";
   selector*=2;
开发者ID:hoangt,项目名称:PandA-bambu,代码行数:31,代码来源:printf_verilog_generator_n.cpp

示例6: addRow

bool DBInsert::addRow(std::stringstream& row)
{
	bool ret = addRow(row.str());
	row.str("");
	return ret;
}
开发者ID:Fir3element,项目名称:035,代码行数:6,代码来源:database.cpp

示例7: message

modification::texception::texception(const std::stringstream& message_stream)
	: message(message_stream.str())
{
}
开发者ID:niegenug,项目名称:wesnoth,代码行数:4,代码来源:image_modifications.cpp

示例8: write

void RSReflectionBase::write(const std::stringstream &t) {
  mText.push_back(mIndent + t.str());
}
开发者ID:Proshivalskiy,项目名称:MT6582_kernel_source,代码行数:3,代码来源:slang_rs_reflection_base.cpp

示例9: EmitIfNotEmpty

static void EmitIfNotEmpty (std::stringstream& out, const std::stringstream& str)
{
	if (str.str().size())
		out << str.str() << "\n";
}
开发者ID:asmboom,项目名称:hlsl2glslfork,代码行数:5,代码来源:hlslLinker.cpp

示例10: test_

void test_()
{
    std::string const src("abcdefg");

    {
        g_ss.str("");
        std::stringstream& ss = oven::adapted_to<std::stringstream&>( copy(src, stream_writer(g_ss)) );
        BOOST_CHECK( equals(g_ss.str(), src) );
        BOOST_CHECK( pstade::egg::is_same(ss, g_ss) );
    }
    {
        g_ss.str("");
        std::stringstream& ss = oven::adapted_to<std::stringstream&>( copy(src, stream_writer(g_ss, ",")) );
        BOOST_CHECK( equals(g_ss.str(), std::string("a,b,c,d,e,f,g")) );
        BOOST_CHECK( pstade::egg::is_same(ss, g_ss) );
    }
#if 0 // seems not to be able to support reference type as 'to_base' target.
    {
        std::wstring rng(L"aabbbcccdddeffg");
        std::stringstream& ss = oven::unique_copy(rng, utf8_encoder |= stream_writer(g_ss))|to_base;
        BOOST_CHECK( pstade::egg::is_same(ss, g_ss) );
    }
#endif
    {
        g_ss.str("");
        copy(src, streambuf_writer(g_ss));
        BOOST_CHECK( equals(g_ss.str(), src) );
    }
    {
        g_ss.str("");
        copy(src, streambuf_writer(g_ss.rdbuf()));
        BOOST_CHECK( equals(g_ss.str(), src) );
    }
    {
        g_ss.str("");
        std::stringstream& ss = oven::adapted_to<std::stringstream&>( copy(src, std_stream_writer(g_ss)) );
        BOOST_CHECK( equals(g_ss.str(), src) );
        BOOST_CHECK( pstade::egg::is_same(ss, g_ss) );
    }
    {
        g_ss.str("");
        std::stringstream& ss = oven::adapted_to<std::stringstream&>( copy(src, std_stream_writer(g_ss, ",")) );
        BOOST_CHECK( equals(g_ss.str(), std::string("a,b,c,d,e,f,g,")) );
        BOOST_CHECK( pstade::egg::is_same(ss, g_ss) );
    }
    {
        g_ss.str("");
        test::output_iterator( stream_writer(g_ss), 'a' );
        test::output_iterator( streambuf_writer(g_ss.rdbuf()), 'a' );
        test::output_iterator( std_stream_writer(g_ss), 'a' );
        test::output_iterator( stream_writer(g_ss, ","), 'a' );
        test::output_iterator( std_stream_writer(g_ss, ","), 'a' );
    }
}
开发者ID:fpelliccioni,项目名称:pstade,代码行数:54,代码来源:stream_writer.cpp

示例11: TEST_CASE

#include "iostream"
#include "catch_with_main.hpp"
#include "rational.hpp"
#include <iomanip>

TEST_CASE( "constructor, two_parameters" ){
   rational v( 3, 4 );
   std::stringstream s;
   s << v;
   REQUIRE( s.str() == "[3/4]" );   
}

TEST_CASE( "equality, equal" ){
   rational v( 1, 2 );
   REQUIRE( v == rational( 1, 2 ) ); 
}

TEST_CASE( "equality, unequal" ){
   rational v( 1, 2 );
   REQUIRE( ! ( v == rational( 1, 3 )) ); 
}

TEST_CASE( "constructor, two_parameters; reduction" ){
   rational v( 10, 2 );
   REQUIRE( v == rational( 5, 1 ) ); 
}

TEST_CASE( "constructor, one parameter" ){
   rational v( 6 );
   REQUIRE( v == rational( 6, 1 ) );   
}
开发者ID:philipijnos,项目名称:TCTI-V1OOPC-15-BASE,代码行数:31,代码来源:main.cpp

示例12:

void Dirichlet_LIMSolver2D::debugOutput(std::stringstream& info)
{
  std::cout << "LP: " << info.str() << "\n"; 
}
开发者ID:JianpingCAI,项目名称:libigl,代码行数:4,代码来源:Dirichlet_LIMSolver2D.cpp

示例13: while

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
TableData RifEclipseUserDataParserTools::tableDataFromText(std::stringstream& streamData, std::vector<std::string>* errorText)
{
    TableData emptyTable;

    std::string origin = "";
    std::string dateFormat = "";
    std::string startDate = "";

    std::string firstLine;
    std::getline(streamData, firstLine);

    while (isLineSkippable(firstLine) || keywordParser(firstLine, origin, dateFormat, startDate))
    {
        if (!streamData.good())
        {
            // End of file
            return emptyTable;
        }

        std::getline(streamData, firstLine);
    }

    std::vector<std::string> quantityNames = splitLineAndRemoveComments(firstLine);
    size_t columnCount = quantityNames.size();

    if (columnCount == 0)
    {
        if (errorText) errorText->push_back("No quantities detected in table");

        return emptyTable;
    }

    std::vector< std::vector< std::string > > allHeaderRows;

    {
        std::stringstream::pos_type posAtStartOfFirstLine = streamData.tellg();

        std::string secondLine;
        std::getline(streamData, firstLine);

        std::stringstream::pos_type posAtStartOfSecondLine = streamData.tellg();
        std::getline(streamData, secondLine);

        bool header = true;
        while (header)
        {
            if (isValidTableData(columnCount, firstLine) &&
                isValidTableData(columnCount, secondLine))
            {
                header = false;
                break;
            }
            else
            {
                std::vector<std::string> words = splitLineAndRemoveComments(firstLine);
                if (words.size() > 0)
                {
                    allHeaderRows.push_back(words);
                }
            }

            posAtStartOfFirstLine = posAtStartOfSecondLine;
            firstLine = secondLine;

            posAtStartOfSecondLine = streamData.tellg();
            std::getline(streamData, secondLine);

            if (!streamData.good())
            {
                header = false;
            }
        }

        streamData.seekg(posAtStartOfFirstLine);
    }

    std::vector<std::string> unitNames;
    std::vector<double> scaleFactors;
    std::vector< std::vector< std::string > > headerRows;

    for (const auto& rowWords : allHeaderRows)
    {
        bool excludeFromHeader = false;

        if (rowWords.size() == columnCount)
        {
            if (unitNames.size() == 0)
            {
                for (const std::string& word : rowWords)
                {
                    if (hasTimeUnit(word))
                    {
                        unitNames = rowWords;
                        excludeFromHeader = true;
                    }
                }
            }
//.........这里部分代码省略.........
开发者ID:OPM,项目名称:ResInsight,代码行数:101,代码来源:RifEclipseUserDataParserTools.cpp

示例14: to_str

static void to_str(string& str, T &i){
    strm.clear();
    strm<<i;
    return strm.str();
}
开发者ID:connorimes,项目名称:GraphZ,代码行数:5,代码来源:util.hpp

示例15: ToString

 std::string ToString() const
 { return _stream.str(); }
开发者ID:koplyarov,项目名称:joint,代码行数:2,代码来源:StringBuilder.hpp


注:本文中的std::stringstream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。