Help - Search - Members - Calendar
Full Version: config_var help
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
danZ
I want to add per look saved values into my dll's portion of the .cfg file

so something like this where the indented stuff is the look specific values

foo_looks.dll
someinternal_val
foo_looks.ski // look specific
----->spectrum 0
----->layout 0
fooAMP.ski // look specific
----->showalbumart 1

Each look would be able to save its own information into a sub section corresponding to the look's name

So far I've just used the config api for my internal storage - all vars are static declared.

So my starter questions.

1. Can you add/delete config vars on the fly

ie.

cfg_int* layout = new cfg_int(1);

2. How can I achieve the sub section management so that I can add/remove entire sub blocks and also have each look be able to grab values from its block? config_var_struct looked like it might be what I wanted but that would only allow for subvalues of a single type, correct?

Any help appreciated.
foosion
CODE
//IMPORTANT:
//cfg_var objects are intended ONLY to be created statically !!!!

I think it's the same for config_var objects.

If you want structured data, you'll have to write your own subclass of cfg_var, unless you can fit the data into some struct. In that case you could use cfg_struct_t<T>.

In case you need some inspiration, look at the masstagger sources to see how masstagger scripts are stored. There's also the foosion_helper library on my plugin page for anyone who dares. It includes a cfg_var subclass that can store string tuples.
danZ
QUOTE(foosion @ Jan 19 2004, 02:02 PM)
CODE
//IMPORTANT:
//cfg_var objects are intended ONLY to be created statically !!!!

I think it's the same for config_var objects.

If you want structured data, you'll have to write your own subclass of cfg_var, unless you can fit the data into some struct. In that case you could use cfg_struct_t<T>.

In case you need some inspiration, look at the masstagger sources to see how masstagger scripts are stored. There's also the foosion_helper library on my plugin page for anyone who dares. It includes a cfg_var subclass that can store string tuples.

I thought the static only was for config_var_callback_autoreg? If all have to be static then my plan is already sunk since I'd want to be able to add/delete on the fly as looks are loaded/unloaded and based on the scripts they call for saving/removing cfg variables.

I'll take a look at the source code you mentioned - what's you page link?
foosion
QUOTE(danZ @ Jan 19 2004, 11:17 PM)
I'll take a look at the source code you mentioned - what's you page link?

http://www.stud.uni-karlsruhe.de/~uzbs/fb2k/html/
as stated in my profile, listed on the "must know sites for fb2k", and reachable through the site in my signature. wink.gif
kode54
You could create a single variable that would contain a variable sized structure. Validating the contents of the structure shouldn't really be a problem, as the configuration file is protected against tampering. So, unless you save garbage yourself...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.