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


C++ plist_new_plist_data函数代码示例

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


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

示例1: parse_real_node

static plist_t parse_real_node(char *bnode, uint8_t size)
{
    plist_data_t data = plist_new_plist_data();
    float floatval = 0.0;
    uint8_t* buf;

    size = 1 << size;			// make length less misleading
    buf = malloc (size);
    memcpy (buf, bnode, size);
    switch (size)
    {
    case sizeof(float):
        float_byte_convert(buf, size);
        floatval = *(float *) buf;
        data->realval = floatval;
        break;
    case sizeof(double):
        float_byte_convert(buf, size);
        data->realval = *(double *) buf;
        break;
    default:
        free(data);
        return NULL;
    }
    free (buf);
    data->type = PLIST_REAL;
    data->length = sizeof(double);

    return g_node_new(data);
}
开发者ID:JonathanBeck,项目名称:libplist,代码行数:30,代码来源:bplist.c

示例2: parse_uint_node

static plist_t parse_uint_node(char *bnode, uint8_t size, char **next_object)
{
    plist_data_t data = plist_new_plist_data();

    size = 1 << size;			// make length less misleading
    switch (size)
    {
    case sizeof(uint8_t):
    case sizeof(uint16_t):
    case sizeof(uint32_t):
    case sizeof(uint64_t):
        memcpy(&data->intval, bnode, size);
        data->intval = UINT_TO_HOST(&data->intval, size);
        break;
    default:
        free(data);
        return NULL;
    };

    *next_object = bnode + size;
    data->type = PLIST_UINT;
    data->length = sizeof(uint64_t);

    return g_node_new(data);
}
开发者ID:JonathanBeck,项目名称:libplist,代码行数:25,代码来源:bplist.c

示例3: parse_unicode_node

static plist_t parse_unicode_node(char *bnode, uint64_t size)
{
    plist_data_t data = plist_new_plist_data();
    uint64_t i = 0;
    gunichar2 *unicodestr = NULL;
    gchar *tmpstr = NULL;
    glong items_read = 0;
    glong items_written = 0;
    GError *error = NULL;

    data->type = PLIST_STRING;
    unicodestr = (gunichar2 *) malloc(sizeof(gunichar2) * size);
    memcpy(unicodestr, bnode, sizeof(gunichar2) * size);
    for (i = 0; i < size; i++)
        byte_convert((uint8_t *) (unicodestr + i), sizeof(gunichar2));

    tmpstr = g_utf16_to_utf8(unicodestr, size, &items_read, &items_written, &error);
    free(unicodestr);

    data->type = PLIST_STRING;
    data->strval = (char *) malloc(sizeof(char) * (items_written + 1));
    memcpy(data->strval, tmpstr, items_written);
    data->strval[items_written] = '\0';
    data->length = strlen(data->strval);
    g_free(tmpstr);
    return g_node_new(data);
}
开发者ID:JonathanBeck,项目名称:libplist,代码行数:27,代码来源:bplist.c

示例4: plist_new_data

plist_t plist_new_data(const char *val, uint64_t length)
{
    plist_data_t data = plist_new_plist_data();
    data->type = PLIST_DATA;
    data->buff = (uint8_t *) malloc(length);
    memcpy(data->buff, val, length);
    data->length = length;
    return plist_new_node(data);
}
开发者ID:daiwx,项目名称:libplist,代码行数:9,代码来源:plist.c

示例5: plist_set_type

void plist_set_type(plist_t node, plist_type type)
{
    if ( node_n_children(node) == 0 )
    {
        plist_data_t data = plist_get_data(node);
        plist_free_data( data );
        data = plist_new_plist_data();
        data->type = type;
        switch (type)
        {
        case PLIST_BOOLEAN:
            data->length = sizeof(uint8_t);
            break;
        case PLIST_UINT:
        case PLIST_UID:
            data->length = sizeof(uint64_t);
            break;
        case PLIST_REAL:
            data->length = sizeof(double);
            break;
        case PLIST_DATE:
            data->length = sizeof(struct timeval);
            break;
        default:
            data->length = 0;
            break;
        }
    }
}
开发者ID:daiwx,项目名称:libplist,代码行数:29,代码来源:plist.c

示例6: plist_copy_node

static void plist_copy_node(GNode * node, gpointer parent_node_ptr)
{
	plist_t newnode = NULL;
	plist_data_t data = plist_get_data(node);
	plist_data_t newdata = plist_new_plist_data();

	assert(data);				// plist should always have data

	memcpy(newdata, data, sizeof(struct plist_data_s));

	plist_type node_type = plist_get_node_type(node);
	if (node_type == PLIST_DATA || node_type == PLIST_STRING || node_type == PLIST_KEY) {
		switch (node_type) {
		case PLIST_DATA:
			newdata->buff = (uint8_t *) malloc(data->length);
			memcpy(newdata->buff, data->buff, data->length);
		case PLIST_KEY:
		case PLIST_STRING:
			newdata->strval = strdup((char *) data->strval);
		default:
			break;
		}
	}
	newnode = plist_new_node(newdata);

	if (*(plist_t*)parent_node_ptr) {
		g_node_append(*(plist_t*)parent_node_ptr, newnode);
	}
	else {
		*(plist_t*)parent_node_ptr = newnode;
	}

	g_node_children_foreach(node, G_TRAVERSE_ALL, plist_copy_node, &newnode);
}
开发者ID:gilir,项目名称:libplist-debian,代码行数:34,代码来源:plist.c

示例7: plist_new_bool

plist_t plist_new_bool(uint8_t val)
{
    plist_data_t data = plist_new_plist_data();
    data->type = PLIST_BOOLEAN;
    data->boolval = val;
    data->length = sizeof(uint8_t);
    return plist_new_node(data);
}
开发者ID:daiwx,项目名称:libplist,代码行数:8,代码来源:plist.c

示例8: plist_new_uid

plist_t plist_new_uid(uint64_t val)
{
    plist_data_t data = plist_new_plist_data();
    data->type = PLIST_UID;
    data->intval = val;
    data->length = sizeof(uint64_t);
    return plist_new_node(data);
}
开发者ID:daiwx,项目名称:libplist,代码行数:8,代码来源:plist.c

示例9: plist_new_real

plist_t plist_new_real(double val)
{
    plist_data_t data = plist_new_plist_data();
    data->type = PLIST_REAL;
    data->realval = val;
    data->length = sizeof(double);
    return plist_new_node(data);
}
开发者ID:daiwx,项目名称:libplist,代码行数:8,代码来源:plist.c

示例10: plist_new_string

plist_t plist_new_string(const char *val)
{
    plist_data_t data = plist_new_plist_data();
    data->type = PLIST_STRING;
    data->strval = strdup(val);
    data->length = strlen(val);
    return plist_new_node(data);
}
开发者ID:daiwx,项目名称:libplist,代码行数:8,代码来源:plist.c

示例11: plist_new_key

//These nodes should not be handled by users
static plist_t plist_new_key(const char *val)
{
    plist_data_t data = plist_new_plist_data();
    data->type = PLIST_KEY;
    data->strval = strdup(val);
    data->length = strlen(val);
    return plist_new_node(data);
}
开发者ID:daiwx,项目名称:libplist,代码行数:9,代码来源:plist.c

示例12: new_uint_node

static struct node_t* new_uint_node(uint64_t value)
{
    plist_data_t data = plist_new_plist_data();
    data->type = PLIST_UINT;
    data->intval = value;
    data->length = sizeof(uint64_t);
    return node_create(NULL, data);
}
开发者ID:EchoLiao,项目名称:libplist,代码行数:8,代码来源:xplist.c

示例13: plist_new_date

plist_t plist_new_date(int32_t sec, int32_t usec)
{
    plist_data_t data = plist_new_plist_data();
    data->type = PLIST_DATE;
    data->timeval.tv_sec = sec;
    data->timeval.tv_usec = usec;
    data->length = sizeof(struct timeval);
    return plist_new_node(data);
}
开发者ID:daiwx,项目名称:libplist,代码行数:9,代码来源:plist.c

示例14: new_key_node

static struct node_t* new_key_node(const char* name)
{
    plist_data_t data = plist_new_plist_data();
    data->type = PLIST_KEY;
    int size = strlen(name);
    data->strval = strdup(name);
    data->length = size;
    return node_create(NULL, data);
}
开发者ID:EchoLiao,项目名称:libplist,代码行数:9,代码来源:xplist.c

示例15: parse_array_node

static plist_t parse_array_node(char *bnode, uint64_t size, uint32_t ref_size)
{
    plist_data_t data = plist_new_plist_data();

    data->type = PLIST_ARRAY;
    data->length = size;
    data->buff = (uint8_t *) malloc(sizeof(uint8_t) * size * ref_size);
    memcpy(data->buff, bnode, sizeof(uint8_t) * size * ref_size);

    return g_node_new(data);
}
开发者ID:JonathanBeck,项目名称:libplist,代码行数:11,代码来源:bplist.c


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