示例#1
0
文件: render.hpp 项目: jeaye/casst
 std::string to_string(T const &t)
 {
   static std::ostringstream oss;
   oss.clear(); oss.str("");
   oss << t;
   return oss.str();
 }
示例#2
0
void logger::log(int line, std::ostringstream &outstring)
{
    if ( logging == 0 ) return;
    *out << file << ":" << line << " - " << outstring.str();
    outstring.str(std::string());
    outstring.clear();
}
示例#3
0
文件: main.cpp 项目: CCJY/coliru
std::string expand(Range const& key)
{
    thread_local std::ostringstream oss;
    oss.str().clear();
    oss.clear();
    oss.seekp(0);
    oss << " (subst_for_" << key.to_string() << ':' << (rand()%42) << ") ";
    return oss.str();
}
示例#4
0
    void
    _SetCommonOptions(const std::string& url) {

        // set url
        CURLcode err = curl_easy_setopt(handle_, CURLOPT_URL, url.c_str());
        _CheckError(err, "set url");

        // Allow redirection
        err = curl_easy_setopt(handle_, CURLOPT_FOLLOWLOCATION, 1L);
        _CheckError(err, "set follow location");

        // Clear write stream
        write_stream_.str("");
        write_stream_.clear();

        // Set callback for write
        err = curl_easy_setopt(handle_, CURLOPT_WRITEFUNCTION, _WriteCb);
        _CheckError(err, "set write callback");

        // Set callback data
        err = curl_easy_setopt(handle_, CURLOPT_WRITEDATA, this);
        _CheckError(err, "set write data");

        if (enable_header_) {
            // Get curl header

            // clear existing header data
            header_stream_.str("");
            header_stream_.clear();

            // Set header callback function
            err = curl_easy_setopt(handle_, CURLOPT_HEADERFUNCTION, _HeaderCb);
            _CheckError(err, "set header callback");

            // Set header user data for callback function
            err = curl_easy_setopt(handle_, CURLOPT_HEADERDATA, this);
            _CheckError(err, "set header data");
        }

        // Set the user agent. Some servers requires this on requests
        err = curl_easy_setopt(handle_, CURLOPT_USERAGENT, "libcurl-agent/1.0");
        _CheckError(err, "set write data");
    }
示例#5
0
文件: api_interp.cpp 项目: 0Chuzz/z3
    int Z3_check_interpolant(Z3_context ctx,
                             unsigned num,
                             Z3_ast *cnsts,
                             unsigned *parents,
                             Z3_ast *itp,
                             Z3_string *error,
                             unsigned num_theory,
                             Z3_ast *theory){

        ast_manager &_m = mk_c(ctx)->m();
        itp_err.clear();

        // need a solver -- make one here, but how?
        params_ref p = params_ref::get_empty(); //FIXME
        scoped_ptr<solver_factory> sf(mk_smt_solver_factory());
        scoped_ptr<solver> sp((*(sf))(_m, p, false, true, false, symbol("AUFLIA")));

        ptr_vector<ast> cnsts_vec(num);  // get constraints in a vector
        for (unsigned i = 0; i < num; i++){
            ast *a = to_ast(cnsts[i]);
            cnsts_vec[i] = a;
        }

        ptr_vector<ast> itp_vec(num);  // get interpolants in a vector
        for (unsigned i = 0; i < num - 1; i++){
            ast *a = to_ast(itp[i]);
            itp_vec[i] = a;
        }

        ::vector<int> parents_vec;  // get parents in a vector
        if (parents){
            parents_vec.resize(num);
            for (unsigned i = 0; i < num; i++)
                parents_vec[i] = parents[i];
        }

        ptr_vector<ast> theory_vec; // get background theory in a vector
        if (theory){
            theory_vec.resize(num_theory);
            for (unsigned i = 0; i < num_theory; i++)
                theory_vec[i] = to_ast(theory[i]);
        }

        bool res = iz3check(_m,
                            sp.get(),
                            itp_err,
                            cnsts_vec,
                            parents_vec,
                            itp_vec,
                            theory_vec);

        *error = res ? 0 : itp_err.str().c_str();
        return res;
    }
示例#6
0
std::string to_binary(std::ostringstream &out, const T &t) {
  out.clear();
  out.seekp(0);
  bf::fold(t, 0, app_item(out));
  // because out.str() gives us the contents of the string buffer,
  // not the contents written since clear() was called, we need to
  // chop off any remaining garbage at the end.
  std::string rv = out.str();
  rv.resize(out.tellp());
  return rv;
}
示例#7
0
文件: actor.cpp 项目: Duion/GuideBot
void Actor::printActions(std::ostringstream& buff, bool full)
{
	buff.clear();
	buff<<"Actor state: "<<m_state->getName()<<std::endl;
	buff<<"Actor actions on effectors: "<<std::endl;
	for(EffectorMap::iterator it = m_effectors.begin(),end = m_effectors.end();
			it!=end;it++)
	{
		Effector* effector = it->second;
		buff<<Effector::convertToString(effector->getId())<<std::endl;
		std::string tabs;

		print(effector,m_rootAction,buff,tabs,full);
	}
}
示例#8
0
void test_per_segment_const(Geometry const& geometry,
        std::string const& expected_dsv,
        double expected_length)
{
    typedef typename bg::point_type<Geometry>::type point_type;

    // function
    g_out.str("");
    g_out.clear();
    bg::for_each_segment(geometry,
            stream_segment<bg::model::referring_segment<point_type const> >);
    std::string out = g_out.str();
    boost::trim(out);
    BOOST_CHECK_EQUAL(out, expected_dsv);

    // functor
    sum_segment_length<bg::model::referring_segment<point_type const> > functor;
    functor = bg::for_each_segment(geometry, functor);

    BOOST_CHECK_CLOSE(functor.sum, expected_length, 0.0001);
}
示例#9
0
文件: api_interp.cpp 项目: 0Chuzz/z3
    static bool iZ3_parse(Z3_context ctx, const char *filename, const char **error, svector<Z3_ast> &assertions){
        read_error.clear();
        try {
            std::string foo(filename);
            if (foo.size() >= 5 && foo.substr(foo.size() - 5) == ".smt2"){
                Z3_ast assrts = Z3_parse_smtlib2_file(ctx, filename, 0, 0, 0, 0, 0, 0);
                Z3_app app = Z3_to_app(ctx, assrts);
                int nconjs = Z3_get_app_num_args(ctx, app);
                assertions.resize(nconjs);
                for (int k = 0; k < nconjs; k++)
                    assertions[k] = Z3_get_app_arg(ctx, app, k);
            }
            else {
                Z3_parse_smtlib_file(ctx, filename, 0, 0, 0, 0, 0, 0);
                int numa = Z3_get_smtlib_num_assumptions(ctx);
                int numf = Z3_get_smtlib_num_formulas(ctx);
                int num = numa + numf;

                assertions.resize(num);
                for (int j = 0; j < num; j++){
                    if (j < numa)
                        assertions[j] = Z3_get_smtlib_assumption(ctx, j);
                    else
                        assertions[j] = Z3_get_smtlib_formula(ctx, j - numa);
                }
            }
        }
        catch (...) {
            read_error << "SMTLIB parse error: " << Z3_get_smtlib_error(ctx);
            read_msg = read_error.str();
            *error = read_msg.c_str();
            return false;
        }
        Z3_set_error_handler(ctx, 0);
        return true;
    }
示例#10
0
void cleanup() {
    featureVector.clear();
    os.clear(); os.seekp(0);    // reset string stream
    os.str("");
}
示例#11
0
 void emptyAndClearString() {
     str.str(std::string());
     str.clear();
 }
示例#12
0
	void writeToConsole(std::ostream &os, std::ostringstream &oss) {
		boost::unique_lock<boost::mutex> console_lock(mutConsole);
		os << oss.str();
		oss.str("");
		oss.clear();
	}