Class Keydata - similar entries from multiple sections?

View: New views
2 Messages — Rating Filter:   Alert me  

Class Keydata - similar entries from multiple sections?

by Wolfgang Alper :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,
i am using commoncpp2-1.5.6.

How can i retrieve keys with the same name from a given section using the
Class Keydata?

Example:
[general]
port = 1234
host = www.myhost.com
[proxy]
port = 4321
host = www.proxy.com

running
load("/mydir/myfile/general");
and
load("/mydir/myfile/proxy]");

This leads to multiple port and host entries.

Of cause i can use getCount("port") and then iterate through the values, but
this assumes to know wether a section has a key "port".
Also i could use clrValue("port") to clear the value before loading a new
section, but this seems to be a bad workaround.

So how can i  query like "general/host" to get the value of host in the
[general] section or "proxy/host" to get the host in the [proxy] section?

Thanks

Wolfgang



_______________________________________________
Bug-commoncpp mailing list
Bug-commoncpp@...
http://lists.gnu.org/mailman/listinfo/bug-commoncpp

Re: Class Keydata - similar entries from multiple sections?

by David Sugar-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Normally you would load each [] into a different keydata object.  If you
merge keydata sections into a single object instance, there is no means
to determine which instance it was loaded under.  Mostly merging is
meant to load "default" keys into a given object, and then override them
with live values.  At least that was the intended use.

Wolfgang Alper wrote:

> Hello,
> i am using commoncpp2-1.5.6.
>
> How can i retrieve keys with the same name from a given section using the
> Class Keydata?
>
> Example:
> [general]
> port = 1234
> host = www.myhost.com
> [proxy]
> port = 4321
> host = www.proxy.com
>
> running
> load("/mydir/myfile/general");
> and
> load("/mydir/myfile/proxy]");
>
> This leads to multiple port and host entries.
>
> Of cause i can use getCount("port") and then iterate through the values, but
> this assumes to know wether a section has a key "port".
> Also i could use clrValue("port") to clear the value before loading a new
> section, but this seems to be a bad workaround.
>
> So how can i  query like "general/host" to get the value of host in the
> [general] section or "proxy/host" to get the host in the [proxy] section?
>
> Thanks
>
> Wolfgang
>
>
>
> _______________________________________________
> Bug-commoncpp mailing list
> Bug-commoncpp@...
> http://lists.gnu.org/mailman/listinfo/bug-commoncpp

[dyfet.vcf]

begin:vcard
fn:David Sugar
n:Sugar;David
org:GNU Telephony
email;internet:dyfet@...
tel;work:+1 201 215 2609
url:http://www.gnutelephony.org
version:2.1
end:vcard



_______________________________________________
Bug-commoncpp mailing list
Bug-commoncpp@...
http://lists.gnu.org/mailman/listinfo/bug-commoncpp