Qt: remove a suspicious delete
[vlc.git] / include / vlc_variables.h
blob420f0b4d026725d423f32ed510276bd53ffcf207
1 /*****************************************************************************
2 * vlc_variables.h: variables handling
3 *****************************************************************************
4 * Copyright (C) 2002-2004 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Samuel Hocevar <sam@zoy.org>
8 * Gildas Bazin <gbazin@netcourrier.com>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #ifndef VLC_VARIABLES_H
26 #define VLC_VARIABLES_H 1
28 /**
29 * \file
30 * This file defines functions and structures for dynamic variables in vlc
33 /**
34 * \defgroup variables Variables
36 * Functions for using the object variables in vlc.
38 * Vlc have a very powerful "object variable" infrastructure useful
39 * for many things.
41 * @{
44 #define VLC_VAR_TYPE 0x00ff
45 #define VLC_VAR_CLASS 0x00f0
46 #define VLC_VAR_FLAGS 0xff00
48 /**
49 * \defgroup var_type Variable types
50 * These are the different types a vlc variable can have.
51 * @{
53 #define VLC_VAR_VOID 0x0010
54 #define VLC_VAR_BOOL 0x0020
55 #define VLC_VAR_INTEGER 0x0030
56 #define VLC_VAR_HOTKEY 0x0031
57 #define VLC_VAR_STRING 0x0040
58 #define VLC_VAR_VARIABLE 0x0044
59 #define VLC_VAR_FLOAT 0x0050
60 #define VLC_VAR_TIME 0x0060
61 #define VLC_VAR_ADDRESS 0x0070
62 #define VLC_VAR_COORDS 0x00A0
63 /**@}*/
65 /** \defgroup var_flags Additive flags
66 * These flags are added to the type field of the variable. Most as a result of
67 * a var_Change() call, but some may be added at creation time
68 * @{
70 #define VLC_VAR_HASCHOICE 0x0100
71 #define VLC_VAR_HASMIN 0x0200
72 #define VLC_VAR_HASMAX 0x0400
73 #define VLC_VAR_HASSTEP 0x0800
75 #define VLC_VAR_ISCOMMAND 0x2000
77 /** Creation flag */
78 /* If the variable is not found on the current module
79 search all parents and finally module config until found */
80 #define VLC_VAR_DOINHERIT 0x8000
81 /**@}*/
83 /**
84 * \defgroup var_action Variable actions
85 * These are the different actions that can be used with var_Change().
86 * The parameters given are the meaning of the two last parameters of
87 * var_Change() when this action is being used.
88 * @{
91 /**
92 * Set the minimum value of this variable
93 * \param p_val The new minimum value
94 * \param p_val2 Unused
96 #define VLC_VAR_SETMIN 0x0010
97 /**
98 * Set the maximum value of this variable
99 * \param p_val The new maximum value
100 * \param p_val2 Unused
102 #define VLC_VAR_SETMAX 0x0011
103 #define VLC_VAR_SETSTEP 0x0012
106 * Set the value of this variable without triggering any callbacks
107 * \param p_val The new value
108 * \param p_val2 Unused
110 #define VLC_VAR_SETVALUE 0x0013
112 #define VLC_VAR_SETTEXT 0x0014
113 #define VLC_VAR_GETTEXT 0x0015
115 #define VLC_VAR_GETMIN 0x0016
116 #define VLC_VAR_GETMAX 0x0017
117 #define VLC_VAR_GETSTEP 0x0018
119 #define VLC_VAR_ADDCHOICE 0x0020
120 #define VLC_VAR_DELCHOICE 0x0021
121 #define VLC_VAR_CLEARCHOICES 0x0022
122 #define VLC_VAR_SETDEFAULT 0x0023
123 #define VLC_VAR_GETCHOICES 0x0024
124 #define VLC_VAR_GETLIST 0x0025
125 #define VLC_VAR_CHOICESCOUNT 0x0026
127 /**@}*/
129 /** \defgroup var_GetAndSet Variable actions
130 * These are the different actions that can be used with var_GetAndSet()
131 * @{
133 enum {
134 VLC_VAR_BOOL_TOGGLE, /**< Invert a boolean value (param ignored) */
135 VLC_VAR_INTEGER_ADD, /**< Add parameter to an integer value */
136 VLC_VAR_INTEGER_OR, /**< Binary OR over an integer bits field */
137 VLC_VAR_INTEGER_NAND,/**< Binary NAND over an integer bits field */
139 /**@}*/
141 /*****************************************************************************
142 * Prototypes
143 *****************************************************************************/
144 VLC_API int var_Create( vlc_object_t *, const char *, int );
145 #define var_Create(a,b,c) var_Create( VLC_OBJECT(a), b, c )
147 VLC_API int var_Destroy( vlc_object_t *, const char * );
148 #define var_Destroy(a,b) var_Destroy( VLC_OBJECT(a), b )
150 VLC_API int var_Change( vlc_object_t *, const char *, int, vlc_value_t *, vlc_value_t * );
151 #define var_Change(a,b,c,d,e) var_Change( VLC_OBJECT(a), b, c, d, e )
153 VLC_API int var_Type( vlc_object_t *, const char * ) VLC_USED;
154 #define var_Type(a,b) var_Type( VLC_OBJECT(a), b )
156 VLC_API int var_Set( vlc_object_t *, const char *, vlc_value_t );
157 #define var_Set(a,b,c) var_Set( VLC_OBJECT(a), b, c )
159 VLC_API int var_Get( vlc_object_t *, const char *, vlc_value_t * );
160 #define var_Get(a,b,c) var_Get( VLC_OBJECT(a), b, c )
162 VLC_API int var_SetChecked( vlc_object_t *, const char *, int, vlc_value_t );
163 #define var_SetChecked(o,n,t,v) var_SetChecked(VLC_OBJECT(o),n,t,v)
164 VLC_API int var_GetChecked( vlc_object_t *, const char *, int, vlc_value_t * );
165 #define var_GetChecked(o,n,t,v) var_GetChecked(VLC_OBJECT(o),n,t,v)
166 VLC_API int var_GetAndSet( vlc_object_t *, const char *, int, vlc_value_t * );
168 VLC_API int var_Inherit( vlc_object_t *, const char *, int, vlc_value_t * );
170 VLC_API void var_FreeList( vlc_value_t *, vlc_value_t * );
173 /*****************************************************************************
174 * Variable callbacks
175 *****************************************************************************
176 * int MyCallback( vlc_object_t *p_this,
177 * char const *psz_variable,
178 * vlc_value_t oldvalue,
179 * vlc_value_t newvalue,
180 * void *p_data);
181 *****************************************************************************/
182 VLC_API int var_AddCallback( vlc_object_t *, const char *, vlc_callback_t, void * );
183 VLC_API int var_DelCallback( vlc_object_t *, const char *, vlc_callback_t, void * );
184 VLC_API int var_TriggerCallback( vlc_object_t *, const char * );
186 #define var_AddCallback(a,b,c,d) var_AddCallback( VLC_OBJECT(a), b, c, d )
187 #define var_DelCallback(a,b,c,d) var_DelCallback( VLC_OBJECT(a), b, c, d )
188 #define var_TriggerCallback(a,b) var_TriggerCallback( VLC_OBJECT(a), b )
190 /*****************************************************************************
191 * helpers functions
192 *****************************************************************************/
195 * Set the value of an integer variable
197 * \param p_obj The object that holds the variable
198 * \param psz_name The name of the variable
199 * \param i The new integer value of this variable
201 static inline int var_SetInteger( vlc_object_t *p_obj, const char *psz_name,
202 int64_t i )
204 vlc_value_t val;
205 val.i_int = i;
206 return var_SetChecked( p_obj, psz_name, VLC_VAR_INTEGER, val );
210 * Set the value of an boolean variable
212 * \param p_obj The object that holds the variable
213 * \param psz_name The name of the variable
214 * \param b The new boolean value of this variable
216 static inline int var_SetBool( vlc_object_t *p_obj, const char *psz_name, bool b )
218 vlc_value_t val;
219 val.b_bool = b;
220 return var_SetChecked( p_obj, psz_name, VLC_VAR_BOOL, val );
224 * Set the value of a time variable
226 * \param p_obj The object that holds the variable
227 * \param psz_name The name of the variable
228 * \param i The new time value of this variable
230 static inline int var_SetTime( vlc_object_t *p_obj, const char *psz_name, int64_t i )
232 vlc_value_t val;
233 val.i_time = i;
234 return var_SetChecked( p_obj, psz_name, VLC_VAR_TIME, val );
237 static inline int var_SetCoords( vlc_object_t *obj, const char *name,
238 int32_t x, int32_t y )
240 vlc_value_t val;
241 val.coords.x = x;
242 val.coords.y = y;
243 return var_SetChecked (obj, name, VLC_VAR_COORDS, val);
245 #define var_SetCoords(o,n,x,y) var_SetCoords(VLC_OBJECT(o),n,x,y)
248 * Set the value of a float variable
250 * \param p_obj The object that holds the variable
251 * \param psz_name The name of the variable
252 * \param f The new float value of this variable
254 static inline int var_SetFloat( vlc_object_t *p_obj, const char *psz_name, float f )
256 vlc_value_t val;
257 val.f_float = f;
258 return var_SetChecked( p_obj, psz_name, VLC_VAR_FLOAT, val );
262 * Set the value of a string variable
264 * \param p_obj The object that holds the variable
265 * \param psz_name The name of the variable
266 * \param psz_string The new string value of this variable
268 static inline int var_SetString( vlc_object_t *p_obj, const char *psz_name, const char *psz_string )
270 vlc_value_t val;
271 val.psz_string = (char *)psz_string;
272 return var_SetChecked( p_obj, psz_name, VLC_VAR_STRING, val );
276 * Set the value of a pointer variable
278 * \param p_obj The object that holds the variable
279 * \param psz_name The name of the variable
280 * \param ptr The new pointer value of this variable
282 static inline
283 int var_SetAddress( vlc_object_t *p_obj, const char *psz_name, void *ptr )
285 vlc_value_t val;
286 val.p_address = ptr;
287 return var_SetChecked( p_obj, psz_name, VLC_VAR_ADDRESS, val );
290 #define var_SetInteger(a,b,c) var_SetInteger( VLC_OBJECT(a),b,c)
291 #define var_SetBool(a,b,c) var_SetBool( VLC_OBJECT(a),b,c)
292 #define var_SetTime(a,b,c) var_SetTime( VLC_OBJECT(a),b,c)
293 #define var_SetFloat(a,b,c) var_SetFloat( VLC_OBJECT(a),b,c)
294 #define var_SetString(a,b,c) var_SetString( VLC_OBJECT(a),b,c)
295 #define var_SetAddress(o, n, p) var_SetAddress(VLC_OBJECT(o), n, p)
299 * Get an integer value
301 * \param p_obj The object that holds the variable
302 * \param psz_name The name of the variable
304 VLC_USED
305 static inline int64_t var_GetInteger( vlc_object_t *p_obj, const char *psz_name )
307 vlc_value_t val;
308 if( !var_GetChecked( p_obj, psz_name, VLC_VAR_INTEGER, &val ) )
309 return val.i_int;
310 else
311 return 0;
315 * Get a boolean value
317 * \param p_obj The object that holds the variable
318 * \param psz_name The name of the variable
320 VLC_USED
321 static inline bool var_GetBool( vlc_object_t *p_obj, const char *psz_name )
323 vlc_value_t val; val.b_bool = false;
325 if( !var_GetChecked( p_obj, psz_name, VLC_VAR_BOOL, &val ) )
326 return val.b_bool;
327 else
328 return false;
332 * Get a time value
334 * \param p_obj The object that holds the variable
335 * \param psz_name The name of the variable
337 VLC_USED
338 static inline int64_t var_GetTime( vlc_object_t *p_obj, const char *psz_name )
340 vlc_value_t val; val.i_time = 0L;
341 if( !var_GetChecked( p_obj, psz_name, VLC_VAR_TIME, &val ) )
342 return val.i_time;
343 else
344 return 0;
347 static inline void var_GetCoords( vlc_object_t *obj, const char *name,
348 int32_t *px, int32_t *py )
350 vlc_value_t val;
352 if (likely(!var_GetChecked (obj, name, VLC_VAR_COORDS, &val)))
354 *px = val.coords.x;
355 *py = val.coords.y;
357 else
358 *px = *py = 0;
360 #define var_GetCoords(o,n,x,y) var_GetCoords(VLC_OBJECT(o),n,x,y)
363 * Get a float value
365 * \param p_obj The object that holds the variable
366 * \param psz_name The name of the variable
368 VLC_USED
369 static inline float var_GetFloat( vlc_object_t *p_obj, const char *psz_name )
371 vlc_value_t val; val.f_float = 0.0;
372 if( !var_GetChecked( p_obj, psz_name, VLC_VAR_FLOAT, &val ) )
373 return val.f_float;
374 else
375 return 0.0;
379 * Get a string value
381 * \param p_obj The object that holds the variable
382 * \param psz_name The name of the variable
384 VLC_USED VLC_MALLOC
385 static inline char *var_GetString( vlc_object_t *p_obj, const char *psz_name )
387 vlc_value_t val; val.psz_string = NULL;
388 if( var_GetChecked( p_obj, psz_name, VLC_VAR_STRING, &val ) )
389 return NULL;
390 else
391 return val.psz_string;
394 VLC_USED VLC_MALLOC
395 static inline char *var_GetNonEmptyString( vlc_object_t *p_obj, const char *psz_name )
397 vlc_value_t val;
398 if( var_GetChecked( p_obj, psz_name, VLC_VAR_STRING, &val ) )
399 return NULL;
400 if( val.psz_string && *val.psz_string )
401 return val.psz_string;
402 free( val.psz_string );
403 return NULL;
406 VLC_USED
407 static inline void *var_GetAddress( vlc_object_t *p_obj, const char *psz_name )
409 vlc_value_t val;
410 if( var_GetChecked( p_obj, psz_name, VLC_VAR_ADDRESS, &val ) )
411 return NULL;
412 else
413 return val.p_address;
417 * Increment an integer variable
418 * \param p_obj the object that holds the variable
419 * \param psz_name the name of the variable
421 static inline int64_t var_IncInteger( vlc_object_t *p_obj, const char *psz_name )
423 vlc_value_t val;
424 val.i_int = 1;
425 var_GetAndSet( p_obj, psz_name, VLC_VAR_INTEGER_ADD, &val );
426 return val.i_int;
428 #define var_IncInteger(a,b) var_IncInteger( VLC_OBJECT(a), b )
431 * Decrement an integer variable
432 * \param p_obj the object that holds the variable
433 * \param psz_name the name of the variable
435 static inline int64_t var_DecInteger( vlc_object_t *p_obj, const char *psz_name )
437 vlc_value_t val;
438 val.i_int = -1;
439 var_GetAndSet( p_obj, psz_name, VLC_VAR_INTEGER_ADD, &val );
440 return val.i_int;
442 #define var_DecInteger(a,b) var_DecInteger( VLC_OBJECT(a), b )
444 static inline uint64_t var_OrInteger( vlc_object_t *obj, const char *name,
445 unsigned v )
447 vlc_value_t val;
448 val.i_int = v;
449 var_GetAndSet( obj, name, VLC_VAR_INTEGER_OR, &val );
450 return val.i_int;
452 #define var_OrInteger(a,b,c) var_OrInteger(VLC_OBJECT(a),b,c)
454 static inline uint64_t var_NAndInteger( vlc_object_t *obj, const char *name,
455 unsigned v )
457 vlc_value_t val;
458 val.i_int = v;
459 var_GetAndSet( obj, name, VLC_VAR_INTEGER_NAND, &val );
460 return val.i_int;
462 #define var_NAndInteger(a,b,c) var_NAndInteger(VLC_OBJECT(a),b,c)
465 * Create a integer variable with inherit and get its value.
467 * \param p_obj The object that holds the variable
468 * \param psz_name The name of the variable
470 VLC_USED
471 static inline int64_t var_CreateGetInteger( vlc_object_t *p_obj, const char *psz_name )
473 var_Create( p_obj, psz_name, VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
474 return var_GetInteger( p_obj, psz_name );
478 * Create a boolean variable with inherit and get its value.
480 * \param p_obj The object that holds the variable
481 * \param psz_name The name of the variable
483 VLC_USED
484 static inline bool var_CreateGetBool( vlc_object_t *p_obj, const char *psz_name )
486 var_Create( p_obj, psz_name, VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
487 return var_GetBool( p_obj, psz_name );
491 * Create a time variable with inherit and get its value.
493 * \param p_obj The object that holds the variable
494 * \param psz_name The name of the variable
496 VLC_USED
497 static inline int64_t var_CreateGetTime( vlc_object_t *p_obj, const char *psz_name )
499 var_Create( p_obj, psz_name, VLC_VAR_TIME | VLC_VAR_DOINHERIT );
500 return var_GetTime( p_obj, psz_name );
504 * Create a float variable with inherit and get its value.
506 * \param p_obj The object that holds the variable
507 * \param psz_name The name of the variable
509 VLC_USED
510 static inline float var_CreateGetFloat( vlc_object_t *p_obj, const char *psz_name )
512 var_Create( p_obj, psz_name, VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
513 return var_GetFloat( p_obj, psz_name );
517 * Create a string variable with inherit and get its value.
519 * \param p_obj The object that holds the variable
520 * \param psz_name The name of the variable
522 VLC_USED VLC_MALLOC
523 static inline char *var_CreateGetString( vlc_object_t *p_obj,
524 const char *psz_name )
526 var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT );
527 return var_GetString( p_obj, psz_name );
530 VLC_USED VLC_MALLOC
531 static inline char *var_CreateGetNonEmptyString( vlc_object_t *p_obj,
532 const char *psz_name )
534 var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT );
535 return var_GetNonEmptyString( p_obj, psz_name );
539 * Create an address variable with inherit and get its value.
541 * \param p_obj The object that holds the variable
542 * \param psz_name The name of the variable
544 VLC_USED
545 static inline void *var_CreateGetAddress( vlc_object_t *p_obj,
546 const char *psz_name )
548 var_Create( p_obj, psz_name, VLC_VAR_ADDRESS | VLC_VAR_DOINHERIT );
549 return var_GetAddress( p_obj, psz_name );
552 #define var_CreateGetInteger(a,b) var_CreateGetInteger( VLC_OBJECT(a),b)
553 #define var_CreateGetBool(a,b) var_CreateGetBool( VLC_OBJECT(a),b)
554 #define var_CreateGetTime(a,b) var_CreateGetTime( VLC_OBJECT(a),b)
555 #define var_CreateGetFloat(a,b) var_CreateGetFloat( VLC_OBJECT(a),b)
556 #define var_CreateGetString(a,b) var_CreateGetString( VLC_OBJECT(a),b)
557 #define var_CreateGetNonEmptyString(a,b) var_CreateGetNonEmptyString( VLC_OBJECT(a),b)
558 #define var_CreateGetAddress(a,b) var_CreateGetAddress( VLC_OBJECT(a),b)
561 * Create a integer command variable with inherit and get its value.
563 * \param p_obj The object that holds the variable
564 * \param psz_name The name of the variable
566 VLC_USED
567 static inline int64_t var_CreateGetIntegerCommand( vlc_object_t *p_obj, const char *psz_name )
569 var_Create( p_obj, psz_name, VLC_VAR_INTEGER | VLC_VAR_DOINHERIT
570 | VLC_VAR_ISCOMMAND );
571 return var_GetInteger( p_obj, psz_name );
575 * Create a boolean command variable with inherit and get its value.
577 * \param p_obj The object that holds the variable
578 * \param psz_name The name of the variable
580 VLC_USED
581 static inline bool var_CreateGetBoolCommand( vlc_object_t *p_obj, const char *psz_name )
583 var_Create( p_obj, psz_name, VLC_VAR_BOOL | VLC_VAR_DOINHERIT
584 | VLC_VAR_ISCOMMAND );
585 return var_GetBool( p_obj, psz_name );
589 * Create a time command variable with inherit and get its value.
591 * \param p_obj The object that holds the variable
592 * \param psz_name The name of the variable
594 VLC_USED
595 static inline int64_t var_CreateGetTimeCommand( vlc_object_t *p_obj, const char *psz_name )
597 var_Create( p_obj, psz_name, VLC_VAR_TIME | VLC_VAR_DOINHERIT
598 | VLC_VAR_ISCOMMAND );
599 return var_GetTime( p_obj, psz_name );
603 * Create a float command variable with inherit and get its value.
605 * \param p_obj The object that holds the variable
606 * \param psz_name The name of the variable
608 VLC_USED
609 static inline float var_CreateGetFloatCommand( vlc_object_t *p_obj, const char *psz_name )
611 var_Create( p_obj, psz_name, VLC_VAR_FLOAT | VLC_VAR_DOINHERIT
612 | VLC_VAR_ISCOMMAND );
613 return var_GetFloat( p_obj, psz_name );
617 * Create a string command variable with inherit and get its value.
619 * \param p_obj The object that holds the variable
620 * \param psz_name The name of the variable
622 VLC_USED VLC_MALLOC
623 static inline char *var_CreateGetStringCommand( vlc_object_t *p_obj,
624 const char *psz_name )
626 var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT
627 | VLC_VAR_ISCOMMAND );
628 return var_GetString( p_obj, psz_name );
631 VLC_USED VLC_MALLOC
632 static inline char *var_CreateGetNonEmptyStringCommand( vlc_object_t *p_obj,
633 const char *psz_name )
635 var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT
636 | VLC_VAR_ISCOMMAND );
637 return var_GetNonEmptyString( p_obj, psz_name );
640 #define var_CreateGetIntegerCommand(a,b) var_CreateGetIntegerCommand( VLC_OBJECT(a),b)
641 #define var_CreateGetBoolCommand(a,b) var_CreateGetBoolCommand( VLC_OBJECT(a),b)
642 #define var_CreateGetTimeCommand(a,b) var_CreateGetTimeCommand( VLC_OBJECT(a),b)
643 #define var_CreateGetFloatCommand(a,b) var_CreateGetFloatCommand( VLC_OBJECT(a),b)
644 #define var_CreateGetStringCommand(a,b) var_CreateGetStringCommand( VLC_OBJECT(a),b)
645 #define var_CreateGetNonEmptyStringCommand(a,b) var_CreateGetNonEmptyStringCommand( VLC_OBJECT(a),b)
647 VLC_USED
648 static inline int var_CountChoices( vlc_object_t *p_obj, const char *psz_name )
650 vlc_value_t count;
651 if( var_Change( p_obj, psz_name, VLC_VAR_CHOICESCOUNT, &count, NULL ) )
652 return 0;
653 return count.i_int;
655 #define var_CountChoices(a,b) var_CountChoices( VLC_OBJECT(a),b)
658 static inline bool var_ToggleBool( vlc_object_t *p_obj, const char *psz_name )
660 vlc_value_t val;
661 var_GetAndSet( p_obj, psz_name, VLC_VAR_BOOL_TOGGLE, &val );
662 return val.b_bool;
664 #define var_ToggleBool(a,b) var_ToggleBool( VLC_OBJECT(a),b )
667 VLC_USED
668 static inline bool var_InheritBool( vlc_object_t *obj, const char *name )
670 vlc_value_t val;
672 if( var_Inherit( obj, name, VLC_VAR_BOOL, &val ) )
673 val.b_bool = false;
674 return val.b_bool;
676 #define var_InheritBool(o, n) var_InheritBool(VLC_OBJECT(o), n)
678 VLC_USED
679 static inline int64_t var_InheritInteger( vlc_object_t *obj, const char *name )
681 vlc_value_t val;
683 if( var_Inherit( obj, name, VLC_VAR_INTEGER, &val ) )
684 val.i_int = 0;
685 return val.i_int;
687 #define var_InheritInteger(o, n) var_InheritInteger(VLC_OBJECT(o), n)
689 VLC_USED
690 static inline float var_InheritFloat( vlc_object_t *obj, const char *name )
692 vlc_value_t val;
694 if( var_Inherit( obj, name, VLC_VAR_FLOAT, &val ) )
695 val.f_float = 0.;
696 return val.f_float;
698 #define var_InheritFloat(o, n) var_InheritFloat(VLC_OBJECT(o), n)
700 VLC_USED VLC_MALLOC
701 static inline char *var_InheritString( vlc_object_t *obj, const char *name )
703 vlc_value_t val;
705 if( var_Inherit( obj, name, VLC_VAR_STRING, &val ) )
706 val.psz_string = NULL;
707 else if( val.psz_string && !*val.psz_string )
709 free( val.psz_string );
710 val.psz_string = NULL;
712 return val.psz_string;
714 #define var_InheritString(o, n) var_InheritString(VLC_OBJECT(o), n)
716 VLC_USED
717 static inline mtime_t var_InheritTime( vlc_object_t *obj, const char *name )
719 vlc_value_t val;
721 if( var_Inherit( obj, name, VLC_VAR_TIME, &val ) )
722 val.i_time = 0;
723 return val.i_time;
725 #define var_InheritTime(o, n) var_InheritTime(VLC_OBJECT(o), n)
727 VLC_USED
728 static inline void *var_InheritAddress( vlc_object_t *obj, const char *name )
730 vlc_value_t val;
732 if( var_Inherit( obj, name, VLC_VAR_ADDRESS, &val ) )
733 val.p_address = NULL;
734 return val.p_address;
736 #define var_InheritAddress(o, n) var_InheritAddress(VLC_OBJECT(o), n)
738 VLC_API int var_InheritURational( vlc_object_t *, unsigned *num, unsigned *den, const char *var );
739 #define var_InheritURational(a,b,c,d) var_InheritURational(VLC_OBJECT(a), b, c, d)
741 #define var_GetInteger(a,b) var_GetInteger( VLC_OBJECT(a),b)
742 #define var_GetBool(a,b) var_GetBool( VLC_OBJECT(a),b)
743 #define var_GetTime(a,b) var_GetTime( VLC_OBJECT(a),b)
744 #define var_GetFloat(a,b) var_GetFloat( VLC_OBJECT(a),b)
745 #define var_GetString(a,b) var_GetString( VLC_OBJECT(a),b)
746 #define var_GetNonEmptyString(a,b) var_GetNonEmptyString( VLC_OBJECT(a),b)
747 #define var_GetAddress(a,b) var_GetAddress( VLC_OBJECT(a),b)
749 VLC_API int var_LocationParse(vlc_object_t *, const char *mrl, const char *prefix);
750 #define var_LocationParse(o, m, p) var_LocationParse(VLC_OBJECT(o), m, p)
753 * @}
755 #endif /* _VLC_VARIABLES_H */