473,795 Members | 3,279 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Serializing a glib data type

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.

Aug 19 '07 #1
10 3863
On Sun, 19 Aug 2007 08:58:07 -0700, in comp.lang.c , akappa
<an******@gmail .comwrote:
>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?
This sounds like an algorithm question. Try asking in
comp.programmin g? 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
Aug 19 '07 #2

"akappa" <an******@gmail .comwrote in message
news:11******** **************@ 50g2000hsm.goog legroups.com...
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?
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

Aug 19 '07 #3
akappa wrote, On 19/08/07 16:58:
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 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
Aug 19 '07 #4
At the first, thanks to all that have replied to my question :)

"Malcolm McLean" wrote:
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.
You're of course right, but I don't want to °break° the datatype's
opaqueness:
The GHashTable struct is an opaque data structure to represent a Hash Table.
It should only be accessed via the following functions.
Unfortunately, glib (seems to) doesn't have no native way to
marshalling their owns data type...

BTW, I'm sorry to be a bit OT in this group, next time I should select
with much care the group :)

Aug 19 '07 #5
akappa wrote:
>
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?
There is no iterator in the C language. Try comp.lang.c++.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Aug 19 '07 #6
On 19 Ago, 19:52, CBFalconer <cbfalco...@yah oo.comwrote:
There is no iterator in the C language. Try comp.lang.c++.
Yes, but I'm talking about the library's iterator:
http://developer.gnome.org/doc/API/2...-table-foreach

(note that C++'s boost have a marshalling framework: If I was coding
in C++, then I wouldn't have any problem with marshalling :P)

Aug 19 '07 #7
CBFalconer <cb********@yah oo.comwrites:
akappa wrote:
>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?

There is no iterator in the C language. Try comp.lang.c++.
C doesn't have linked lists or binary trees either, but they can be
built in standard C. He's not talking about a C++ iterator; he's
talking about an "interator" provided by glib, which is a C library.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Aug 19 '07 #8
Keith Thompson wrote:
CBFalconer <cb********@yah oo.comwrites:
>akappa wrote:
>>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?

There is no iterator in the C language. Try comp.lang.c++.

C doesn't have linked lists or binary trees either, but they can be
built in standard C. He's not talking about a C++ iterator; he's
talking about an "interator" provided by glib, which is a C library.
OK, but GNU stuff is no more on-topic here than Windoze junk.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Aug 20 '07 #9
akappa wrote:
On 19 Ago, 19:52, CBFalconer <cbfalco...@yah oo.comwrote:
>There is no iterator in the C language. Try comp.lang.c++.

Yes, but I'm talking about the library's iterator:
http://developer.gnome.org/doc/API/2...-table-foreach

(note that C++'s boost have a marshalling framework: If I was
coding in C++, then I wouldn't have any problem with marshalling
The 'library' is not defined in the C standard. Unless you post
the C-standard code involved here the question remains off-topic.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Aug 20 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3301
by: Aleksei Guzev | last post by:
Imagine one writing a class library CL1 for data storage. He defines classes ‘DataItem’ and ‘DataRecord’ so that the latter contains a collection of the former. And he derives class ‘IntItem’ from ‘DataItem’ public class DataItem { public DataItem() {}
3
4820
by: Daniel C Bastos | last post by:
intro: i have a simple c program that uses gtk (1.2) which in turn uses glib. using the flag -Wall i get no warnings. using -Wall -ansi no warnings. using -Wall -ansi -pedantic I get these warnings In file included from /usr/include/gtk-1.2/gdk/gdktypes.h:33, from /usr/include/gtk-1.2/gdk/gdk.h:31, from /usr/include/gtk-1.2/gtk/gtk.h:31,
10
8315
by: copx | last post by:
I want to save a struct to disk.... as plain text. At the moment I do it with a function that just writes the data using fprintf. I mean like this: fprintf(fp, "%d %d", my_struct.a, my_struct.b) This way I have to write another "serializing" function for every new kind of struct I want to write, though. Is there a way to write functions that can write/read any struct to/from plain text format in a portable way?
2
3524
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: + More ways to contact me __________________________________________________________________
3
3574
by: Tom | last post by:
I am having trouble serializing a color property. Basically, it is not serializing the value. For instance, in the following: <Serializable()> _ Public Class TestColor Private _MyColor As System.Drawing.Color = System.Drawing.Color.Red Public Property MyColor() As System.Drawing.Color Get Return _MyColor
3
6877
by: axr | last post by:
Having trouble with Serilization of objects that contain members which are of type Interface eg public class SomeClass { ISomeInterface1 itf1; ClassType1 ct1; ISomeInterface2 itf2;
1
5688
by: Loic Mahe | last post by:
Hello, I would like to compile GLib as a static library on Windows XP with MinGW if possible. I downloaded GLib and needed librairies, but only the .dll files are included in the zip file. I manage to create a static lib project with CodeBlocks IDE. and I manage to use Glib as a dynamic lib but not as a static one.
1
1788
by: ramasubramanian.rahul | last post by:
hi people.. dont know if this the right forum for this doubt ... so sorry if i am mis-posting... i was looking at the way glib 2.10.3 does export optimization using a list of "to be exposed" function names in a file caleed glib.symbols. this file is used by a perl script to generate a header a .c file ( galias.h and galiasdefs.c). This files essentially enusres default visibility for these functions (using the __attribute__((default))__...
4
4636
by: MN | last post by:
Hi all, I'm learning how to use some Glib-functions for simple linked list. I wrote a small program that prepends 2 data (let's say to integers "1" and "2") in list, display them, count total number of elements and returns index of each element. How to avoid these warnings? warning: passing argument 1 of ‘g_list_nth’ from incompatible pointer type warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘struct GList *’
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10435
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9037
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6779
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.