您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ write_string函数代码示例

51自学网 2021-06-03 10:07:04
  C++
这篇教程C++ write_string函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中write_string函数的典型用法代码示例。如果您正苦于以下问题:C++ write_string函数的具体用法?C++ write_string怎么用?C++ write_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

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

示例1: command_find_frame_props_cache_client

static void command_find_frame_props_cache_client(void * x) {    CommandFindFrameInfo * args = (CommandFindFrameInfo *)x;    Channel * c = cache_channel();    Context * ctx = NULL;    StackTracingInfo * info = NULL;    int err = 0;    ctx = id2ctx(args->id);    if (ctx == NULL) err = ERR_INV_CONTEXT;    else if (get_stack_tracing_info(ctx, args->addr, &info) < 0) err = errno;    cache_exit();    write_stringz(&c->out, "R");    write_stringz(&c->out, args->token);    write_errno(&c->out, err);    if (args->props) {        unsigned cnt = 0;        write_stream(&c->out, '{');        if (info != NULL && info->size) {            json_write_string(&c->out, "CodeAddr");            write_stream(&c->out, ':');            json_write_uint64(&c->out, info->addr);            write_stream(&c->out, ',');            json_write_string(&c->out, "CodeSize");            write_stream(&c->out, ':');            json_write_uint64(&c->out, info->size);            cnt++;        }        if (info != NULL && info->fp != NULL) {            if (cnt++ > 0) write_stream(&c->out, ',');            json_write_string(&c->out, "FP");            write_stream(&c->out, ':');            write_commands(&c->out, ctx, info->fp->cmds, info->fp->cmds_cnt);        }        if (info != NULL && info->regs != NULL) {            int i;            if (cnt++ > 0) write_stream(&c->out, ',');            json_write_string(&c->out, "Regs");            write_stream(&c->out, ':');            write_stream(&c->out, '{');            for (i = 0; i < info->reg_cnt; i++) {                if (i > 0) write_stream(&c->out, ',');                json_write_string(&c->out, register2id(ctx, STACK_NO_FRAME, info->regs[i]->reg));                write_stream(&c->out, ':');                write_commands(&c->out, ctx, info->regs[i]->cmds, info->regs[i]->cmds_cnt);            }            write_stream(&c->out, '}');        }        if (info != NULL && info->subs != NULL) {            int i;            if (cnt++ > 0) write_stream(&c->out, ',');            json_write_string(&c->out, "Inlined");            write_stream(&c->out, ':');            write_stream(&c->out, '[');            for (i = 0; i < info->sub_cnt; i++) {                if (i > 0) write_stream(&c->out, ',');                write_inlined_subroutine_info(&c->out, info->subs[i]);            }            write_stream(&c->out, ']');        }        write_stream(&c->out, '}');        write_stream(&c->out, 0);    }    else {        /* Deprecated, use findFrameProps */        json_write_uint64(&c->out, info ? info->addr : 0);        write_stream(&c->out, 0);        json_write_uint64(&c->out, info ? info->size : 0);        write_stream(&c->out, 0);        if (info == NULL || info->fp == NULL) write_string(&c->out, "null");        else write_commands(&c->out, ctx, info->fp->cmds, info->fp->cmds_cnt);        write_stream(&c->out, 0);        if (info != NULL && info->regs != NULL) {            int i;            write_stream(&c->out, '{');            for (i = 0; i < info->reg_cnt; i++) {                if (i > 0) write_stream(&c->out, ',');                json_write_string(&c->out, register2id(ctx, STACK_NO_FRAME, info->regs[i]->reg));                write_stream(&c->out, ':');                write_commands(&c->out, ctx, info->regs[i]->cmds, info->regs[i]->cmds_cnt);            }            write_stream(&c->out, '}');        }        else {            write_string(&c->out, "null");        }        write_stream(&c->out, 0);    }    write_stream(&c->out, MARKER_EOM);//.........这里部分代码省略.........
开发者ID:tom3333,项目名称:tcf.agent,代码行数:101,


示例2: write_sref

static void write_sref(FILE *fob, mxArray *data, double uu_to_dbu){   mxArray *internal, *propfield, *pxy;   double *pdxy=NULL;   int32_t xy[2];   int mxy=0;   int k,nlen;   element_t sref;   /* internal structure */   if ( !get_field_ptr(data, "internal", &internal) )      mexErrMsgTxt("gds_write_element (sref) :  missing internal data field.");   memcpy(&sref, (int32_t *)mxGetData(internal), sizeof(element_t));   /* number of sref locations contained in compound element */   if ( get_field_ptr(data, "xy", &pxy) ) {      mxy = mxGetM(pxy);      pdxy = (double *)mxGetData(pxy);   }   else         mexErrMsgTxt("gds_write_element (sref) :  missing or empty xy field.");   /*     * write out the individual sref elements     */   for (k=0; k<mxy; k++) {      /* SREF */      write_record_hdr(fob, SREF, 0);      /* ELFLAGS */      if ( sref.has & HAS_ELFLAGS ) {	 write_record_hdr(fob, ELFLAGS, sizeof(uint16_t));	 write_word(fob, sref.elflags);      }      /* PLEX */      if ( sref.has & HAS_PLEX ) {	 write_record_hdr(fob, PLEX, sizeof(int32_t));	 write_int(fob, sref.plex);      }      /* SNAME */      nlen = strlen(sref.sname);      if ( !nlen )	 mexErrMsgTxt("gds_write_element (sref) :  name of referenced structure missing.");      if (nlen % 2)	 nlen += 1;      if (nlen > 32)	 mexErrMsgTxt("gds_write_element (sref) :  structure name must have <= 32 chars.");      write_record_hdr(fob, SNAME, nlen);      write_string(fob, sref.sname, nlen);      /* STRANS */      if ( sref.has & HAS_STRANS ) {	 write_record_hdr(fob, STRANS, sizeof(uint16_t));	 write_word(fob, sref.strans.flags);	 if ( sref.has & HAS_MAG && sref.strans.mag != 1.0) {	    write_record_hdr(fob, MAG, 8);	    write_real8(fob, sref.strans.mag);	 }	 if ( sref.has & HAS_ANGLE && sref.strans.angle != 0.0) {	    write_record_hdr(fob, ANGLE, 8);	    write_real8(fob, sref.strans.angle);	 }      }      /* XY */      xy[0] = floor(0.5 + pdxy[k]     * uu_to_dbu);      xy[1] = floor(0.5 + pdxy[k+mxy] * uu_to_dbu);      write_record_hdr(fob, XY, 2*sizeof(int32_t));      write_int_n(fob, xy, 2);         /* Property */      if ( get_field_ptr(data, "prop", &propfield) )	 write_property(fob, propfield);      /* ENDEL */      write_record_hdr(fob, ENDEL, 0);   }} 
开发者ID:huihui7987,项目名称:matlab_hui,代码行数:83,


示例3: write_aref

static void write_aref(FILE *fob, mxArray *data, double uu_to_dbu){   mxArray *field, *propfield, *internal;   double *pd;   int32_t xy[6];   int mxy,nxy=0,nlen;   element_t aref;   /* internal structure */   if ( !get_field_ptr(data, "internal", &internal) )      mexErrMsgTxt("gds_write_element (aref) :  missing internal data field.");   memcpy(&aref, (int32_t *)mxGetData(internal), sizeof(element_t));   /* AREF */   write_record_hdr(fob, AREF, 0);   /* ELFLAGS */   if ( aref.has & HAS_ELFLAGS ) {      write_record_hdr(fob, ELFLAGS, sizeof(uint16_t));      write_word(fob, aref.elflags);   }   /* PLEX */   if ( aref.has & HAS_PLEX ) {      write_record_hdr(fob, PLEX, sizeof(int32_t));      write_int(fob, aref.plex);   }   /* SNAME */      nlen = strlen(aref.sname);   if ( !nlen )      mexErrMsgTxt("gds_write_element (aref) :  name of referenced structure missing.");   if (nlen % 2)      nlen += 1;   if (nlen > 32)      mexErrMsgTxt("gds_write_element (aref) :  structure name must have <= 32 chars.");   write_record_hdr(fob, SNAME, nlen);   write_string(fob, aref.sname, nlen);   /* STRANS */   if ( aref.has & HAS_STRANS ) {      write_record_hdr(fob, STRANS, sizeof(uint16_t));      write_word(fob, aref.strans.flags);      if ( aref.has & HAS_MAG && aref.strans.mag != 1.0) {	 write_record_hdr(fob, MAG, 8);	 write_real8(fob, aref.strans.mag);      }      if ( aref.has & HAS_ANGLE && aref.strans.angle != 0.0) {	 write_record_hdr(fob, ANGLE, 8);	 write_real8(fob, aref.strans.angle);      }   }   /* COLROW */   if ( !aref.nrow )      mexErrMsgTxt("gds_write_element (aref) :  number of rows is 0; must be > 0.");   if ( !aref.ncol )      mexErrMsgTxt("gds_write_element (aref) :  number of columns is 0; must be > 0.");   write_record_hdr(fob, COLROW, 2*sizeof(uint16_t));   write_word(fob, aref.ncol);   write_word(fob, aref.nrow);      /* XY */   if ( get_field_ptr(data, "xy", &field) ) {      pd = (double *)mxGetData(field);      mxy = mxGetM(field);      nxy = mxGetN(field);      if ( (mxy != 3) || (nxy != 2) )	 mexErrMsgTxt("gds_write_element (aref) :  xy must be 3x2 matrix.");      scale_trans(pd, xy, mxy, uu_to_dbu);      write_record_hdr(fob, XY, mxy*nxy*sizeof(int32_t));      write_int_n(fob, xy, 6);   }   else         mexErrMsgTxt("gds_write_element (aref) :  missing or empty xy field.");   /* Property */   if ( get_field_ptr(data, "prop", &propfield) )      write_property(fob, propfield);   /* ENDEL */   write_record_hdr(fob, ENDEL, 0);} 
开发者ID:huihui7987,项目名称:matlab_hui,代码行数:85,


示例4: write_string

std::wstring json_spirit::write_formatted( const wmValue&  value ){    return write_string( value, true );}
开发者ID:ya3-old-c-coder,项目名称:yacoin,代码行数:4,


示例5: prefix

pfs::error_code ubjson_ostream<OStreamType, JsonType>::write_object (json_type const & j){    _os << UBJSON_CHAR_OBJECT_BEGIN;    bool use_count_optimization = ((_flags & count_optimized) && !j.empty());    bool is_special_case = false;    // If a type is specified, a count must also be specified.    // A type cannot be specified by itself.    bool use_type_optimization  = ((_flags & type_optimized) && use_count_optimization);    // Additional checks for type optimization    if (use_type_optimization) {        // This call is safe. Array is not empty as checked before        int8_t first_prefix = prefix(*j.cbegin());        use_type_optimization = pfs::all_of(j.cbegin(), j.cend(), compare_prefix(first_prefix));        if (use_type_optimization) {            _os << UBJSON_CHAR_TYPE;            _os << first_prefix;            // Check special cases            if (first_prefix == UBJSON_CHAR_NOOP                    || first_prefix == UBJSON_CHAR_NULL                    || first_prefix == UBJSON_CHAR_TRUE                    || first_prefix == UBJSON_CHAR_FALSE) {                is_special_case = true;            }        }    }    if (use_count_optimization) {        _os << UBJSON_CHAR_SIZE;        write_integer(static_cast<typename json_type::integer_type>(j.size()), true);    }    typename json_type::const_iterator first = j.cbegin();    typename json_type::const_iterator last = j.cend();    if (is_special_case) {        for (; first != last; ++first) {            // The [S] (string) marker is omitted from each of the names in the            // name/value pairings inside the object. The JSON specification does            // not allow non-string name values, therefore the [S] marker            // is redundant and must not be used.           write_string(first.key(), false);        }    } else {        for (; first != last; ++first) {            write_string(first.key(), false);            write_json(*first, !use_type_optimization);        }    }    // If a count is specified the container must not specify an end-marker.    if (!use_count_optimization)        _os << UBJSON_CHAR_OBJECT_END;    return pfs::error_code();}
开发者ID:semenovf,项目名称:pfs,代码行数:61,


示例6: append_key

static inline voidappend_key(struct bson *bs, int type, const char *key, size_t sz) {	write_byte(bs, type);	write_string(bs, key, sz);}
开发者ID:yangxgkem,项目名称:server,代码行数:5,


示例7: content_handler

/* ==================================================================== * Here's the real content handler. * ==================================================================== */static int content_handler(request_rec *r){    long length;    wkcfg *cfg;    WFILE* env_dict = NULL;    int i;    char msgbuf[MAX_STRING_LEN];    int conn_attempt = 0;    WFILE* whole_dict = NULL;    WFILE* int_dict = NULL;    const char *value;    const char *key;    array_header *hdr_arr;    table_entry *elts;    cfg = ap_get_module_config(r->per_dir_config, &webkit_module);    if (cfg == NULL) {        log_debug("No cfg", r);        cfg = (wkcfg*)wk_create_dir_config(r->pool, "/");    }    env_dict = setup_WFILE(r);    whole_dict = setup_WFILE(r);    int_dict = setup_WFILE(r);    if (env_dict == NULL || whole_dict == NULL) {        log_error("Couldn't allocate Python data structures", r->server);        return HTTP_INTERNAL_SERVER_ERROR;    }    ap_add_common_vars(r);    ap_add_cgi_vars(r); /* not included in the common_vars above */    /* Build the environment dictionary */    hdr_arr = ap_table_elts(r->subprocess_env);    elts = (table_entry *)hdr_arr->elts;    /* start dictionary */    w_byte(TYPE_DICT, env_dict);    for (i = 0; i < hdr_arr->nelts; ++i) {        if (!elts[i].key)            continue;        key = elts[i].key;        value = ap_table_get(r->subprocess_env, elts[i].key);        write_string(key, env_dict);        if (value != NULL)            write_string(value, env_dict);        else            w_byte(TYPE_NONE, env_dict);    }    hdr_arr = cfg->passheaders;    if (hdr_arr) {        char **headers = (char **)hdr_arr->elts;        for (i = 0; i < hdr_arr->nelts; i++) {            key = headers[i];            value = ap_table_get(r->headers_in, key);            if (value && *value) {                write_string(key, env_dict);                write_string(value, env_dict);            }        }    }#ifdef SECURITY_HOLE_PASS_AUTHORIZATION    /* Ordinarily Apache only makes the username available to CGI scripts,    keeping the password secret. It can be configured to make the complete    credential details available, but only by completely rebuilding the    server with SECURITY_HOLE_PASS_AUTHORIZATION set (enabling this feature    is considered a security risk). By setting the same constant, you can    have mod_webkit pass the authorization information to WebKit instead.    (suggested by Maximillian Dornseif 2003-10-27) */    key = "Authorization";    value = ap_table_get(r->headers_in, key);    if (value && *value) {      write_string("X-HTTP_AUTHORIZATION", env_dict);      write_string(value, env_dict);    }#endif    w_byte(TYPE_NULL, env_dict);    /* end dictionary */    log_debug("Built env dictionary", r);    /* We can start building the full dictionary now */    w_byte(TYPE_DICT, whole_dict);    write_string("format", whole_dict); /* key */    write_string("CGI", whole_dict); /* value */    write_string("time", whole_dict); /* key */    w_byte(TYPE_INT, whole_dict); /* value */    /* patch from Ken Lalonde to make the time entry useful */    w_long((long)r->request_time, whole_dict); /* value */    write_string("environ", whole_dict); /* key */    /* copy env_dict into whole_dict *///.........这里部分代码省略.........
开发者ID:Cito,项目名称:w4py-olde-docs,代码行数:101,


示例8: write_string

void Core::handleMessage(const Message& msg, MessageSession* session){	write_string(session->target().bare() + " -> " + msg.body());	// to debug	//print_session_id(session->target().bare());}
开发者ID:ratsy,项目名称:Cptalk-,代码行数:5,


示例9: serialize_tree

//.........这里部分代码省略.........                    // increment data pointer if node is a union                    if (node_is_union)                        *data = (char*)initial_data + largest_child_data_field;                }                // indent to current level using tab                chars = add_indent(&target_buffer, &target_size, &target_offset, level);                if (chars < 0)                    return chars;                // write node end                if (level == 0 || (*desc)[1].type == KOW_BRANCH_END)                    node_end_str = "]}/n";                else                    node_end_str = "]},/n";                chars = add_string(&target_buffer, &target_size, &target_offset, node_end_str);                if (chars < 0)                    return chars;                break;            }            default:            {                int value_size = kowhai_get_node_type_size(node->type);                // write header                chars = add_header(&target_buffer, &target_size, &target_offset, node, get_name_param, get_name);                if (chars < 0)                    return chars;                // write value identifier                chars = add_string(&target_buffer, &target_size, &target_offset, ", /""VALUE"/": ");                if (chars < 0)                    return chars;                // write value/s                if (node->type == KOW_CHAR && node->count > 1 && str_printable((char *)*data, node->count))                {                    // special string case                    chars = write_string(target_buffer, target_size, "/"%.*s/"", node->count, (char*)*data);                    if (chars >= 0)                    {                        target_buffer += chars;                        target_size -= chars;                        target_offset += chars;                    }                    else                        return chars;                    // increment data pointer                    if (!in_union)                        *data = (char*)*data + value_size * node->count;                    else if (value_size * node->count > *largest_data_field)                        *largest_data_field = value_size * node->count;                }                else if (node->count > 1)                {                    // write start bracket                    chars = add_string(&target_buffer, &target_size, &target_offset, "[");                    if (chars < 0)                        return chars;                    for (i = 0; i < node->count; i++)                    {                        // write leaf node array item value                        chars = add_value(&target_buffer, &target_size, &target_offset, node->type, (char*)*data + i * value_size);                        if (chars < 0)                            return chars;                        // write comma if there is another array item                        if (i < node->count - 1)                        {                            chars = add_string(&target_buffer, &target_size, &target_offset, ", ");                            if (chars < 0)                                return chars;
开发者ID:othane,项目名称:kowhai,代码行数:67,


示例10: filecache_update

void filecache_update(TARGET *t){	MD5SUM blobmd5sum;	int haveblobmd5sum = 0;	const char *cachedname;	const char *blobname;	int cacheerror;	if (!t->filecache_generate)		return;	/* If the buildmd5sum is empty, then the file doesn't exist. */	cacheerror = ismd5empty(t->buildmd5sum);	if (cacheerror)		return;	haveblobmd5sum = 0;	cachedname = filecache_getfilename(t, t->buildmd5sum, NULL);	if (!cachedname)		return;	/* Search for the appropriate .link file that matches the target. */	haveblobmd5sum = filecache_findlink(cachedname, blobmd5sum);	/* If we weren't able to determine the target md5sum, do it now. */	if (!haveblobmd5sum)	{#ifdef OPT_BUILTIN_LUA_SUPPORT_EXT		LIST *md5callback;		pushsettings( t->settings );		md5callback = var_get( "MD5CALLBACK" );		popsettings( t->settings );		if ( md5callback )		{			luahelper_md5callback(t->boundname, blobmd5sum, md5callback->string);		}		else		{#endif			md5file(t->boundname, blobmd5sum);#ifdef OPT_BUILTIN_LUA_SUPPORT_EXT		}#endif		memcpy(t->contentmd5sum, blobmd5sum, sizeof(MD5SUM));		if (ismd5empty(t->contentmd5sum))			return;	}	{		/* Is the blob already there? */		time_t blobtime;		blobname = filecache_getfilename(t, blobmd5sum, ".blob");		if (file_time(blobname, &blobtime) == -1)		{			time_t blobpartialtime;			const char *blobpartialname;			if(DEBUG_MD5HASH)				printf("Caching %s as %s/n", t->name, cachedname);			else				printf("Caching %s/n", t->name);			/* Write the new .blob to the cache. */			blobpartialname = filecache_getfilename(t, blobmd5sum, ".blob.partial");			if (file_time(blobpartialname, &blobpartialtime) == -1)			{				if (copyfile(blobpartialname, t->boundname, &blobmd5sum) == 0  ||					rename(blobpartialname, blobname) != 0)				{					printf("** Unable to write %s to cache./n", t->name, cachedname);					filecache_disable(t);					return;				}			}		}	}	/* Write the new .link file to the cache. */	{		FILE *file;		BUFFER linknamebuff;		buffer_init(&linknamebuff);		buffer_addstring(&linknamebuff, cachedname, strlen(cachedname));		buffer_addchar(&linknamebuff, '-');		buffer_addstring(&linknamebuff, md5tostring(blobmd5sum), 32);		buffer_addstring(&linknamebuff, ".link", 5);		buffer_addchar(&linknamebuff, 0);		file_mkdir(buffer_ptr(&linknamebuff));		file = fopen(buffer_ptr(&linknamebuff), "wb");		if (file)		{			write_md5sum(file, blobmd5sum);			write_string(file, t->name);			fclose(file);		}		buffer_free(&linknamebuff);//.........这里部分代码省略.........
开发者ID:0xb1dd1e,项目名称:jamplus,代码行数:101,


示例11: add_value

int add_value(char** dest, size_t* dest_size, int* current_offset, uint16_t node_type, void* data){    int chars;    union any_type_t val;    // on some systems vsnprintf requires the src buffer to be aligned    // properly, since data is possibly packed to make the tree tidier    // the memcpy below gets our data into an aligned var    memcpy(&val, data, kowhai_get_node_type_size(node_type));    switch (node_type)    {        case KOW_CHAR:            if (val.c < 32 || val.c >= 127)                chars = write_string(*dest, *dest_size, "%d", val.c);            else                chars = write_string(*dest, *dest_size, "%c", val.c);            break;        case KOW_INT8:            chars = write_string(*dest, *dest_size, "%d", val.i8);            break;        case KOW_INT16:            chars = write_string(*dest, *dest_size, "%d", val.i16);            break;        case KOW_INT32:            chars = write_string(*dest, *dest_size, "%d", val.i32);            break;        case KOW_INT64:            chars = write_string(*dest, *dest_size, "%ld", val.i64);            break;        case KOW_UINT8:            chars = write_string(*dest, *dest_size, "%d", val.ui8);            break;        case KOW_UINT16:            chars = write_string(*dest, *dest_size, "%d", val.ui16);            break;        case KOW_UINT32:            chars = write_string(*dest, *dest_size, "%d", val.ui32);            break;        case KOW_UINT64:            chars = write_string(*dest, *dest_size, "%ld", val.ui64);            break;        case KOW_FLOAT:            chars = write_string(*dest, *dest_size, "%.17g", val.f);            break;        case KOW_DOUBLE:            chars = write_string(*dest, *dest_size, "%.17lg", val.d);            break;        default:            return -1;    }    if (chars >= 0)    {        *dest += chars;        *dest_size -= chars;        *current_offset += chars;    }    return chars;}
开发者ID:othane,项目名称:kowhai,代码行数:59,


示例12: hcache_writefile

void	hcache_writefile(HCACHEFILE *file){	FILE	*f;	HCACHEDATA	*c;	int		header_count = 0;	int		maxage;	if( !file  ||  !file->dirty  ||  !file->cachefilename )		return;	file_mkdir(file->cachefilename);	if( ! (f = fopen( file->cachefilename, "wb" ) ) )		return;	maxage = cache_maxage();	/* print out the version */	fprintf( f, "@%[email
C++ write_string_file函数代码示例
C++ write_stream函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。