I'm using libconfig
.
I've a .cfg
file. In this file, I have one only category: Services
. Inside this category, I have many objects. Each object name has this format:
objectname
+ underscore
+ 4numbers
For example:
alfa_1111
So, let's consider:
Services =
{
alfa_1111 = {
key = "value"
};
beta_2222 = {
key = "value"
};
gamma_3333 = {
key = "value"
};
}
The 4 numbers are a unique identifier. There is one only 1111
, one only 2222
and so on. My scope is to retrivie the key value for a specific object. The problem is, that the only parameter I know, are the 4 numbers.
To be more clear:
I receive for example 2222
. I know that in the file there is one only 2222
, so I look into beta_2222
and retrieve the key value.
However, I am not aware of the name before the underscore. I simply receive 2222
. So, inside the .cfg
there could be any name before _2222
(x_2222
? y_2222
? z_2222
?)
So, in the config lookup I would need something like that:
config_setting_t *setting;
config_t cfg;
setting = config_lookup(&cfg, "Services.*_2222);
(with *
I mean "any character you find until _2222
")
Is there a way to say:
search for the object that contains _2222, it doesn't matter of the previous characters...