libxr — developer's documentation

- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

xr-value.h
Go to the documentation of this file.
1 /*
2 * Copyright 2006-2008 Ondrej Jirman <ondrej.jirman@zonio.net>
3 *
4 * This file is part of libxr.
5 *
6 * Libxr is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU Lesser General Public License as published by the Free
8 * Software Foundation, either version 2 of the License, or (at your option) any
9 * later version.
10 *
11 * Libxr is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 * details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with libxr. If not, see <http://www.gnu.org/licenses/>.
18 */
19
37 #ifndef __XR_VALUE_H__
38 #define __XR_VALUE_H__
39
40 #include "xr-lib.h"
41
44 enum _xr_value_node_type {
45 XRV_ARRAY,
46 XRV_STRUCT,
47 XRV_MEMBER,
48 XRV_INT,
49 XRV_STRING,
50 XRV_BOOLEAN,
51 XRV_DOUBLE,
52 XRV_TIME,
53 XRV_BLOB
54 };
55
58 typedef struct _xr_value xr_value;
59
62 typedef struct _xr_blob xr_blob;
63
66 struct _xr_blob
67 {
68 char* buf;
69 int len;
70 char refs;
71 };
72
73 G_BEGIN_DECLS
74
87 xr_blob* xr_blob_new(char* buf, int len);
88
93 void xr_blob_unref(xr_blob* blob);
94
101 xr_blob* xr_blob_ref(xr_blob* blob);
102
109 xr_value* xr_value_ref(xr_value* val);
110
117 void xr_value_unref(xr_value* val);
118
125 xr_value* xr_value_string_new(const char* val);
126
133 xr_value* xr_value_int_new(int val);
134
141 xr_value* xr_value_bool_new(int val);
142
149 xr_value* xr_value_double_new(double val);
150
157 xr_value* xr_value_time_new(const char* val);
158
167 xr_value* xr_value_blob_new(xr_blob* val);
168
180 gboolean xr_value_to_int(xr_value* val, int* nval);
181
195 gboolean xr_value_to_string(xr_value* val, char** nval);
196
208 gboolean xr_value_to_bool(xr_value* val, int* nval);
209
221 gboolean xr_value_to_double(xr_value* val, double* nval);
222
236 gboolean xr_value_to_time(xr_value* val, char** nval);
237
252 gboolean xr_value_to_blob(xr_value* val, xr_blob** nval);
253
262 gboolean xr_value_to_value(xr_value* val, xr_value** nval);
263
270 int xr_value_get_type(xr_value* val);
271
276 xr_value* xr_value_array_new();
277
284 void xr_value_array_append(xr_value* arr, xr_value* val);
285
293 GSList* xr_value_get_items(xr_value* arr);
294
299 xr_value* xr_value_struct_new();
300
307 void xr_value_struct_set_member(xr_value* str, const char* name, xr_value* val);
308
318 xr_value* xr_value_get_member(xr_value* str, const char* name);
319
327 GSList* xr_value_get_members(xr_value* str);
328
335 const char* xr_value_get_member_name(xr_value* mem);
336
343 xr_value* xr_value_get_member_value(xr_value* mem);
344
356 gboolean xr_value_is_error_retval(xr_value* val, int* errcode, char** errmsg);
357
364 void xr_value_dump(xr_value* v, GString* string, int indent);
365
366 G_END_DECLS
367
368 #endif
XRV_ARRAY
Array.
Definition: xr-value.h:45
xr-lib.h
XML-RPC Library Setup API.
xr_value_double_new
xr_value * xr_value_double_new(double val)
Create new xr_value node of type XRV_DOUBLE.
xr_value_get_type
int xr_value_get_type(xr_value *val)
Get type of xr_value node.
xr_value_is_error_retval
gboolean xr_value_is_error_retval(xr_value *val, int *errcode, char **errmsg)
Check if given node is stadard XML-RPC error struct.
xr_value_to_time
gboolean xr_value_to_time(xr_value *val, char **nval)
Extract xr_value of type XRV_TIME into the native language type.
XRV_STRUCT
Struct.
Definition: xr-value.h:46
xr_value_string_new
xr_value * xr_value_string_new(const char *val)
Create new xr_value node of type XRV_STRING.
XRV_BOOLEAN
Boolean.
Definition: xr-value.h:50
xr_value_array_append
void xr_value_array_append(xr_value *arr, xr_value *val)
Add value to the array node.
XRV_STRING
String.
Definition: xr-value.h:49
xr_value
struct _xr_value xr_value
Opaque data structure that holds information about particular node.
Definition: xr-value.h:58
xr_value_ref
xr_value * xr_value_ref(xr_value *val)
Take reference to the node.
xr_value_unref
void xr_value_unref(xr_value *val)
Unref xr_value node.
xr_value_to_blob
gboolean xr_value_to_blob(xr_value *val, xr_blob **nval)
Extract xr_value of type XRV_BLOB into the native language type.
xr_value_to_double
gboolean xr_value_to_double(xr_value *val, double *nval)
Extract xr_value of type XRV_DOUBLE into the native language type.
xr_value_struct_new
xr_value * xr_value_struct_new()
Create new struct xr_value node.
xr_value_get_member_name
const char * xr_value_get_member_name(xr_value *mem)
Get name of the struct member from the XRV_MEMBER node.
xr_value_array_new
xr_value * xr_value_array_new()
Create new array xr_value node.
_xr_blob::buf
char * buf
Buffer.
Definition: xr-value.h:68
xr_value_to_string
gboolean xr_value_to_string(xr_value *val, char **nval)
Extract xr_value of type XRV_STRING into the native language type.
xr_value_get_member_value
xr_value * xr_value_get_member_value(xr_value *mem)
Get value of the struct member from the XRV_MEMBER node.
xr_value_get_members
GSList * xr_value_get_members(xr_value *str)
Get list of XRV_MEMBER nodes from the struct node.
xr_value_blob_new
xr_value * xr_value_blob_new(xr_blob *val)
Create new xr_value node of type XRV_BLOB.
xr_value_to_int
gboolean xr_value_to_int(xr_value *val, int *nval)
Extract xr_value of type XRV_INT into the native language type.
xr_blob_unref
void xr_blob_unref(xr_blob *blob)
Free blob.
XRV_BLOB
Blob (base64).
Definition: xr-value.h:53
xr_value_get_items
GSList * xr_value_get_items(xr_value *arr)
Get list of items from the array node.
xr_value_get_member
xr_value * xr_value_get_member(xr_value *str, const char *name)
Get member value from the struct node.
XRV_MEMBER
Struct member.
Definition: xr-value.h:47
XRV_INT
Integer.
Definition: xr-value.h:48
xr_blob_ref
xr_blob * xr_blob_ref(xr_blob *blob)
Take reference to blbo.
_xr_blob::refs
char refs
Number of references.
Definition: xr-value.h:70
xr_value_struct_set_member
void xr_value_struct_set_member(xr_value *str, const char *name, xr_value *val)
Set struct member value.
xr_value_dump
void xr_value_dump(xr_value *v, GString *string, int indent)
Debugging function that dumps node tree to the string.
xr_value_to_bool
gboolean xr_value_to_bool(xr_value *val, int *nval)
Extract xr_value of type XRV_BOOLEAN into the native language type.
xr_value_bool_new
xr_value * xr_value_bool_new(int val)
Create new xr_value node of type XRV_BOOLEAN.
_xr_value_node_type
_xr_value_node_type
Value Node Types.
Definition: xr-value.h:44
xr_value_time_new
xr_value * xr_value_time_new(const char *val)
Create new xr_value node of type XRV_TIME.
_xr_blob::len
int len
Buffer length.
Definition: xr-value.h:69
xr_value_int_new
xr_value * xr_value_int_new(int val)
Create new xr_value node of type XRV_INT.
_xr_blob
Type used to pass blobs around in the user code.
Definition: xr-value.h:66
XRV_DOUBLE
Double.
Definition: xr-value.h:51
xr_value_to_value
gboolean xr_value_to_value(xr_value *val, xr_value **nval)
Just a convenience interface to xr_value_ref.
xr_blob_new
G_BEGIN_DECLS xr_blob * xr_blob_new(char *buf, int len)
Create new blob.
XRV_TIME
Time.
Definition: xr-value.h:52
Documentation for libxr, Mon Jan 6 2014 07:32:37.