rapidyaml  0.11.1
parse and emit YAML, and do it fast
Emit to resizeable container

Functions

template<class CharOwningContainer >
substr c4::yml::emitrs_yaml (Tree const &t, id_type id, EmitOptions const &opts, CharOwningContainer *cont, bool append=false)
 (1) emit+resize: emit YAML to the given std::string/std::vector-like container, resizing it as needed to fit the emitted YAML. More...
 
template<class CharOwningContainer >
substr c4::yml::emitrs_yaml (Tree const &t, id_type id, CharOwningContainer *cont, bool append=false)
 (2) like (1), but use default emit options More...
 
template<class CharOwningContainer >
substr c4::yml::emitrs_json (Tree const &t, id_type id, EmitOptions const &opts, CharOwningContainer *cont, bool append=false)
 (1) emit+resize: emit JSON to the given std::string/std::vector-like container, resizing it as needed to fit the emitted JSON. More...
 
template<class CharOwningContainer >
substr c4::yml::emitrs_json (Tree const &t, id_type id, CharOwningContainer *cont, bool append=false)
 (2) like (1), but use default emit options More...
 
template<class CharOwningContainer >
CharOwningContainer c4::yml::emitrs_yaml (Tree const &t, id_type id, EmitOptions const &opts={})
 (3) emit+resize: YAML to a newly-created std::string/std::vector-like container. More...
 
template<class CharOwningContainer >
CharOwningContainer c4::yml::emitrs_json (Tree const &t, id_type id, EmitOptions const &opts={})
 (3) emit+resize: JSON to a newly-created std::string/std::vector-like container. More...
 
template<class CharOwningContainer >
substr c4::yml::emitrs_yaml (Tree const &t, EmitOptions const &opts, CharOwningContainer *cont, bool append=false)
 (1) emit+resize: YAML to the given std::string/std::vector-like container, resizing it as needed to fit the emitted YAML. More...
 
template<class CharOwningContainer >
substr c4::yml::emitrs_yaml (Tree const &t, CharOwningContainer *cont, bool append=false)
 (2) like (1), but use default emit options More...
 
template<class CharOwningContainer >
substr c4::yml::emitrs_json (Tree const &t, EmitOptions const &opts, CharOwningContainer *cont, bool append=false)
 (1) emit+resize: JSON to the given std::string/std::vector-like container, resizing it as needed to fit the emitted JSON. More...
 
template<class CharOwningContainer >
substr c4::yml::emitrs_json (Tree const &t, CharOwningContainer *cont, bool append=false)
 (2) like (1), but use default emit options More...
 
template<class CharOwningContainer >
CharOwningContainer c4::yml::emitrs_yaml (Tree const &t, EmitOptions const &opts={})
 (3) emit+resize: YAML to a newly-created std::string/std::vector-like container. More...
 
template<class CharOwningContainer >
CharOwningContainer c4::yml::emitrs_json (Tree const &t, EmitOptions const &opts={})
 (3) emit+resize: JSON to a newly-created std::string/std::vector-like container. More...
 
template<class CharOwningContainer >
substr c4::yml::emitrs_yaml (ConstNodeRef const &n, EmitOptions const &opts, CharOwningContainer *cont, bool append=false)
 (1) emit+resize: YAML to the given std::string/std::vector-like container, resizing it as needed to fit the emitted YAML. More...
 
template<class CharOwningContainer >
substr c4::yml::emitrs_yaml (ConstNodeRef const &n, CharOwningContainer *cont, bool append=false)
 (2) like (1), but use default emit options More...
 
template<class CharOwningContainer >
substr c4::yml::emitrs_json (ConstNodeRef const &n, EmitOptions const &opts, CharOwningContainer *cont, bool append=false)
 (1) emit+resize: JSON to the given std::string/std::vector-like container, resizing it as needed to fit the emitted JSON. More...
 
template<class CharOwningContainer >
substr c4::yml::emitrs_json (ConstNodeRef const &n, CharOwningContainer *cont, bool append=false)
 (2) like (1), but use default emit options More...
 
template<class CharOwningContainer >
CharOwningContainer c4::yml::emitrs_yaml (ConstNodeRef const &n, EmitOptions const &opts={})
 (3) emit+resize: YAML to a newly-created std::string/std::vector-like container. More...
 
template<class CharOwningContainer >
CharOwningContainer c4::yml::emitrs_json (ConstNodeRef const &n, EmitOptions const &opts={})
 (3) emit+resize: JSON to a newly-created std::string/std::vector-like container. More...
 

Detailed Description

Function Documentation

◆ emitrs_yaml() [1/9]

template<class CharOwningContainer >
substr c4::yml::emitrs_yaml ( Tree const &  t,
id_type  id,
EmitOptions const &  opts,
CharOwningContainer *  cont,
bool  append = false 
)

(1) emit+resize: emit YAML to the given std::string/std::vector-like container, resizing it as needed to fit the emitted YAML.

If append is set to true, the emitted YAML is appended at the end of the container.

Returns
a substr trimmed to the emitted YAML (excluding the initial contents, when appending)

Definition at line 764 of file emit.hpp.

765 {
766  size_t startpos = append ? cont->size() : 0u;
767  cont->resize(cont->capacity()); // otherwise the first emit would be certain to fail
768  substr buf = to_substr(*cont).sub(startpos);
769  substr ret = emit_yaml(t, id, opts, buf, /*error_on_excess*/false);
770  if(ret.str == nullptr && ret.len > 0)
771  {
772  cont->resize(startpos + ret.len);
773  buf = to_substr(*cont).sub(startpos);
774  ret = emit_yaml(t, id, opts, buf, /*error_on_excess*/true);
775  }
776  else
777  {
778  cont->resize(startpos + ret.len);
779  }
780  return ret;
781 }
substr emit_yaml(ConstNodeRef const &r, substr buf, bool error_on_excess=true)
(2) like (1), but use default emit options
Definition: emit.hpp:717
substr to_substr(substr s) noexcept
neutral version for use in generic code
Definition: substr.hpp:2208

References c4::yml::emit_yaml(), and c4::to_substr().

◆ emitrs_yaml() [2/9]

template<class CharOwningContainer >
substr c4::yml::emitrs_yaml ( Tree const &  t,
id_type  id,
CharOwningContainer *  cont,
bool  append = false 
)

(2) like (1), but use default emit options

Definition at line 784 of file emit.hpp.

785 {
786  return emitrs_yaml(t, id, EmitOptions{}, cont, append);
787 }
CharOwningContainer emitrs_yaml(ConstNodeRef const &n, EmitOptions const &opts={})
(3) emit+resize: YAML to a newly-created std::string/std::vector-like container.
Definition: emit.hpp:944

References c4::yml::emitrs_yaml().

◆ emitrs_json() [1/9]

template<class CharOwningContainer >
substr c4::yml::emitrs_json ( Tree const &  t,
id_type  id,
EmitOptions const &  opts,
CharOwningContainer *  cont,
bool  append = false 
)

(1) emit+resize: emit JSON to the given std::string/std::vector-like container, resizing it as needed to fit the emitted JSON.

If append is set to true, the emitted YAML is appended at the end of the container.

Returns
a substr trimmed to the emitted JSON (excluding the initial contents, when appending)

Definition at line 794 of file emit.hpp.

795 {
796  const size_t startpos = append ? cont->size() : 0u;
797  cont->resize(cont->capacity()); // otherwise the first emit would be certain to fail
798  substr buf = to_substr(*cont).sub(startpos);
799  EmitterBuf em(opts, buf);
800  substr ret = emit_json(t, id, opts, buf, /*error_on_excess*/false);
801  if(ret.str == nullptr && ret.len > 0)
802  {
803  cont->resize(startpos + ret.len);
804  buf = to_substr(*cont).sub(startpos);
805  ret = emit_json(t, id, opts, buf, /*error_on_excess*/true);
806  }
807  else
808  {
809  cont->resize(startpos + ret.len);
810  }
811  return ret;
812 }
substr emit_json(ConstNodeRef const &r, substr buf, bool error_on_excess=true)
(2) like (1), but use default emit options
Definition: emit.hpp:740
Emitter< WriterBuf > EmitterBuf
Definition: emit.hpp:39

References c4::yml::emit_json(), and c4::to_substr().

◆ emitrs_json() [2/9]

template<class CharOwningContainer >
substr c4::yml::emitrs_json ( Tree const &  t,
id_type  id,
CharOwningContainer *  cont,
bool  append = false 
)

(2) like (1), but use default emit options

Definition at line 815 of file emit.hpp.

816 {
817  return emitrs_json(t, id, EmitOptions{}, cont, append);
818 }
CharOwningContainer emitrs_json(ConstNodeRef const &n, EmitOptions const &opts={})
(3) emit+resize: JSON to a newly-created std::string/std::vector-like container.
Definition: emit.hpp:954

References c4::yml::emitrs_json().

◆ emitrs_yaml() [3/9]

template<class CharOwningContainer >
CharOwningContainer c4::yml::emitrs_yaml ( Tree const &  t,
id_type  id,
EmitOptions const &  opts = {} 
)

(3) emit+resize: YAML to a newly-created std::string/std::vector-like container.

Definition at line 823 of file emit.hpp.

823  {})
824 {
825  CharOwningContainer c;
826  emitrs_yaml(t, id, opts, &c);
827  return c;
828 }

◆ emitrs_json() [3/9]

template<class CharOwningContainer >
CharOwningContainer c4::yml::emitrs_json ( Tree const &  t,
id_type  id,
EmitOptions const &  opts = {} 
)

(3) emit+resize: JSON to a newly-created std::string/std::vector-like container.

Definition at line 831 of file emit.hpp.

831  {})
832 {
833  CharOwningContainer c;
834  emitrs_json(t, id, opts, &c);
835  return c;
836 }

◆ emitrs_yaml() [4/9]

template<class CharOwningContainer >
substr c4::yml::emitrs_yaml ( Tree const &  t,
EmitOptions const &  opts,
CharOwningContainer *  cont,
bool  append = false 
)

(1) emit+resize: YAML to the given std::string/std::vector-like container, resizing it as needed to fit the emitted YAML.

Returns
a substr trimmed to the new emitted contents.

Definition at line 845 of file emit.hpp.

846 {
847  if(t.empty())
848  return {};
849  return emitrs_yaml(t, t.root_id(), opts, cont, append);
850 }

References c4::yml::emitrs_yaml(), c4::yml::Tree::empty(), and c4::yml::Tree::root_id().

◆ emitrs_yaml() [5/9]

template<class CharOwningContainer >
substr c4::yml::emitrs_yaml ( Tree const &  t,
CharOwningContainer *  cont,
bool  append = false 
)

(2) like (1), but use default emit options

Definition at line 853 of file emit.hpp.

854 {
855  if(t.empty())
856  return {};
857  return emitrs_yaml(t, t.root_id(), EmitOptions{}, cont, append);
858 }

References c4::yml::emitrs_yaml(), c4::yml::Tree::empty(), and c4::yml::Tree::root_id().

◆ emitrs_json() [4/9]

template<class CharOwningContainer >
substr c4::yml::emitrs_json ( Tree const &  t,
EmitOptions const &  opts,
CharOwningContainer *  cont,
bool  append = false 
)

(1) emit+resize: JSON to the given std::string/std::vector-like container, resizing it as needed to fit the emitted JSON.

Returns
a substr trimmed to the new emitted contents.

Definition at line 863 of file emit.hpp.

864 {
865  if(t.empty())
866  return {};
867  return emitrs_json(t, t.root_id(), opts, cont, append);
868 }

References c4::yml::emitrs_json(), c4::yml::Tree::empty(), and c4::yml::Tree::root_id().

◆ emitrs_json() [5/9]

template<class CharOwningContainer >
substr c4::yml::emitrs_json ( Tree const &  t,
CharOwningContainer *  cont,
bool  append = false 
)

(2) like (1), but use default emit options

Definition at line 871 of file emit.hpp.

872 {
873  if(t.empty())
874  return {};
875  return emitrs_json(t, t.root_id(), EmitOptions{}, cont, append);
876 }

References c4::yml::emitrs_json(), c4::yml::Tree::empty(), and c4::yml::Tree::root_id().

◆ emitrs_yaml() [6/9]

template<class CharOwningContainer >
CharOwningContainer c4::yml::emitrs_yaml ( Tree const &  t,
EmitOptions const &  opts = {} 
)

(3) emit+resize: YAML to a newly-created std::string/std::vector-like container.

Definition at line 881 of file emit.hpp.

881  {})
882 {
883  CharOwningContainer c;
884  if(t.empty())
885  return c;
886  emitrs_yaml(t, t.root_id(), opts, &c);
887  return c;
888 }

◆ emitrs_json() [6/9]

template<class CharOwningContainer >
CharOwningContainer c4::yml::emitrs_json ( Tree const &  t,
EmitOptions const &  opts = {} 
)

(3) emit+resize: JSON to a newly-created std::string/std::vector-like container.

Definition at line 891 of file emit.hpp.

891  {})
892 {
893  CharOwningContainer c;
894  if(t.empty())
895  return c;
896  emitrs_json(t, t.root_id(), opts, &c);
897  return c;
898 }

◆ emitrs_yaml() [7/9]

template<class CharOwningContainer >
substr c4::yml::emitrs_yaml ( ConstNodeRef const &  n,
EmitOptions const &  opts,
CharOwningContainer *  cont,
bool  append = false 
)

(1) emit+resize: YAML to the given std::string/std::vector-like container, resizing it as needed to fit the emitted YAML.

Returns
a substr trimmed to the new emitted contents

Definition at line 908 of file emit.hpp.

909 {
910  if(!n.readable())
911  return {};
912  return emitrs_yaml(*n.tree(), n.id(), opts, cont, append);
913 }

References c4::yml::emitrs_yaml(), c4::yml::ConstNodeRef::id(), c4::yml::ConstNodeRef::readable(), and c4::yml::ConstNodeRef::tree().

◆ emitrs_yaml() [8/9]

template<class CharOwningContainer >
substr c4::yml::emitrs_yaml ( ConstNodeRef const &  n,
CharOwningContainer *  cont,
bool  append = false 
)

(2) like (1), but use default emit options

Definition at line 916 of file emit.hpp.

917 {
918  if(!n.readable())
919  return {};
920  return emitrs_yaml(*n.tree(), n.id(), EmitOptions{}, cont, append);
921 }

References c4::yml::emitrs_yaml(), c4::yml::ConstNodeRef::id(), c4::yml::ConstNodeRef::readable(), and c4::yml::ConstNodeRef::tree().

◆ emitrs_json() [7/9]

template<class CharOwningContainer >
substr c4::yml::emitrs_json ( ConstNodeRef const &  n,
EmitOptions const &  opts,
CharOwningContainer *  cont,
bool  append = false 
)

(1) emit+resize: JSON to the given std::string/std::vector-like container, resizing it as needed to fit the emitted JSON.

Returns
a substr trimmed to the new emitted contents

Definition at line 926 of file emit.hpp.

927 {
928  if(!n.readable())
929  return {};
930  return emitrs_json(*n.tree(), n.id(), opts, cont, append);
931 }

References c4::yml::emitrs_json(), c4::yml::ConstNodeRef::id(), c4::yml::ConstNodeRef::readable(), and c4::yml::ConstNodeRef::tree().

◆ emitrs_json() [8/9]

template<class CharOwningContainer >
substr c4::yml::emitrs_json ( ConstNodeRef const &  n,
CharOwningContainer *  cont,
bool  append = false 
)

(2) like (1), but use default emit options

Definition at line 934 of file emit.hpp.

935 {
936  if(!n.readable())
937  return {};
938  return emitrs_json(*n.tree(), n.id(), EmitOptions{}, cont, append);
939 }

References c4::yml::emitrs_json(), c4::yml::ConstNodeRef::id(), c4::yml::ConstNodeRef::readable(), and c4::yml::ConstNodeRef::tree().

◆ emitrs_yaml() [9/9]

template<class CharOwningContainer >
CharOwningContainer c4::yml::emitrs_yaml ( ConstNodeRef const &  n,
EmitOptions const &  opts = {} 
)

(3) emit+resize: YAML to a newly-created std::string/std::vector-like container.

Definition at line 944 of file emit.hpp.

944  {})
945 {
946  if(!n.readable())
947  return {};
948  CharOwningContainer c;
949  emitrs_yaml(*n.tree(), n.id(), opts, &c);
950  return c;
951 }

◆ emitrs_json() [9/9]

template<class CharOwningContainer >
CharOwningContainer c4::yml::emitrs_json ( ConstNodeRef const &  n,
EmitOptions const &  opts = {} 
)

(3) emit+resize: JSON to a newly-created std::string/std::vector-like container.

Definition at line 954 of file emit.hpp.

954  {})
955 {
956  if(!n.readable())
957  return {};
958  CharOwningContainer c;
959  emitrs_json(*n.tree(), n.id(), opts, &c);
960  return c;
961 }