OMCompiler/SimulationRuntime/c/util/string_array.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file belongs to the OpenModelica Run-Time System | ||
| 3 | * | ||
| 4 | * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), c/o Linköpings | ||
| 5 | * universitet, Department of Computer and Information Science, SE-58183 Linköping, Sweden. All rights | ||
| 6 | * reserved. | ||
| 7 | * | ||
| 8 | * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE | ||
| 9 | * AGPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. ANY | ||
| 10 | * USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S | ||
| 11 | * ACCEPTANCE OF THE BSD NEW LICENSE OR THE OSMC PUBLIC LICENSE OR THE AGPL | ||
| 12 | * VERSION 3, ACCORDING TO RECIPIENTS CHOICE. | ||
| 13 | * | ||
| 14 | * The OpenModelica software and the OSMC (Open Source Modelica Consortium) Public License | ||
| 15 | * (OSMC-PL) are obtained from OSMC, either from the above address, from the URLs: | ||
| 16 | * http://www.openmodelica.org or https://github.com/OpenModelica/ or | ||
| 17 | * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica distribution. GNU | ||
| 18 | * AGPL version 3 is obtained from: https://www.gnu.org/licenses/licenses.html#GPL. The BSD NEW | ||
| 19 | * License is obtained from: http://www.opensource.org/licenses/BSD-3-Clause. | ||
| 20 | * | ||
| 21 | * This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY | ||
| 23 | * SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF | ||
| 24 | * OSMC-PL. | ||
| 25 | * | ||
| 26 | */ | ||
| 27 | |||
| 28 | #ifndef STRING_ARRAY_H_ | ||
| 29 | #define STRING_ARRAY_H_ | ||
| 30 | |||
| 31 | #include <stdarg.h> | ||
| 32 | #include "../openmodelica.h" | ||
| 33 | #include "base_array.h" | ||
| 34 | #include "generic_array.h" | ||
| 35 | |||
| 36 | /* Indexing */ | ||
| 37 | modelica_string string_get(const string_array a, size_t i); | ||
| 38 | modelica_string string_get_2D(const string_array a, size_t i, size_t j); | ||
| 39 | modelica_string string_get_3D(const string_array a, size_t i, size_t j, size_t k); | ||
| 40 | modelica_string string_get_4D(const string_array a, size_t i, size_t j, size_t k, size_t l); | ||
| 41 | modelica_string string_get_5D(const string_array a, size_t i, size_t j, size_t k, size_t l, size_t m); | ||
| 42 | |||
| 43 | /* Setting the fields of a string_array */ | ||
| 44 | extern void string_array_create(string_array *dest, modelica_string *data, int ndims, ...); | ||
| 45 | |||
| 46 | /* Allocation of a vector */ | ||
| 47 | extern void simple_alloc_1d_string_array(string_array* dest, int n); | ||
| 48 | |||
| 49 | /* Allocation of a matrix */ | ||
| 50 | extern void simple_alloc_2d_string_array(string_array *dest, int r, int c); | ||
| 51 | |||
| 52 | extern void alloc_string_array(string_array *dest, int ndims, ...); | ||
| 53 | extern void fill_alloc_string_array(string_array* dest, modelica_string value, int ndims, ...); | ||
| 54 | |||
| 55 | /* Allocation of string data */ | ||
| 56 | extern void alloc_string_array_data(string_array* a); | ||
| 57 | |||
| 58 | /* Frees memory*/ | ||
| 59 | extern void free_string_array_data(string_array* a); | ||
| 60 | |||
| 61 | /* Clones data*/ | ||
| 62 | static inline void clone_string_array_spec(const string_array * src, | ||
| 63 | string_array* dst) | ||
| 64 | ✗ | { clone_base_array_spec(src, dst); } | |
| 65 | |||
| 66 | /* Copy string data given memory ptr*/ | ||
| 67 | extern void copy_string_array_data_mem(const string_array source,modelica_string* dest); | ||
| 68 | |||
| 69 | /* Copy string array*/ | ||
| 70 | extern void copy_string_array(const string_array source, string_array* dest); | ||
| 71 | extern void omc_string_array_copy_data(const string_array source, string_array* dest); | ||
| 72 | extern void omc_string_array_alloc_copy(const string_array source, string_array* dest); | ||
| 73 | |||
| 74 | extern modelica_string* calc_string_index(int ndims, const _index_t* idx_vec, const string_array * arr); | ||
| 75 | extern modelica_string* calc_string_index_va(const string_array * source,int ndims, | ||
| 76 | va_list ap); | ||
| 77 | |||
| 78 | extern void put_string_element(modelica_string value,int i1,string_array* dest); | ||
| 79 | extern void put_string_matrix_element(modelica_string value, int r, int c, | ||
| 80 | string_array* dest); | ||
| 81 | |||
| 82 | extern void print_string_matrix(const string_array * source); | ||
| 83 | extern void print_string_array(const string_array * source); | ||
| 84 | |||
| 85 | void string_vector_to_string(const string_array *source, modelica_boolean isScalar, char *buffer, size_t bufsize); | ||
| 86 | /* | ||
| 87 | |||
| 88 | a[1:3] := b; | ||
| 89 | |||
| 90 | */ | ||
| 91 | extern void indexed_assign_string_array(const string_array source, | ||
| 92 | string_array* dest, | ||
| 93 | const index_spec_t* dest_spec); | ||
| 94 | extern void simple_indexed_assign_string_array1(const string_array * source, | ||
| 95 | int i1, | ||
| 96 | string_array* dest); | ||
| 97 | extern void simple_indexed_assign_string_array2(const string_array * source, | ||
| 98 | int i1, int i2, | ||
| 99 | string_array* dest); | ||
| 100 | |||
| 101 | /* | ||
| 102 | |||
| 103 | a := b[1:3]; | ||
| 104 | |||
| 105 | */ | ||
| 106 | extern void index_string_array(const string_array * source, | ||
| 107 | const index_spec_t* source_spec, | ||
| 108 | string_array* dest); | ||
| 109 | extern void index_alloc_string_array(const string_array * source, | ||
| 110 | const index_spec_t* source_spec, | ||
| 111 | string_array* dest); | ||
| 112 | |||
| 113 | extern void simple_index_alloc_string_array1(const string_array * source, int i1, | ||
| 114 | string_array* dest); | ||
| 115 | |||
| 116 | extern void simple_index_string_array1(const string_array * source, | ||
| 117 | int i1, | ||
| 118 | string_array* dest); | ||
| 119 | extern void simple_index_string_array2(const string_array * source, | ||
| 120 | int i1, int i2, | ||
| 121 | string_array* dest); | ||
| 122 | |||
| 123 | /* array(A,B,C) for arrays A,B,C */ | ||
| 124 | extern void array_string_array(string_array* dest,int n, | ||
| 125 | string_array first,...); | ||
| 126 | extern void array_alloc_string_array(string_array* dest,int n, | ||
| 127 | string_array first,...); | ||
| 128 | |||
| 129 | /* array(s1,s2,s3) for scalars s1,s2,s3 */ | ||
| 130 | extern void array_scalar_string_array(string_array* dest,int n, | ||
| 131 | modelica_string first,...); | ||
| 132 | extern void array_alloc_scalar_string_array(string_array* dest,int n, | ||
| 133 | modelica_string first,...); | ||
| 134 | |||
| 135 | extern void cat_string_array(int k,string_array* dest, int n, | ||
| 136 | const string_array* first,...); | ||
| 137 | extern void cat_alloc_string_array(int k,string_array* dest, int n, | ||
| 138 | const string_array* first,...); | ||
| 139 | |||
| 140 | extern void promote_string_array(const string_array * a, int n,string_array* dest); | ||
| 141 | extern void promote_scalar_string_array(modelica_string s,int n, | ||
| 142 | string_array* dest); | ||
| 143 | extern void promote_alloc_string_array(const string_array * a, int n, | ||
| 144 | string_array* dest); | ||
| 145 | |||
| 146 | static inline int ndims_string_array(const string_array * a) | ||
| 147 | { return ndims_base_array(a); } | ||
| 148 | |||
| 149 | extern const char** data_of_string_c89_array(const string_array a); | ||
| 150 | |||
| 151 | extern void size_string_array(const string_array * a, integer_array* dest); | ||
| 152 | extern modelica_string scalar_string_array(const string_array * a); | ||
| 153 | extern void vector_string_array(const string_array * a, string_array* dest); | ||
| 154 | extern void vector_string_scalar(modelica_string a,string_array* dest); | ||
| 155 | extern void matrix_string_array(const string_array * a, string_array* dest); | ||
| 156 | extern void matrix_string_scalar(modelica_string a,string_array* dest); | ||
| 157 | extern void transpose_alloc_string_array(const string_array * a, string_array* dest); | ||
| 158 | extern void transpose_string_array(const string_array * a, string_array* dest); | ||
| 159 | |||
| 160 | extern void fill_string_array(string_array* dest,modelica_string s); | ||
| 161 | |||
| 162 | static inline void clone_reverse_string_array_spec(const string_array *source, | ||
| 163 | string_array *dest) | ||
| 164 | { clone_reverse_base_array_spec(source, dest); } | ||
| 165 | extern void convert_alloc_string_array_to_f77(const string_array * a, | ||
| 166 | string_array* dest); | ||
| 167 | extern void convert_alloc_string_array_from_f77(const string_array * a, | ||
| 168 | string_array* dest); | ||
| 169 | |||
| 170 | extern void fill_alloc_real_array(real_array* dest, modelica_real value, int ndims, ...); | ||
| 171 | |||
| 172 | extern void unpack_string_array(const string_array *a, const char **data); | ||
| 173 | |||
| 174 | #endif | ||
| 175 |