• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

src/include/xmmsc/xmmsv.h

Go to the documentation of this file.
00001 /*  XMMS2 - X Music Multiplexer System
00002  *  Copyright (C) 2003-2009 XMMS2 Team
00003  *
00004  *  PLUGINS ARE NOT CONSIDERED TO BE DERIVED WORK !!!
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2.1 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Lesser General Public License for more details.
00015  */
00016 
00017 #ifndef __XMMSV_H__
00018 #define __XMMSV_H__
00019 
00020 #include "xmmsc/xmmsc_compiler.h"
00021 #include "xmmsc/xmmsc_stdint.h"
00022 #include "xmmsc/xmmsv_coll.h"
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 typedef enum {
00029     XMMSV_TYPE_NONE,
00030     XMMSV_TYPE_ERROR,
00031     XMMSV_TYPE_INT32,
00032     XMMSV_TYPE_STRING,
00033     XMMSV_TYPE_COLL,
00034     XMMSV_TYPE_BIN,
00035     XMMSV_TYPE_LIST,
00036     XMMSV_TYPE_DICT,
00037     XMMSV_TYPE_END
00038 } xmmsv_type_t;
00039 
00040 static inline xmmsv_type_t XMMSV_TYPE_UINT32_IS_DEPRECATED(void) XMMS_DEPRECATED;
00041 static inline xmmsv_type_t
00042 XMMSV_TYPE_UINT32_IS_DEPRECATED (void)
00043 {
00044     return XMMSV_TYPE_INT32;
00045 }
00046 #define XMMSV_TYPE_UINT32 XMMSV_TYPE_UINT32_IS_DEPRECATED()
00047 
00048 
00049 
00050 typedef struct xmmsv_St xmmsv_t;
00051 
00052 typedef struct xmmsv_list_iter_St xmmsv_list_iter_t;
00053 typedef struct xmmsv_dict_iter_St xmmsv_dict_iter_t;
00054 
00055 xmmsv_t *xmmsv_new_none (void);
00056 xmmsv_t *xmmsv_new_error (const char *errstr); /* FIXME: err id? */
00057 xmmsv_t *xmmsv_new_int (int32_t i);
00058 xmmsv_t *xmmsv_new_string (const char *s);
00059 xmmsv_t *xmmsv_new_coll (xmmsv_coll_t *coll);
00060 xmmsv_t *xmmsv_new_bin (unsigned char *data, unsigned int len);
00061 
00062 xmmsv_t *xmmsv_new_list (void);
00063 xmmsv_t *xmmsv_new_dict (void);
00064 
00065 xmmsv_t *xmmsv_ref (xmmsv_t *val);
00066 void xmmsv_unref (xmmsv_t *val);
00067 
00068 xmmsv_type_t xmmsv_get_type (const xmmsv_t *val);
00069 int xmmsv_is_type (const xmmsv_t *val, xmmsv_type_t t);
00070 
00071 /* legacy aliases */
00072 int xmmsv_is_error (const xmmsv_t *val);
00073 int xmmsv_is_list (const xmmsv_t *val) XMMS_DEPRECATED;
00074 int xmmsv_is_dict (const xmmsv_t *val) XMMS_DEPRECATED;
00075 
00076 const char * xmmsv_get_error_old (const xmmsv_t *val) XMMS_DEPRECATED;
00077 xmmsv_t *xmmsv_make_stringlist (char *array[], int num);
00078 
00079 typedef void (*xmmsv_list_foreach_func) (xmmsv_t *value, void *user_data);
00080 typedef void (*xmmsv_dict_foreach_func) (const char *key, xmmsv_t *value, void *user_data);
00081 
00082 /* legacy transitional utilities */
00083 xmmsv_type_t xmmsv_dict_entry_get_type (xmmsv_t *val, const char *key);
00084 int xmmsv_dict_entry_get_string (xmmsv_t *val, const char *key, const char **r);
00085 int xmmsv_dict_entry_get_int (xmmsv_t *val, const char *key, int32_t *r);
00086 int xmmsv_dict_entry_get_coll (xmmsv_t *val, const char *key, xmmsv_coll_t **coll);
00087 xmmsv_t *xmmsv_propdict_to_dict (xmmsv_t *propdict, const char **src_prefs);
00088 
00089 int xmmsv_get_error (const xmmsv_t *val, const char **r);
00090 int xmmsv_get_int (const xmmsv_t *val, int32_t *r);
00091 int xmmsv_get_uint (const xmmsv_t *val, uint32_t *r) XMMS_DEPRECATED;
00092 int xmmsv_get_string (const xmmsv_t *val, const char **r);
00093 int xmmsv_get_coll (const xmmsv_t *val, xmmsv_coll_t **coll);
00094 int xmmsv_get_bin (const xmmsv_t *val, const unsigned char **r, unsigned int *rlen);
00095 
00096 int xmmsv_get_list_iter (const xmmsv_t *val, xmmsv_list_iter_t **it);
00097 int xmmsv_get_dict_iter (const xmmsv_t *val, xmmsv_dict_iter_t **it);
00098 
00099 void xmmsv_list_iter_explicit_destroy (xmmsv_list_iter_t *it);
00100 void xmmsv_dict_iter_explicit_destroy (xmmsv_dict_iter_t *it);
00101 
00102 
00103 /* List */
00104 int xmmsv_list_get (xmmsv_t *listv, int pos, xmmsv_t **val);
00105 int xmmsv_list_set (xmmsv_t *listv, int pos, xmmsv_t *val);
00106 int xmmsv_list_append (xmmsv_t *listv, xmmsv_t *val);
00107 int xmmsv_list_insert (xmmsv_t *listv, int pos, xmmsv_t *val);
00108 int xmmsv_list_remove (xmmsv_t *listv, int pos);
00109 int xmmsv_list_clear (xmmsv_t *listv);
00110 int xmmsv_list_foreach (xmmsv_t *listv, xmmsv_list_foreach_func func, void* user_data);
00111 int xmmsv_list_get_size (xmmsv_t *listv);
00112 int xmmsv_list_restrict_type (xmmsv_t *listv, xmmsv_type_t type);
00113 
00114 int  xmmsv_list_iter_entry (xmmsv_list_iter_t *it, xmmsv_t **val);
00115 int  xmmsv_list_iter_valid (xmmsv_list_iter_t *it);
00116 void xmmsv_list_iter_first (xmmsv_list_iter_t *it);
00117 void xmmsv_list_iter_last (xmmsv_list_iter_t *it);
00118 void xmmsv_list_iter_next (xmmsv_list_iter_t *it);
00119 void xmmsv_list_iter_prev (xmmsv_list_iter_t *it);
00120 int  xmmsv_list_iter_seek (xmmsv_list_iter_t *it, int pos);
00121 int  xmmsv_list_iter_tell (const xmmsv_list_iter_t *it);
00122 xmmsv_t *xmmsv_list_iter_get_parent (const xmmsv_list_iter_t *it);
00123 
00124 int  xmmsv_list_iter_insert (xmmsv_list_iter_t *it, xmmsv_t *val);
00125 int  xmmsv_list_iter_remove (xmmsv_list_iter_t *it);
00126 
00127 /* Dict */
00128 int xmmsv_dict_get (xmmsv_t *dictv, const char *key, xmmsv_t **val);
00129 int xmmsv_dict_set (xmmsv_t *dictv, const char *key, xmmsv_t *val);
00130 int xmmsv_dict_remove (xmmsv_t *dictv, const char *key);
00131 int xmmsv_dict_clear (xmmsv_t *dictv);
00132 int xmmsv_dict_foreach (xmmsv_t *dictv, xmmsv_dict_foreach_func func, void *user_data);
00133 int xmmsv_dict_get_size (xmmsv_t *dictv);
00134 int xmmsv_dict_has_key (xmmsv_t *dictv, const char *key);
00135 
00136 int  xmmsv_dict_iter_pair (xmmsv_dict_iter_t *it, const char **key, xmmsv_t **val);
00137 int  xmmsv_dict_iter_valid (xmmsv_dict_iter_t *it);
00138 void xmmsv_dict_iter_first (xmmsv_dict_iter_t *it);
00139 void xmmsv_dict_iter_next (xmmsv_dict_iter_t *it);
00140 int  xmmsv_dict_iter_find (xmmsv_dict_iter_t *it, const char *key);
00141 
00142 int  xmmsv_dict_iter_set (xmmsv_dict_iter_t *it, xmmsv_t *val);
00143 int  xmmsv_dict_iter_remove (xmmsv_dict_iter_t *it);
00144 
00145 /* Utils */
00146 
00147 #define xmmsv_check_type(type) ((type) > XMMSV_TYPE_NONE && (type) < XMMSV_TYPE_END)
00148 
00149 
00150 xmmsv_t *xmmsv_decode_url (const xmmsv_t *url);
00151 int xmmsv_dict_format (char *target, int len, const char *fmt, xmmsv_t *val);
00152 
00153 int xmmsv_utf8_validate (const char *str);
00154 
00155 
00156 /* These helps us doing compiletime typechecking */
00157 static inline const char *__xmmsv_identity_const_charp (const char *v) {return v;}
00158 static inline xmmsv_t *__xmmsv_identity_xmmsv (xmmsv_t *v) {return v;}
00159 #define XMMSV_DICT_ENTRY(k, v) __xmmsv_identity_const_charp (k), __xmmsv_identity_xmmsv (v)
00160 #define XMMSV_DICT_ENTRY_STR(k, v) XMMSV_DICT_ENTRY (k, xmmsv_new_string (v))
00161 #define XMMSV_DICT_ENTRY_INT(k, v) XMMSV_DICT_ENTRY (k, xmmsv_new_int (v))
00162 #define XMMSV_DICT_END NULL
00163 xmmsv_t *xmmsv_build_dict (const char *firstkey, ...);
00164 
00165 #ifdef __cplusplus
00166 }
00167 #endif
00168 
00169 #endif

Generated on Wed Feb 9 2011 for XMMS2 by  doxygen 1.7.1