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

C++ ostringstream类代码示例

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

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



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

示例1: ofs

void 
MrsLog::mrsMessage(const ostringstream& oss)
{
#ifdef MARSYAS_LOG_MESSAGES
	if (!messages_off_) 
    {
#ifdef MARSYAS_LOG2STDOUT
		cout << "[MRS_MESSAGE] " << oss.str() << endl;
#endif

#ifdef MARSYAS_LOG2STDERR
		cerr << "[MRS_MESSAGE] " << oss.str() << endl;
#endif      

#ifdef MARSYAS_LOG2FILE
		ofstream ofs(fname_.c_str(), ios::out | ios::app);
		if (ofs.fail())
			return;
		if (!(ofs << "[MRS_MESSAGE] " <<  oss.str() << endl))
		{
			ofs.close();
			return;
		}
		ofs.close();
		return;

#endif
	}
	

#else 
	; 
#endif 
	
}
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:35,代码来源:MrsLog.cpp


示例2: mutex_print

void mutex_print(ostringstream& oss)
{
    pthread_mutex_lock(&mutex2);
    cerr << oss.str();
    oss.str("");
    pthread_mutex_unlock(&mutex2);
}
开发者ID:everwind,项目名称:nlpnet,代码行数:7,代码来源:testEigen.cpp


示例3: compile

void compile(const std::vector<Sym>& syms, std::vector<single_function>& functions) {
    symc_init();
    
    static ostringstream os;
    os.str("");
    
    os << make_prototypes();
    HashMap map(Sym::get_dag().size());
    for (unsigned i = 0; i < syms.size(); ++i) {
	
	os << "double func" << i << "(const double* x) { return ";
	os << print_code(syms[i], map); //c_print(syms[i]);
	os << ";}\n";

	//symc_compile(os.str().c_str());
	//cout << "compiling " << os.str() << endl;	
    }

    os << ends;
#ifdef INTERVAL_DEBUG
    //cout << "Compiling " << os.str() << endl;
#endif
    
    symc_compile(os.str().c_str()); 
    symc_link();

    functions.resize(syms.size());
    for (unsigned i = 0; i < syms.size(); ++i) {
	ostringstream os2;
	os2 << "func" << i;
	
	functions[i] = (single_function) symc_get_fun(os2.str().c_str());
    }

}
开发者ID:AdeleH,项目名称:paradiseo,代码行数:35,代码来源:sym_compile.cpp


示例4: decode

result_t Message::decode(SymbolString& masterData, SymbolString& slaveData,
		ostringstream& output, OutputFormat outputFormat,
		bool leadingSeparator)
{
	unsigned char offset = (unsigned char)(m_id.size() - 2);
	size_t startPos = output.str().length();
	result_t result = m_data->read(pt_masterData, masterData, offset, output, outputFormat, leadingSeparator, NULL, -1);
	if (result < RESULT_OK)
		return result;
	bool empty = result == RESULT_EMPTY;
	offset = 0;
	leadingSeparator |= output.str().length() > startPos;
	result = m_data->read(pt_slaveData, slaveData, offset, output, outputFormat, leadingSeparator, NULL, -1);
	if (result < RESULT_OK)
		return result;
	if (result == RESULT_EMPTY && !empty)
		result = RESULT_OK; // OK if at least one part was non-empty
	time(&m_lastUpdateTime);
	switch (masterData.compareMaster(m_lastMasterData)) {
	case 1: // completely different
		m_lastChangeTime = m_lastUpdateTime;
		m_lastMasterData = masterData;
		break;
	case 2: // only master address is different
		m_lastMasterData = masterData;
		break;
	}
	if (slaveData != m_lastSlaveData) {
		m_lastChangeTime = m_lastUpdateTime;
		m_lastSlaveData = slaveData;
	}
	return result;
}
开发者ID:Giermann,项目名称:ebusd,代码行数:33,代码来源:message.cpp


示例5: toString

string Text::toString(int n)
{
	static ostringstream out;
	out.str("");
	out.clear();
	out << n;
	string newStr = out.str();
	return newStr;
}
开发者ID:eckerdj1,项目名称:Comp446_Game2,代码行数:9,代码来源:Text.cpp


示例6: throw

void
CSipResponse::BuildPacket() throw(CSipException *)
{
	if(GetCommand().length() == 0)
		throw(new CSipException(SipError::UNSUPPORTED_COMMAND));
	//
	static ostringstream response;
	response.clear();
	response.str("");
	//
	if(GetCSeqCommand().length() == 0)
		SetCSeqCommand(GetCommand());
	//
	response << "SIP/2.0" << GetStatusCode() << GetStatus() << " SIP/2.0\r\n"
			 << "Via: SIP/2.0/UDP " << GetCallerAddress() << ":" << GetCallerPort()
			 << ";branch=" << GetBranch() << "\r\n"
			 << "Contact: <sip:" << GetCallerId() << "@" << GetCallerAddress()
			 << ":" << GetCallerPort() << ">;expires=" << GetExpires() << "\r\n"
			 << "Call-ID: " << GetCallId() << "\r\n"
			 << "Cseq: " << GetCSeq() << " " << GetCSeqCommand() << "\r\n";
	//
	if(GetServer().length() > 0)
		response << "Server: " << GetServer() << "\r\n";
	//
	// To field:
	response << "To: ";
	if(GetCalleeScreenName().length() > 0)
		response << "\"" << GetCalleeScreenName() << "\"";
	//
	response << "<sip:" << GetCalleeId() << "@" << GetSipServerAddress() << ">";
	response << ";tag=" << GetCalleeTag() << "\r\n";
	//
	// From field:
	response << "From: ";
	if(GetCallerScreenName().length() > 0)
		response << "\"" << GetCallerScreenName() << "\"";
	//
	response << "<sip:" << GetCallerId() << "@" << GetCallerAddress() << ">"
			 << ";tag=" << GetCallerTag() << "\r\n";
	//
	response << "Allow: REGISTER, INVITE, ACK, CANCEL, BYE\r\n";
	//
	if(GetContent().length() > 0)
	{
		response << "Content-Length: " << GetContent().length() << "\r\n"
				 << "Content-Type: " << GetContentType() << "\r\n"
				 << "\r\n" << GetContent();
	}
	else
		response << "\r\n";
	//
	SetBuffer(response.str().c_str(), response.str().length());
}
开发者ID:petegerhat,项目名称:rtmp2sipdaemon,代码行数:53,代码来源:SIPResponse.cpp


示例7:

string header::double2str(const double in, const double missing_value)
{
	if (in == missing_value)
		return ".";
	else
	{
		static ostringstream out;
		out.str(""); out.clear();
		out << in;
		return out.str();
	}
}
开发者ID:DylanGraham,项目名称:vcftools,代码行数:12,代码来源:header.cpp


示例8: execute

/**
 * This method will execute the given codeStream passed in.
 * @param codeStream stream of C++ code that contains a compilable main() method
 * @param force_rollback if set, this will rollback any changes made to the code
 *                       during execution. This is used for the '!' and '@'
 *                       commands.
 * @return 0 if compilation is successful
 */
int execute(ostringstream* codeStream, bool force_rollback) {
  int output = 0;

  //Backup the main file before it gets overwritten by the code stream.
  backup_file(sMainPath);

  //Write the code stream to the main file.
  ofstream outputFile;
  outputFile.open(sMainPath.c_str());
  outputFile << codeStream->str();
  outputFile.close();

  //Backup the current executable before compiling.
  backup_file(sExecPath);

  //Attempt to compile
  output = compile();

  if (output == 0) {
    //If compiling is successful, get the full path of the executable and send
    //it to system() to compile.
    char full_path[256];
    realpath(sExecPath.c_str(), full_path);
    system(full_path);
  }

  //Rollback if force flag is set, or if compilation failed.
  if ((force_rollback) || (output != 0)) {
    rollback_file(sMainPath);
    output=1;
  }

  //Rollback the executable after it is done.  This is to prevent a project
  //executable from getting modified.  This only applies when the console in
  //running in a project directory.
  rollback_file(sExecPath);

  //Reset variables now that the code was executed.
  sCodeBuffer.str(""); //Clear out the code buffer to allow new user input.
  sCodeBuffer.clear();
  sCodeType = MAIN_CODE; //Reset the code type to its default.
  sBraceCount = 0; //Ensure the brace count is zero.  A reload! can force an
  //execution even if the brace count is not zero.

  //Ensure a newline is printed since the output may not have one.
  cout << "\n";

  return output;
}
开发者ID:Hoblirm,项目名称:CppConsole,代码行数:57,代码来源:main.cpp


示例9: buildURLGoogle

void buildURLGoogle(const axutil_env_t* env,axis2_char_t* symbol,axutil_date_time_t* start, axutil_date_time_t* end,ostringstream& oss)
{
	int syear = axutil_date_time_get_year(start,env);
	int smonth = axutil_date_time_get_month(start,env);
	int sdate = axutil_date_time_get_date(start,env);
	int eyear = axutil_date_time_get_year(end,env);
	int emonth = axutil_date_time_get_month(end,env);
	int edate = axutil_date_time_get_date(end,env);
	oss.str("");
	oss<<"http://www.google.com/finance/historical?q=";
	oss<<symbol<<"&startdate=";
	oss<<GlobalVariables::m_months[smonth]<<"+"<<sdate<<"%2C+"<<syear<<"&enddate=";
	oss<<GlobalVariables::m_months[emonth]<<"+"<<edate<<"%2C+"<<eyear<<"&histperiod=weekly&num=30&output=csv";
	AXIS2_LOG_INFO(env->log,"build url google version [%s]",oss.str().c_str());
}
开发者ID:fqiang,项目名称:edinburgh-smartphone,代码行数:15,代码来源:alm_service_common.cpp


示例10: add_code

/**
 * This method will add a new line of code to the main file.
 * @param str the new line of code to add
 */
void add_code(string str) {
  //Count the braces and keep track of how deeply they are nested.
  sBraceCount += count(str.begin(), str.end(), '{');
  sBraceCount -= count(str.begin(), str.end(), '}');
  if (sBraceCount < 0) sBraceCount = 0;

  //Force rollback defaults to false. It is only set by the '!' and '@' commands
  bool force_rollback = false;
  if (sBraceCount == 0) {
    if (str[str.length() - 1] == '!') {
      //The '!' command was used.  Replace it with a semi-colon and set the flag.
      str[str.length() - 1] = ';';
      force_rollback = true;
    } else if (str[str.length() - 1] == '@') {
      //The '@' command was used.  Wrap the code in the cpp_console_print() method.
      force_rollback = true;
      str[str.length() - 1] = ' ';
      str = string("cpp_console_print(") + str + string(");");
    }
  }

  //Add the code to the buffer.
  sCodeBuffer << str << "\n";

  //If the code is not nested in any braces, we can attempt to execute.
  if (sBraceCount == 0) {
    ostringstream merge;
    string dump_string = sCodeBuffer.str();
    insert_code(&merge,&sCodeBuffer);
    if (execute(&merge, force_rollback)==0) sDumpBuffer << dump_string;
  }
}
开发者ID:Hoblirm,项目名称:CppConsole,代码行数:36,代码来源:main.cpp


示例11: finalizeOutput

/*
* finalizeOutput Default implementation just outputs the stream
*
*/
void NyxCmdOutput::finalizeOutput(ostringstream &output)
{
	if (printOutputEnabled)
	{
		cout << output.str();
	}
}
开发者ID:azimut2000,项目名称:nyx-utils,代码行数:11,代码来源:nyx_cmd_output.cpp


示例12: build_wx_wildcard_from_io_factory_aux

void build_wx_wildcard_from_io_factory_aux(const std::string& family, const std::string& group, const vector<factory_key>& id, ostringstream& wildcard)
{
    ostringstream oss1;
    ostringstream oss2;
    bool first = true;
    for(vector<factory_key>::const_iterator it = id.begin(); it!=id.end(); ++it)
    {
        if(family!="" && it->family != family) continue;
        if(group !="" && it->group  != group ) continue;
        if(!first)
        {
            oss1 << " ";
            oss2 << ";";
        }
        string current_ext = it->extension;
        oss1 << current_ext;
        oss2 << "*." << current_ext << ";";
        to_upper(current_ext);
        oss2 << "*." << current_ext;
        first = false;
    }
    if(!first)
    {
        if(wildcard.tellp()>0) wildcard << "|";
        wildcard << (family==""?(group==""?"Supported":group):family) << " files (" << oss1.str() << ")|" << oss2.str();
    }
}
开发者ID:myirci,项目名称:gilviewer,代码行数:27,代码来源:utils.cpp


示例13: broadCast

/**
Sends messages to all clients or to all clients not in a game.
*/
void broadCast(bool global){
    verbose && cout << ticks() << ": server broadcasts: .:" << buffer.str() <<":." << endl;
    for (Clients::iterator it = clients.begin(); it != clients.end(); it++) if (it->second != 0){
        if (it->second && ((global) || (it->second->game == 0))) it->second->cast();
    }
    buffer.str("");
}
开发者ID:blaf,项目名称:ditchers,代码行数:10,代码来源:data.hpp


示例14: listAllParticipateMeetings

void AgendaUI::listAllParticipateMeetings(void) {
    cout  << endl << "****************" << endl << "listAllParticipateMeetings"  << endl << "***************" << endl;
    os << endl;
    os << "[list all participator meetings]" << endl;
    os << endl;
    os << left << setw(17) << "title";
    os << left << setw(17) << "sponsor";
    os << left << setw(17) << "participator";
    os << left << setw(17) << "start time";
    os << left << setw(17) << "end time" << endl;
    list<Meeting> l = agendaService_.listAllParticipateMeetings(userName_);
    for (list<Meeting>::iterator it = l.begin(); it != l.end(); it++) {
        os << left << setw(17) << it->getTitle();
        os << left << setw(17) << it->getSponsor();
        os << left << setw(17) << it->getParticipator();
        os << left << setw(17) << Date::dateToString(it->getStartDate());
        os << left << setw(17) << Date::dateToString(it->getEndDate()) << endl;
    }
    os << endl;
    os << endl;
    os << "[email protected]" << userName_ << " : # ";
    res = os.str();
    strcpy(buffer, res.c_str());
    os.str("");
    __send();
    input();
}
开发者ID:chenzl25,项目名称:Agenda_socket,代码行数:27,代码来源:UDPUI.cpp


示例15: deleteUser

void AgendaUI::deleteUser(void) {
    cout  << endl << "****************" << endl << "deleteUser"  << endl << "***************" << endl;
    if (agendaService_.deleteUser(userName_, userPassword_)) {
        os << "[delete agenda account] succeed!" << endl;
        os << "--------------------------------Agenda--------------------------------" << endl;
        os << "Action :" << endl;
        os << "l   - log in Agenda by user name and password" << endl;
        os << "r   - register an Agenda account" << endl;
        os << "q   - quit Agenda" << endl;
        os << "help- show the operation list" << endl;
        os << "----------------------------------------------------------------------" << endl;
        os << endl;
        os << "Agenda : ~$ ";
        res = os.str();
        strcpy(buffer, res.c_str());
        os.str("");
        __send();
        start_input();
    } else {
        os << "[error] delete agenda acount fail!" << endl;
        os << endl;
        os << "[email protected]" << userName_ << " : # ";
        res = os.str();
        strcpy(buffer, res.c_str());
        os.str("");
        __send();
        input();
    }
}
开发者ID:chenzl25,项目名称:Agenda_socket,代码行数:29,代码来源:UDPUI.cpp


示例16: start_input

void AgendaUI::start_input() {
    cout  << endl << "****************" << endl << "start_input"  << endl << "***************" << endl;
    // os << endl;
    // os << "Agenda : ~$ ";
    // res = os.str(); strcpy(buffer, res.c_str()); os.str(""); __send();
    while(1) {
        string op = getOperation();
        if(op == "l" || op == "r" || op == "q" || op == "help") {
            if (op == "help") {
                executeOperation("help_start");
            } else {
                executeOperation(op);
            }
            break;
        } else {
            os << "your enter is wrong please enter again" << endl;
            os << endl;
            os << "Agenda : ~$ ";
            res = os.str();
            strcpy(buffer, res.c_str());
            os.str("");
            __send();
            start_input();
            break;
        }
    }
}
开发者ID:chenzl25,项目名称:Agenda_socket,代码行数:27,代码来源:UDPUI.cpp


示例17: get_round

string get_round(int i) {
  string ret =  NO_ROUND;
  char buff[100];
  sprintf(buff, "https://old.jutge.org/competitions/AlbertAtserias:BolaDeDrac2015/round/%d", i);
  string url = buff;
  request.setOpt(curlpp::options::Url(url));

  request.perform();
  string re = responseStream.str();
  size_t found = re.find("Player out:");

  if (found != string::npos) {
    size_t inici = re.find("<p class='indent'>",found+1);
    size_t fi =  re.find("(",found+1);
    cout << " --> ";
    if (inici != string::npos and fi != string::npos) {
      ret =  re.substr(inici+18, fi-(inici+18));
      cout << ret << endl;
    }
  } else if (re.find("Turn 1") != string::npos) {
    ret = ONGOING;
  }

  responseStream.str(string());
  return ret;
}
开发者ID:AinaSG,项目名称:EDABOT-temp,代码行数:26,代码来源:main.cpp


示例18: quitAgenda

void AgendaUI::quitAgenda(void) {
    os << "quit";
    res = os.str();
    strcpy(buffer, res.c_str());
    os.str("");
    __send();
    agendaService_.quitAgenda();
}
开发者ID:chenzl25,项目名称:Agenda_socket,代码行数:8,代码来源:UDPUI.cpp


示例19: main

int main(int argc, char *argv[])
{
    if(argc < 3) {
        cerr << "Usage: " << argv[0] << " <collection.db> <boffin.db>" << endl;
        return 1;
    }

    try {
        BoffinDb db(argv[2], argv[1]);
            
        // build up the request:
        db.map_tracks_without_tags(track_out);
        ossreq.flush();
        issreq = new istringstream(ossreq.str());

        // setup curl:
        CURL* curl = curl_easy_init();
        CurlChecker cc;

        // io options:
        cc("WRITEFUNCTION") = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_writer);  
        cc("READFUNCTION") = curl_easy_setopt(curl, CURLOPT_READFUNCTION, curl_reader);

        // http options:
        cc("URL") = curl_easy_setopt(curl, CURLOPT_URL, MUSICLOOKUP_URL);  
        cc("HEADER") = curl_easy_setopt(curl, CURLOPT_HEADER, 0);                           // don't include header in response

        cc("FOLLOWLOCATION") = curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);           // follow http redirects
        // leave this to the defaults with older versions of curl
#if defined(CURLOPT_POSTREDIR) && defined(CURL_REDIR_POST_ALL)
        cc("POSTREDIR") = curl_easy_setopt(curl, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL );  // keep on posting when redir'd (301 or 302)
#endif
        cc("POST") = curl_easy_setopt(curl, CURLOPT_POST, 1);
        cc("POSTFIELDSIZE") = curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, issreq->rdbuf()->in_avail());
        cc("USERAGENT") = curl_easy_setopt(curl, CURLOPT_USERAGENT, "playdar boffin tagger");
        struct curl_slist *headers = 0;
        headers = curl_slist_append(headers, "content-type: text/plain; charset=utf-8");
        headers = curl_slist_append(headers, "expect:");
        cc("HTTPHEADER") = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        
        cc("easy_perform") = curl_easy_perform(curl);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);

        ossresp.flush();
        issresp = new istringstream(ossresp.str());
        db.update_tags( parse_line );
    } 
    catch (const std::exception& e) {
        cerr << "failed: " << e.what();
        return 1;
    } 
    //catch (...) {
    //    cerr << "failed with unhandled exception";
    //    return 1;
    //}

}
开发者ID:RJ,项目名称:playdar,代码行数:58,代码来源:Tagger.cpp


示例20: draw_gameover

void draw_gameover()
{
    output_h(350,100,"G A M E    O V E R");
	output(400,200, "Your  Score ");
    temp1<<score;
	sscore=temp1.str();
	temp = new char [sscore.length()+1];
  	strcpy (temp, sscore.c_str());
	output(440, 250, temp);
	delete temp;
	temp1.str("");
}
开发者ID:abhinavp13,项目名称:Opengl-Ubuntu,代码行数:12,代码来源:myfile.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ otl_connect类代码示例发布时间:2022-05-31
下一篇:
C++ ostream类代码示例发布时间: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