Lines Matching +full:string +full:- +full:array
1 # SPDX-License-Identifier: Apache-2.0
9 # It supports basic key-value pairs, like
12 # basic key-object pairs, like
18 # - foo1
19 # - foo2
20 # - foo3
27 # - alpha
28 # - beta
29 # - gamma
35 # - bar: val1
37 # - bar: val2
92 "${CMAKE_CURRENT_FUNCTION}(EXISTS NAME ${ARG_YAML_NAME} <result-var>)."
98 list(POP_FRONT ARG_YAML_UNPARSED_ARGUMENTS out-var)
99 set(${out-var} TRUE PARENT_SCOPE)
101 set(${out-var} ${ARG_YAML_NAME}-NOTFOUND PARENT_SCOPE)
151 execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
168 # yaml_get(<out-var> NAME <name> KEY <key>...)
170 # Get the value of the given key and store the value in <out-var>.
177 # <out-var> : Name of output variable.
181 # - Anything will be returned, even json object strings.
190 # If key is not found, then type becomes '-NOTFOUND' and value handling is done below.
191 string(JSON type ERROR_VARIABLE error TYPE "${json_content}" ${ARG_YAML_KEY})
192 if(type STREQUAL ARRAY)
193 string(JSON subjson GET "${json_content}" ${ARG_YAML_KEY})
194 string(JSON arraylength LENGTH "${subjson}")
195 set(array) variable
196 math(EXPR arraystop "${arraylength} - 1")
199 string(JSON item GET "${subjson}" ${i})
200 list(APPEND array ${item})
203 set(${out_var} ${array} PARENT_SCOPE)
206 # Searching for a non-existing key should just result in the output value '-NOTFOUND'
207 string(JSON value ERROR_VARIABLE error GET "${json_content}" ${ARG_YAML_KEY})
213 # yaml_length(<out-var> NAME <name> KEY <key>...)
215 # Get the length of the array defined by the given key and store the length in <out-var>.
216 # If key does not define an array, then the length -1 is returned.
220 # <out-var> : Name of output variable.
230 string(JSON type ERROR_VARIABLE error TYPE "${json_content}" ${ARG_YAML_KEY})
231 if(type STREQUAL ARRAY)
232 string(JSON subjson GET "${json_content}" ${ARG_YAML_KEY})
233 string(JSON arraylength LENGTH "${subjson}")
235 elseif(type MATCHES ".*-NOTFOUND")
238 message(WARNING "YAML key: ${ARG_YAML_KEY} is not an array.")
239 set(${out_var} -1 PARENT_SCOPE)
272 # non-existing keys will throw errors but also set type to NOT-FOUND.
273 string(JSON type ERROR_VARIABLE ignore TYPE "${json_content}" ${valid_keys} ${k})
293 string(JSON json_content SET "${json_content}"
300 string(JSON json_content SET "${json_content}" ${ARG_YAML_KEY} "[]")
303 string(JSON subjson GET "${json_content}" ${ARG_YAML_KEY})
304 string(JSON index LENGTH "${subjson}")
306 math(EXPR stop "${index} + ${length} - 1")
310 string(JSON json_content SET "${json_content}" ${ARG_YAML_KEY} ${i} "\"${value}\"")
314 string(JSON json_content SET "${json_content}" ${ARG_YAML_KEY} "\"${ARG_YAML_VALUE}\"")
340 string(JSON json_content REMOVE "${json_content}" ${ARG_YAML_KEY})
384 math(EXPR level_dec "${level} - 1")
388 string(JSON length LENGTH "${json}")
394 math(EXPR stop "${length} - 1")
396 string(JSON member MEMBER "${json}" ${i})
398 string(JSON type TYPE "${json}" ${member})
399 string(JSON subjson GET "${json}" ${member})
404 elseif(type STREQUAL ARRAY)
406 string(JSON arraylength LENGTH "${subjson}")
411 math(EXPR arraystop "${arraylength} - 1")
413 string(JSON item GET "${json}" ${member} ${i})
414 set(${yaml} "${${yaml}}${indent_${level}} - ${item}\n")