library.alc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. include "primitives.alh"
  2. Element function export_node(model_name : String, model_reference : Element):
  3. Element splitted
  4. splitted = string_split(model_name, "/")
  5. Integer length
  6. length = list_len(splitted) - 1
  7. Integer counter_i
  8. counter_i = 0
  9. Element current
  10. current = dict_read(read_root(), "__hierarchy")
  11. while(counter_i < length):
  12. if (bool_not(dict_in(current, splitted[counter_i]))):
  13. // Create the new node
  14. dict_add(current, splitted[counter_i], dict_create())
  15. dict_add(current[splitted[counter_i]], "__hierarchy_node", dict_create())
  16. // Read out newly created element
  17. current = current[splitted[counter_i]]
  18. counter_i = counter_i + 1
  19. // current now contains the place where we should add the element
  20. dict_overwrite(current, splitted[length], model_reference)
  21. return model_reference!
  22. Element function import_node(model_name : String):
  23. Element splitted
  24. splitted = string_split(model_name, "/")
  25. Integer length
  26. length = list_len(splitted)
  27. Integer counter_i
  28. counter_i = 0
  29. Element current
  30. current = dict_read(read_root(), "__hierarchy")
  31. while (counter_i < length):
  32. if dict_in(current, splitted[counter_i]):
  33. current = current[splitted[counter_i]]
  34. counter_i = counter_i + 1
  35. else:
  36. return read_root()!
  37. return current!