| 1 | /* |
| 2 | * Copyright 2013 Ecole Normale Superieure |
| 3 | * |
| 4 | * Use of this software is governed by the MIT license |
| 5 | * |
| 6 | * Written by Sven Verdoolaege, |
| 7 | * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France |
| 8 | */ |
| 9 | |
| 10 | #include <isl/stream.h> |
| 11 | |
| 12 | #include <isl_list_macro.h> |
| 13 | |
| 14 | /* Read a sequence of EL objects and return them as a list. |
| 15 | */ |
| 16 | static __isl_give LIST(EL) *FN(isl_stream_yaml_read,LIST(EL_BASE))( |
| 17 | isl_stream *s) |
| 18 | { |
| 19 | isl_ctx *ctx; |
| 20 | LIST(EL) *list; |
| 21 | isl_bool more; |
| 22 | |
| 23 | ctx = isl_stream_get_ctx(s); |
| 24 | |
| 25 | if (isl_stream_yaml_read_start_sequence(s) < 0) |
| 26 | return NULL; |
| 27 | |
| 28 | list = FN(LIST(EL),alloc)(ctx, n: 0); |
| 29 | while ((more = isl_stream_yaml_next(s)) == isl_bool_true) { |
| 30 | EL *el; |
| 31 | |
| 32 | el = FN(isl_stream_read,EL_BASE)(s); |
| 33 | list = FN(LIST(EL),add)(list, el); |
| 34 | } |
| 35 | |
| 36 | if (more < 0 || isl_stream_yaml_read_end_sequence(s) < 0) |
| 37 | return FN(LIST(EL),free)(list); |
| 38 | |
| 39 | return list; |
| 40 | } |
| 41 | |