rapidyaml  0.12.0
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 765 of file emit.hpp.

766 {
767  size_t startpos = append ? cont->size() : 0u;
768  cont->resize(cont->capacity()); // otherwise the first emit would be certain to fail
769  substr buf = to_substr(*cont).sub(startpos);
770  substr ret = emit_yaml(t, id, opts, buf, /*error_on_excess*/false);
771  if(ret.str == nullptr && ret.len > 0)
772  {
773  cont->resize(startpos + ret.len);
774  buf = to_substr(*cont).sub(startpos);
775  ret = emit_yaml(t, id, opts, buf, /*error_on_excess*/true);
776  }
777  else
778  {
779  cont->resize(startpos + ret.len);
780  }
781  return ret;
782 }
substr emit_yaml(ConstNodeRef const &r, substr buf, bool error_on_excess=true)
(2) like (1), but use default emit options
Definition: emit.hpp:718
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 785 of file emit.hpp.

786 {
787  return emitrs_yaml(t, id, EmitOptions{}, cont, append);
788 }
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:945

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 795 of file emit.hpp.

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

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 816 of file emit.hpp.

817 {
818  return emitrs_json(t, id, EmitOptions{}, cont, append);
819 }
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:955

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 824 of file emit.hpp.

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

◆ 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 832 of file emit.hpp.

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

◆ 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 846 of file emit.hpp.

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

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 854 of file emit.hpp.

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

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 864 of file emit.hpp.

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

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 872 of file emit.hpp.

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

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 882 of file emit.hpp.

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

◆ 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 892 of file emit.hpp.

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

◆ 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 909 of file emit.hpp.

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

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 917 of file emit.hpp.

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

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 927 of file emit.hpp.

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

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 935 of file emit.hpp.

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

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 945 of file emit.hpp.

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

◆ 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 955 of file emit.hpp.

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