Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: config_var help (Read 3169 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

config_var help

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.

config_var help

Reply #1
Code: [Select]
//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.

config_var help

Reply #2
Quote
Code: [Select]
//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?


config_var help

Reply #4
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...