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


C++ ostringstream::str方法代码示例

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


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

示例1: 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

示例2: ofs

void 
MrsLog::mrsErr(const ostringstream& oss)
{
 
#ifdef MARSYAS_LOG_ERRORS 

#ifdef MARSYAS_LOG2STDOUT
	cout << "[MRSERR] " << oss.str() << endl;
#endif

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

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

#else 
 
	return;
#endif 
}
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:32,代码来源:MrsLog.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: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15:

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


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