158 {
159 if(item->is_value()) {
162 std::vector<MString> data(1);
163 data[0] = item->as<std::string>()->get();
165 }
167 std::vector<MInt> data(1);
168#if defined(MAIA_GCC_COMPILER)
169#pragma GCC diagnostic push
170#pragma GCC diagnostic ignored "-Wnull-dereference"
171#endif
172 data[0] =
static_cast<MInt>(item->as<int64_t>()->get());
173#if defined(MAIA_GCC_COMPILER)
174#pragma GCC diagnostic pop
175#endif
176 return Property(name, data);
177 }
179 std::vector<MFloat> data(1);
180 data[0] = item->as<double>()->get();
181 return Property(name, data);
182 }
184 std::vector<MBool> data(1);
185 data[0] = item->as<bool>()->get();
186 return Property(name, data);
187 }
188 default:
189 TERMM(1, "bad value type");
190 }
191 } else if(item->is_array() || item->is_table()) {
192 if(item->as_array()->get().empty()) {
193 TERMM(1, "array of size 0 found, cannot detect type");
194 }
195
198 auto v = *item->as_array()->get_array_of<std::string>();
199 std::vector<MString> data(v.size());
200 copy(v.begin(), v.end(), data.begin());
201 return Property(name, data);
202 }
204 auto v = *item->as_array()->get_array_of<
MLong>();
205 std::vector<MInt> data(v.size());
206 copy(v.begin(), v.end(), data.begin());
207 return Property(name, data);
208 }
210 auto v = *item->as_array()->get_array_of<double>();
211 std::vector<MFloat> data(v.size());
212 copy(v.begin(), v.end(), data.begin());
213 return Property(name, data);
214 }
216 auto v = *item->as_array()->get_array_of<bool>();
217 std::vector<MBool> data(v.size());
218 copy(v.begin(), v.end(), data.begin());
219 return Property(name, data);
220 }
221 default:
222 TERMM(1, "bad value type");
223 }
224 } else {
225 TERMM(1, "item is not a value or array");
226 }
227}
Class that represents a single key-value pair for TOML properties.