本文整理汇总了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();
}
示例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);
示例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);
示例4: PostWriteIntegralType
void Emitter::PostWriteIntegralType(const std::stringstream& str)
{
m_stream << str.str();
PostAtomicWrite();
}
示例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;
示例6: addRow
bool DBInsert::addRow(std::stringstream& row)
{
bool ret = addRow(row.str());
row.str("");
return ret;
}
示例7: message
modification::texception::texception(const std::stringstream& message_stream)
: message(message_stream.str())
{
}
示例8: write
void RSReflectionBase::write(const std::stringstream &t) {
mText.push_back(mIndent + t.str());
}
示例9: EmitIfNotEmpty
static void EmitIfNotEmpty (std::stringstream& out, const std::stringstream& str)
{
if (str.str().size())
out << str.str() << "\n";
}
示例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' );
}
}
示例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 ) );
}
示例12:
void Dirichlet_LIMSolver2D::debugOutput(std::stringstream& info)
{
std::cout << "LP: " << info.str() << "\n";
}
示例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;
}
}
}
//.........这里部分代码省略.........
示例14: to_str
static void to_str(string& str, T &i){
strm.clear();
strm<<i;
return strm.str();
}
示例15: ToString
std::string ToString() const
{ return _stream.str(); }