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


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

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


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

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

示例2: cbKeyPressed

void cbKeyPressed(unsigned char key, int x, int y)
{
    int tmp;
    double tmpd;
    switch (key) {
    
    case 'Q': case 'q': case 27:
        glutDestroyWindow(window_id);
        //        exit(1);
        break;

    // force entropy changes
	case 'a':
		ff_io_entropy_change();
		break;
	
	case 'd':
        Lx *= 1.05;
        Ly *= 1.05;
        Lz *= 1.05;
        break;

    case 'D':
        Lx /= 1.05;
        Ly /= 1.05;
        Lz /= 1.05;
        break;

	case 'V': case 'v':
		show_m = show_m ? 0 : 1;
		show_sphere = show_sphere ? 0 : 1;
		break;

	case 'M': case 'm':
        show_m = show_m?0:1;
        break;

    case 'X': case 'x':
        show_cube = show_cube ? 0 : 1;
        break;

    case '5':
        show_steric = show_steric?0:1;
        break;

    case 'O': case 'o':
        show_droplet = show_droplet?0:1;
        break;

    case 'B': case 'b':
        show_b = show_b?0:1;
        break;

    case 'R': case 'r':
        if (BmanY == 0) {BmanY = BmanX; BmanX = 0;}
        else if (BmanX == 0) {BmanX = -BmanY; BmanY = 0;}
        break;

    case 'l':
        ff_io_load(0);
        break;

    case 'L':
        ff_io_load(100);
        break;

    case 'S': case 's':
        show_sphere = show_sphere?0:1;
        break;

    case 'T': case 't':
        T += 1;
        break;

    case 'C': case 'c':
        T -= 1;
        break;

    case 'P': case 'p':
        projection_type = projection_type ? 0 : 1;
        cbResizeScene(window_width, window_height);
        break;

    case 'E': case 'e':
        show_bext = show_bext?0:1;
        break;
	
	case 'N': case 'n':
		
		out<<"step ="<<step << " V_oleic = " << v_oleic<<" V_car = "<<v_car<<" Bmanz ="<<BmanZ;
		GetScreenShot(out.str());
		out.str("");
		out.flush();
		break;
	case 'z':
		addPosition(x_rot, y_rot, space_k, projection_type);
		break;
	case 'Z':
		delPosition();
		break;
//.........这里部分代码省略.........
开发者ID:psci2195,项目名称:ffans,代码行数:101,代码来源:ff_model_io.cpp


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