Discussion:
wxRegKey and multi string values
jon bird
2014-09-21 13:35:03 UTC
Permalink
Hi,

Can anyone give some guidance on how you use the wxRegKey class to read
and write multi-string values (so that is type REG_MULTI_SZ in Win32
terms). In the introduction, the docs mention the multi-string key type
but then there is no further mention of it.

Rgs,


Jon.
--
== jon bird - software engineer
== <reply to address _may_ be invalid, real mail below>
== <reduce rsi, stop using the shift key>
== posted as: news 'at' onastick 'dot' clara.co.uk
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-09-21 23:24:46 UTC
Permalink
On Sun, 21 Sep 2014 14:35:03 +0100 jon bird wrote:

jb> Can anyone give some guidance on how you use the wxRegKey class to read
jb> and write multi-string values (so that is type REG_MULTI_SZ in Win32
jb> terms).

There is no support for REG_MULTI_SZ in wxRegKey, it only supports REG_SZ,
REG_EXPAND_SZ, REG_DWORD and REG_BINARY.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
jon bird
2014-09-22 18:33:05 UTC
Permalink
Post by Vadim Zeitlin
jb> Can anyone give some guidance on how you use the wxRegKey class to read
jb> and write multi-string values (so that is type REG_MULTI_SZ in Win32
jb> terms).
There is no support for REG_MULTI_SZ in wxRegKey, it only supports REG_SZ,
REG_EXPAND_SZ, REG_DWORD and REG_BINARY.
Regards,
VZ
Ok, thanks for letting me know, I shall work around it.

Rgs,


Jon.
--
== jon bird - software engineer
== <reply to address _may_ be invalid, real mail below>
== <reduce rsi, stop using the shift key>
== posted as: news 'at' onastick 'dot' clara.co.uk
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Carl Godkin
2014-09-22 18:50:22 UTC
Permalink
I wrote a little function to help work around this. Maybe you can use
something like this.

carl

static size_t queryRegKeyMultiStrings (wxRegKey &key,
const wxString &name,
wxArrayString &names,
wxArrayString &values)
{
wxASSERT (key.GetValueType (name) == wxRegKey::Type_Multi_String);
wxMemoryBuffer buf;
if (key.QueryValue (name, buf)) {
wxChar *data = static_cast<wxChar *>(buf.GetData());
size_t begin = 0;
for (size_t i=0; i<buf.GetDataLen()-1; i++) {
if (data[i] == 0) {
if (i > begin) {
wxString pair (&data[begin]);
names.Add (pair.BeforeFirst ('='));
values.Add (pair.AfterFirst ('='));
}
begin = i+1;
}
}
}

return names.Count();
}
Post by jon bird
Post by Vadim Zeitlin
jb> Can anyone give some guidance on how you use the wxRegKey class to read
jb> and write multi-string values (so that is type REG_MULTI_SZ in Win32
jb> terms).
There is no support for REG_MULTI_SZ in wxRegKey, it only supports REG_SZ,
REG_EXPAND_SZ, REG_DWORD and REG_BINARY.
Regards,
VZ
Ok, thanks for letting me know, I shall work around it.
Rgs,
Jon.
--
== jon bird - software engineer
== <reply to address _may_ be invalid, real mail below>
== <reduce rsi, stop using the shift key>
== posted as: news 'at' onastick 'dot' clara.co.uk
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
or visit http://groups.google.com/group/wx-users
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Marian 'VooDooMan' Meravy
2014-09-22 20:22:13 UTC
Permalink
Greetings,
Post by Carl Godkin
I wrote a little function to help work around this. Maybe you can use
something like this.
Could you please incorporate your code into SVN trunk as an improvement
(write a patch)? IMO Many users needs this (even me myself), but your
solution looks much better than my own (non-portable - I mean
cygwin/msys) ugly hack.

best,
vdm
.
Carl Godkin
2014-09-22 22:51:51 UTC
Permalink
Hi,

Let's see if my little function works for the original poster first, or if
anyone suggests improvements or has objections.

Also, what would you suggest for the API? Would it be another overload of
wxRegEx::QueryValue(), for instance?

Thanks,

carl
Post by Marian 'VooDooMan' Meravy
Greetings,
Post by Carl Godkin
I wrote a little function to help work around this. Maybe you can use
something like this.
Could you please incorporate your code into SVN trunk as an improvement
(write a patch)? IMO Many users needs this (even me myself), but your
solution looks much better than my own (non-portable - I mean
cygwin/msys) ugly hack.
best,
vdm
.
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-09-22 23:31:13 UTC
Permalink
On Mon, 22 Sep 2014 15:51:51 -0700 Carl Godkin wrote:

CG> Also, what would you suggest for the API? Would it be another overload of
CG> wxRegEx::QueryValue(), for instance?

Yes, this would be natural (one taking wxArrayString or wxVector<wxString>
presumably). Especially if we put it in wxRegKey instead of wxRegEx :-)

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
jon bird
2014-09-23 20:07:07 UTC
Permalink
In article
I wrote a little function to help work around this.  Maybe you can use
something like this.
carl
static size_t queryRegKeyMultiStrings (wxRegKey &key,
      const wxString &name,
      wxArrayString &names,
      wxArrayString &values)
[...]

When I first scanned the API, I wondered if the MemoryBuffer variant
would suffice and yes as your code demonstrates (although I've not had a
chance to try it), it should certainly retrieve the strings ok. However
I also need to write multi-strings and unless I've missed something, the
reverse of this approach won't work - it'll end up storing it as binary
data. So I'd still need to write something bespoke for that.

Rgs,


Jon.
Post by Vadim Zeitlin
jb> Can anyone give some guidance on how you use the wxRegKey class to read
jb> and write multi-string values (so that is type REG_MULTI_SZ in Win32
jb> terms).
There is no support for REG_MULTI_SZ in wxRegKey, it only
supports REG_SZ,
REG_EXPAND_SZ, REG_DWORD and REG_BINARY.
Regards,
VZ
Ok, thanks for letting me know, I shall work around it.
Rgs,
Jon.
--
== jon bird - software engineer
== <reply to address _may_ be invalid, real mail below>
== <reduce rsi, stop using the shift key>
== posted as: news 'at' onastick 'dot' clara.co.uk
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
or visit http://groups.google.com/group/wx-users
--
== jon bird - software engineer
== <reply to address _may_ be invalid, real mail below>
== <reduce rsi, stop using the shift key>
== posted as: news 'at' onastick 'dot' clara.co.uk
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...