Commit ff536344 authored by Jonathan Beck's avatar Jonathan Beck

Remove deprecated functions from API.

parent 51c24ae5
......@@ -578,169 +578,7 @@ extern "C"
*/
PLIST_API char plist_compare_node_value(plist_t node_l, plist_t node_r);
//DEPRECATED API BELOW
/*@}*/
/**
* \defgroup DeprecatedAPI Deprecated libplist API
*/
/*@{*/
/********************************************
* *
* Tree navigation *
* *
********************************************/
/**
* Get the first child of a node
*
* @param node the first child
*/
PLIST_API plist_t plist_get_first_child(plist_t node);
/**
* Get the next sibling of a node
*
* @param node the next sibling
*/
PLIST_API plist_t plist_get_next_sibling(plist_t node);
/**
* Get the previous sibling of a node
*
* @param node the previous sibling
*/
PLIST_API plist_t plist_get_prev_sibling(plist_t node);
/**
* Get the nth child of a #PLIST_ARRAY node.
*
* @param node the node of type #PLIST_ARRAY
* @param n the index of the child to get. Range is [0, array_size[
* @return the nth children or NULL if node is not of type #PLIST_ARRAY
*/
PLIST_API plist_t plist_get_array_nth_el(plist_t node, uint32_t n);
/**
* Get the child of a #PLIST_DICT node from the associated key value.
*
* @param node the node of type #PLIST_DICT
* @param key the key associated to the requested value
* @return the key associated value or NULL if node is not of type #PLIST_DICT
*/
PLIST_API plist_t plist_get_dict_el_from_key(plist_t node, const char *key);
/********************************************
* *
* Setters *
* *
********************************************/
/**
* Add a subnode to a node. The node must be of a structured type
* (ie #PLIST_DICT or #PLIST_ARRAY). This function fails silently
* if subnode already has a father.
*
* @param node the node to add a children to
* @param subnode the children node
*/
PLIST_API void plist_add_sub_node(plist_t node, plist_t subnode);
/**
* Add a subnode of type #PLIST_KEY to a node. The node must be of a structured type
* (ie #PLIST_DICT or #PLIST_ARRAY).
*
* @param node the node to add a children to
* @param val the key value encoded as an ASCII string (must be null terminated)
*/
PLIST_API void plist_add_sub_key_el(plist_t node, const char *val);
/**
* Add a subnode of type #PLIST_STRING to a node. The node must be of a structured type
* (ie #PLIST_DICT or #PLIST_ARRAY).
*
* @param node the node to add a children to
* @param val the string value encoded as an ASCII or UTF-8 string (must be null terminated)
*/
PLIST_API void plist_add_sub_string_el(plist_t node, const char *val);
/**
* Add a subnode of type #PLIST_BOOLEAN to a node. The node must be of a structured type
* (ie #PLIST_DICT or #PLIST_ARRAY).
*
* @param node the node to add a children to
* @param val the boolean value (TRUE or FALSE)
*/
PLIST_API void plist_add_sub_bool_el(plist_t node, uint8_t val);
/**
* Add a subnode of type #PLIST_UINT to a node. The node must be of a structured type
* (ie #PLIST_DICT or #PLIST_ARRAY).
*
* @param node the node to add a children to
* @param val the unsigned integer value
*/
PLIST_API void plist_add_sub_uint_el(plist_t node, uint64_t val);
/**
* Add a subnode of type #PLIST_REAL to a node. The node must be of a structured type
* (ie #PLIST_DICT or #PLIST_ARRAY).
*
* @param node the node to add a children to
* @param val the real value
*/
PLIST_API void plist_add_sub_real_el(plist_t node, double val);
/**
* Add a subnode of type #PLIST_DATA to a node. The node must be of a structured type
* (ie #PLIST_DICT or #PLIST_ARRAY).
*
* @param node the node to add a children to
* @param val the binary buffer
* @param length the length of the buffer
*/
PLIST_API void plist_add_sub_data_el(plist_t node, const char *val, uint64_t length);
/**
* Add a subnode of type #PLIST_DATE to a node. The node must be of a structured type
* (ie #PLIST_DICT or #PLIST_ARRAY).
*
* @param node the node to add a children to
* @param sec the number of seconds since 01/01/2001
* @param usec the number of microseconds
*/
PLIST_API void plist_add_sub_date_el(plist_t node, int32_t sec, int32_t usec);
/********************************************
* *
* Utils *
* *
********************************************/
/**
* Find the first encountered #PLIST_KEY node mathing that key.
* Search is breath first order.
*
* @param plist the root node of the plist structure.
* @param value the ASCII Key to match.
*/
PLIST_API plist_t plist_find_node_by_key(plist_t plist, const char *value);
/**
* Find the first encountered #PLIST_STRING node mathing that string.
* Search is breath first order.
*
* @param plist the root node of the plist structure.
* @param value the ASCII String to match.
*/
PLIST_API plist_t plist_find_node_by_string(plist_t plist, const char *value);
/*@}*/
#ifdef __cplusplus
}
......
......@@ -786,192 +786,3 @@ void plist_set_date_val(plist_t node, int32_t sec, int32_t usec)
plist_set_element_val(node, PLIST_DATE, &val, sizeof(GTimeVal));
}
//DEPRECATED API BELOW
static plist_t plist_add_sub_element(plist_t node, plist_type type, const void *value, uint64_t length)
{
//only structured types can have children
plist_type node_type = plist_get_node_type(node);
if (node_type == PLIST_DICT || node_type == PLIST_ARRAY)
{
//only structured types are allowed to have nulll value
if (value || (!value && (type == PLIST_DICT || type == PLIST_ARRAY)))
{
plist_t subnode = NULL;
//now handle value
plist_data_t data = plist_new_plist_data();
data->type = type;
data->length = length;
switch (type)
{
case PLIST_BOOLEAN:
data->boolval = *((char *) value);
break;
case PLIST_UINT:
data->intval = *((uint64_t *) value);
break;
case PLIST_REAL:
data->realval = *((double *) value);
break;
case PLIST_KEY:
case PLIST_STRING:
data->strval = strdup((char *) value);
break;
case PLIST_DATA:
data->buff = (uint8_t *) malloc(length);
memcpy(data->buff, value, length);
break;
case PLIST_DATE:
data->timeval.tv_sec = ((GTimeVal *) value)->tv_sec;
data->timeval.tv_usec = ((GTimeVal *) value)->tv_usec;
break;
case PLIST_ARRAY:
case PLIST_DICT:
default:
break;
}
subnode = plist_new_node(data);
if (node)
g_node_append(node, subnode);
return subnode;
}
else
return NULL;
}
return NULL;
}
plist_t plist_get_first_child(plist_t node)
{
return (plist_t) g_node_first_child((GNode *) node);
}
plist_t plist_get_next_sibling(plist_t node)
{
return (plist_t) g_node_next_sibling((GNode *) node);
}
plist_t plist_get_prev_sibling(plist_t node)
{
return (plist_t) g_node_prev_sibling((GNode *) node);
}
plist_t plist_get_array_nth_el(plist_t node, uint32_t n)
{
plist_t ret = NULL;
if (node && PLIST_ARRAY == plist_get_node_type(node))
{
uint32_t i = 0;
plist_t temp = plist_get_first_child(node);
while (i <= n && temp)
{
if (i == n)
ret = temp;
temp = plist_get_next_sibling(temp);
i++;
}
}
return ret;
}
plist_t plist_get_dict_el_from_key(plist_t node, const char *key)
{
plist_t ret = NULL;
if (node && PLIST_DICT == plist_get_node_type(node))
{
plist_t key_node = plist_find_node_by_key(node, key);
ret = plist_get_next_sibling(key_node);
}
return ret;
}
void plist_add_sub_node(plist_t node, plist_t subnode)
{
if (node && subnode)
{
plist_type type = plist_get_node_type(node);
if (type == PLIST_DICT || type == PLIST_ARRAY)
g_node_append(node, subnode);
}
}
void plist_add_sub_key_el(plist_t node, const char *val)
{
plist_add_sub_element(node, PLIST_KEY, val, strlen(val));
}
void plist_add_sub_string_el(plist_t node, const char *val)
{
plist_add_sub_element(node, PLIST_STRING, val, strlen(val));
}
void plist_add_sub_bool_el(plist_t node, uint8_t val)
{
plist_add_sub_element(node, PLIST_BOOLEAN, &val, sizeof(uint8_t));
}
void plist_add_sub_uint_el(plist_t node, uint64_t val)
{
plist_add_sub_element(node, PLIST_UINT, &val, sizeof(uint64_t));
}
void plist_add_sub_real_el(plist_t node, double val)
{
plist_add_sub_element(node, PLIST_REAL, &val, sizeof(double));
}
void plist_add_sub_data_el(plist_t node, const char *val, uint64_t length)
{
plist_add_sub_element(node, PLIST_DATA, val, length);
}
void plist_add_sub_date_el(plist_t node, int32_t sec, int32_t usec)
{
GTimeVal val = { sec, usec };
plist_add_sub_element(node, PLIST_DATE, &val, sizeof(GTimeVal));
}
static plist_t plist_find_node(plist_t plist, plist_type type, const void *value, uint64_t length)
{
plist_t current = NULL;
if (!plist)
return NULL;
for (current = (plist_t)g_node_first_child(plist); current; current = (plist_t)g_node_next_sibling(current))
{
plist_data_t data = plist_get_data(current);
if (data->type == type && data->length == length && compare_node_value(type, data, value, length))
{
return current;
}
if (data->type == PLIST_DICT || data->type == PLIST_ARRAY)
{
plist_t sub = plist_find_node(current, type, value, length);
if (sub)
return sub;
}
}
return NULL;
}
plist_t plist_find_node_by_key(plist_t plist, const char *value)
{
return plist_find_node(plist, PLIST_KEY, value, strlen(value));
}
plist_t plist_find_node_by_string(plist_t plist, const char *value)
{
return plist_find_node(plist, PLIST_STRING, value, strlen(value));
}
#build the test executable
INCLUDE_DIRECTORIES( ${GLIB2_INCLUDE_DIR} )
SET(plist_test_SRC
plist_test.c)
......
......@@ -27,10 +27,27 @@
#include <string.h>
#include <sys/stat.h>
#include <glib.h>
#ifdef _MSC_VER
#pragma warning(disable:4996)
#endif
static plist_t plist_get_first_child(plist_t node)
{
return (plist_t) g_node_first_child((GNode *) node);
}
static plist_t plist_get_next_sibling(plist_t node)
{
return (plist_t) g_node_next_sibling((GNode *) node);
}
static plist_t plist_get_prev_sibling(plist_t node)
{
return (plist_t) g_node_prev_sibling((GNode *) node);
}
char compare_plist(plist_t node_l, plist_t node_r)
{
plist_t cur_l = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment