pr0078-add-node-style-setter.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. From 68dffeb3346282c7cf3b382040c5252ca7babac8 Mon Sep 17 00:00:00 2001
  2. From: Innokentii Mokin <innokentii@yandex-team.ru>
  3. Date: Thu, 13 Apr 2023 15:07:25 +0300
  4. Subject: [PATCH] add node style setter
  5. ---
  6. include/libfyaml.h | 14 ++++++++++++++
  7. src/lib/fy-doc.c | 12 ++++++++++++
  8. 2 files changed, 26 insertions(+)
  9. diff --git a/include/libfyaml.h b/include/libfyaml.h
  10. index 16d8971..40e72f5 100644
  11. --- a/include/libfyaml.h
  12. +++ b/include/libfyaml.h
  13. @@ -2784,6 +2784,20 @@ enum fy_node_style
  14. fy_node_get_style(struct fy_node *fyn)
  15. FY_EXPORT;
  16. +/**
  17. + * fy_node_set_style() - Set the node style
  18. + *
  19. + * Set the node rendering style.
  20. + * If current node style is alias it won't be changed
  21. + * to save document structure
  22. + *
  23. + * @fyn: The node
  24. + * @style: The node style
  25. + */
  26. +void
  27. +fy_node_set_style(struct fy_node *fyn, enum fy_node_style style)
  28. + FY_EXPORT;
  29. +
  30. /**
  31. * fy_node_is_scalar() - Check whether the node is a scalar
  32. *
  33. diff --git a/src/lib/fy-doc.c b/src/lib/fy-doc.c
  34. index 7df5105..e7cd64a 100644
  35. --- a/src/lib/fy-doc.c
  36. +++ b/src/lib/fy-doc.c
  37. @@ -3343,6 +3343,18 @@ enum fy_node_style fy_node_get_style(struct fy_node *fyn)
  38. return fyn ? fyn->style : FYNS_PLAIN;
  39. }
  40. +void fy_node_set_style(struct fy_node *fyn, enum fy_node_style style)
  41. +{
  42. + if (!fyn)
  43. + return;
  44. +
  45. + /* ignore alias nodes to save document structure */
  46. + if (fyn->style == FYNS_ALIAS)
  47. + return;
  48. +
  49. + fyn->style = style;
  50. +}
  51. +
  52. bool fy_node_is_null(struct fy_node *fyn)
  53. {
  54. if (!fyn)