序列化glib数据类型 [英] Serializing a glib data type

查看:72
本文介绍了序列化glib数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想序列化一个glib数据类型(一个哈希),但我不想

直接访问各种字段结构,因为它是一个

不透明数据类型:有一种或多或少的标准方法,

它更多比使用迭代器读取所有字段更有效,

将它们保存在文件中并连续重新创建哈希值每次使用

一次?


感谢您的建议。

Hi,
I want to serialize a glib data type (an hash), but I don''t want to
access directly to the fields of the various structs, since it''s an
opaque data type: there is one "more-or-less standard way to do it"
that it''s more efficient than read all the fields with the iterator,
saves them on file and successively recreating the hash putting them
once per time?

Thanks in advice.

推荐答案

On Sun,2007年8月19日08:58:07 -0700,in comp.lang .c,akappa

< an ****** @ gmail.comwrote:
On Sun, 19 Aug 2007 08:58:07 -0700, in comp.lang.c , akappa
<an******@gmail.comwrote:

>
我想序列化一个glib数据类型(哈希),但我不想直接访问各种结构的字段,因为它是一个不透明的数据类型:那里是一种或多或少的标准方式,它比阅读全部更有效率使用迭代器的字段,
将它们保存在文件中并连续重新创建每次使用它们一次的哈希值?
>Hi,
I want to serialize a glib data type (an hash), but I don''t want to
access directly to the fields of the various structs, since it''s an
opaque data type: there is one "more-or-less standard way to do it"
that it''s more efficient than read all the fields with the iterator,
saves them on file and successively recreating the hash putting them
once per time?



这听起来像算法问题。尝试询问

comp.programming?或者,数据类型是否提供了一些

访问器功能?

-

马克麦金太尔


"调试是第一次编写代码的两倍。

因此,如果你尽可能巧妙地编写代码,那么,

根据定义,不够聪明,不能调试它。

--Brian Kernighan

This sounds like an algorithm question. Try asking in
comp.programming? Alternatively, doesn''t the data type provide some
accessor functions?
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan




" akappa" < a ****** @ gmail.com写信息

新闻:11 ********************** @ 50g2000hsm .googlegro ups.com ...

"akappa" <an******@gmail.comwrote in message
news:11**********************@50g2000hsm.googlegro ups.com...



我想序列化一个glib数据类型(哈希),但我不知道不希望

直接访问各种结构的字段,因为它是一个

不透明数据类型:有一个更多 - 或 - 不太标准的方法

它比使用迭代器读取所有字段更有效,

将它们保存在文件中并连续重新创建散列它们

每次一次?
Hi,
I want to serialize a glib data type (an hash), but I don''t want to
access directly to the fields of the various structs, since it''s an
opaque data type: there is one "more-or-less standard way to do it"
that it''s more efficient than read all the fields with the iterator,
saves them on file and successively recreating the hash putting them
once per time?



这是C做得不好的事情。所有对象都应该具有

序列化在基础层面建立的方法。在C当然你已经知道如何处理共享指针。

glib是开源的,所以通过查看哈希结构,你应该能够写一个序列化/反序列化对,比重建表更快地执行
。但是表格中的对象还需要序列化方法。

glib可能已经有了这样的方法,但我对此表示怀疑,因为它增加了这么多

基本哈希界面的复杂程度。

-

免费游戏和编程好东西。
http://www.personal.leeds.ac.uk/~bgy1mm

This is something that C doesn''t do well. All objects ought to have
"serialise" methods built in at a fundamental level. In C of course you''ve
got the problem of what to do with shared pointers.
glib is open source, so by looking at the hash structure, you ought to be
able to write a serialise / deserialise pair that executes quite a bit
faster than rebuilding the table. However the objects in the table would
also need serialise methods.
glib might already have such methods, but I doubt it, because it adds so
much complexity to the basic hash interface.
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm


akappa写道,在19/08/07 16:58:
akappa wrote, On 19/08/07 16:58:



我想序列化一个glib数据类型(哈希),但我不想直接访问各种结构的字段,因为它是一个

opaque数据类型:有一种或多或少的标准方法,

它比使用迭代器读取所有字段更有效,

将它们保存在文件中并连续重新创建哈希值每次使用它们一次?

Hi,
I want to serialize a glib data type (an hash), but I don''t want to
access directly to the fields of the various structs, since it''s an
opaque data type: there is one "more-or-less standard way to do it"
that it''s more efficient than read all the fields with the iterator,
saves them on file and successively recreating the hash putting them
once per time?



C本身没有提供自动执行所需操作的机制。 glib

可能,但为此您需要询问GLib在哪里是热门话题,例如gnome邮件列表中的一个

http://mail.gnome.org/

-

Flash Gordon

C itself provides no mechanism to automatically do what you want. glib
might, but for that you need to ask where GLib is topical, such as one
of the gnome mailing lists http://mail.gnome.org/
--
Flash Gordon


这篇关于序列化glib数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆