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


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

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


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

示例1: writeSymbols

result_t ValueListDataField::writeSymbols(istringstream& input,
		const unsigned char offset,
		SymbolString& output, const bool isMaster, unsigned char* usedLength)
{
	NumberDataType* numType = (NumberDataType*)m_dataType;
	if (isIgnored())
		return numType->writeRawValue(numType->getReplacement(), offset, m_length, output, usedLength); // replacement value

	const char* str = input.str().c_str();

	for (map<unsigned int, string>::iterator it = m_values.begin(); it != m_values.end(); it++)
		if (it->second.compare(str) == 0)
			return numType->writeRawValue(it->first, offset, m_length, output, usedLength);

	if (strcasecmp(str, NULL_VALUE) == 0)
		return numType->writeRawValue(numType->getReplacement(), offset, m_length, output, usedLength); // replacement value

	char* strEnd = NULL; // fall back to raw value in input
	unsigned int value;
	value = (unsigned int)strtoul(str, &strEnd, 10);
	if (strEnd == NULL || strEnd == str || (*strEnd != 0 && *strEnd != '.'))
		return RESULT_ERR_INVALID_NUM; // invalid value
	if (m_values.find(value) != m_values.end())
		return numType->writeRawValue(value, offset, m_length, output, usedLength);

	return RESULT_ERR_NOTFOUND; // value assignment not found
}
开发者ID:john30,项目名称:ebusd,代码行数:27,代码来源:data.cpp

示例2: createFromXml

void Bank::createFromXml( istringstream& is, Program& program )
{
    Document doc;
    try
    {
	    doc.Parse( is.str(), true );
        Node* root = &doc;

        Node* programNode = doc.FirstChild( "Program", false );
        if( programNode != NULL ) {
            root = programNode;
        }

	    Iterator< Element > it( "Module" );
	    for( it = it.begin( root ); it != it.end(); it++ )
	    {
		    ModuleData* data = new ModuleData();
		    Element* moduleElement = it.Get();
		    readModule( moduleElement, data );

		    program.addModule( data );
	    }
    }
    catch( const exception& e ) {
        TRACE( e.what() );
    }
}
开发者ID:dreieier,项目名称:Nexus,代码行数:27,代码来源:Bank.cpp

示例3: getline

const float& CPUPercentage::get_percentage()
{
  m_stat_file.open("/proc/stat");
  getline(m_stat_file, m_stat_line);
  m_stat_file.close();

  // skip "cpu"
  m_line_start_pos = m_stat_line.find_first_not_of(" ", 3);
  m_line_end_pos = m_stat_line.find_first_of(' ', m_line_start_pos);
  m_line_end_pos = m_stat_line.find_first_of(' ', m_line_end_pos + 1);
  m_line_end_pos = m_stat_line.find_first_of(' ', m_line_end_pos + 1);
  m_line_end_pos = m_stat_line.find_first_of(' ', m_line_end_pos + 1);
  m_iss.str(m_stat_line.substr(m_line_start_pos, m_line_end_pos - m_line_start_pos));
  m_iss >> m_next_user >> m_next_nice >> m_next_system >> m_next_idle;
  m_iss.clear();

  m_diff_user   = m_next_user - m_current_user;
  m_diff_system = m_next_system - m_current_system;
  m_diff_nice   = m_next_nice - m_current_nice;
  m_diff_idle   = m_next_idle - m_current_idle;
  m_percentage = static_cast<float>(m_diff_user + m_diff_system + m_diff_nice)/static_cast<float>(m_diff_user + m_diff_system + m_diff_nice + m_diff_idle)*100.0;

  m_current_user = m_next_user;
  m_current_system = m_next_system;
  m_current_nice = m_next_nice;
  m_current_idle = m_next_idle;

  return m_percentage;
}
开发者ID:thewtex,项目名称:screen-cpu-mem,代码行数:29,代码来源:screen-cpu-usage.cpp

示例4: createMeeting

void AgendaUI::createMeeting(void) {
    cout  << endl << "****************" << endl << "CreateMeeting"  << endl << "***************" << endl;
    os << "[create meeting] [title] [participator] [start time(yyyy-mm-dd/hh:mm)] [end time(yyy-mm-dd/hh:mm)]" << endl;
    os << "[create meeting] ";
    res = os.str();
    strcpy(buffer, res.c_str());
    os.str("");
    __send();
    __read();
    string title, participator, startDate, endDate;
    istringstream ss(is.str());
    ss >> title >> participator >> startDate >> endDate;

    cout << "!!!!!!!!" <<  title << participator << startDate << endDate << endl;
    if (agendaService_.createMeeting(userName_, title, participator, startDate, endDate)) {
        os << "[create meeting] succeed!" << endl;
        os << endl;
        os << "[email protected]" << userName_ << " : # ";
        res = os.str();
        strcpy(buffer, res.c_str());
        os.str("");
        __send();
        input();
    } else {
        os << "[error] create meeting fail!" << endl;
        os << endl;
        os << "[email protected]" << userName_ << " : # ";
        res = os.str();
        strcpy(buffer, res.c_str());
        os.str("");
        __send();
        input();
    }
}
开发者ID:chenzl25,项目名称:Agenda_socket,代码行数:34,代码来源:UDPUI.cpp

示例5: __read

void __read() {
//    clntAddr.sin_family = AF_INET;
//    clntAddr.sin_port = htons(6666);
//    inet_pton(AF_INET, "20.1.0.60", &clntAddr.sin_addr);
    addrLen = sizeof(toAddr);
    clear_buffer();
    is.str("");
    cout << "__reading ...." << endl;
    if ((len = recvfrom(s, buffer, 2048, 0, (struct sockaddr*)&toAddr,&addrLen))<0) {
        cout << "shit" << endl;
    }
    printf("__read from  %s with the string:\n%s\n",inet_ntoa(toAddr.sin_addr), buffer);
    cout << "__read finished" << endl;
    cout << "the client enter : " << buffer << endl;
    string tem = buffer;
    cout << "the tem is " << tem << endl;
    is.str(tem);
}
开发者ID:chenzl25,项目名称:Agenda_socket,代码行数:18,代码来源:UDPUI.cpp

示例6: next_cluster

bool FirecrestInput::next_cluster( int *plane, int *ptile, int *px, int* py ) 
{
    string line ;
    if( !getline( intensities_, line ) ) return false ;
    cur_line_.str( line ) ;
    cur_line_.clear() ;
    cycle_ = 0 ;
    return cur_line_ >> *plane >> *ptile >> *px >> *py ; 
}
开发者ID:grenaud,项目名称:freeIbis,代码行数:9,代码来源:firecrest_input.cpp

示例7: userLogIn

void AgendaUI::userLogIn(void) {
    cout  << endl << "****************" << endl << "login"  << endl << "***************" << endl;
    list<User> l = agendaService_.listAllUsers();
    if (l.empty()) {
        os << "[error] No User" << endl;
        res = os.str();
        strcpy(buffer, res.c_str());
        os.str("");
        __send();
        start_input();
        return;
    }
    os << endl;
    os << "[log in] [user name] [password]" << endl;
    os << "[log in] ";
    res = os.str();
    strcpy(buffer, res.c_str());
    os.str("");
    __send();
    __read();
    istringstream ss(is.str());
    ss >> userName_ >> userPassword_;

    // is >> userName_ >> userPassword_;
    cout << is.str() << endl;
    cout << "!!!!!!!!!" << userName_ << "   " << userPassword_ << endl;
    if (agendaService_.userLogIn(userName_, userPassword_)) {
        os << "[log in] succeed!" << endl;
        os << endl;
        help();
    } else {
        os << "[error] log in fail!" << endl;
        res = os.str();
        strcpy(buffer, res.c_str());
        os.str("");
        userLogIn();
    }
}
开发者ID:chenzl25,项目名称:Agenda_socket,代码行数:38,代码来源:UDPUI.cpp

示例8: queryMeetingByTimeInterval

void AgendaUI::queryMeetingByTimeInterval(void) {
    cout  << endl << "****************" << endl << "queryMeetingByTimeInterval"  << endl << "***************" << endl;
    os << endl;
    os << "[query meetings] [start time(yyyy-mm-dd/hh:mm)] [end time(yyyy-mm-dd/hh:mm)]" << endl;
    os << "[query meeting] ";
    res = os.str();
    strcpy(buffer, res.c_str());
    os.str("");
    __send(),  __read();;
    std::string startDate, endDate;
    // is >> startDate >> endDate;
    istringstream ss(is.str());
    ss >> startDate >> endDate;
    cout << "!!!!!" << startDate << "   " << endDate << 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_.meetingQuery(userName_, startDate, endDate);
    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,代码行数:37,代码来源:UDPUI.cpp

示例9: queryMeetingByTitle

void AgendaUI::queryMeetingByTitle(void) {
    cout  << endl << "****************" << endl << "queryMeetingByTitle"  << endl << "***************" << endl;
    os << endl;
    os << "[query meeting] [title]:" << endl;
    os << "[query meeting] ";
    res = os.str();
    strcpy(buffer, res.c_str());
    os.str("");
    __send();
    __read();
    string title;
    istringstream ss(is.str());
    // is >> title;
    ss >> title;
    cout << "!!!!!!!!" << title << endl;
    os << endl;
    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_.meetingQuery(userName_, title);
    for (list<Meeting>::iterator it = l.begin(); it != l.end(); it++) {
        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,代码行数:36,代码来源:UDPUI.cpp

示例10: s

inline const ObjIO::e_FaceFormat ObjIO::parseFaceFormat(const istringstream & line)
{
    string s(line.str());
    trim(s);

    size_t l(s.find(" "));
    if(string::npos == l)
        l = s.length();

    const size_t f0(s.find("/", 0));

    if(string::npos == f0)
        return FF_V;

    const size_t f1(s.find("/", f0 + 1));

    if(string::npos == f1 || f1 > l)
        return FF_VT;

    if(string::npos == s.find("//", 0))
        return FF_VTN;
    else
        return FF_VN;
}
开发者ID:Tymolc,项目名称:CG-I-2015,代码行数:24,代码来源:objio.cpp

示例11: main

int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
freopen("out","w",stdout);
#endif
scanf("%d\n",&cas);
tt=0;
while(cas--){
    printf("Case #%d: ",++tt);
    bases.clear();
    getline(cin,strtmp);
    inss.clear();
    inss.str(strtmp);
    while(inss>>a){
        bases.push_back(a);
    }
    j=2;
    while(!test(j)){
        j++;
    }
    printf("%d\n",j);
}
}
开发者ID:ZxMYS,项目名称:Xiaos-ACM-Solution-Set,代码行数:24,代码来源:ROUND1A-A.cpp

示例12: assign

void assign(istringstream &iss, const string &str) {
	iss.clear();
	iss.str(str);
}
开发者ID:oerpli,项目名称:ComputationalPhysics,代码行数:4,代码来源:Functions.cpp

示例13: reset_stringstreams

		/// \brief TODOCUMENT
		void istreams_equal_test_suite_fixture::reset_stringstreams() {
			compare_ss.str        ( compare_str        );
			compare_ss_equal.str  ( compare_str_equal  );
			compare_ss_longer.str ( compare_str_longer );
			compare_ss_diff.str   ( compare_str_diff   );
		}
开发者ID:UCLOrengoGroup,项目名称:cath-tools,代码行数:7,代码来源:istreams_equal_test.cpp

示例14: readStr

string OBJLoader::readStr(istringstream &input) {
	return input.str().substr(1+input.tellg());
}
开发者ID:ming-hai,项目名称:CubicVR,代码行数:3,代码来源:OBJLoader.cpp


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