libxrdeveloper's documentation
xr-value.h
Go to the documentation of this file.
00001 /* 
00002  * Copyright 2006-2008 Ondrej Jirman <ondrej.jirman@zonio.net>
00003  * 
00004  * This file is part of libxr.
00005  *
00006  * Libxr is free software: you can redistribute it and/or modify it under the
00007  * terms of the GNU Lesser General Public License as published by the Free
00008  * Software Foundation, either version 2 of the License, or (at your option) any
00009  * later version.
00010  *
00011  * Libxr is distributed in the hope that it will be useful, but WITHOUT ANY
00012  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00013  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00014  * details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with libxr.  If not, see <http://www.gnu.org/licenses/>.
00018  */
00019 
00037 #ifndef __XR_VALUE_H__
00038 #define __XR_VALUE_H__
00039 
00040 #include "xr-lib.h"
00041 
00044 enum _xr_value_node_type {
00045   XRV_ARRAY,   
00046   XRV_STRUCT,  
00047   XRV_MEMBER,  
00048   XRV_INT,     
00049   XRV_STRING,  
00050   XRV_BOOLEAN, 
00051   XRV_DOUBLE,  
00052   XRV_TIME,    
00053   XRV_BLOB     
00054 };
00055 
00058 typedef struct _xr_value xr_value;
00059 
00062 typedef struct _xr_blob xr_blob;
00063 
00066 struct _xr_blob
00067 {
00068   char* buf;   
00069   int len;     
00070   char refs;   
00071 };
00072 
00073 G_BEGIN_DECLS
00074 
00087 xr_blob* xr_blob_new(char* buf, int len);
00088 
00093 void xr_blob_unref(xr_blob* blob);
00094 
00101 xr_blob* xr_blob_ref(xr_blob* blob);
00102 
00109 xr_value* xr_value_ref(xr_value* val);
00110 
00117 void xr_value_unref(xr_value* val);
00118 
00125 xr_value* xr_value_string_new(const char* val);
00126 
00133 xr_value* xr_value_int_new(int val);
00134 
00141 xr_value* xr_value_bool_new(int val);
00142 
00149 xr_value* xr_value_double_new(double val);
00150 
00157 xr_value* xr_value_time_new(const char* val);
00158 
00167 xr_value* xr_value_blob_new(xr_blob* val);
00168 
00180 gboolean xr_value_to_int(xr_value* val, int* nval);
00181 
00195 gboolean xr_value_to_string(xr_value* val, char** nval);
00196 
00208 gboolean xr_value_to_bool(xr_value* val, int* nval);
00209 
00221 gboolean xr_value_to_double(xr_value* val, double* nval);
00222 
00236 gboolean xr_value_to_time(xr_value* val, char** nval);
00237 
00252 gboolean xr_value_to_blob(xr_value* val, xr_blob** nval);
00253 
00262 gboolean xr_value_to_value(xr_value* val, xr_value** nval);
00263 
00270 int xr_value_get_type(xr_value* val);
00271 
00276 xr_value* xr_value_array_new();
00277 
00284 void xr_value_array_append(xr_value* arr, xr_value* val);
00285 
00293 GSList* xr_value_get_items(xr_value* arr);
00294 
00299 xr_value* xr_value_struct_new();
00300 
00307 void xr_value_struct_set_member(xr_value* str, const char* name, xr_value* val);
00308 
00318 xr_value* xr_value_get_member(xr_value* str, const char* name);
00319 
00327 GSList* xr_value_get_members(xr_value* str);
00328 
00335 const char* xr_value_get_member_name(xr_value* mem);
00336 
00343 xr_value* xr_value_get_member_value(xr_value* mem);
00344 
00356 gboolean xr_value_is_error_retval(xr_value* val, int* errcode, char** errmsg);
00357 
00364 void xr_value_dump(xr_value* v, GString* string, int indent);
00365 
00366 G_END_DECLS
00367 
00368 #endif
Documentation for libxr, Thu Jun 9 2011 22:42:39.