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
/**
* .. _asdf/file.h:
*
* This is the high-level public API for working with ASDF files. It includes
* functions for opening and closing ASDF file handles, represented by
* `asdf_file_t` pointers.
*
* Most of these functions work on an open `asdf_file_t *` as their first
* argument, and retrieve scalar values and more complex objects out of the
* ASDF tree.
*/
//
/**
* .. _file-handles:
*
* File handles
* ------------
*/
/**
* An opaque struct representing an open ASDF file handle
*
* Pointers to `asdf_file_t` are the primary interface to each open ASDF file
* and can be created and allocated with `asdf_open`, `asdf_open_file`,
* `asdf_open_fp`, or `asdf_open_mem`.
*/
typedef struct asdf_file asdf_file_t;
/**
* .. _file-configuration:
*
* Configuration
* -------------
*/
/**
* Options for block decompression mode, for use with the ``decomp.mode`` field
* of `asdf_config_t`
*
* This controls *when* compressed binary block data is decompressed: eagerly
* (all at once the first time a block is accessed) or lazily (decompressed in
* page-sized chunks on demand, where supported). See :ref:`compression` for
* details, and the individual `asdf_block_decomp_mode_t` members below.
*
* .. todo::
*
* When lazy is implemented there may likely be multiple implementations
* (userfaultfd, sigsegv, etc.). Add options to specify exactly which
* implementation to use, where ASDF_DECOMP_MODE_LAZY by itself will
* choose the most appropriate choice (generally userfaultfd if available)
*/
typedef enum asdf_block_decomp_mode_t;
/**
* Struct containing extended options to use when opening and reading files
*
* For use with `asdf_open_ex` and relatives.
*/
typedef struct asdf_config_t;
// Forward-declarations for asdf_open_ex and so on
asdf_file_t *;
asdf_file_t *;
asdf_file_t *;
static asdf_file_t *;
static asdf_file_t *;
static asdf_file_t *;
// Helpers to build the `asdf_open` multiple-dispatch macro
/**
* .. _file-openers:
*
* File openers
* ------------
*/
/**
* Opens an ASDF file for reading
*
* This is a convenience macro for `asdf_open_file`, `asdf_open_fp`, or `asdf_open_mem`
* depending on the argument types
*/
/**
* Opens an ASDF file for reading with extended options
*
* Extended version of `asdf_open` taking an optional pointer to
* :c:type:`asdf_config_t` configuration options as the last argument, or
* `NULL` to use the default options (equivalent to `asdf_open`).
*
* When passing in an `asdf_config_t *`, the config struct is *copied*:
*
* * This allows passing in the options from a local variable
* * Prevents modifications of the options while the file is open
* * In many cases you can leave options set to zero, and they will be filled
* in with defaults.
*
* This is a convenience macro for `asdf_open_file_ex`, `asdf_open_fp_ex`, or
* `asdf_open_mem_ex` depending on the argument types
*/
/**
* Opens an ASDF file for reading
*
* Equivalent to `asdf_open`.
*
* :param filename: A null-terminated string containing the local filesystem
* path to open
* :param mode: Currently must always be just ``"r"``
* :return: An `asdf_file_t *`, or ``NULL`` on error
*/
static inline asdf_file_t *
/**
* Opens an ASDF file from an already open `FILE *`
*
* This assumes the file is open for reading.
*
* :param fp: An open `FILE *`
* :param filename: An optional filename for the open file.
* This need not be a real filesystem path, and can be any display name for
* the file; used mainly in error messages.
* :return: An `asdf_file_t *`
*/
static inline asdf_file_t *
/**
* Opens an ASDF file from an memory buffer
*
* :param buf: An arbitrary block of memory from a `void *`
* :param size: The size of the memory buffer
* :return: An `asdf_file_t *`
*/
static inline asdf_file_t *
/**
* Write the contents of an ``asdf_file_t`` to a destination
*
* This is a type-generic macro that dispatches to one of the following based
* on the type and number of arguments after ``file``:
*
* * ``asdf_write_to(file, filename)`` -- where ``filename`` is a
* ``const char *`` or ``char *``: calls `asdf_write_to_file`
* * ``asdf_write_to(file, fp)`` -- where ``fp`` is a ``FILE *``: calls
* `asdf_write_to_fp`
* * ``asdf_write_to(file, buf, size)`` -- where ``buf`` is a ``void **`` and
* ``size`` is a ``size_t *``: calls `asdf_write_to_mem`
*
* :param file: The `asdf_file_t *` to write
* :param ...: Destination argument(s) -- see above
* :return: 0 on success, non-zero on failure
*/
/**
* Write the contents of the ``asdf_file_t`` to the given filesystem path
*
* :param file: The `asdf_file_t *` to write
* :param filename: Path to the output file; created or truncated as needed
* :return: 0 on success, non-zero on failure
*/
ASDF_EXPORT int ;
/**
* Write the contents of the ``asdf_file_t`` to the given writeable ``FILE *``
* stream
*
* :param file: The `asdf_file_t *` to write
* :param fp: An open, writeable ``FILE *`` stream
* :return: 0 on success, non-zero on failure
*/
ASDF_EXPORT int ;
/**
* Write the contents of the ``asdf_file_t`` to a memory buffer
*
* If ``*buf`` is non-NULL, a user-provided buffer is assumed and its size is
* read from ``*size``. If the buffer is not large enough to hold the file,
* the output is truncated and a non-zero value is returned.
*
* If ``*buf`` is NULL, a buffer is allocated for the caller and a pointer to
* it is stored in ``*buf``; the allocated size is written to ``*size``. The
* caller is responsible for releasing the buffer with `asdf_free`.
*
* :param file: The `asdf_file_t *` to write
* :param buf: Address of a ``void *`` buffer pointer (in/out)
* :param size: Address of a ``size_t`` holding the buffer size (in/out)
* :return: 0 on success, non-zero on failure
*/
ASDF_EXPORT int ;
/**
* Closes an open `asdf_file_t *`, freeing associated resources where possible
*
* Any other resources associated with that file handle, such as ndarrays,
* should no longer be expected to work and should ideally be freed before
* closing the file.
*
* :param file: The `asdf_file_t *` to close
*/
ASDF_EXPORT void ;
/**
* Opens an ASDF file for reading
*
* Extended version of `asdf_open` taking an optional pointer to
* :c:type:`asdf_config_t` configuration options, or `NULL` to
* use the default options (equivalent to `asdf_open`).
*
* When passing in an `asdf_config_t *`, the config struct is *copied*:
*
* * This allows passing in the options from a local variable
* * Prevents modifications of the options while the file is open
* * In many cases you can leave options set to zero, and they will be filled
* in with defaults.
*
* This is an alias for `asdf_open_file_ex`.
*
* :param filename: A null-terminated string containing the local filesystem
* path to open
* :param mode: Currently must always be just ``"r"``. This will support other
* opening modes in the future (e.g. for writes, updates).
* :param config: A pointer to an `asdf_config_t` (may be partially initialized)
* :return: An `asdf_file_t *`
*/
ASDF_EXPORT asdf_file_t *;
/**
* Opens an ASDF file from an already open `FILE *`, with optional extended
* options
*
* This assumes the file is open for reading.
*
* :param fp: An open `FILE *`
* :param filename: An optional filename for the open file.
* This need not be a real filesystem path, and can be any display name for
* the file; used mainly in error messages.
* :param config: A pointer to an `asdf_config_t` (may be partially initialized)
* :return: An `asdf_file_t *`
*/
ASDF_EXPORT asdf_file_t *;
/**
* Opens an ASDF file from an memory buffer, with optional extended options
*
* :param buf: An arbitrary block of memory from a `void *`
* :param size: The size of the memory buffer
* :param config: A pointer to an `asdf_config_t` (may be partially initialized)
* :return: An `asdf_file_t *`
*/
ASDF_EXPORT asdf_file_t *;
/**
* .. _file-errors:
*
* Error handling
* --------------
*/
/**
* Retrieve an error on a file
*
* This is typically used to check for errors on the file itself, such as
* parse errors, and not for user data errors (such as invalid type conversions
* on an `asdf_value_t`).
*
* If passed `NULL`, returns any global error, if set (typically from errors
* opening a file), or from library initialization.
*
* See the section on :ref:`error-handling` for more details.
*
* :param file: An open `asdf_file_t *` or `NULL`
* :return: `NULL` if there is no error set, otherwise a pointer to the error
* message string
*/
ASDF_EXPORT const char *;
/**
* Retrieve the error code set on a file
*
* Returns `ASDF_ERR_NONE` if no error is set, or if ``file`` is ``NULL`` and
* there is no global error.
*
* :param file: An open `asdf_file_t *` or `NULL`
* :return: The `asdf_error_code_t` for the current error
*/
ASDF_EXPORT asdf_error_code_t ;
/**
* Retrieve the saved OS ``errno`` from the last ``ASDF_ERR_SYSTEM`` error
*
* Only meaningful when `asdf_error_code` returns `ASDF_ERR_SYSTEM`.
* Returns ``0`` when there is no system error or ``file`` is ``NULL`` and
* there is no global error.
*
* :param file: An open `asdf_file_t *` or `NULL`
* :return: The saved ``errno`` value
*/
ASDF_EXPORT int ;
/**
* .. _file-value-getters:
*
* Reading values
* --------------
*/
/**
* The following functions are the high-level interface for retrieving typed
* values out of the ASDF metadata tree. These include plain scalar values,
* mappings, sequences, as tagged data structures that have a registered
* extension for handling them (this includes objects belonging to the ASDF
* core schema, such as ``core/history_entry`` or ``core/ndarray``). The
* getters for schema-specific objects are not documented here, but follow
* the same patterns.
*
* For each type that can be read out of the ASDF tree there is an
* ``asdf_is_<type>`` function which just checks the type and returns a `bool`.
* Then there is an ``asdf_get_<type>`` function. Each of these takes the
* `asdf_file_t *` as their first argument, then a :ref:`yaml-pointer`
* expression for the path within the tree to that value, and finally a
* pointer for the return value's type. Each of these functions return their
* value by reference through an input argument. The return value is always
* `asdf_value_err_t`.
*
* If the value exists and successfully converts to the requested type the
* return value is `ASDF_VALUE_OK`. There are other return values such as
* `ASDF_VALUE_ERR_NOT_FOUND` (the path simply does not exist) or
* `ASDF_VALUE_ERR_TYPE_MISMATCH` (a value exists at that path but is the wrong
* type). A few other more obscure errors can occur--see `asdf_value_err_t`.
*
* The one exception to the above is `asdf_get_value` which simply returns the
* generic `asdf_value_t *` if the path exists, or `NULL` otherwise. See
* :ref:`values` for more details on generic values.
*
* .. todo::
*
* Add support for referencing ASDF schemas.
*/
/**
* Get an arbitrary `asdf_value_t *` out of the tree
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the value
* :return: An `asdf_value_t *` wrapping the value, or `NULL` if the path does
* not exist in the tree
*/
ASDF_EXPORT asdf_value_t *;
/**
* Check if the value at the given tree path is a YAML mapping
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the value
* :return: `true` if the value is a mapping, `false` if it is another
* type of value or if no value exists at that path.
*/
ASDF_EXPORT bool ;
/**
* Get a mapping out of the ASDF tree
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the mapping
* :param value: An `asdf_mapping_t **` into which to return the mapping
* :return: `ASDF_VALUE_OK` if the value exists and is a mapping, otherwise
* `ASDF_VALUE_ERR_NOT_FOUND` or `ASDF_VALUE_ERR_TYPE_MISMATCH`.
*/
ASDF_EXPORT ;
/**
* Check if the value at the given tree path is a YAML sequence
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the value
* :return: `true` if the value is a sequence, `false` if it is another
* type of value or if no value exists at that path.
*/
ASDF_EXPORT bool ;
/**
* Get a sequence out of the ASDF tree
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the sequence
* :param value: An `asdf_sequence_t **` into which to return the sequence
* :return: `ASDF_VALUE_OK` if the value exists and is a sequence, otherwise
* `ASDF_VALUE_ERR_NOT_FOUND` or `ASDF_VALUE_ERR_TYPE_MISMATCH`.
*/
ASDF_EXPORT ;
/**
* Check if the value at the given tree path is a string scalar
*
* .. note::
*
* libasdf adheres to the `YAML Core Schema`_ in the interpretation of scalar
* values. So here "is a string" means strictly not interpreted as any other
* data type (int, bool, etc.) under the YAML. This is the same convention
* used in many other programming languages like Python, etc.
*
* To check if the value is simply a scalar of any type use `asdf_is_scalar`.
*
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the string
* :return: `true` if the value is a string, `false` if it is another
* type of value or if no value exists at that path.
*/
ASDF_EXPORT bool ;
/**
* Get a string out of the ASDF tree
*
* This version returns the string without a null terminator, and the length of
* the string into the ``out_len`` parameter. This employs zero-copy where
* possible, so the memory pointing to the string may become unusable once the
* file is closed.
*
* .. note::
*
* See the note about `asdf_is_string`. This only returns `ASDF_VALUE_OK` if
* the value exists and is strictly a string. For a more generic version
* that returns the raw text of a scalar see `asdf_get_scalar`.
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the string
* :param out: A `const char **` into which to return the string as a `const char *`
* :param out_len: A `size_t *` into which to return the length of the string
* :return: `ASDF_VALUE_OK` if the value exists and is a string, otherwise
* `ASDF_VALUE_ERR_NOT_FOUND` or `ASDF_VALUE_ERR_TYPE_MISMATCH`.
*/
ASDF_EXPORT ;
/**
* Get a null-terminated string out of the ASDF tree
*
* Like `asdf_get_string` but returns a null-terminated copy of the string.
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the string
* :param out: A `const char **` into which to return the string as a `const char *`
* :return: `ASDF_VALUE_OK` if the value exists and is a string, otherwise
* `ASDF_VALUE_ERR_NOT_FOUND` or `ASDF_VALUE_ERR_TYPE_MISMATCH`.
*/
ASDF_EXPORT ;
/**
* Check if the value at the given tree path is a YAML scalar of any kind
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the value
* :return: `true` if the value is a scalar, `false` if it is another
* type of value or if no value exists at that path.
*/
ASDF_EXPORT bool ;
/**
* Like `asdf_get_string` but returns the raw text of a scalar value as a
* string without interpretation under the `YAML Core Schema`_.
*
* This can be especially useful in the implementation of :ref:`extensions`
* to process tagged scalars.
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the scalar
* :param out: A `const char **` into which to return the scalar as a
* `const char *`
* :param out_len: A `size_t *` into which to return the length of the scalar
* :return: `ASDF_VALUE_OK` if the value exists and is a scalar, otherwise
* `ASDF_VALUE_ERR_NOT_FOUND` or `ASDF_VALUE_ERR_TYPE_MISMATCH`.
*/
ASDF_EXPORT ;
/**
* Like `asdf_get_scalar0` but returns a null-terminated string
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the scalar
* :param out: A `const char **` into which to return the scalar as a
* `const char *`
* :return: `ASDF_VALUE_OK` if the value exists and is a scalar, otherwise
* `ASDF_VALUE_ERR_NOT_FOUND` or `ASDF_VALUE_ERR_TYPE_MISMATCH`.
*/
ASDF_EXPORT ;
/**
* Check if the value at the given tree path is a boolean scalar
*
* This returns true for the non-string (that is, unquoted) scalars
* ``true/True/TRUE``, ``false/False/FALSE`` as well as ints ``0`` or ``1``
* strictly.
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the bool
* :return: `true` if the value is a bool, `false` if it is another
* type of value or if no value exists at that path.
*/
ASDF_EXPORT bool ;
/**
* Get a bool value out of the ASDF tree
*
* See `asdf_is_bool`.
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the string
* :param out: A `bool *` into which to return the bool
* :return: `ASDF_VALUE_OK` if the value exists and is a bool, otherwise
* `ASDF_VALUE_ERR_NOT_FOUND` or `ASDF_VALUE_ERR_TYPE_MISMATCH`.
*/
ASDF_EXPORT asdf_value_err_t ;
/**
* Check if the value at the given tree path is null
*
* This returns true for the unquoted scalars ``null/Null/NULL`` or ``~`` as
* well as empty values (e.g. if a mapping key is followed by nothing but
* whitespace).
*
* There is no corresponding ``asdf_get_null`` as it would probably be useless.
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the null value
* :return: `true` if the value is null, `false` if it is another
* type of value or if no value exists at that path.
*/
ASDF_EXPORT bool ;
/**
* .. _int getters:
*
* Integer getters
* ---------------
*
* The following functions are the type checkers and getters for integer types.
*
* When libasdf detects an integer scalar it assigns to it the smallest C
* integer type that can hold that value. For example the number ``42`` is
* typed as `ASDF_VALUE_UINT8`.
*
* However, integer up-casting to larger integer types is allowed
* Downcasting that would cause an overflow is not allowed. For example ``42``
* can be cast to an ``int16``, but ``-42`` cannot be cast to a ``uint16``.
*
* .. note::
*
* In practice, unless you know some schema expects a small integer for a
* value, you will mostly just want to use `asdf_get_int64`.
*
* With the ``asdf_get_(uint)N`` getters the `asdf_value_err_t` return value
* may also be `ASDF_VALUE_ERR_OVERFLOW` if the value is an integer that is too
* large to represent in the requested type.
*
* Big integers (greater than ``UINT64_MAX`` or less than ``INT64_MIN``) are
* not supported--in fact the ASDF Standard expressly
* `forbids <ASDF Numeric Literals>`_ writing them to ASDF files. Nevertheless
* it could be supported in the future if the need arises. In fact,
* technically the ASDF Standard disallows integers greater than ``INT64_MAX``
* but here we do allow unsigned integers up to ``UINT64_MAX``.
*/
/**
* Check if the value at the given tree path is a integer scalar of any byte
* size
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the int
* :return: `true` if the value is an integer, `false` if it is another
* type of value or if no value exists at that path.
*/
ASDF_EXPORT bool ;
/** See :ref:`int getters` */
ASDF_EXPORT bool ;
/** See :ref:`int getters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`int getters` */
ASDF_EXPORT bool ;
/** See :ref:`int getters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`int getters` */
ASDF_EXPORT bool ;
/** See :ref:`int getters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`int getters` */
ASDF_EXPORT bool ;
/** See :ref:`int getters` */
ASDF_EXPORT asdf_value_err_t ;
/** Alias for `asdf_get_int64` */
/** See :ref:`int getters` */
ASDF_EXPORT bool ;
/** See :ref:`int getters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`int getters` */
ASDF_EXPORT bool ;
/** See :ref:`int getters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`int getters` */
ASDF_EXPORT bool ;
/** See :ref:`int getters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`int getters` */
ASDF_EXPORT bool ;
/** See :ref:`int getters` */
ASDF_EXPORT asdf_value_err_t ;
/**
* .. _float getters:
*
* Float getters
* -------------
*
* Similarly to the integer getters the `asdf_is_float` method will return true
* if the floating point value can be represented as accurately in a 32-bit
* float as in a double (the mantissa and exponent are small).
*
* Otherwise it is safe to `asdf_is_double` and `asdf_get_double` for most
* cases. The `asdf_value_err_t` return value can also be
* `ASDF_VALUE_ERR_OVERFLOW` if the number is too large to represent as an
* IEEE 64-bit float (in particular, if `strtod` sets `errno = ERANGE`).
*/
/** See :ref:`float getters` */
ASDF_EXPORT bool ;
/** See :ref:`float getters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`float getters` */
ASDF_EXPORT bool ;
/** See :ref:`float getters` */
ASDF_EXPORT asdf_value_err_t ;
/**
* .. _file-extension-getters:
*
* Extension object getters
* ------------------------
*/
/**
* These functions are the generic forms behind the per-extension
* ``asdf_is_<extension>`` / ``asdf_get_<extension>`` / ``asdf_set_<extension>``
* helpers (such as `asdf_get_ndarray`) that each registered extension
* generates. They take an explicit `asdf_extension_t *`, which can be looked
* up for a registered tag with ``asdf_extension_get``, and are useful when the
* extension type is only known at runtime. See :ref:`extensions` for more on
* the extension mechanism.
*/
/**
* Check whether the value at ``path`` is of the given extension type
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the value
* :param ext: The `asdf_extension_t *` describing the extension type
* :return: ``true`` if a value exists at ``path`` and matches the extension
* type, otherwise ``false``
*/
ASDF_EXPORT bool ;
/**
* Get the value at ``path`` deserialized into the given extension type
*
* On success the deserialized extension object is written through ``out``; the
* concrete type of ``*out`` is the C type associated with the extension (for
* example ``asdf_ndarray_t *`` for the ndarray extension). The caller owns the
* returned object and must release it with the extension's corresponding
* ``asdf_<extension>_destroy`` function.
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` to the value
* :param ext: The `asdf_extension_t *` describing the extension type
* :param out: Receives the deserialized extension object on success
* :return: `ASDF_VALUE_OK` if the value exists and is of the extension type,
* otherwise `ASDF_VALUE_ERR_NOT_FOUND` or `ASDF_VALUE_ERR_TYPE_MISMATCH`
*/
ASDF_EXPORT ;
/**
* Serialize an extension object into the tree at ``path``
*
* The object pointed to by ``obj`` is serialized according to ``ext`` and
* written into the tree at ``path``, creating any intermediate mappings as
* needed and replacing any existing value already at that path.
*
* Typically it is better to use the higher level ``asdf_set_<extension>``
* functions, (e.g. `asdf_set_ndarray`) which are type-safe wrappers around
* this function, and don't require looking up the extension.
*
* :param file: The `asdf_file_t *` for the file
* :param path: The :ref:`yaml-pointer` at which to write the value
* :param obj: Pointer to the extension object to serialize
* :param ext: The `asdf_extension_t *` describing the extension type
* :return: `ASDF_VALUE_OK` on success, otherwise an `asdf_value_err_t` error
*/
ASDF_EXPORT asdf_value_err_t ;
/**
* .. _file-value-setters:
*
* Setting values
* --------------
*
* The ``asdf_set_<type>`` family is the high-level counterpart to the
* ``asdf_get_<type>`` getters: each writes a value into the ASDF metadata tree
* at a given :ref:`yaml-pointer` path. Every setter takes the `asdf_file_t *`
* as its first argument, the path as its second, and the value to write as the
* remaining argument(s).
*
* Any intermediate mappings named in the path that do not yet exist are
* created automatically, and an existing value already at the path is
* replaced. Each function returns `ASDF_VALUE_OK` on success or an
* `asdf_value_err_t` error code.
*
* `asdf_set_value` inserts a pre-built generic `asdf_value_t *`;
* `asdf_set_string` takes an explicit byte length while `asdf_set_string0`
* expects a NUL-terminated string; `asdf_set_null` takes no value argument.
* The remaining scalar variants accept the corresponding C type directly
*
* For extension types, each register extension has a corresponding
* ``asdf_set_<extension>``, mirroring the ``asdf_get_<extension>`` functions
* described in :ref:`file-extension-getters`. For example, `asdf_set_ndarray`
* can be used to assign an `asdf_ndarray_t *` to a path in YAML tree.
*
* See :ref:`writing` for a narrative guide.
*/
//
/** See :ref:`file-value-setters` */
ASDF_EXPORT ;
/** See :ref:`file-value-setters` */
ASDF_EXPORT ;
/** See :ref:`file-value-setters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`file-value-setters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`file-value-setters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`file-value-setters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`file-value-setters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`file-value-setters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`file-value-setters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`file-value-setters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`file-value-setters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`file-value-setters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`file-value-setters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`file-value-setters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`file-value-setters` */
ASDF_EXPORT asdf_value_err_t ;
/** See :ref:`file-value-setters` */
ASDF_EXPORT ;
/** See :ref:`file-value-setters` */
ASDF_EXPORT ;
/**
* .. _file-traversal:
*
* Tree traversal
* --------------
*/
// clang-format off
/**
* Traverse the tree breadth-first starting from ``root`` and return the first
* value matching ``pred``
*
* The caller owns the returned `asdf_value_t *` and must eventually destroy it
* with `asdf_value_destroy`. Returns ``NULL`` if no matching value was found.
*
* This is a macro that can take either an `asdf_file_t *` or `asdf_value_t *`
* as the root from which to traverse. In the former case, this is equivalent
* to starting the traversal from the root of the tree (via `asdf_file_find`).
*
* :param root: `asdf_value_t *` handle for the root node to search from or
* an `asdf_file_t *`.
* :param pred: A predicate function to match the value to return; see
* `asdf_value_pred_t`
* :return: The first matching `asdf_value_t *`, or ``NULL`` if not found
*/
/**
* Extended version of `asdf_find` with additional traversal options
*
* Like `asdf_find` but allows controlling traversal order, which
* container types to descend into, and the maximum search depth.
*
* :param root: `asdf_value_t *` handle for the root node to search from
* or an `asdf_file_t *`
* :param pred: A predicate function to match the value to return; see
* `asdf_value_pred_t`
* :param depth_first: If ``true`` descend the tree in depth-first order;
* otherwise the tree is traversed breadth-first
* :param descend_pred: Optional predicate (``NULL`` means descend into all
* containers) controlling which containers are descended into
* :param max_depth: Maximum depth to descend; ``-1`` means no limit
* :return: The first matching `asdf_value_t *`, or ``NULL`` if not found
*/
// clang-format on
/**
* Traverse the tree breadth-first starting from root of the given file's tree
* and return the first value matching ``pred``
*
* This is a shorthand for calling `asdf_value_find` starting from the root
* of the tree, equivalent to:
*
* .. code:: c
*
* asdf_value_t *root = asdf_get_value(file, "");
* asdf_value_t *found = asdf_value_find(root, pred);
*
* :param root: `asdf_file_t *` handle for the file to search
* :param pred: A predicate function to match the value to return; see
* `asdf_value_pred_t`
* :return: The first matching `asdf_value_t *`, or ``NULL`` if not found
*/
ASDF_EXPORT asdf_value_t *;
/**
* Extended version of `asdf_file_find` with additional traversal options
*
* This is just the file-level companion to `asdf_file_find`, similarly to
* `asdf_value_find_ex`.
*
* :param root: `asdf_file_t *` handle for the file to search
* :param pred: A predicate function to match the value to return; see
* `asdf_value_pred_t`
* :param depth_first: If ``true`` descend the tree in depth-first order;
* otherwise the tree is traversed breadth-first
* :param descend_pred: Optional predicate (``NULL`` means descend into all
* containers) controlling which containers are descended into
* :param max_depth: Maximum depth to descend; ``-1`` means no limit
* :return: The first matching `asdf_value_t *`, or ``NULL`` if not found
*/
ASDF_EXPORT asdf_value_t *;
/* ASDF_FILE_H */