• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了stringstream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: PostWriteStreamable

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


示例15: if

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RifEclipseUserDataParserTools::findValidHeaderLines(std::stringstream& streamData)
{
    std::vector<std::string> headerLines;

    std::stringstream::pos_type posAtTableDataStart = streamData.tellg();

    size_t columnCount = 0;
    std::string line;
    bool continueParsing = true;
    bool hasStepType = false;
    size_t minimunRequiredExtraHeaderLines = 0;

    while (continueParsing)
    {
        posAtTableDataStart = streamData.tellg();

        if (!std::getline(streamData, line))
        {
            continueParsing = false;
        }
        else
        {
            if (!RifEclipseUserDataParserTools::isLineSkippable(line))
            {
                auto words = RifEclipseUserDataParserTools::splitLineAndRemoveComments(line);

                if (!hasStepType)
                {
                    for (size_t i = 0; i < words.size(); i++)
                    {
                        if (RifEclipseUserDataKeywordTools::isStepType(words[i]))
                        {
                            hasStepType = true;
                        }
                    }
                }

                if (isUnitText(line))
                {
                    minimunRequiredExtraHeaderLines += 1;
                }

                if (isScalingText(line))
                {
                    minimunRequiredExtraHeaderLines += 1;
                }

                if (columnCount == 0)
                {
                    // Fist line with valid header data defines the number of columns

                    columnCount = words.size();

                    minimunRequiredExtraHeaderLines = RifEclipseUserDataKeywordTools::computeRequiredHeaderLineCount(words);

                    headerLines.push_back(line);
                }
                else if (headerLines.size() < minimunRequiredExtraHeaderLines)
                {
                    headerLines.push_back(line);
                }
                else
                {
                    std::vector<double> doubleValues = RifEclipseUserDataParserTools::splitLineToDoubles(line);

                    if (doubleValues.size() < columnCount && words.size() < columnCount)
                    {
                        if (hasStepType && (words.size() + 1 == columnCount))
                        {
                            continueParsing = false;
                        }
                        else
                        {
                            // Consider a line with double values less than column count as a table header
                            headerLines.push_back(line);
                        }
                    }
                    else
                    {
                        continueParsing = false;
                    }
                }
            }
        }
    }

    streamData.seekg(posAtTableDataStart);

    return headerLines;
}
开发者ID:OPM,项目名称:ResInsight,代码行数:93,代码来源:RifEclipseUserDataParserTools.cpp


示例16: Increment

// Helper Function because lazy
void Increment(SGD::Point& pos, std::stringstream& display, int multi = 1)
{
		pos.y += 35.0f * multi;
		display.str(std::string());
}
开发者ID:MatthewSalow,项目名称:soorry,代码行数:6,代码来源:StatTracker.cpp


示例17:

    map[distance] = i;
  }

  // Distances are stored in a list in ascending order.
  QList<double> distances = map.keys();

  // The first element in the list therefore has the shortest distance.
  double shortestDistance = distances[0];
  size_t nearestPointIndex = map[shortestDistance];

  // Obtains the x and y coordinates of the closest data point, ready to be displayed.
  double nearestPointXCoord = mwd->x(nearestPointIndex);
  double nearestPointYCoord = mwd->y(nearestPointIndex);
  double errorOfNearestPoint = mwd->e(nearestPointIndex);

  std::stringstream precisionValueX;
  precisionValueX.precision(6);
  precisionValueX << nearestPointXCoord;
  m_xPosSigFigs = precisionValueX.str();

  std::stringstream precisionValueY;
  precisionValueY.precision(6);
  precisionValueY << nearestPointYCoord;
  m_yPosSigFigs = precisionValueY.str();

  std::stringstream error;
  error.precision(6);
  error << errorOfNearestPoint;
  std::string errorSigFigs = error.str();

  m_dataCoords = "(" + m_xPosSigFigs + ", " + m_yPosSigFigs + ")";
开发者ID:trnielsen,项目名称:mantid,代码行数:31,代码来源:LabelTool.cpp


示例18: DumpStringStream

void
DumpStringStream(std::stringstream& ss)
{
    std::cerr << ss.str() << std::endl;
}
开发者ID:DarumasLegs,项目名称:volumedriver,代码行数:5,代码来源:DebugPrint.cpp


示例19: to_str

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


示例20: ToString

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ std::thread类代码示例发布时间:2022-05-31
下一篇:
C++ std::string_view类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap