Gwyfile Library
gwyfile.h
Go to the documentation of this file.
1 /*
2  * $Id: gwyfile.h 397 2023-02-08 14:10:25Z yeti-dn $
3  *
4  * Copyright © 2014-2022, David Nečas (Yeti) <yeti@gwyddion.net>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
7  * documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
8  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
12  * Software.
13  *
14  * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
15  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
16  * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18  */
19 
20 #ifndef __GWYFILE_GWYFILE_H__
21 #define __GWYFILE_GWYFILE_H__ 1
22 
23 #if 1
24 #include <stdbool.h>
25 #else
26 /* For an antique pre-C99 compiler you can define instead: */
27 typedef enum { false = 0, true = 1 } bool;
28 #endif
29 
30 #if 1
31 #include <stdint.h>
32 #else
33 /* For an antique pre-C99 compiler you need to define int32_t, uint32_t, int64_t and uint64_t to EXACTLY(!) 32bit and
34  * 64bit signed and unsigned integral types. The following may not be correct for your system. */
35 typedef int int32_t;
36 typedef unsigned int uint32_t;
37 typedef long long int int64_t;
38 typedef unsigned long long int uint64_t;
39 #endif
40 
41 #if 1
42 #else
43 /* For an antique pre-C99 compiler you may also need to #define `inline' to an empty comment. */
44 #define inline /* */
45 #endif
46 
47 #include <stdio.h>
48 #include <stdlib.h>
49 
50 /* gwyfile_read_wfile() and gwyfile_write_wfile() are defined only on MS Windows. Avoid including wchar.h elsewhere. */
51 #ifdef _WIN32
52 #include <wchar.h>
53 #endif
54 
55 #ifndef DOXYGEN_SHOULD_SKIP_THIS
56 #ifdef __GNUC__
57 #define GWYFILE_NULL_TERMINATED __attribute__((sentinel))
58 #define GWYFILE_MALLOC __attribute__((malloc))
59 #define GWYFILE_PURE __attribute__((pure))
60 #define GWYFILE_UNUSED __attribute__((unused))
61 #else
62 #define GWYFILE_NULL_TERMINATED /* */
63 #define GWYFILE_MALLOC /* */
64 #define GWYFILE_PURE /* */
65 #define GWYFILE_UNUSED /* */
66 #endif
67 #endif
68 
87 typedef enum {
104 typedef struct _GwyfileItem GwyfileItem;
105 typedef struct _GwyfileObject GwyfileObject;
106 
110 typedef enum {
116 
117 typedef enum {
130 
131 typedef struct {
133  int code;
134  char *message;
135 } GwyfileError;
136 
137 typedef struct {
139  size_t n;
141 
142 void gwyfile_error_clear (GwyfileError **error);
150 typedef enum {
155 
156 typedef enum {
162 
163 typedef enum {
167 
168 bool gwyfile_check_object(const GwyfileObject *object,
169  unsigned int flags,
170  GwyfileErrorList *errlist);
176 typedef enum {
187 bool gwyfile_write_file(GwyfileObject *object,
188  const char *filename,
189  GwyfileError **error);
190 GwyfileObject* gwyfile_read_file (const char *filename,
191  GwyfileError **error) GWYFILE_MALLOC;
192 
193 bool gwyfile_fwrite (GwyfileObject *object,
194  FILE *stream,
195  GwyfileError **error);
196 GwyfileObject* gwyfile_fread (FILE *stream,
197  size_t max_size,
198  GwyfileError **error) GWYFILE_MALLOC;
199 
200 #ifdef _WIN32
201 bool gwyfile_write_wfile(GwyfileObject *object,
202  const wchar_t *filename,
203  GwyfileError **error);
204 GwyfileObject* gwyfile_read_wfile (const wchar_t *filename,
205  GwyfileError **error) GWYFILE_MALLOC;
206 #endif
207 
213 typedef void (*GwyfileObjectForeachFunc)(const GwyfileItem *item,
214  void *user_data);
215 
216 GwyfileObject* gwyfile_object_new (const char *name,
217  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
218 GwyfileObject* gwyfile_object_newv (const char *name,
219  GwyfileItem **items,
220  unsigned int nitems) GWYFILE_MALLOC;
221 void gwyfile_object_free (GwyfileObject *object);
222 const char* gwyfile_object_name (const GwyfileObject *object) GWYFILE_PURE;
223 size_t gwyfile_object_size (const GwyfileObject *object) GWYFILE_PURE;
224 bool gwyfile_object_add (GwyfileObject *object,
225  GwyfileItem *item);
226 bool gwyfile_object_remove (GwyfileObject *object,
227  const char *name);
228 GwyfileItem* gwyfile_object_get (const GwyfileObject *object,
229  const char *name) GWYFILE_PURE;
230 GwyfileItem* gwyfile_object_take (GwyfileObject *object,
231  const char *name);
232 GwyfileItem* gwyfile_object_get_with_type (const GwyfileObject *object,
233  const char *name,
234  GwyfileItemType type) GWYFILE_PURE;
235 GwyfileItem* gwyfile_object_take_with_type(GwyfileObject *object,
236  const char *name,
237  GwyfileItemType type);
238 size_t gwyfile_object_data_size (const GwyfileObject *object) GWYFILE_PURE;
239 GwyfileItem* gwyfile_object_get_nth (const GwyfileObject *object,
240  unsigned int n) GWYFILE_PURE;
241 void gwyfile_object_foreach (const GwyfileObject *object,
242  GwyfileObjectForeachFunc function,
243  void *user_data);
244 unsigned int gwyfile_object_nitems (const GwyfileObject *object) GWYFILE_PURE;
245 const char** gwyfile_object_item_names (const GwyfileObject *object) GWYFILE_MALLOC;
246 GwyfileObject* gwyfile_object_copy (const GwyfileObject *object,
247  GwyfileCopyMethod method) GWYFILE_MALLOC;
253 bool gwyfile_object_fwrite (GwyfileObject *object,
254  FILE *stream,
255  GwyfileError **error);
256 GwyfileObject* gwyfile_object_fread (FILE *stream,
257  size_t max_size,
258  GwyfileError **error) GWYFILE_MALLOC;
259 size_t gwyfile_object_write_memory (const GwyfileObject *object,
260  void *buffer,
261  size_t size,
262  GwyfileError **error);
263 GwyfileObject* gwyfile_object_read_memory (const void *buffer,
264  size_t size,
265  size_t *bytes_read,
266  GwyfileError **error) GWYFILE_MALLOC;
272 GwyfileObject* gwyfile_object_new_datafield (int xres,
273  int yres,
274  double xreal,
275  double yreal,
276  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
277 bool gwyfile_object_datafield_get (const GwyfileObject *object,
278  GwyfileError **error,
279  ...) GWYFILE_NULL_TERMINATED;
280 GwyfileObject* gwyfile_object_new_dataline (int res,
281  double real,
282  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
283 bool gwyfile_object_dataline_get (const GwyfileObject *object,
284  GwyfileError **error,
285  ...) GWYFILE_NULL_TERMINATED;
286 GwyfileObject* gwyfile_object_new_brick (int xres,
287  int yres,
288  int zres,
289  double xreal,
290  double yreal,
291  double zreal,
292  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
293 bool gwyfile_object_brick_get (const GwyfileObject *object,
294  GwyfileError **error,
295  ...) GWYFILE_NULL_TERMINATED;
296 GwyfileObject* gwyfile_object_new_surface (int n,
297  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
298 bool gwyfile_object_surface_get (const GwyfileObject *object,
299  GwyfileError **error,
300  ...) GWYFILE_NULL_TERMINATED;
301 GwyfileObject* gwyfile_object_new_lawn (int xres,
302  int yres,
303  int ncurves,
304  double xreal,
305  double yreal,
306  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
307 bool gwyfile_object_lawn_get (const GwyfileObject *object,
308  GwyfileError **error,
309  ...) GWYFILE_NULL_TERMINATED;
310 GwyfileObject* gwyfile_object_new_spectra (int ncurves,
311  GwyfileObject **curves,
312  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
313 bool gwyfile_object_spectra_get (const GwyfileObject *object,
314  GwyfileError **error,
315  ...) GWYFILE_NULL_TERMINATED;
316 GwyfileObject* gwyfile_object_new_graphmodel (int ncurves,
317  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
318 bool gwyfile_object_graphmodel_get (const GwyfileObject *object,
319  GwyfileError **error,
320  ...) GWYFILE_NULL_TERMINATED;
321 GwyfileObject* gwyfile_object_new_graphcurvemodel (int ndata,
322  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
323 bool gwyfile_object_graphcurvemodel_get (const GwyfileObject *object,
324  GwyfileError **error,
325  ...) GWYFILE_NULL_TERMINATED;
326 GwyfileObject* gwyfile_object_new_selectionpoint (int nsel,
327  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
328 bool gwyfile_object_selectionpoint_get (const GwyfileObject *object,
329  GwyfileError **error,
330  ...) GWYFILE_NULL_TERMINATED;
331 GwyfileObject* gwyfile_object_new_selectioncross (int nsel,
332  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
333 bool gwyfile_object_selectioncross_get (const GwyfileObject *object,
334  GwyfileError **error,
335  ...) GWYFILE_NULL_TERMINATED;
336 GwyfileObject* gwyfile_object_new_selectionline (int nsel,
337  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
338 bool gwyfile_object_selectionline_get (const GwyfileObject *object,
339  GwyfileError **error,
340  ...) GWYFILE_NULL_TERMINATED;
341 GwyfileObject* gwyfile_object_new_selectionrectangle (int nsel,
342  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
343 bool gwyfile_object_selectionrectangle_get (const GwyfileObject *object,
344  GwyfileError **error,
345  ...) GWYFILE_NULL_TERMINATED;
346 GwyfileObject* gwyfile_object_new_selectionellipse (int nsel,
347  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
348 bool gwyfile_object_selectionellipse_get (const GwyfileObject *object,
349  GwyfileError **error,
350  ...) GWYFILE_NULL_TERMINATED;
351 GwyfileObject* gwyfile_object_new_selectionlattice (int nsel,
352  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
353 bool gwyfile_object_selectionlattice_get (const GwyfileObject *object,
354  GwyfileError **error,
355  ...) GWYFILE_NULL_TERMINATED;
356 GwyfileObject* gwyfile_object_new_selectionprojective(int nsel,
357  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
358 bool gwyfile_object_selectionprojective_get(const GwyfileObject *object,
359  GwyfileError **error,
360  ...) GWYFILE_NULL_TERMINATED;
361 GwyfileObject* gwyfile_object_new_selectionaxis (int nsel,
362  int orientation,
363  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
364 bool gwyfile_object_selectionaxis_get (const GwyfileObject *object,
365  GwyfileError **error,
366  ...) GWYFILE_NULL_TERMINATED;
367 GwyfileObject* gwyfile_object_new_selectionpath (int nsel,
368  double slackness,
369  bool closed,
370  ...) GWYFILE_NULL_TERMINATED GWYFILE_MALLOC;
371 bool gwyfile_object_selectionpath_get (const GwyfileObject *object,
372  GwyfileError **error,
373  ...) GWYFILE_NULL_TERMINATED;
374 GwyfileObject* gwyfile_object_new_siunit (const char *unitstr) GWYFILE_MALLOC;
375 bool gwyfile_object_siunit_get (const GwyfileObject *object,
376  GwyfileError **error,
377  ...) GWYFILE_NULL_TERMINATED;
383 int* gwyfile_object_container_enumerate_channels (const GwyfileObject *object,
384  unsigned int *nchannels) GWYFILE_MALLOC;
385 int* gwyfile_object_container_enumerate_volume (const GwyfileObject *object,
386  unsigned int *nvolume) GWYFILE_MALLOC;
387 int* gwyfile_object_container_enumerate_graphs (const GwyfileObject *object,
388  unsigned int *ngraphs) GWYFILE_MALLOC;
389 int* gwyfile_object_container_enumerate_xyz (const GwyfileObject *object,
390  unsigned int *nxyz) GWYFILE_MALLOC;
391 int* gwyfile_object_container_enumerate_curvemaps(const GwyfileObject *object,
392  unsigned int *nxyz) GWYFILE_MALLOC;
393 int* gwyfile_object_container_enumerate_spectra (const GwyfileObject *object,
394  unsigned int *nspectra) GWYFILE_MALLOC;
400 void gwyfile_item_free (GwyfileItem *item);
401 GwyfileItemType gwyfile_item_type (const GwyfileItem *item) GWYFILE_PURE;
402 const char* gwyfile_item_name (const GwyfileItem *item) GWYFILE_PURE;
403 uint32_t gwyfile_item_array_length(const GwyfileItem *item) GWYFILE_PURE;
404 size_t gwyfile_item_size (const GwyfileItem *item) GWYFILE_PURE;
405 size_t gwyfile_item_data_size (const GwyfileItem *item) GWYFILE_PURE;
406 GwyfileItem* gwyfile_item_copy (const GwyfileItem *item,
407  GwyfileCopyMethod method) GWYFILE_MALLOC;
408 bool gwyfile_item_fwrite (const GwyfileItem *item,
409  FILE *stream,
410  GwyfileError **error);
411 GwyfileItem* gwyfile_item_fread (FILE *stream,
412  size_t max_size,
413  GwyfileError **error) GWYFILE_MALLOC;
414 size_t gwyfile_item_write_memory(const GwyfileItem *item,
415  void *buffer,
416  size_t size,
417  GwyfileError **error);
418 GwyfileItem* gwyfile_item_read_memory (const void *buffer,
419  size_t size,
420  size_t *bytes_read,
421  GwyfileError **error) GWYFILE_MALLOC;
422 bool gwyfile_item_owns_data (const GwyfileItem *item) GWYFILE_PURE;
428 GwyfileItem* gwyfile_item_new_bool(const char *name,
429  bool value) GWYFILE_MALLOC;
430 bool gwyfile_item_get_bool(const GwyfileItem *item);
431 void gwyfile_item_set_bool(GwyfileItem *item,
432  bool value);
438 GwyfileItem* gwyfile_item_new_char(const char *name,
439  char value) GWYFILE_MALLOC;
440 char gwyfile_item_get_char(const GwyfileItem *item) GWYFILE_PURE;
441 void gwyfile_item_set_char(GwyfileItem *item,
442  char value);
448 GwyfileItem* gwyfile_item_new_int32(const char *name,
449  int32_t value) GWYFILE_MALLOC;
450 int32_t gwyfile_item_get_int32(const GwyfileItem *item) GWYFILE_PURE;
451 void gwyfile_item_set_int32(GwyfileItem *item,
452  int32_t value);
458 GwyfileItem* gwyfile_item_new_int64(const char *name,
459  int64_t value) GWYFILE_MALLOC;
460 int64_t gwyfile_item_get_int64(const GwyfileItem *item) GWYFILE_PURE;
461 void gwyfile_item_set_int64(GwyfileItem *item,
462  int64_t value);
468 GwyfileItem* gwyfile_item_new_double(const char *name,
469  double value) GWYFILE_MALLOC;
470 double gwyfile_item_get_double(const GwyfileItem *item) GWYFILE_PURE;
471 void gwyfile_item_set_double(GwyfileItem *item,
472  double value);
478 GwyfileItem* gwyfile_item_new_string (const char *name,
479  char *value) GWYFILE_MALLOC;
480 GwyfileItem* gwyfile_item_new_string_copy (const char *name,
481  const char *value) GWYFILE_MALLOC;
482 GwyfileItem* gwyfile_item_new_string_const(const char *name,
483  const char *value) GWYFILE_MALLOC;
484 const char* gwyfile_item_get_string (const GwyfileItem *item) GWYFILE_PURE;
485 char* gwyfile_item_take_string (GwyfileItem *item);
486 void gwyfile_item_set_string (GwyfileItem *item,
487  char *value);
488 void gwyfile_item_set_string_copy (GwyfileItem *item,
489  const char *value);
490 void gwyfile_item_set_string_const(GwyfileItem *item,
491  const char *value);
497 GwyfileItem* gwyfile_item_new_object (const char *name,
498  GwyfileObject *value) GWYFILE_MALLOC;
499 GwyfileObject* gwyfile_item_get_object (const GwyfileItem *item) GWYFILE_PURE;
500 GwyfileObject* gwyfile_item_release_object(GwyfileItem *item);
501 void gwyfile_item_set_object (GwyfileItem *item,
502  GwyfileObject *value);
508 GwyfileItem* gwyfile_item_new_char_array (const char *name,
509  char *value,
510  uint32_t array_length) GWYFILE_MALLOC;
511 GwyfileItem* gwyfile_item_new_char_array_copy (const char *name,
512  const char *value,
513  uint32_t array_length) GWYFILE_MALLOC;
514 GwyfileItem* gwyfile_item_new_char_array_const(const char *name,
515  const char *value,
516  uint32_t array_length) GWYFILE_MALLOC;
517 const char* gwyfile_item_get_char_array (const GwyfileItem *item) GWYFILE_PURE;
518 char* gwyfile_item_take_char_array (GwyfileItem *item);
519 void gwyfile_item_set_char_array (GwyfileItem *item,
520  char *value,
521  uint32_t array_length);
522 void gwyfile_item_set_char_array_copy (GwyfileItem *item,
523  const char *value,
524  uint32_t array_length);
525 void gwyfile_item_set_char_array_const(GwyfileItem *item,
526  const char *value,
527  uint32_t array_length);
533 GwyfileItem* gwyfile_item_new_int32_array (const char *name,
534  int32_t *value,
535  uint32_t array_length) GWYFILE_MALLOC;
536 GwyfileItem* gwyfile_item_new_int32_array_copy (const char *name,
537  const int32_t *value,
538  uint32_t array_length) GWYFILE_MALLOC;
539 GwyfileItem* gwyfile_item_new_int32_array_const(const char *name,
540  const int32_t *value,
541  uint32_t array_length) GWYFILE_MALLOC;
542 const int32_t* gwyfile_item_get_int32_array (const GwyfileItem *item) GWYFILE_PURE;
543 int32_t* gwyfile_item_take_int32_array (GwyfileItem *item);
544 void gwyfile_item_set_int32_array (GwyfileItem *item,
545  int32_t *value,
546  uint32_t array_length);
547 void gwyfile_item_set_int32_array_copy (GwyfileItem *item,
548  const int32_t *value,
549  uint32_t array_length);
550 void gwyfile_item_set_int32_array_const(GwyfileItem *item,
551  const int32_t *value,
552  uint32_t array_length);
558 GwyfileItem* gwyfile_item_new_int64_array (const char *name,
559  int64_t *value,
560  uint32_t array_length) GWYFILE_MALLOC;
561 GwyfileItem* gwyfile_item_new_int64_array_copy (const char *name,
562  const int64_t *value,
563  uint32_t array_length) GWYFILE_MALLOC;
564 GwyfileItem* gwyfile_item_new_int64_array_const(const char *name,
565  const int64_t *value,
566  uint32_t array_length) GWYFILE_MALLOC;
567 const int64_t* gwyfile_item_get_int64_array (const GwyfileItem *item) GWYFILE_PURE;
568 int64_t* gwyfile_item_take_int64_array (GwyfileItem *item);
569 void gwyfile_item_set_int64_array (GwyfileItem *item,
570  int64_t *value,
571  uint32_t array_length);
572 void gwyfile_item_set_int64_array_copy (GwyfileItem *item,
573  const int64_t *value,
574  uint32_t array_length);
575 void gwyfile_item_set_int64_array_const(GwyfileItem *item,
576  const int64_t *value,
577  uint32_t array_length);
583 GwyfileItem* gwyfile_item_new_double_array (const char *name,
584  double *value,
585  uint32_t array_length) GWYFILE_MALLOC;
586 GwyfileItem* gwyfile_item_new_double_array_copy (const char *name,
587  const double *value,
588  uint32_t array_length) GWYFILE_MALLOC;
589 GwyfileItem* gwyfile_item_new_double_array_const(const char *name,
590  const double *value,
591  uint32_t array_length) GWYFILE_MALLOC;
592 const double* gwyfile_item_get_double_array (const GwyfileItem *item) GWYFILE_PURE;
593 double* gwyfile_item_take_double_array (GwyfileItem *item);
594 void gwyfile_item_set_double_array (GwyfileItem *item,
595  double *value,
596  uint32_t array_length);
597 void gwyfile_item_set_double_array_copy (GwyfileItem *item,
598  const double *value,
599  uint32_t array_length);
600 void gwyfile_item_set_double_array_const(GwyfileItem *item,
601  const double *value,
602  uint32_t array_length);
608 GwyfileItem* gwyfile_item_new_string_array (const char *name,
609  char **value,
610  uint32_t array_length) GWYFILE_MALLOC;
611 GwyfileItem* gwyfile_item_new_string_array_copy (const char *name,
612  const char *const *value,
613  uint32_t array_length) GWYFILE_MALLOC;
614 GwyfileItem* gwyfile_item_new_string_array_const(const char *name,
615  const char *const *value,
616  uint32_t array_length) GWYFILE_MALLOC;
617 const char* const* gwyfile_item_get_string_array (const GwyfileItem *item) GWYFILE_PURE;
618 char** gwyfile_item_take_string_array (GwyfileItem *item);
619 void gwyfile_item_set_string_array (GwyfileItem *item,
620  char **value,
621  uint32_t array_length);
622 void gwyfile_item_set_string_array_copy (GwyfileItem *item,
623  const char *const *value,
624  uint32_t array_length);
625 void gwyfile_item_set_string_array_const(GwyfileItem *item,
626  const char *const *value,
627  uint32_t array_length);
633 GwyfileItem* gwyfile_item_new_object_array (const char *name,
634  GwyfileObject **value,
635  uint32_t array_length) GWYFILE_MALLOC;
636 GwyfileObject* const* gwyfile_item_get_object_array (const GwyfileItem *item) GWYFILE_PURE;
637 void gwyfile_item_set_object_array (GwyfileItem *item,
638  GwyfileObject **value,
639  uint32_t array_length);
642 #endif
643 
644 /* vim: set cin et ts=4 sw=4 columns=120 tw=119 cino=>1s,e0,n0,f0,{0,}0,^0,\:1s,=0,g1s,h0,t0,+1s,c3,(0,u0 : */
GwyfileCopyMethod
Definition: gwyfile.h:176
@ GWYFILE_COPY_ALL
All data are copied. The copy will own all its data.
Definition: gwyfile.h:179
@ GWYFILE_COPY_DEFAULT
The default behaviour, i.e. GWYFILE_COPY_IF_OWNED.
Definition: gwyfile.h:178
@ GWYFILE_COPY_NONE
No data are copied. The copy will not own any data.
Definition: gwyfile.h:180
@ GWYFILE_COPY_IF_OWNED
Owned data are copied so the copy also own its data; not owned data are not copied.
Definition: gwyfile.h:177
bool gwyfile_write_file(GwyfileObject *object, const char *filename, GwyfileError **error)
Writes a GWY file to a named file.
Definition: gwyfile.c:331
GwyfileObject * gwyfile_read_file(const char *filename, GwyfileError **error)
Reads a GWY file from a named file and returns its top-level object.
Definition: gwyfile.c:405
GwyfileObject * gwyfile_read_wfile(const wchar_t *filename, GwyfileError **error)
Reads a GWY file from a named file and returns its top-level object (wide-character variant).
Definition: gwyfile.c:486
bool gwyfile_write_wfile(GwyfileObject *object, const wchar_t *filename, GwyfileError **error)
Writes a GWY file to a named file (wide-character variant).
Definition: gwyfile.c:447
bool gwyfile_fwrite(GwyfileObject *object, FILE *stream, GwyfileError **error)
Writes a GWY file to a stdio stream.
Definition: gwyfile.c:523
GwyfileObject * gwyfile_fread(FILE *stream, size_t max_size, GwyfileError **error)
Reads a GWY file from a stdio stream and returns the top-level object.
Definition: gwyfile.c:565
GwyfileObject * gwyfile_object_new_lawn(int xres, int yres, int ncurves, double xreal, double yreal,...)
Creates a new GWY file GwyLawn object.
Definition: gwyfile.c:1256
GwyfileObject * gwyfile_object_new_surface(int n,...)
Creates a new GWY file GwySurface object.
Definition: gwyfile.c:1098
bool gwyfile_object_selectionpath_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwySelectionPath object.
Definition: gwyfile.c:4084
GwyfileObject * gwyfile_object_new_selectionprojective(int nsel,...)
Creates a new GWY file GwySelectionProjective object.
Definition: gwyfile.c:1970
bool gwyfile_object_datafield_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwyDataField object.
Definition: gwyfile.c:2372
bool gwyfile_object_selectionellipse_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwySelectionEllipse object.
Definition: gwyfile.c:3790
bool gwyfile_object_selectioncross_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwySelectionCross object.
Definition: gwyfile.c:3676
bool gwyfile_object_siunit_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwySIUnit object.
Definition: gwyfile.c:4154
bool gwyfile_object_selectionrectangle_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwySelectionRectangle object.
Definition: gwyfile.c:3733
GwyfileObject * gwyfile_object_new_selectionellipse(int nsel,...)
Creates a new GWY file GwySelectionEllipse object.
Definition: gwyfile.c:1891
bool gwyfile_object_selectionaxis_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwySelectionAxis object.
Definition: gwyfile.c:4019
bool gwyfile_object_spectra_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwySpectra object.
Definition: gwyfile.c:3487
GwyfileObject * gwyfile_object_new_brick(int xres, int yres, int zres, double xreal, double yreal, double zreal,...)
Creates a new GWY file GwyBrick object.
Definition: gwyfile.c:1003
bool gwyfile_object_graphmodel_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwyGraphModel object.
Definition: gwyfile.c:3319
GwyfileObject * gwyfile_object_new_datafield(int xres, int yres, double xreal, double yreal,...)
Creates a new GWY file GwyDataField object.
Definition: gwyfile.c:831
GwyfileObject * gwyfile_object_new_selectioncross(int nsel,...)
Creates a new GWY file GwySelectionCross object.
Definition: gwyfile.c:1774
GwyfileObject * gwyfile_object_new_selectionaxis(int nsel, int orientation,...)
Creates a new GWY file GwySelectionAxis object.
Definition: gwyfile.c:2009
GwyfileObject * gwyfile_object_new_spectra(int ncurves, GwyfileObject **curves,...)
Creates a new GWY file GwySpectra object.
Definition: gwyfile.c:1389
bool gwyfile_object_graphcurvemodel_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwyGraphCurveModel object.
Definition: gwyfile.c:3168
bool gwyfile_object_lawn_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwyLawn object.
Definition: gwyfile.c:2960
GwyfileObject * gwyfile_object_new_selectionline(int nsel,...)
Creates a new GWY file GwySelectionLine object.
Definition: gwyfile.c:1813
bool gwyfile_object_selectionpoint_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwySelectionPoint object.
Definition: gwyfile.c:3619
GwyfileObject * gwyfile_object_new_selectionrectangle(int nsel,...)
Creates a new GWY file GwySelectionRectangle object.
Definition: gwyfile.c:1852
GwyfileObject * gwyfile_object_new_dataline(int res, double real,...)
Creates a new GWY file GwyDataLine object.
Definition: gwyfile.c:911
GwyfileObject * gwyfile_object_new_selectionpoint(int nsel,...)
Creates a new GWY file GwySelectionPoint object.
Definition: gwyfile.c:1734
bool gwyfile_object_brick_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwyBrick object.
Definition: gwyfile.c:2613
GwyfileObject * gwyfile_object_new_siunit(const char *unitstr)
Creates a new GWY file GwySIUnit object.
Definition: gwyfile.c:2091
bool gwyfile_object_surface_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwySurface object.
Definition: gwyfile.c:2716
bool gwyfile_object_selectionlattice_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwySelectionLattice object.
Definition: gwyfile.c:3903
GwyfileObject * gwyfile_object_new_graphcurvemodel(int ndata,...)
Creates a new GWY file GwyGraphCurveModel object.
Definition: gwyfile.c:1487
bool gwyfile_object_dataline_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwyDataLine object.
Definition: gwyfile.c:2478
bool gwyfile_object_selectionprojective_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwySelectionProjective object.
Definition: gwyfile.c:3962
bool gwyfile_object_selectionline_get(const GwyfileObject *object, GwyfileError **error,...)
Obtains information and/or data from a GWY file GwySelectionLine object.
Definition: gwyfile.c:3846
GwyfileObject * gwyfile_object_new_selectionlattice(int nsel,...)
Creates a new GWY file GwySelectionLattice object.
Definition: gwyfile.c:1930
GwyfileObject * gwyfile_object_new_graphmodel(int ncurves,...)
Creates a new GWY file GwyGraphModel object.
Definition: gwyfile.c:1608
GwyfileObject * gwyfile_object_new_selectionpath(int nsel, double slackness, bool closed,...)
Creates a new GWY file GwySelectionPath object.
Definition: gwyfile.c:2057
bool gwyfile_check_object(const GwyfileObject *object, unsigned int flags, GwyfileErrorList *errlist)
Checks an object for specifications violations.
Definition: gwyfile.c:9065
GwyfileInvalidCode
Definition: gwyfile.h:156
GwyfileWarningCode
Definition: gwyfile.h:163
GwyfileCheckFlags
Definition: gwyfile.h:150
@ GWYFILE_INVALID_DOUBLE
Double value is infinity or not-a-number.
Definition: gwyfile.h:160
@ GWYFILE_INVALID_UTF8_NAME
Item name is not a valid UTF-8 string.
Definition: gwyfile.h:157
@ GWYFILE_INVALID_UTF8_STRING
String value (or string array value) is not a valid UTF-8 string.
Definition: gwyfile.h:159
@ GWYFILE_INVALID_UTF8_TYPE
Object type is not a valid UTF-8 string.
Definition: gwyfile.h:158
@ GWYFILE_WARNING_TYPE_IDENTIFIER
Object type is not a valid C identifier.
Definition: gwyfile.h:164
@ GWYFILE_WARNING_EMPTY_NAME
Item name is an empty string.
Definition: gwyfile.h:165
@ GWYFILE_CHECK_FLAG_GWYDDION
Enables checking for errors from the GWYFILE_ERROR_DOMAIN_WARNING category in gwyfile_check_object() ...
Definition: gwyfile.h:153
@ GWYFILE_CHECK_FLAG_WARNING
Enables checking for errors from the GWYFILE_ERROR_DOMAIN_WARNING category in gwyfile_check_object().
Definition: gwyfile.h:152
@ GWYFILE_CHECK_FLAG_VALIDITY
Enables checking for errors from the GWYFILE_ERROR_DOMAIN_VALIDITY category in gwyfile_check_object()...
Definition: gwyfile.h:151
GwyfileErrorCode
Definition: gwyfile.h:117
void gwyfile_error_list_init(GwyfileErrorList *errlist)
Initializes a GwyfileErrorList.
Definition: gwyfile.c:9009
void gwyfile_error_clear(GwyfileError **error)
Clears a GwyfileError.
Definition: gwyfile.c:8990
void gwyfile_error_list_clear(GwyfileErrorList *errlist)
Frees all errors in a GwyfileErrorList.
Definition: gwyfile.c:9026
GwyfileErrorDomain
Definition: gwyfile.h:110
@ GWYFILE_ERROR_OBJECT_NAME
A Gwyddion-specific GWY file data object has the wrong name (type).
Definition: gwyfile.h:125
@ GWYFILE_ERROR_CONFINEMENT
A piece of data does not fit inside its parent object or item.
Definition: gwyfile.h:120
@ GWYFILE_ERROR_TRUNCATED
The top-level object is truncated.
Definition: gwyfile.h:128
@ GWYFILE_ERROR_LONG_STRING
Too long string was encountered.
Definition: gwyfile.h:123
@ GWYFILE_ERROR_TOO_DEEP_NESTING
The object/item nesting depth exceeds the allowed maximum.
Definition: gwyfile.h:127
@ GWYFILE_ERROR_ARRAY_SIZE
An array has an invalid size, i.e. zero or mismatching other sizes.
Definition: gwyfile.h:121
@ GWYFILE_ERROR_MISSING_ITEM
A mandatory item in a Gwyddion-specific GWY file data object is missing.
Definition: gwyfile.h:126
@ GWYFILE_ERROR_ITEM_TYPE
Unknown data item type was encountered.
Definition: gwyfile.h:119
@ GWYFILE_ERROR_DUPLICATE_NAME
Multiple items of the same name were encountered in an object.
Definition: gwyfile.h:122
@ GWYFILE_ERROR_OBJECT_SIZE
An object size does not fit into a 32bit integer.
Definition: gwyfile.h:124
@ GWYFILE_ERROR_MAGIC
The file does not have the expected magic header.
Definition: gwyfile.h:118
@ GWYFILE_ERROR_DOMAIN_SYSTEM
System error domain: codes are equal to errno values. They reflect I/O failures and other system erro...
Definition: gwyfile.h:111
@ GWYFILE_ERROR_DOMAIN_VALIDITY
Libgwyfle validity error domain: codes are equal to GwyfileInvalidCode values. Errors from this domai...
Definition: gwyfile.h:113
@ GWYFILE_ERROR_DOMAIN_DATA
Libgwyfle data error domain: codes are equal to GwyfileErrorCode values. They represent data format e...
Definition: gwyfile.h:112
@ GWYFILE_ERROR_DOMAIN_WARNING
Libgwyfle validity error domain: codes are equal to GwyfileInvalidCode values. Errors from this domai...
Definition: gwyfile.h:114
int * gwyfile_object_container_enumerate_volume(const GwyfileObject *object, unsigned int *nvolume)
Enumerates volume data in a Gwyddion GWY file.
Definition: gwyfile.c:4325
int * gwyfile_object_container_enumerate_channels(const GwyfileObject *object, unsigned int *nchannels)
Enumerates channels in a Gwyddion GWY file.
Definition: gwyfile.c:4271
int * gwyfile_object_container_enumerate_spectra(const GwyfileObject *object, unsigned int *nspectra)
Enumerates spectra in a Gwyddion GWY file.
Definition: gwyfile.c:4546
int * gwyfile_object_container_enumerate_xyz(const GwyfileObject *object, unsigned int *nxyz)
Enumerates XYZ data in a Gwyddion GWY file.
Definition: gwyfile.c:4435
int * gwyfile_object_container_enumerate_graphs(const GwyfileObject *object, unsigned int *ngraphs)
Enumerates graphs in a Gwyddion GWY file.
Definition: gwyfile.c:4380
int * gwyfile_object_container_enumerate_curvemaps(const GwyfileObject *object, unsigned int *nxyz)
Enumerates curve map data in a Gwyddion GWY file.
Definition: gwyfile.c:4490
bool gwyfile_item_get_bool(const GwyfileItem *item)
Gets the boolean value contained in a GWY file data item.
Definition: gwyfile.c:5440
void gwyfile_item_set_bool(GwyfileItem *item, bool value)
Sets the value of a boolean GWY file item.
Definition: gwyfile.c:5422
GwyfileItem * gwyfile_item_new_bool(const char *name, bool value)
Creates a new boolean GWY file item.
Definition: gwyfile.c:5406
void gwyfile_item_set_char_array_const(GwyfileItem *item, const char *value, uint32_t array_length)
Sets the value of a character array GWY file item.
Definition: gwyfile.c:6099
const char * gwyfile_item_get_char_array(const GwyfileItem *item)
Gets the character array value contained in a GWY file data item.
Definition: gwyfile.c:6132
void gwyfile_item_set_char_array_copy(GwyfileItem *item, const char *value, uint32_t array_length)
Sets the value of a character array GWY file item.
Definition: gwyfile.c:6037
GwyfileItem * gwyfile_item_new_char_array_copy(const char *name, const char *value, uint32_t array_length)
Creates a new character array GWY file item.
Definition: gwyfile.c:6008
GwyfileItem * gwyfile_item_new_char_array_const(const char *name, const char *value, uint32_t array_length)
Creates a new character array GWY file item.
Definition: gwyfile.c:6071
void gwyfile_item_set_char_array(GwyfileItem *item, char *value, uint32_t array_length)
Sets the value of a character array GWY file item.
Definition: gwyfile.c:5973
char * gwyfile_item_take_char_array(GwyfileItem *item)
Takes the character array value contained in a GWY file data item.
Definition: gwyfile.c:6156
GwyfileItem * gwyfile_item_new_char_array(const char *name, char *value, uint32_t array_length)
Creates a new character array GWY file item.
Definition: gwyfile.c:5949
GwyfileItem * gwyfile_item_new_char(const char *name, char value)
Creates a new character GWY file item.
Definition: gwyfile.c:5456
char gwyfile_item_get_char(const GwyfileItem *item)
Gets the character value contained in a GWY file data item.
Definition: gwyfile.c:5490
void gwyfile_item_set_char(GwyfileItem *item, char value)
Sets the value of a character GWY file item.
Definition: gwyfile.c:5472
GwyfileItem * gwyfile_item_new_double_array_copy(const char *name, const double *value, uint32_t array_length)
Creates a new double array GWY file item.
Definition: gwyfile.c:6697
void gwyfile_item_set_double_array(GwyfileItem *item, double *value, uint32_t array_length)
Sets the value of a double array GWY file item.
Definition: gwyfile.c:6662
double * gwyfile_item_take_double_array(GwyfileItem *item)
Takes the double array value contained in a GWY file data item.
Definition: gwyfile.c:6844
GwyfileItem * gwyfile_item_new_double_array(const char *name, double *value, uint32_t array_length)
Creates a new double array GWY file item.
Definition: gwyfile.c:6638
GwyfileItem * gwyfile_item_new_double_array_const(const char *name, const double *value, uint32_t array_length)
Creates a new double array GWY file item.
Definition: gwyfile.c:6760
void gwyfile_item_set_double_array_const(GwyfileItem *item, const double *value, uint32_t array_length)
Sets the value of a double array GWY file item.
Definition: gwyfile.c:6788
const double * gwyfile_item_get_double_array(const GwyfileItem *item)
Gets the double array value contained in a GWY file data item.
Definition: gwyfile.c:6820
void gwyfile_item_set_double_array_copy(GwyfileItem *item, const double *value, uint32_t array_length)
Sets the value of a 64bit integer array GWY file item.
Definition: gwyfile.c:6726
GwyfileItem * gwyfile_item_new_double(const char *name, double value)
Creates a new double GWY file item.
Definition: gwyfile.c:5606
double gwyfile_item_get_double(const GwyfileItem *item)
Gets the double value contained in a GWY file data item.
Definition: gwyfile.c:5640
void gwyfile_item_set_double(GwyfileItem *item, double value)
Sets the value of a double GWY file item.
Definition: gwyfile.c:5622
GwyfileItem * gwyfile_item_new_int32_array_copy(const char *name, const int32_t *value, uint32_t array_length)
Creates a new 32bit integer array GWY file item.
Definition: gwyfile.c:6238
void gwyfile_item_set_int32_array_const(GwyfileItem *item, const int32_t *value, uint32_t array_length)
Sets the value of a 32bit integer array GWY file item.
Definition: gwyfile.c:6326
void gwyfile_item_set_int32_array_copy(GwyfileItem *item, const int32_t *value, uint32_t array_length)
Sets the value of a 32bit integer array GWY file item.
Definition: gwyfile.c:6267
GwyfileItem * gwyfile_item_new_int32_array_const(const char *name, const int32_t *value, uint32_t array_length)
Creates a new 32bit integer array GWY file item.
Definition: gwyfile.c:6298
GwyfileItem * gwyfile_item_new_int32_array(const char *name, int32_t *value, uint32_t array_length)
Creates a new 32bit integer array GWY file item.
Definition: gwyfile.c:6179
const int32_t * gwyfile_item_get_int32_array(const GwyfileItem *item)
Gets the 32bit integer array value contained in a GWY file data item.
Definition: gwyfile.c:6359
int32_t * gwyfile_item_take_int32_array(GwyfileItem *item)
Takes the 32bit integer array value contained in a GWY file data item.
Definition: gwyfile.c:6384
void gwyfile_item_set_int32_array(GwyfileItem *item, int32_t *value, uint32_t array_length)
Sets the value of a 32bit integer array GWY file item.
Definition: gwyfile.c:6203
void gwyfile_item_set_int32(GwyfileItem *item, int32_t value)
Sets the value of a 32bit integer GWY file item.
Definition: gwyfile.c:5522
int32_t gwyfile_item_get_int32(const GwyfileItem *item)
Gets the 32bit integer value contained in a GWY file data item.
Definition: gwyfile.c:5540
GwyfileItem * gwyfile_item_new_int32(const char *name, int32_t value)
Creates a new 32bit integer GWY file item.
Definition: gwyfile.c:5506
void gwyfile_item_set_int64_array_copy(GwyfileItem *item, const int64_t *value, uint32_t array_length)
Sets the value of a 64bit integer array GWY file item.
Definition: gwyfile.c:6495
void gwyfile_item_set_int64_array(GwyfileItem *item, int64_t *value, uint32_t array_length)
Sets the value of a 64bit integer array GWY file item.
Definition: gwyfile.c:6431
GwyfileItem * gwyfile_item_new_int64_array_copy(const char *name, const int64_t *value, uint32_t array_length)
Creates a new 64bit integer array GWY file item.
Definition: gwyfile.c:6466
int64_t * gwyfile_item_take_int64_array(GwyfileItem *item)
Takes the 64bit integer array value contained in a GWY file data item.
Definition: gwyfile.c:6615
GwyfileItem * gwyfile_item_new_int64_array_const(const char *name, const int64_t *value, uint32_t array_length)
Creates a new 64bit integer array GWY file item.
Definition: gwyfile.c:6529
void gwyfile_item_set_int64_array_const(GwyfileItem *item, const int64_t *value, uint32_t array_length)
Sets the value of a 64bit integer array GWY file item.
Definition: gwyfile.c:6557
const int64_t * gwyfile_item_get_int64_array(const GwyfileItem *item)
Gets the 64bit integer array value contained in a GWY file data item.
Definition: gwyfile.c:6590
GwyfileItem * gwyfile_item_new_int64_array(const char *name, int64_t *value, uint32_t array_length)
Creates a new 64bit integer array GWY file item.
Definition: gwyfile.c:6407
int64_t gwyfile_item_get_int64(const GwyfileItem *item)
Gets the 64bit integer value contained in a GWY file data item.
Definition: gwyfile.c:5590
void gwyfile_item_set_int64(GwyfileItem *item, int64_t value)
Sets the value of a 64bit integer GWY file item.
Definition: gwyfile.c:5572
GwyfileItem * gwyfile_item_new_int64(const char *name, int64_t value)
Creates a new 64bit integer GWY file item.
Definition: gwyfile.c:5556
GwyfileItem * gwyfile_item_new_object_array(const char *name, GwyfileObject **value, uint32_t array_length)
Creates a new object array GWY file item.
Definition: gwyfile.c:7155
void gwyfile_item_set_object_array(GwyfileItem *item, GwyfileObject **value, uint32_t array_length)
Sets the value of a object array GWY file item.
Definition: gwyfile.c:7184
GwyfileObject *const * gwyfile_item_get_object_array(const GwyfileItem *item)
Gets the object array value contained in a GWY file data item.
Definition: gwyfile.c:8100
GwyfileObject * gwyfile_item_get_object(const GwyfileItem *item)
Gets the object value contained in a GWY file data item.
Definition: gwyfile.c:5903
GwyfileItem * gwyfile_item_new_object(const char *name, GwyfileObject *value)
Creates a new object GWY file item.
Definition: gwyfile.c:5856
void gwyfile_item_set_object(GwyfileItem *item, GwyfileObject *value)
Sets the value of an object GWY file item.
Definition: gwyfile.c:5877
GwyfileObject * gwyfile_item_release_object(GwyfileItem *item)
Releases the object contained in a GWY file data item and frees the item.
Definition: gwyfile.c:5922
GwyfileItem * gwyfile_item_new_string_array_const(const char *name, const char *const *value, uint32_t array_length)
Creates a new string array GWY file item.
Definition: gwyfile.c:7034
const char *const * gwyfile_item_get_string_array(const GwyfileItem *item)
Gets the string array value contained in a GWY file data item.
Definition: gwyfile.c:7109
char ** gwyfile_item_take_string_array(GwyfileItem *item)
Takes the string array value contained in a GWY file data item.
Definition: gwyfile.c:7133
void gwyfile_item_set_string_array_const(GwyfileItem *item, const char *const *value, uint32_t array_length)
Sets the value of a string array GWY file item.
Definition: gwyfile.c:7068
void gwyfile_item_set_string_array_copy(GwyfileItem *item, const char *const *value, uint32_t array_length)
Sets the value of a string array GWY file item.
Definition: gwyfile.c:6987
GwyfileItem * gwyfile_item_new_string_array(const char *name, char **value, uint32_t array_length)
Creates a new string array GWY file item.
Definition: gwyfile.c:6867
void gwyfile_item_set_string_array(GwyfileItem *item, char **value, uint32_t array_length)
Sets the value of a string array GWY file item.
Definition: gwyfile.c:6896
GwyfileItem * gwyfile_item_new_string_array_copy(const char *name, const char *const *value, uint32_t array_length)
Creates a new string array GWY file item.
Definition: gwyfile.c:6940
GwyfileItem * gwyfile_item_new_string(const char *name, char *value)
Creates a new string GWY file item.
Definition: gwyfile.c:5660
GwyfileItem * gwyfile_item_new_string_copy(const char *name, const char *value)
Creates a new string GWY file item.
Definition: gwyfile.c:5712
GwyfileItem * gwyfile_item_new_string_const(const char *name, const char *value)
Creates a new string GWY file item.
Definition: gwyfile.c:5763
void gwyfile_item_set_string_const(GwyfileItem *item, const char *value)
Sets the value of a string GWY file item.
Definition: gwyfile.c:5786
void gwyfile_item_set_string_copy(GwyfileItem *item, const char *value)
Sets the value of a string GWY file item.
Definition: gwyfile.c:5733
void gwyfile_item_set_string(GwyfileItem *item, char *value)
Sets the value of a string GWY file item.
Definition: gwyfile.c:5681
const char * gwyfile_item_get_string(const GwyfileItem *item)
Gets the string value contained in a GWY file data item.
Definition: gwyfile.c:5814
char * gwyfile_item_take_string(GwyfileItem *item)
Takes the string value contained in a GWY file data item.
Definition: gwyfile.c:5836
GwyfileItem * gwyfile_item_read_memory(const void *buffer, size_t size, size_t *bytes_read, GwyfileError **error)
Reads a GWY file data item from a memory buffer.
Definition: gwyfile.c:8056
uint32_t gwyfile_item_array_length(const GwyfileItem *item)
Obtains the array length of a GWY file data item.
Definition: gwyfile.c:7326
bool gwyfile_item_fwrite(const GwyfileItem *item, FILE *stream, GwyfileError **error)
Writes a GWY file data item to a stdio stream.
Definition: gwyfile.c:7382
GwyfileItem * gwyfile_item_copy(const GwyfileItem *item, GwyfileCopyMethod method)
Creates a copy of a data item.
Definition: gwyfile.c:5309
size_t gwyfile_item_size(const GwyfileItem *item)
Obtains the serialized total size of a GWY file data item.
Definition: gwyfile.c:7363
size_t gwyfile_item_data_size(const GwyfileItem *item)
Obtains the serialized size of a GWY file data item data.
Definition: gwyfile.c:7345
const char * gwyfile_item_name(const GwyfileItem *item)
Obtains the name of a GWY file data item.
Definition: gwyfile.c:7311
GwyfileItem * gwyfile_item_fread(FILE *stream, size_t max_size, GwyfileError **error)
Reads a GWY file data item from a stdio stream.
Definition: gwyfile.c:7830
GwyfileItemType
Definition: gwyfile.h:87
size_t gwyfile_item_write_memory(const GwyfileItem *item, void *buffer, size_t size, GwyfileError **error)
Writes a GWY file data item to a memory buffer.
Definition: gwyfile.c:7511
void gwyfile_item_free(GwyfileItem *item)
Frees a GWY file data item.
Definition: gwyfile.c:7229
bool gwyfile_item_owns_data(const GwyfileItem *item)
Reports if a GWY file item owns its data.
Definition: gwyfile.c:8082
GwyfileItemType gwyfile_item_type(const GwyfileItem *item)
Obtains the type of a GWY file data item.
Definition: gwyfile.c:7298
@ GWYFILE_ITEM_INT32
32bit integer.
Definition: gwyfile.h:90
@ GWYFILE_ITEM_DOUBLE_ARRAY
Array of IEEE double precision floating point numbers.
Definition: gwyfile.h:98
@ GWYFILE_ITEM_STRING
String of characters.
Definition: gwyfile.h:93
@ GWYFILE_ITEM_OBJECT_ARRAY
Array of objects, i.e. a nested data structures.
Definition: gwyfile.h:100
@ GWYFILE_ITEM_INT64_ARRAY
Array of 64bit integers.
Definition: gwyfile.h:97
@ GWYFILE_ITEM_STRING_ARRAY
Array of character strings.
Definition: gwyfile.h:99
@ GWYFILE_ITEM_CHAR_ARRAY
Array of characters.
Definition: gwyfile.h:95
@ GWYFILE_ITEM_BOOL
Boolean (true or false).
Definition: gwyfile.h:88
@ GWYFILE_ITEM_INT64
64bit integer.
Definition: gwyfile.h:91
@ GWYFILE_ITEM_INT32_ARRAY
Array of 32bit integers.
Definition: gwyfile.h:96
@ GWYFILE_ITEM_OBJECT
Object, i.e. a nested data structure.
Definition: gwyfile.h:94
@ GWYFILE_ITEM_DOUBLE
IEEE double precision floating point number.
Definition: gwyfile.h:92
@ GWYFILE_ITEM_CHAR
Single character.
Definition: gwyfile.h:89
GwyfileItem * gwyfile_object_take(GwyfileObject *object, const char *name)
Takes an item from a GWY file data object.
Definition: gwyfile.c:4771
void gwyfile_object_foreach(const GwyfileObject *object, GwyfileObjectForeachFunc function, void *user_data)
Calls a function for each item contained in a GWY file data object.
Definition: gwyfile.c:4894
GwyfileObject * gwyfile_object_new(const char *name,...)
Creates a new GWY file object.
Definition: gwyfile.c:607
GwyfileItem * gwyfile_object_get_nth(const GwyfileObject *object, unsigned int n)
Gets n-th data item from a GWY file object.
Definition: gwyfile.c:4875
const char * gwyfile_object_name(const GwyfileObject *object)
Obtains the name of a GWY file data object.
Definition: gwyfile.c:4599
bool gwyfile_object_remove(GwyfileObject *object, const char *name)
Removes an item from a GWY file data object and frees it.
Definition: gwyfile.c:4712
GwyfileItem * gwyfile_object_get_with_type(const GwyfileObject *object, const char *name, GwyfileItemType type)
Finds a data item in a GWY file object, ensuring its type.
Definition: gwyfile.c:4806
size_t gwyfile_object_size(const GwyfileObject *object)
Obtains the serialized size of a GWY file data object.
Definition: gwyfile.c:4615
GwyfileObject * gwyfile_object_newv(const char *name, GwyfileItem **items, unsigned int nitems)
Creates a new GWY file object.
Definition: gwyfile.c:651
bool gwyfile_object_add(GwyfileObject *object, GwyfileItem *item)
Adds an data item to a GWY file data object.
Definition: gwyfile.c:4652
GwyfileObject * gwyfile_object_copy(const GwyfileObject *object, GwyfileCopyMethod method)
Creates a copy of a GWY file object.
Definition: gwyfile.c:686
void(* GwyfileObjectForeachFunc)(const GwyfileItem *item, void *user_data)
Type of function for iterating over GWY file data object items.
Definition: gwyfile.h:213
GwyfileObject * gwyfile_object_read_memory(const void *buffer, size_t size, size_t *bytes_read, GwyfileError **error)
Reads a GWY file data object from a memory buffer.
Definition: gwyfile.c:5196
GwyfileObject * gwyfile_object_fread(FILE *stream, size_t max_size, GwyfileError **error)
Reads a GWY file data object from a stdio stream.
Definition: gwyfile.c:5233
size_t gwyfile_object_write_memory(const GwyfileObject *object, void *buffer, size_t size, GwyfileError **error)
Writes a GWY file data object to a memory buffer.
Definition: gwyfile.c:5255
size_t gwyfile_object_data_size(const GwyfileObject *object)
Obtains the serialized data size of a GWY file data object.
Definition: gwyfile.c:4631
bool gwyfile_object_fwrite(GwyfileObject *object, FILE *stream, GwyfileError **error)
Writes a GWY file data object to a stdio stream.
Definition: gwyfile.c:4972
unsigned int gwyfile_object_nitems(const GwyfileObject *object)
Obtains the number of items in a GWY file data object.
Definition: gwyfile.c:4920
GwyfileItem * gwyfile_object_take_with_type(GwyfileObject *object, const char *name, GwyfileItemType type)
Takes a data item from a GWY file object, ensuring its type.
Definition: gwyfile.c:4836
GwyfileItem * gwyfile_object_get(const GwyfileObject *object, const char *name)
Finds a data item in a GWY file object.
Definition: gwyfile.c:4746
const char ** gwyfile_object_item_names(const GwyfileObject *object)
Constructs the list of names of all items in a GWY file data object.
Definition: gwyfile.c:4937
void gwyfile_object_free(GwyfileObject *object)
Frees a GWY file data object.
Definition: gwyfile.c:4577
List of errors.
Definition: gwyfile.h:137
GwyfileError ** errors
Array holding the errors.
Definition: gwyfile.h:138
size_t n
Number of errors in the list.
Definition: gwyfile.h:139
Detailed information about an error.
Definition: gwyfile.h:131
char * message
Text message describing the error. It is allocated when the error struct is created and freed with gw...
Definition: gwyfile.h:134
int code
Particular error code. For errors from the system domain it is equal to errno while for libgwyfile-sp...
Definition: gwyfile.h:133
GwyfileErrorDomain domain
Identifier of the class of errors.
Definition: gwyfile.h:132
One piece of data in a GWY file.
Data structure with named components.