home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / libgimp / gserialize.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-27  |  2.8 KB  |  82 lines

  1. /* gserialize.h
  2.  * Copyright (C) 1998 Jay Cox <jaycox@earthlink.net>
  3.  *
  4.  * This library is free software; you can redistribute it and/or
  5.  * modify it under the terms of the GNU Lesser General Public
  6.  * License as published by the Free Software Foundation; either
  7.  * version 2 of the License, or (at your option) any later version.
  8.  *
  9.  * This library is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.  * Lesser General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU Lesser General Public
  15.  * License along with this library; if not, write to the
  16.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17.  * Boston, MA 02111-1307, USA.
  18.  */
  19.  
  20. #ifndef __GSERIALIZE_H__
  21. #define __GSERIALIZE_H__
  22.  
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif /* __cplusplus */
  26.  
  27. #include <glib.h>
  28. #include <stdarg.h>
  29.  
  30. typedef enum {
  31.   GSERIAL_END          = 0,           /* for internal use only */
  32.   GSERIAL_INT8         = 1,
  33.   GSERIAL_INT16        = 2,
  34.   GSERIAL_INT32        = 3,
  35.   GSERIAL_FLOAT        = 4,         /* 32 bit IEEE fp value */
  36.   GSERIAL_DOUBLE       = 5,        /* 64 bit IEEE fp value */
  37.   GSERIAL_STRING       = 101,
  38.   GSERIAL_INT8ARRAY    = 102,
  39.   GSERIAL_INT16ARRAY   = 103,
  40.   GSERIAL_INT32ARRAY   = 104,
  41.   GSERIAL_FLOATARRAY   = 105,
  42.   GSERIAL_DOUBLEARRAY  = 106,
  43.   GSERIAL_LAST_TYPE    = 107
  44. } GSerialType;
  45.  
  46. typedef struct _GSerialItem GSerialItem;
  47. typedef struct _GSerialDescription GSerialDescription;
  48.  
  49.  
  50. GSerialItem *g_new_serial_item(GSerialType type, gulong offset,
  51.                    gint32 length, gulong length_offset);
  52.  
  53. #define g_serial_item(type, struct_, member) \
  54.   g_new_serial_item(type, G_STRUCT_OFFSET(struct_, member), 0, 0)
  55.  
  56. #define g_serial_array(type, struct_, member, length) \
  57.   g_new_serial_item(type, G_STRUCT_OFFSET(struct_, member), length, 0)
  58.  
  59. #define g_serial_vlen_array(type, struct_, member, length_member) \
  60.   g_new_serial_item(type, G_STRUCT_OFFSET(struct_, member), -1,   \
  61.             G_STRUCT_OFFSET(struct_, length_member))
  62.  
  63. GSerialDescription *g_new_serial_description(char *name, ...);
  64.                        /* pass it g_serial_s.  null terminated */
  65. void g_free_serial_description(GSerialDescription *);
  66.  
  67. long g_serialize(GSerialDescription *d, void **output, void *struct_data);
  68.    /* returns the length of the serialized data.
  69.       g_mallocs space for the data and stores a pointer to it in output */
  70.  
  71. long g_deserialize(GSerialDescription *d,  void *output, void *serial);
  72.    /* output must be a preallocated area large enough to hold the
  73.       deserialized struct. */
  74.  
  75.  
  76. #ifdef __cplusplus
  77. }
  78. #endif /* __cplusplus */
  79.  
  80. #endif /* __GSERIALIZE_H__*/
  81.  
  82.