/usr/share/gtk-doc/html/libgwyddion/GwySerializable.html is in libgwyddion20-doc 2.44-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GwySerializable: Gwyddion Library Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="index.html" title="Gwyddion Library Reference Manual">
<link rel="up" href="index.html" title="Gwyddion Library Reference Manual">
<link rel="prev" href="libgwyddion-gwyddionenums.html" title="gwyddionenums">
<link rel="next" href="GwyContainer.html" title="GwyContainer">
<meta name="generator" content="GTK-Doc V1.19 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts">
<a href="#" class="shortcut">Top</a><span id="nav_description"> <span class="dim">|</span>
<a href="#GwySerializable.description" class="shortcut">Description</a></span><span id="nav_hierarchy"> <span class="dim">|</span>
<a href="#GwySerializable.object-hierarchy" class="shortcut">Object Hierarchy</a></span><span id="nav_prerequisites"> <span class="dim">|</span>
<a href="#GwySerializable.prerequisites" class="shortcut">Prerequisites</a></span><span id="nav_implementations"> <span class="dim">|</span>
<a href="#GwySerializable.implementations" class="shortcut">Known Implementations</a></span>
</td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><img src="up-insensitive.png" width="16" height="16" border="0"></td>
<td><a accesskey="p" href="libgwyddion-gwyddionenums.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="GwyContainer.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="GwySerializable"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="GwySerializable.top_of_page"></a>GwySerializable</span></h2>
<p>GwySerializable — Abstract interface for serializable objects</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="GwySerializable.functions"></a><h2>Functions</h2>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="functions_return">
<col class="functions_name">
</colgroup>
<tbody>
<tr>
<td class="function_type">
<a href="http://developer.gnome.org/doc/API/2.0/glib/glib-Byte-Arrays.html#GByteArray"><span class="returnvalue">GByteArray</span></a> *
</td>
<td class="function_name">
<span class="c_punctuation">(</span><a class="link" href="GwySerializable.html#GwySerializeFunc" title="GwySerializeFunc ()">*GwySerializeFunc</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="returnvalue">GObject</span></a> *
</td>
<td class="function_name">
<span class="c_punctuation">(</span><a class="link" href="GwySerializable.html#GwyDeserializeFunc" title="GwyDeserializeFunc ()">*GwyDeserializeFunc</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="http://developer.gnome.org/doc/API/2.0/glib/glib-Byte-Arrays.html#GByteArray"><span class="returnvalue">GByteArray</span></a> *
</td>
<td class="function_name">
<a class="link" href="GwySerializable.html#gwy-serializable-serialize" title="gwy_serializable_serialize ()">gwy_serializable_serialize</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="returnvalue">GObject</span></a> *
</td>
<td class="function_name">
<a class="link" href="GwySerializable.html#gwy-serializable-deserialize" title="gwy_serializable_deserialize ()">gwy_serializable_deserialize</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="returnvalue">GObject</span></a> *
</td>
<td class="function_name">
<a class="link" href="GwySerializable.html#gwy-serializable-duplicate" title="gwy_serializable_duplicate ()">gwy_serializable_duplicate</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="GwySerializable.html#gwy-serializable-clone" title="gwy_serializable_clone ()">gwy_serializable_clone</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="http://developer.gnome.org/doc/API/2.0/glib/glib-Basic-Types.html#gsize"><span class="returnvalue">gsize</span></a>
</td>
<td class="function_name">
<a class="link" href="GwySerializable.html#gwy-serializable-get-size" title="gwy_serializable_get_size ()">gwy_serializable_get_size</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="http://developer.gnome.org/doc/API/2.0/glib/glib-Basic-Types.html#gsize"><span class="returnvalue">gsize</span></a>
</td>
<td class="function_name">
<a class="link" href="GwySerializable.html#gwy-serialize-get-struct-size" title="gwy_serialize_get_struct_size ()">gwy_serialize_get_struct_size</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="http://developer.gnome.org/doc/API/2.0/glib/glib-Basic-Types.html#gsize"><span class="returnvalue">gsize</span></a>
</td>
<td class="function_name">
<a class="link" href="GwySerializable.html#gwy-serialize-get-items-size" title="gwy_serialize_get_items_size ()">gwy_serialize_get_items_size</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="http://developer.gnome.org/doc/API/2.0/glib/glib-Byte-Arrays.html#GByteArray"><span class="returnvalue">GByteArray</span></a> *
</td>
<td class="function_name">
<a class="link" href="GwySerializable.html#gwy-serialize-pack-object-struct" title="gwy_serialize_pack_object_struct ()">gwy_serialize_pack_object_struct</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="http://developer.gnome.org/doc/API/2.0/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="GwySerializable.html#gwy-serialize-unpack-object-struct" title="gwy_serialize_unpack_object_struct ()">gwy_serialize_unpack_object_struct</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="http://developer.gnome.org/doc/API/2.0/glib/glib-Basic-Types.html#gsize"><span class="returnvalue">gsize</span></a>
</td>
<td class="function_name">
<a class="link" href="GwySerializable.html#gwy-serialize-check-string" title="gwy_serialize_check_string ()">gwy_serialize_check_string</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="http://developer.gnome.org/doc/API/2.0/glib/glib-Byte-Arrays.html#GByteArray"><span class="returnvalue">GByteArray</span></a> *
</td>
<td class="function_name">
<a class="link" href="GwySerializable.html#gwy-serialize-object-items" title="gwy_serialize_object_items ()">gwy_serialize_object_items</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="GwySerializable.html#GwySerializeItem" title="GwySerializeItem"><span class="returnvalue">GwySerializeItem</span></a> *
</td>
<td class="function_name">
<a class="link" href="GwySerializable.html#gwy-deserialize-object-hash" title="gwy_deserialize_object_hash ()">gwy_deserialize_object_hash</a> <span class="c_punctuation">()</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="GwySerializable.other"></a><h2>Types and Values</h2>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="name">
<col class="description">
</colgroup>
<tbody>
<tr>
<td class="datatype_keyword"> </td>
<td class="function_name"><a class="link" href="GwySerializable.html#GwySerializable-struct" title="GwySerializable">GwySerializable</a></td>
</tr>
<tr>
<td class="datatype_keyword"> </td>
<td class="function_name"><a class="link" href="GwySerializable.html#GwySerializeSpec" title="GwySerializeSpec">GwySerializeSpec</a></td>
</tr>
<tr>
<td class="datatype_keyword"> </td>
<td class="function_name"><a class="link" href="GwySerializable.html#GwySerializeValue" title="GwySerializeValue">GwySerializeValue</a></td>
</tr>
<tr>
<td class="datatype_keyword"> </td>
<td class="function_name"><a class="link" href="GwySerializable.html#GwySerializeItem" title="GwySerializeItem">GwySerializeItem</a></td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="GwySerializable.object-hierarchy"></a><h2>Object Hierarchy</h2>
<pre class="screen"> <a href="http://developer.gnome.org/doc/API/2.0/gobject/GTypeModule.html">GInterface</a>
<span class="lineart">╰──</span> GwySerializable
</pre>
</div>
<div class="refsect1">
<a name="GwySerializable.prerequisites"></a><h2>Prerequisites</h2>
<p>
GwySerializable requires
<a href="http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a>.</p>
</div>
<div class="refsect1">
<a name="GwySerializable.implementations"></a><h2>Known Implementations</h2>
<p>
GwySerializable is implemented by
<a class="link" href="GwyContainer.html" title="GwyContainer">GwyContainer</a>, <a class="link" href="GwySIUnit.html" title="GwySIUnit">GwySIUnit</a> and <a class="link" href="GwyStringList.html" title="GwyStringList">GwyStringList</a>.</p>
</div>
<div class="refsect1">
<a name="GwySerializable.includes"></a><h2>Includes</h2>
<pre class="synopsis">#include <libgwyddion/gwyddion.h>
</pre>
</div>
<div class="refsect1">
<a name="GwySerializable.description"></a><h2>Description</h2>
<p>GwySerializable is an abstract interface for data-like object that can be
serialized and deserialized. You can serialize any object implementing this
interface with <a class="link" href="GwySerializable.html#gwy-serializable-serialize" title="gwy_serializable_serialize ()"><code class="function">gwy_serializable_serialize()</code></a> and the restore (deserialize) it
with <a class="link" href="GwySerializable.html#gwy-serializable-deserialize" title="gwy_serializable_deserialize ()"><code class="function">gwy_serializable_deserialize()</code></a>. It is also posible it duplicate any
such object with <a class="link" href="GwySerializable.html#gwy-serializable-duplicate" title="gwy_serializable_duplicate ()"><code class="function">gwy_serializable_duplicate()</code></a> and transform one object to
copy of another with <a class="link" href="GwySerializable.html#gwy-serializable-clone" title="gwy_serializable_clone ()"><code class="function">gwy_serializable_clone()</code></a>.</p>
<p>Note all <a class="link" href="GwySerializable.html" title="GwySerializable"><span class="type">GwySerializable</span></a> methods work with object `value', whatever it means
for a particular type. Beside that, objects also have their identity which
is unique and can't be subject of cloning. It consists of properties like
memory address or references held by object users. Two important properties
related to identity (and thus NOT retained) are: signals connected to
a particular object and user data set with <a href="http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html#g-object-set-data"><code class="function">g_object_set_data()</code></a> or
<a href="http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html#g-object-set-qdata"><code class="function">g_object_set_qdata()</code></a>.</p>
<p>You can implement serialization and deserialization in your classes with
<a class="link" href="GwySerializable.html#gwy-serialize-pack-object-struct" title="gwy_serialize_pack_object_struct ()"><code class="function">gwy_serialize_pack_object_struct()</code></a> and <a class="link" href="GwySerializable.html#gwy-serialize-unpack-object-struct" title="gwy_serialize_unpack_object_struct ()"><code class="function">gwy_serialize_unpack_object_struct()</code></a>
or with <a class="link" href="GwySerializable.html#gwy-serialize-object-items" title="gwy_serialize_object_items ()"><code class="function">gwy_serialize_object_items()</code></a> and <a class="link" href="GwySerializable.html#gwy-deserialize-object-hash" title="gwy_deserialize_object_hash ()"><code class="function">gwy_deserialize_object_hash()</code></a>.
The former two are useful for struct-like objects (most objects are of this
kind), the latter two for hash-like objects, i.e., objects that can contain
components of arbitrary name and type. Serialized size calculations can be
in most cases performed by <a class="link" href="GwySerializable.html#gwy-serialize-get-struct-size" title="gwy_serialize_get_struct_size ()"><code class="function">gwy_serialize_get_struct_size()</code></a> and
<a class="link" href="GwySerializable.html#gwy-serialize-get-items-size" title="gwy_serialize_get_items_size ()"><code class="function">gwy_serialize_get_items_size()</code></a> helper functions.</p>
</div>
<div class="refsect1">
<a name="GwySerializable.functions_details"></a><h2>Functions</h2>
<div class="refsect2">
<a name="GwySerializeFunc"></a><h3>GwySerializeFunc ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Byte-Arrays.html#GByteArray"><span class="returnvalue">GByteArray</span></a> *
<span class="c_punctuation">(</span>*GwySerializeFunc<span class="c_punctuation">)</span> (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a> *serializable</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a> *buffer</code></em>);</pre>
<p>The type of serialization method, see <a class="link" href="GwySerializable.html#gwy-serializable-serialize" title="gwy_serializable_serialize ()"><code class="function">gwy_serializable_serialize()</code></a> for
description.</p>
<div class="refsect3">
<a name="id-1.4.10.2.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>serializable</p></td>
<td class="parameter_description"><p>An object to serialize.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>buffer</p></td>
<td class="parameter_description"><p>A buffer to append the representation to, may be <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> indicating
a new one should be allocated.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.4.10.2.6"></a><h4>Returns</h4>
<p> <em class="parameter"><code>buffer</code></em>
with serialized object appended.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="GwyDeserializeFunc"></a><h3>GwyDeserializeFunc ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="returnvalue">GObject</span></a> *
<span class="c_punctuation">(</span>*GwyDeserializeFunc<span class="c_punctuation">)</span> (<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *buffer</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> *position</code></em>);</pre>
<p>The type of deserialization method, see <a class="link" href="GwySerializable.html#gwy-serializable-deserialize" title="gwy_serializable_deserialize ()"><code class="function">gwy_serializable_deserialize()</code></a> for
description.</p>
<div class="refsect3">
<a name="id-1.4.10.3.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>buffer</p></td>
<td class="parameter_description"><p>A buffer containing a serialized object.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>size</p></td>
<td class="parameter_description"><p>The size of <em class="parameter"><code>buffer</code></em>
.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>position</p></td>
<td class="parameter_description"><p>The current position in <em class="parameter"><code>buffer</code></em>
.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.4.10.3.6"></a><h4>Returns</h4>
<p> A newly created (restored) object.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gwy-serializable-serialize"></a><h3>gwy_serializable_serialize ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Byte-Arrays.html#GByteArray"><span class="returnvalue">GByteArray</span></a> *
gwy_serializable_serialize (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a> *serializable</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a> *buffer</code></em>);</pre>
<p>Serializes an object to byte buffer.</p>
<p>This is a high-level method. Do not use it for implementation of child
object serialization (should you ever need to do it manually), it would
lead to repeated required buffer size calculations. In such a case, use
<code class="function">gwy_serializable_do_serialize()</code> FIXME: but that's not public.</p>
<div class="refsect3">
<a name="id-1.4.10.4.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>serializable</p></td>
<td class="parameter_description"><p>A <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a> that implements <a class="link" href="GwySerializable.html" title="GwySerializable"><span class="type">GwySerializable</span></a> interface.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>buffer</p></td>
<td class="parameter_description"><p>A buffer to which the serialized object should be appended,
or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to allocate and return a new <a href="/usr/share/gtk-doc/html/glib/glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.4.10.4.7"></a><h4>Returns</h4>
<p> <em class="parameter"><code>buffer</code></em>
or a newly allocated <a href="/usr/share/gtk-doc/html/glib/glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a> with serialized
object appended.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gwy-serializable-deserialize"></a><h3>gwy_serializable_deserialize ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="returnvalue">GObject</span></a> *
gwy_serializable_deserialize (<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *buffer</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> *position</code></em>);</pre>
<p>Restores a serialized object from byte buffer.</p>
<p>The newly created object has reference count according to its nature, thus
a <span class="type">GtkObject</span> will have a floating reference, a <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a> will have a
refcount of 1, etc.</p>
<div class="refsect3">
<a name="id-1.4.10.5.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>buffer</p></td>
<td class="parameter_description"><p>A block of memory of size <em class="parameter"><code>size</code></em>
contaning object representation.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>size</p></td>
<td class="parameter_description"><p>The size of <em class="parameter"><code>buffer</code></em>
.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>position</p></td>
<td class="parameter_description"><p>The position of the object in <em class="parameter"><code>buffer</code></em>
, it's updated to
point after it.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.4.10.5.7"></a><h4>Returns</h4>
<p> A newly created object.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gwy-serializable-duplicate"></a><h3>gwy_serializable_duplicate ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="returnvalue">GObject</span></a> *
gwy_serializable_duplicate (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a> *object</code></em>);</pre>
<p>Creates a copy of an object.</p>
<p>If the object doesn't support duplication natively, it's brute-force
serialized and then deserialized, this may be quite inefficient,
namely for large objects.</p>
<p>You can duplicate a <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, too, but you are discouraged from doing it.</p>
<div class="refsect3">
<a name="id-1.4.10.6.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>object</p></td>
<td class="parameter_description"><p>An object implementing <a class="link" href="GwySerializable.html" title="GwySerializable"><span class="type">GwySerializable</span></a> interface.</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.4.10.6.8"></a><h4>Returns</h4>
<p> The newly created object copy. However if the object is a
singleton, <em class="parameter"><code>object</code></em>
itself (with incremented reference count)
can be returned, too.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gwy-serializable-clone"></a><h3>gwy_serializable_clone ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
gwy_serializable_clone (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a> *source</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a> *copy</code></em>);</pre>
<p>Makes an object identical to another object of the same type.</p>
<p>More precisely, <em class="parameter"><code>source</code></em>
may be subclass of <em class="parameter"><code>copy</code></em>
(the extra information
is lost then).</p>
<div class="refsect3">
<a name="id-1.4.10.7.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>source</p></td>
<td class="parameter_description"><p>An object implementing <a class="link" href="GwySerializable.html" title="GwySerializable"><span class="type">GwySerializable</span></a> interface.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>copy</p></td>
<td class="parameter_description"><p>An object of the same type as <em class="parameter"><code>source</code></em>
to modify after it.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gwy-serializable-get-size"></a><h3>gwy_serializable_get_size ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="returnvalue">gsize</span></a>
gwy_serializable_get_size (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a> *serializable</code></em>);</pre>
<p>Calculates the expected size of serialized object.</p>
<div class="refsect3">
<a name="id-1.4.10.8.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>serializable</p></td>
<td class="parameter_description"><p>A <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a> that implements <a class="link" href="GwySerializable.html" title="GwySerializable"><span class="type">GwySerializable</span></a> interface.</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.4.10.8.6"></a><h4>Returns</h4>
<p> The expected size of serialized <em class="parameter"><code>serializable</code></em>
.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gwy-serialize-get-struct-size"></a><h3>gwy_serialize_get_struct_size ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="returnvalue">gsize</span></a>
gwy_serialize_get_struct_size (<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *object_name</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> nspec</code></em>,
<em class="parameter"><code>const <a class="link" href="GwySerializable.html#GwySerializeSpec" title="GwySerializeSpec"><span class="type">GwySerializeSpec</span></a> *spec</code></em>);</pre>
<p>Calculates serialized object size for struct-like objects.</p>
<p>The component specification is the same as in
<a class="link" href="GwySerializable.html#gwy-serialize-pack-object-struct" title="gwy_serialize_pack_object_struct ()"><code class="function">gwy_serialize_pack_object_struct()</code></a>.</p>
<div class="refsect3">
<a name="id-1.4.10.9.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>object_name</p></td>
<td class="parameter_description"><p>The type name of the object.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>nspec</p></td>
<td class="parameter_description"><p>The number of items in <em class="parameter"><code>spec</code></em>
.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>spec</p></td>
<td class="parameter_description"><p>The components to serialize.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.4.10.9.7"></a><h4>Returns</h4>
<p> Serialized object size, it included space for object name and size.
The value is exact unless some components are objects that do not
return exact size estimate themselves.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gwy-serialize-get-items-size"></a><h3>gwy_serialize_get_items_size ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="returnvalue">gsize</span></a>
gwy_serialize_get_items_size (<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *object_name</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> nitems</code></em>,
<em class="parameter"><code>const <a class="link" href="GwySerializable.html#GwySerializeItem" title="GwySerializeItem"><span class="type">GwySerializeItem</span></a> *items</code></em>);</pre>
<p>Calculates serialized object size for hash-like objects.</p>
<p>The component specification is the same as in
<a class="link" href="GwySerializable.html#gwy-serialize-object-items" title="gwy_serialize_object_items ()"><code class="function">gwy_serialize_object_items()</code></a>.</p>
<div class="refsect3">
<a name="id-1.4.10.10.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>object_name</p></td>
<td class="parameter_description"><p>The type name of the object.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>nitems</p></td>
<td class="parameter_description"><p>The number of <em class="parameter"><code>items</code></em>
items.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>items</p></td>
<td class="parameter_description"><p>The components to serialize.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.4.10.10.7"></a><h4>Returns</h4>
<p> Serialized object size, it included space for object name and size.
The value is exact unless some components are objects that do not
return exact size estimate themselves.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gwy-serialize-pack-object-struct"></a><h3>gwy_serialize_pack_object_struct ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Byte-Arrays.html#GByteArray"><span class="returnvalue">GByteArray</span></a> *
gwy_serialize_pack_object_struct (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a> *buffer</code></em>,
<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *object_name</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> nspec</code></em>,
<em class="parameter"><code>const <a class="link" href="GwySerializable.html#GwySerializeSpec" title="GwySerializeSpec"><span class="type">GwySerializeSpec</span></a> *spec</code></em>);</pre>
<p>Appends serialization of object with <a href="/usr/share/gtk-doc/html/gobject/gobject-Type-Information.html#g-type-name"><code class="function">g_type_name()</code></a> <em class="parameter"><code>object_name</code></em>
and
components described by <em class="parameter"><code>spec</code></em>
to <em class="parameter"><code>buffer</code></em>
in gwy-file format.</p>
<p>Here's how a serialization method of a simple object whose state is
described by a single real number foo could look (without error checking):</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar">guchar</a></span><span class="symbol">*</span>
<span class="function">my_object_serialize</span><span class="symbol">(</span><span class="usertype">GObject</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">obj</span><span class="symbol">,</span>
<span class="normal"> </span><span class="usertype">guchar</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">buffer</span><span class="symbol">,</span>
<span class="normal"> </span><span class="usertype">gsize</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">size</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> </span><span class="usertype">MyObject</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">my_object </span><span class="symbol">=</span><span class="normal"> </span><span class="function">MY_OBJECT</span><span class="symbol">(</span><span class="normal">obj</span><span class="symbol">);</span>
<span class="normal"> </span><span class="usertype">GwySerializeSpec</span><span class="normal"> spec</span><span class="symbol">[]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal"> </span><span class="cbracket">{</span><span class="normal"> </span><span class="string">'d'</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"foo"</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">&</span><span class="normal">my_object</span><span class="symbol">-></span><span class="normal">foo</span><span class="symbol">,</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">,</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal"> </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal"> </span><span class="keyword">return</span><span class="normal"> </span><span class="function"><a href="#gwy-serialize-pack-object-struct">gwy_serialize_pack_object_struct</a></span><span class="symbol">(</span><span class="normal">buffer</span><span class="symbol">,</span><span class="normal"> size</span><span class="symbol">,</span>
<span class="normal"> </span><span class="string">"MyObject"</span><span class="symbol">,</span>
<span class="normal"> </span><span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#G-N-ELEMENTS:CAPS">G_N_ELEMENTS</a></span><span class="symbol">(</span><span class="normal">spec</span><span class="symbol">),</span><span class="normal"> spec</span><span class="symbol">);</span>
<span class="cbracket">}</span></pre></td>
</tr>
</tbody>
</table>
</div>
<div class="refsect3">
<a name="id-1.4.10.11.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>buffer</p></td>
<td class="parameter_description"><p>A buffer to which the serialized components should be appended.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>object_name</p></td>
<td class="parameter_description"><p>The type name of the object.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>nspec</p></td>
<td class="parameter_description"><p>The number of items in <em class="parameter"><code>spec</code></em>
.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>spec</p></td>
<td class="parameter_description"><p>The components to serialize.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.4.10.11.8"></a><h4>Returns</h4>
<p> The buffer with serialization of <em class="parameter"><code>spec</code></em>
components appended.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gwy-serialize-unpack-object-struct"></a><h3>gwy_serialize_unpack_object_struct ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>
gwy_serialize_unpack_object_struct (<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *buffer</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> *position</code></em>,
<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *object_name</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> nspec</code></em>,
<em class="parameter"><code><a class="link" href="GwySerializable.html#GwySerializeSpec" title="GwySerializeSpec"><span class="type">GwySerializeSpec</span></a> *spec</code></em>);</pre>
<p>Deserializes an object with named components packed into gwy-file format by
<a class="link" href="GwySerializable.html#gwy-serialize-pack-object-struct" title="gwy_serialize_pack_object_struct ()"><code class="function">gwy_serialize_pack_object_struct()</code></a>.</p>
<p>Extra components are ignored (but cause a warning), components of different
type than expected cause failure, missing components are not detected.</p>
<p>It is safe to pass pointers to existing non-atomic objects (strings, arrays,
objects) in <em class="parameter"><code>spec</code></em>
values, they will be dereferenced and freed as necessary
when an unpacked value is about to replace them.
For the same reason it is an error to pass pointers to unintialized memory
there, always initialize non-atomic <em class="parameter"><code>spec</code></em>
values to <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> pointers, at
least.</p>
<p>Caller is responsible for use/clean-up of these values if deserialization
succeeds or not.</p>
<p>Here's how a deserialization method of a simple object whose state is
described by a single real number <em class="parameter"><code>foo</code></em>
could look (without error checking):</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a></span><span class="symbol">*</span>
<span class="function">my_object_deserialize</span><span class="symbol">(</span><span class="keyword">const</span><span class="normal"> </span><span class="usertype">guchar</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">buffer</span><span class="symbol">,</span>
<span class="normal"> </span><span class="usertype">gsize</span><span class="normal"> size</span><span class="symbol">,</span>
<span class="normal"> </span><span class="usertype">gsize</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">position</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> </span><span class="type">double</span><span class="normal"> foo </span><span class="symbol">=</span><span class="normal"> </span><span class="number">1.0</span><span class="symbol">;</span>
<span class="normal"> </span><span class="usertype">GwySerializeSpec</span><span class="normal"> spec</span><span class="symbol">[]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal"> </span><span class="cbracket">{</span><span class="normal"> </span><span class="string">'d'</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"foo"</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">&</span><span class="normal">foo</span><span class="symbol">,</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">,</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal"> </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal"> </span><span class="usertype">MyObject</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">my_object</span><span class="symbol">;</span>
<span class="normal"> </span><span class="function"><a href="#gwy-serialize-unpack-object-struct">gwy_serialize_unpack_object_struct</a></span><span class="symbol">(</span><span class="normal">buffer</span><span class="symbol">,</span><span class="normal"> size</span><span class="symbol">,</span><span class="normal"> position</span><span class="symbol">,</span>
<span class="normal"> </span><span class="string">"MyObject"</span><span class="symbol">,</span>
<span class="normal"> </span><span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#G-N-ELEMENTS:CAPS">G_N_ELEMENTS</a></span><span class="symbol">(</span><span class="normal">spec</span><span class="symbol">),</span><span class="normal"> spec</span><span class="symbol">);</span>
<span class="normal"> </span><span class="keyword">return</span><span class="normal"> </span><span class="function">my_object_new</span><span class="symbol">(</span><span class="normal">foo</span><span class="symbol">);</span>
<span class="cbracket">}</span></pre></td>
</tr>
</tbody>
</table>
</div>
<div class="refsect3">
<a name="id-1.4.10.12.10"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>buffer</p></td>
<td class="parameter_description"><p>A memory location containing a serialized object at position
<em class="parameter"><code>position</code></em>
.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>size</p></td>
<td class="parameter_description"><p>Current size of <em class="parameter"><code>buffer</code></em>
, new size is returned here.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>position</p></td>
<td class="parameter_description"><p>The position of the object in <em class="parameter"><code>buffer</code></em>
, it's updated to point
after it.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>object_name</p></td>
<td class="parameter_description"><p>The type name of the object.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>nspec</p></td>
<td class="parameter_description"><p>The number of items in <em class="parameter"><code>spec</code></em>
.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>spec</p></td>
<td class="parameter_description"><p>The components to deserialize.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.4.10.12.11"></a><h4>Returns</h4>
<p> Whether the unpacking succeeded
(see description body for definition of success and failure).</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gwy-serialize-check-string"></a><h3>gwy_serialize_check_string ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="returnvalue">gsize</span></a>
gwy_serialize_check_string (<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *buffer</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> position</code></em>,
<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *compare_to</code></em>);</pre>
<p>Check whether <em class="parameter"><code>size</code></em>
bytes of memory in <em class="parameter"><code>buffer</code></em>
can be interpreted as a
nul-terminated string, and eventually whether it's equal to <em class="parameter"><code>compare_to</code></em>
.</p>
<p>When <em class="parameter"><code>compare_to</code></em>
is <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, the comparsion is not performed.</p>
<div class="refsect3">
<a name="id-1.4.10.13.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>buffer</p></td>
<td class="parameter_description"><p>A memory location containing a nul-terminated string at position
<em class="parameter"><code>position</code></em>
.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>size</p></td>
<td class="parameter_description"><p>The size of <em class="parameter"><code>buffer</code></em>
.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>position</p></td>
<td class="parameter_description"><p>The position of the string in <em class="parameter"><code>buffer</code></em>
.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>compare_to</p></td>
<td class="parameter_description"><p>String to compare <em class="parameter"><code>buffer</code></em>
to, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.4.10.13.7"></a><h4>Returns</h4>
<p> The length of the nul-terminated string including the nul
character; zero otherwise.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gwy-serialize-object-items"></a><h3>gwy_serialize_object_items ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Byte-Arrays.html#GByteArray"><span class="returnvalue">GByteArray</span></a> *
gwy_serialize_object_items (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a> *buffer</code></em>,
<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *object_name</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> nitems</code></em>,
<em class="parameter"><code>const <a class="link" href="GwySerializable.html#GwySerializeItem" title="GwySerializeItem"><span class="type">GwySerializeItem</span></a> *items</code></em>);</pre>
<p>Serializes an object to buffer in gwy-file format.</p>
<p>More precisely, it appends serialization of object with <a href="/usr/share/gtk-doc/html/gobject/gobject-Type-Information.html#g-type-name"><code class="function">g_type_name()</code></a>
<em class="parameter"><code>object_name</code></em>
with components described by <em class="parameter"><code>items</code></em>
to <em class="parameter"><code>buffer</code></em>
.</p>
<div class="refsect3">
<a name="id-1.4.10.14.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>buffer</p></td>
<td class="parameter_description"><p>A buffer to which the serialized components should be appended,
or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>object_name</p></td>
<td class="parameter_description"><p>The type of the object.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>nitems</p></td>
<td class="parameter_description"><p>The number of <em class="parameter"><code>items</code></em>
items.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>items</p></td>
<td class="parameter_description"><p>The components to serialize.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.4.10.14.7"></a><h4>Returns</h4>
<p> <em class="parameter"><code>buffer</code></em>
or a newly allocated <a href="/usr/share/gtk-doc/html/glib/glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a> with serialization of
<em class="parameter"><code>items</code></em>
components appended.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="gwy-deserialize-object-hash"></a><h3>gwy_deserialize_object_hash ()</h3>
<pre class="programlisting"><a class="link" href="GwySerializable.html#GwySerializeItem" title="GwySerializeItem"><span class="returnvalue">GwySerializeItem</span></a> *
gwy_deserialize_object_hash (<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *buffer</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> *position</code></em>,
<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *object_name</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> *nitems</code></em>);</pre>
<p>Deserializes an object with arbitrary components from gwy-file format.</p>
<p>This function works like <a class="link" href="GwySerializable.html#gwy-serialize-unpack-object-struct" title="gwy_serialize_unpack_object_struct ()"><code class="function">gwy_serialize_unpack_object_struct()</code></a>, except that
it does not use any a priori knowledge of what the object contains. So
instead of filling values in supplied <a class="link" href="GwySerializable.html#GwySerializeSpec" title="GwySerializeSpec"><span class="type">GwySerializeSpec</span></a>'s, it constructs
<a class="link" href="GwySerializable.html#GwySerializeItem" title="GwySerializeItem"><span class="type">GwySerializeItem</span></a>'s completely from what is found in <em class="parameter"><code>buffer</code></em>
. It does
considerably less sanity checks and even allows several components of the
same name.</p>
<div class="refsect3">
<a name="id-1.4.10.15.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>buffer</p></td>
<td class="parameter_description"><p>A block of memory of size <em class="parameter"><code>size</code></em>
contaning object representation.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>size</p></td>
<td class="parameter_description"><p>The size of <em class="parameter"><code>buffer</code></em>
.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>position</p></td>
<td class="parameter_description"><p>Current position in buffer, will be updated to point after
object.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>object_name</p></td>
<td class="parameter_description"><p>The type name of the object.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>nitems</p></td>
<td class="parameter_description"><p>Where the number of deserialized components should be stored.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.4.10.15.7"></a><h4>Returns</h4>
<p> A newly allocated array of deserialized components. Note the
<em class="parameter"><code>name</code></em>
fields of <a class="link" href="GwySerializable.html#GwySerializeSpec" title="GwySerializeSpec"><span class="type">GwySerializeSpec</span></a>'s point to <em class="parameter"><code>buffer</code></em>
and thus are
valid only as long as <em class="parameter"><code>buffer</code></em>
is; any arrays or strings are newly
allocated and must be reused or freed by caller.</p>
</div>
</div>
</div>
<div class="refsect1">
<a name="GwySerializable.other_details"></a><h2>Types and Values</h2>
<div class="refsect2">
<a name="GwySerializable-struct"></a><h3>GwySerializable</h3>
<pre class="programlisting">typedef struct _GwySerializable GwySerializable;</pre>
</div>
<hr>
<div class="refsect2">
<a name="GwySerializeSpec"></a><h3>GwySerializeSpec</h3>
<pre class="programlisting">typedef struct {
guchar ctype;
const guchar *name;
gpointer value;
guint32 *array_size;
} GwySerializeSpec;
</pre>
<p>A structure containing information for one object/struct component
serialization or deserialization.</p>
<p>This component information is used in <a class="link" href="GwySerializable.html#gwy-serialize-pack-object-struct" title="gwy_serialize_pack_object_struct ()"><code class="function">gwy_serialize_pack_object_struct()</code></a>
and <a class="link" href="GwySerializable.html#gwy-serialize-unpack-object-struct" title="gwy_serialize_unpack_object_struct ()"><code class="function">gwy_serialize_unpack_object_struct()</code></a> suitable for (de)serialization
of struct-like objects.</p>
<p>Following atomic component types (<em class="parameter"><code>ctype</code></em>
's) exist:
<code class="literal">'b'</code> for a boolean,
<code class="literal">'c'</code> for a character,
<code class="literal">'i'</code> for a 32bit integer,
<code class="literal">'q'</code> for a 64bit integer,
<code class="literal">'d'</code> for a gdouble,
<code class="literal">'s'</code> for a nul-terminated string,
<code class="literal">'o'</code> for a serializable object.</p>
<p>And array component types:
<code class="literal">'C'</code> for a character array,
<code class="literal">'I'</code> for a 32bit integer array,
<code class="literal">'Q'</code> for a 64bit integer array,
<code class="literal">'D'</code> for a gdouble array,
<code class="literal">'S'</code> for an array of nul-terminated strings,
<code class="literal">'O'</code> for an array of objects.</p>
<div class="refsect3">
<a name="id-1.4.11.3.8"></a><h4>Members</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="300px" class="struct_members_name">
<col class="struct_members_description">
<col width="200px" class="struct_members_annotations">
</colgroup>
<tbody>
<tr>
<td class="struct_member_name"><p><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> <em class="structfield"><code><a name="GwySerializeSpec.ctype"></a>ctype</code></em>;</p></td>
<td class="struct_member_description"><p>Component type, see description body for possible values.</p></td>
<td class="struct_member_annotations"> </td>
</tr>
<tr>
<td class="struct_member_name"><p>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *<em class="structfield"><code><a name="GwySerializeSpec.name"></a>name</code></em>;</p></td>
<td class="struct_member_description"><p>Component name as a nul-terminated string.</p></td>
<td class="struct_member_annotations"> </td>
</tr>
<tr>
<td class="struct_member_name"><p><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> <em class="structfield"><code><a name="GwySerializeSpec.value"></a>value</code></em>;</p></td>
<td class="struct_member_description"><p>Pointer to component (always add one level of indirection; for
an object, a <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a>** pointer should be stored). If it is
<a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, the component is ignored. For serialization it means it
is not serialized, for deserialization it means its existence
is acknowledged (no unknown component warning) but it's skipped
instead of unpacking.</p></td>
<td class="struct_member_annotations"> </td>
</tr>
<tr>
<td class="struct_member_name"><p><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint32"><span class="type">guint32</span></a> *<em class="structfield"><code><a name="GwySerializeSpec.array-size"></a>array_size</code></em>;</p></td>
<td class="struct_member_description"><p>Pointer to array size if component is an array, <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
otherwise.</p></td>
<td class="struct_member_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="GwySerializeValue"></a><h3>GwySerializeValue</h3>
</div>
<hr>
<div class="refsect2">
<a name="GwySerializeItem"></a><h3>GwySerializeItem</h3>
<pre class="programlisting">typedef struct {
guchar ctype;
const guchar *name;
GwySerializeValue value;
guint32 array_size;
} GwySerializeItem;
</pre>
<p>A structure containing information for one object/struct component
serialization or deserialization.</p>
<p>This component information is used in <a class="link" href="GwySerializable.html#gwy-serialize-object-items" title="gwy_serialize_object_items ()"><code class="function">gwy_serialize_object_items()</code></a> and
<a class="link" href="GwySerializable.html#gwy-deserialize-object-hash" title="gwy_deserialize_object_hash ()"><code class="function">gwy_deserialize_object_hash()</code></a> suitable for (de)serialization of hash-like
objects.</p>
<div class="refsect3">
<a name="id-1.4.11.5.6"></a><h4>Members</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="300px" class="struct_members_name">
<col class="struct_members_description">
<col width="200px" class="struct_members_annotations">
</colgroup>
<tbody>
<tr>
<td class="struct_member_name"><p><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> <em class="structfield"><code><a name="GwySerializeItem.ctype"></a>ctype</code></em>;</p></td>
<td class="struct_member_description"><p>Component type, see <a class="link" href="GwySerializable.html#GwySerializeSpec" title="GwySerializeSpec"><span class="type">GwySerializeSpec</span></a> for details.</p></td>
<td class="struct_member_annotations"> </td>
</tr>
<tr>
<td class="struct_member_name"><p>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *<em class="structfield"><code><a name="GwySerializeItem.name"></a>name</code></em>;</p></td>
<td class="struct_member_description"><p>Component name as a nul-terminated string.</p></td>
<td class="struct_member_annotations"> </td>
</tr>
<tr>
<td class="struct_member_name"><p><a class="link" href="GwySerializable.html#GwySerializeValue" title="GwySerializeValue"><span class="type">GwySerializeValue</span></a> <em class="structfield"><code><a name="GwySerializeItem.value"></a>value</code></em>;</p></td>
<td class="struct_member_description"><p>Component value.</p></td>
<td class="struct_member_annotations"> </td>
</tr>
<tr>
<td class="struct_member_name"><p><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint32"><span class="type">guint32</span></a> <em class="structfield"><code><a name="GwySerializeItem.array-size"></a>array_size</code></em>;</p></td>
<td class="struct_member_description"><p>Array size if component is an array, unused otherwise.</p></td>
<td class="struct_member_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
</div>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.19</div>
</body>
</html>
|