这篇教程C++ sstr函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中sstr函数的典型用法代码示例。如果您正苦于以下问题:C++ sstr函数的具体用法?C++ sstr怎么用?C++ sstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了sstr函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mainint main(){ char s[10]="hello"; printf("%s: %d/n",s,slen(s)); //testing for slen char cpy[15]="aba"; printf("After scpy, %s became: ",cpy); scpy(cpy,s); printf("%s/n",cpy); char ncpy[15]="abalaba"; printf("After sncpy (n=3), %s became: ",ncpy); sncpy(ncpy,s,3); printf("%s/n",ncpy); char cat[15]="AddOn"; printf("After scat, %s became: ",cpy); scat(cpy,cat); printf("%s/n",cpy); char s2[18]="hello"; char s3[5]="po"; char s4[5]="bao"; printf("scmp %s and %s: %d/n",s,s2,scmp(s,s2)); printf("scmp %s and %s: %d/n",s,cpy,scmp(s,cpy)); printf("scmp %s and %s: %d/n",s,s3,scmp(s,s3)); printf("scmp %s and %s: %d/n",s,s4,scmp(s,s4)); printf("schr %s and %c: %s/n",s,'l',schr(s,'l')); printf("schr %s and %c: %s/n",s,'t',schr(s,'t')); char s5[5]="el"; printf("sstr %s and %s: %s/n",s,s5,sstr(s,s5)); printf("sstr %s and %s: %s/n",s,s3,sstr(s,s3)); return 0;}
开发者ID:Zilby,项目名称:Stuy-Stuff,代码行数:29,
示例2: QMessageBoxvoid gui_settings::ShowBox(bool confirm, const QString& title, const QString& text, const gui_save& entry, int* result = nullptr, QWidget* parent = nullptr){ const std::string dialog_type = confirm ? "Confirmation" : "Info"; if (entry.name.isEmpty() || GetValue(entry).toBool()) { const QFlags<QMessageBox::StandardButton> buttons = confirm ? QMessageBox::Yes | QMessageBox::No : QMessageBox::Ok; const QMessageBox::Icon icon = confirm ? QMessageBox::Question : QMessageBox::Information; QMessageBox* mb = new QMessageBox(icon, title, text, buttons, parent); mb->deleteLater(); if (!entry.name.isEmpty()) { mb->setCheckBox(new QCheckBox(tr("Don't show again"))); } connect(mb, &QMessageBox::finished, [&](int res) { if (result) { *result = res; } if (!entry.name.isEmpty() && mb->checkBox()->isChecked()) { SetValue(entry, false); LOG_NOTICE(GENERAL, "%s Dialog for Entry %s is now disabled", dialog_type, sstr(entry.name)); } }); mb->exec(); } else LOG_NOTICE(GENERAL, "%s Dialog for Entry %s was ignored", dialog_type, sstr(entry.name));}
开发者ID:AniLeo,项目名称:rpcs3,代码行数:34,
示例3: mail_OpenSessionint mail_OpenSession( KMail mail, int tls, AuthType auth ){ if( !smtp_OpenSession( mail->smtp, sstr( mail->host ), mail->port, tls ) ) { return mail_set_SMTP_error( mail ); } if( auth == AUTH_PLAIN ) { if( !smtp_AUTH_PLAIN( mail->smtp, sstr( mail->login ), sstr( mail->password ) ) ) return mail_set_SMTP_error( mail ); } else if( auth == AUTH_LOGIN ) { if( !smtp_AUTH_LOGIN( mail->smtp, sstr( mail->login ), sstr( mail->password ) ) ) return mail_set_SMTP_error( mail ); } else { mail_FormatError( mail, "Unknown AUTH type: %d", auth ); return 0; } return 1;}
开发者ID:klopp,项目名称:ksmtp,代码行数:25,
示例4: mail_AttachFilesstatic int mail_AttachFiles( KMail mail, KMsg msg, const char * boundary ){ struct _MFile file = { NULL, NULL }; Pair afile = lfirst( msg->afiles ); file.headers = snew(); while( afile ) { if( !msg_CreateFile( msg, &file, mail->error, boundary, F_NAME(afile), F_CTYPE(afile), "attachment", NULL ) ) { return delMFile( &file ); } if( !smtp_write( mail->smtp, sstr( file.headers ) ) || !smtp_write( mail->smtp, sstr( file.body ) ) || !smtp_write( mail->smtp, "/r/n" ) ) { mail_FormatError( mail, "mail_AttachFiles(/"%s/"), internal error", F_NAME(afile) ); return delMFile( &file ); } afile = lnext( msg->afiles ); } delMFile( &file ); return 1;}
开发者ID:klopp,项目名称:ksmtp,代码行数:27,
示例5: mail_EmbedFilesstatic int mail_EmbedFiles( KMail mail, KMsg msg, const char * boundary ){ struct _MFile file = { NULL, NULL }; EFile efile = lfirst( msg->efiles ); file.headers = snew(); while( efile ) { if( !msg_CreateFile( msg, &file, mail->error, boundary, efile->name, efile->ctype, "inline", efile->cid ) ) { return delMFile( &file ); } if( !smtp_write( mail->smtp, sstr( file.headers ) ) || !smtp_write( mail->smtp, sstr( file.body ) ) || !smtp_write( mail->smtp, "/r/n" ) ) { mail_FormatError( mail, "mail_EmbedFiles(/"%s/"), internal error", efile->name ); return delMFile( &file ); } efile = lnext( msg->efiles ); } delMFile( &file ); return 1;}
开发者ID:klopp,项目名称:ksmtp,代码行数:27,
示例6: disasmvoid cg_disasm_window::ShowDisasm(){ if (QFileInfo(m_path_last).isFile()) { CgBinaryDisasm disasm(sstr(m_path_last)); disasm.BuildShaderBody(); m_disasm_text->setText(qstr(disasm.GetArbShader())); m_glsl_text->setText(qstr(disasm.GetGlslShader())); } else if (!m_path_last.isEmpty()) { LOG_ERROR(LOADER, "CgDisasm: Failed to open %s", sstr(m_path_last)); }}
开发者ID:Ekaseo,项目名称:rpcs3,代码行数:14,
示例7: buf_numbervoid GuessMyNumber::OnGuessClick() { // Validate number. unsigned int buf_number( 0 ); std::stringstream sstr( static_cast<std::string>( m_number_entry->GetText() ) ); sstr >> buf_number; if( buf_number < 1 || buf_number > 100 ) { m_hint_label->SetText( "Enter a number from 1 to 100." ); return; } ++m_tries; UpdateUI(); unsigned char number( static_cast<unsigned char>( buf_number ) ); if( number < m_number ) { m_hint_label->SetText( "My number is higher." ); } else if( number > m_number ) { m_hint_label->SetText( "My number is lower." ); } else { m_hint_label->SetText( "Correct!" ); m_guess_button->Show( false ); } m_number_entry->SetText( "" );}
开发者ID:DrJonki,项目名称:I-want-it-back,代码行数:29,
示例8: sstrvoid Graph::read_line( std::string line, std::vector<int> * tmp ) { int n; std::istringstream sstr (line); while(sstr >> n) { tmp->push_back(n); };};
开发者ID:qwwqwwq,项目名称:coursera_algo_hw,代码行数:7,
示例9: sstrdouble EXParser::strToDbl(const std::string num){ double val; std::istringstream sstr(num); sstr>>std::setprecision(decimal_precision)>>val; return val;}
开发者ID:sukovanej,项目名称:qum,代码行数:7,
示例10: perrorint ThingSpeakClient::GetField(char *s_field, char *e_field) { char *s_fld = "<field5>"; char *e_fld = "</field5>"; if(connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { perror("ThingSpeak_connect"); //return -1; } char message[]= "GET /channels/46795/feeds.xml?results=2/r/n/r/n"; fcntl(sock, F_SETFL, O_NONBLOCK); send(sock, message, sizeof(message), 0); sleep(1); if (recv(sock, buf, 16048, 0)>=0) { std::string sstr(buf); pos = sstr.find("<feed>"); start_pos = sstr.find(s_field, pos)+8; end_pos = sstr.find(e_field, start_pos)-1; result[0] = sstr[start_pos]; result[1] = sstr[end_pos]; result[3]= 0; humidity = (result[0]-48)*10+(result[1]-48); close(sock); return humidity; } else return 0;}
开发者ID:stepan-dzhanov,项目名称:IoT_BeagleBone,代码行数:30,
示例11: sstr/** * 初始化我们的数据成员,顶点数和弧数 * 格式:4 7 */void MGraphDG::intiVAnum(std::string line){ std::stringstream sstr(line); //用这个类可以很好地处理string类型 std::string num1, num2; sstr >> num1 >> num2; //获取两个数字的字符串 this->vexnum = atoi(num1.c_str()); this->arcnum = atoi(num2.c_str());}
开发者ID:cutterpoint,项目名称:DataStructureAndAlgorithm,代码行数:12,
示例12: sstr// -----------------------------------------------------------------------------------------int CPepeEngineConverter::parseInt(const tstring& str){ tstringstream sstr(str); int ret = 0; sstr >> ret; return ret;}
开发者ID:pepewuzzhere,项目名称:PepeEngine,代码行数:9,
示例13: getUniformStructLocStrstd::string getUniformStructLocStr(const std::string &structName, const std::string &memberName, int arrayIndex = -1) { std::stringstream sstr(""); sstr << structName; if (arrayIndex >= 0) { sstr << "[" << arrayIndex << "]"; } sstr << "." << memberName; return sstr.str();}
开发者ID:CompN3rd,项目名称:cg2,代码行数:9,
示例14: TESTTEST(TestSymbolString, testUnescaped){ SymbolString sstr(false); auto result = sstr.parseHex("10feb5050427a90015a90177", true); ASSERT_EQ(result, RESULT_OK); ASSERT_EQ(sstr.getDataStr(true, false),"10feb5050427a915aa77");}
开发者ID:pnxs,项目名称:ebusd,代码行数:9,
示例15: sstrbool Coin::onPlayerSteping( Player* player ){ Label* text = Label::createWithTTF( sstr("+%d",m_coin), "fonts/Marker Felt.ttf", 32); text->setColor(Color3B(255,215,64)); text->setPosition(getPosition()); text->runAction( Sequence::create(MoveBy::create(2, Vec2(0, 64)), CCCallFunc::create(std::bind(&CCNode::removeFromParent, text)), 0) ); text->setLocalZOrder(player->getLocalZOrder()); getParentCell()->playTopEffect(text); return true;}
开发者ID:gittor,项目名称:Explore,代码行数:10,
示例16: sstrAnimation* TrapFire::fireAnimation( int end_pos ){ Animation* animation = Animation::create(); animation->setDelayPerUnit( end_pos==2 ? 1/10.0f : 1/20.0f ); for (int i=0; i<end_pos; ++i) { animation->addSpriteFrameWithFile( sstr("fire_%03d.png", i) ); } animation->addSpriteFrameWithFile( "fire_000.png" ); return animation;}
开发者ID:Davion8948,项目名称:Explore,代码行数:11,
示例17: get template <typename T> const T get(const std::string &key) const throw(PropertyConversionFailed, PropertyLookupFailed) { const std::string val(get(key)); std::stringstream sstr(val); T ret; sstr >> ret; if (!sstr) { throw PropertyConversionFailed(key, val); } else { return ret; } }
开发者ID:BackupTheBerlios,项目名称:xenbee-svn,代码行数:11,
示例18: sfgogl_LoadFunctionsbool NonLegacyRenderer::IsAvailable() { static bool checked = false; if( !checked ) { // Make sure we have a valid GL context before messing around // with GLLoader or else it will report missing extensions sometimes. sf::Context context; if( !gl_initialized ) { auto result = sfgogl_LoadFunctions() - sfgogl_LOAD_SUCCEEDED; if( result ) {#if defined( SFGUI_DEBUG ) std::cerr << "GL extension initialization failed. Missing " << result << " functions./n";#endif return false; } gl_initialized = true; } if( GLEXT_vertex_buffer_object ) { vbo_supported = true; } if( GLEXT_vertex_program ) { vap_supported = true; } if( sf::Shader::isAvailable() ) { auto glsl_version_string = CheckGLError( glGetString( GLEXT_GL_SHADING_LANGUAGE_VERSION ) ); if( glsl_version_string ) { std::stringstream sstr( reinterpret_cast<const char*>( glsl_version_string ) ); auto version = 0.0; sstr >> version; if( version > 1.29 ) { shader_supported = true; } } } if( GLEXT_vertex_array_object ) { vao_supported = true; } if( GLEXT_framebuffer_object ) { fbo_supported = true; } checked = true; }
开发者ID:TankOs,项目名称:SFGUI,代码行数:53,
示例19: invoid comm_param_settings::business_channel_confirm_event(){ char buffer[256]; std::ifstream in(_path.toStdString()); if (! in.is_open()) { std::cout << "Error opening file"; QMessageBox::information(this, QString::fromStdString("警告"),QString::fromStdString("文件读取失败!")); return; } int lineNum = 0; //行号. while (!in.eof() ) { in.getline (buffer,256); lineNum++; //读取一行的数据 std::string strline = buffer; if( lineNum >= 1 ) { if(strline[strline.length()-1]=='/n') { strline.erase(strline.length()-1,1); } //将分割后的字符串写到字符串数组 std::vector<std::string> stu; //存放一行数据的数组 std::stringstream sstr(strline); std::string token; while(getline(sstr, token, ' ')) { stu.push_back(token); } //根据数组中数据给创建的结构体赋值 PG_RTUI_StaticRoute *data = new PG_RTUI_StaticRoute(); data->clientAddr.ip_addr =_ip;//ip uInt32_t型 data->clientAddr.port = 65500;//port uInt32_t型 data->type = ePG_RTUI_static_route; //type data->length = sizeof(PG_RTUI_StaticRoute);//lengrh大小 data->pdsi_delay_time = 0; data->nodeId = std::stoi(stu[0]); strcpy(data->dst_ip,stu[1].data()); strcpy(data->nxt_hop,stu[2].data()); strcpy(data->out_itf_ip,stu[3].data()); data->cost = std::stoi(stu[4]); //发送数据给qualnet通信软件 _msHandler->config_comm_param(data); } //2.将文本数据显示在list缓存 current_cloud_id_list.push_back(QString::fromStdString(strline)); } //current_cloud_id_list.push_back(QString::fromStdString("strline"));//再次往list中添加数据 model->setStringList(current_cloud_id_list);//往listView中添加数据 ui->listView->setModel(model);}
开发者ID:yacbo,项目名称:Co-Simulation,代码行数:53,
示例20: sstr int Value::ToInt() const { if (IsNumber()) { std::stringstream sstr(valueStr); int val; sstr >> val; return val; } else { return 0;
开发者ID:mindeng,项目名称:MyPhotos,代码行数:12,
示例21: sstr/** * /brief Reads a line from a file and adds the data * Reads a line from a file, replaces , with <TAB> and casts it as a double * /param std::string line - line to read */void Plotter::read_line(std::string line){ std::string first,sec; std::string TR = line.c_str(); std::replace(TR.begin(),TR.end(),',','/t'); std::stringstream sstr(TR); sstr >> first >> sec; if(check(first) &&check(sec)){ double _first = boost::lexical_cast<double>(first); double _sec = boost::lexical_cast<double>(sec); data_x.push_back(_first); data_y.push_back(_sec); }}
开发者ID:wutzi15,项目名称:plot_lib,代码行数:18,
示例22: piAccTo//Returns value of Pi as a string accurate to a certain number of digits.std::string piAccTo(int digitsAcc){ //Approximating pi using an integer fraction to double then to ostringstream, then to string. std::ostringstream sstr(""); sstr << std::fixed << std::setprecision(digitsAcc); sstr << double(2549491779)/811528438; std::string strPi = sstr.str(); //Next ostringstream for getting the correct number of digits of accuracy. std::ostringstream endSstr(""); for (int i = 0; i <= digitsAcc; i++){ endSstr << strPi[i]; } std::string newPi = endSstr.str(); return newPi;}
开发者ID:Looney1300,项目名称:OperatingSystems,代码行数:15,
示例23: mainint main() { std::cout << " host is " << (is_big_endian() ? "big endian/n" : "little endian/n"); unsigned int uliteral = 0x456e7120; int sliteral = 0x456e7120; std::cout << " unsigned 0x456e7120 = " << uliteral << "/n"; std::cout << " signed 0x456e7120 = " << sliteral << "/n"; std::stringstream sstr(std::ios::binary); // Write 0x456e7120 in little endian to stream sstr << 0x20 << 0x71 << 0x6e << 0x45 << std::flush; std::cout << " " << parse_uint32(std::istreambuf_iterator<char>(sstr)) << "/n"; return 0;}
开发者ID:CCJY,项目名称:coliru,代码行数:14,
示例24: assertvoid ConfigFile::Remove(CTSTR lpSection, CTSTR lpKey){ assert(lpSection); assert(lpKey); TSTR lpTemp = lpFileData, lpEnd = &lpFileData[dwLength], lpSectionStart; DWORD dwSectionNameSize = slen(lpSection), dwKeyNameSize = slen(lpKey); BOOL bInSection = 0; do { lpTemp = sstr(lpTemp, TEXT("/n[")); if(!lpTemp) break; lpTemp += 2; if((scmpi_n(lpTemp, lpSection, dwSectionNameSize) == 0) && (lpTemp[dwSectionNameSize] == ']')) { bInSection = 1; lpSectionStart = lpTemp = schr(lpTemp, '/n')+1; break; } }while(lpTemp < lpEnd); if(!bInSection) return; //not possible, usually. do { if(*lpTemp == '[') return; else if(bInSection && (*(LPWORD)lpTemp != '//')) { if((scmpi_n(lpTemp, lpKey, dwKeyNameSize) == 0) && (lpTemp[dwKeyNameSize] == '=')) { TSTR lpNextLine = schr(lpTemp, '/n')+1; XFile file(strFileName, XFILE_WRITE, XFILE_CREATEALWAYS); file.Write("/xEF/xBB/xBF", 3); file.WriteAsUTF8(&lpFileData[2], DWORD(lpTemp-lpFileData-2)); file.WriteAsUTF8(lpNextLine, slen(lpNextLine)-2); file.Close(); if(LoadFile(XFILE_OPENEXISTING)) LoadData(); return; } } lpTemp = schr(lpTemp, '/n')+1; }while(lpTemp < lpEnd);}
开发者ID:373137461,项目名称:OBS,代码行数:50,
示例25: failvoid FFmpeg_Decoder::getInfo(int *samplerate, ChannelConfig *chans, SampleType *type){ if(!mStream) fail("No audio stream info"); if((*mStream)->codec->sample_fmt == AV_SAMPLE_FMT_U8) *type = SampleType_UInt8; else if((*mStream)->codec->sample_fmt == AV_SAMPLE_FMT_S16) *type = SampleType_Int16; else if((*mStream)->codec->sample_fmt == AV_SAMPLE_FMT_FLT) *type = SampleType_Float32; else fail(std::string("Unsupported sample format: ")+ av_get_sample_fmt_name((*mStream)->codec->sample_fmt)); if((*mStream)->codec->channel_layout == AV_CH_LAYOUT_MONO) *chans = ChannelConfig_Mono; else if((*mStream)->codec->channel_layout == AV_CH_LAYOUT_STEREO) *chans = ChannelConfig_Stereo; else if((*mStream)->codec->channel_layout == AV_CH_LAYOUT_QUAD) *chans = ChannelConfig_Quad; else if((*mStream)->codec->channel_layout == AV_CH_LAYOUT_5POINT1) *chans = ChannelConfig_5point1; else if((*mStream)->codec->channel_layout == AV_CH_LAYOUT_7POINT1) *chans = ChannelConfig_7point1; else if((*mStream)->codec->channel_layout == 0) { /* Unknown channel layout. Try to guess. */ if((*mStream)->codec->channels == 1) *chans = ChannelConfig_Mono; else if((*mStream)->codec->channels == 2) *chans = ChannelConfig_Stereo; else { std::stringstream sstr("Unsupported raw channel count: "); sstr << (*mStream)->codec->channels; fail(sstr.str()); } } else { char str[1024]; av_get_channel_layout_string(str, sizeof(str), (*mStream)->codec->channels, (*mStream)->codec->channel_layout); fail(std::string("Unsupported channel layout: ")+str); } *samplerate = (*mStream)->codec->sample_rate;}
开发者ID:Aozi,项目名称:openmw,代码行数:49,
示例26: sstr int Value::AsInt() const { if (IsNull()) return 0; else { if (IsInt() || IsDouble()) { std::stringstream sstr(valueStr); int val; sstr >> val; return val; } else throw ValueException();
开发者ID:mqudsi,项目名称:Jzon,代码行数:15,
示例27: jit_objectcache_hitsstd::unique_ptr<llvm::MemoryBuffer> PystonObjectCache::getObject(const llvm::Module* M)#endif{ static StatCounter jit_objectcache_hits("num_jit_objectcache_hits"); static StatCounter jit_objectcache_misses("num_jit_objectcache_misses"); module_identifier = M->getModuleIdentifier(); RELEASE_ASSERT(!hash_before_codegen.empty(), "hash should have already got calculated"); if (!haveCacheFileForHash()) {#if 0 // This code helps with identifying why we got a cache miss for a file. // - clear the cache directory // - run pyston // - run pyston a second time // - Now look for "*_second.ll" files in the cache directory and compare them to the "*_first.ll" IR dump std::string llvm_ir; llvm::raw_string_ostream sstr(llvm_ir); M->print(sstr, 0); sstr.flush(); llvm::sys::fs::create_directories(cache_dir.str()); std::string filename = cache_dir.str().str() + "/" + module_identifier + "_first.ll"; if (llvm::sys::fs::exists(filename)) filename = cache_dir.str().str() + "/" + module_identifier + "_second.ll"; FILE* f = fopen(filename.c_str(), "wt"); ASSERT(f, "%s", strerror(errno)); fwrite(llvm_ir.c_str(), 1, llvm_ir.size(), f); fclose(f);#endif // This file isn't in our cache jit_objectcache_misses.log(); return NULL; } llvm::SmallString<128> cache_file = cache_dir; llvm::sys::path::append(cache_file, hash_before_codegen); std::unique_ptr<llvm::MemoryBuffer> mem_buff = CompressedFile::getFile(cache_file); if (!mem_buff) { jit_objectcache_misses.log(); return NULL; } jit_objectcache_hits.log(); return mem_buff;}
开发者ID:KrishMunot,项目名称:pyston,代码行数:48,
示例28: multiHandleMensa::Mensa(const Configs& cfg) : multiHandle(curl_multi_init()), lastupdate(0), updating(false){ cfg.GetValue("menuurl", menuurl); cfg.GetValue("metaurl", metaurl); cfg.GetValue("login", login); cfg.GetValue("canteen", canteen); std::string rawlines; cfg.GetValue("lines", rawlines); std::istringstream sstr(rawlines); std::string newline; while(std::getline(sstr, newline, ',')) lines.insert(newline);}
开发者ID:c-14,项目名称:Keksbot,代码行数:16,
注:本文中的sstr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ sstrcat函数代码示例 C++ sst_sc_reg_access函数代码示例 |