• Project Info
  • Language
  • C++
  • License
  • MIT
  • Version Released
  • Jan. 5, 2021
  • Docs Built
  • May 30, 2021
  • Latest Version
  • master
  • Collaborators
  • admin
  • Tags
  • yaml

Class Emitter

Synopsis

#include <include/yaml-cpp/emitter.h>

class YAML_CPP_API Emitter

Description

No description yet.

Mentioned in

Methods

Emitter overload
~Emitter
c_stroutput
GetLastError
goodstate checking
operator=
RestoreGlobalModifiedSettings
SetBoolFormat
SetDoublePrecision
SetFloatPrecision
SetIndent
SetIntBase
SetLocalIndent
SetLocalPrecision
SetLocalValuelocal setters
SetMapFormat
SetNullFormat
SetOutputCharsetglobal setters
SetPostCommentIndent
SetPreCommentIndent
SetSeqFormat
SetStringFormat
size
Write overloadoverloads of write
WriteIntegralType
WriteStreamable

Source

Lines 33-134 in include/yaml-cpp/emitter.h.

class YAML_CPP_API Emitter {
 public:
  Emitter();
  explicit Emitter(std::ostream& stream);
  Emitter(const Emitter&) = delete;
  Emitter& operator=(const Emitter&) = delete;
  ~Emitter();

  // output
  const char* c_str() const;
  std::size_t size() const;

  // state checking
  bool good() const;
  const std::string GetLastError() const;

  // global setters
  bool SetOutputCharset(EMITTER_MANIP value);
  bool SetStringFormat(EMITTER_MANIP value);
  bool SetBoolFormat(EMITTER_MANIP value);
  bool SetNullFormat(EMITTER_MANIP value);
  bool SetIntBase(EMITTER_MANIP value);
  bool SetSeqFormat(EMITTER_MANIP value);
  bool SetMapFormat(EMITTER_MANIP value);
  bool SetIndent(std::size_t n);
  bool SetPreCommentIndent(std::size_t n);
  bool SetPostCommentIndent(std::size_t n);
  bool SetFloatPrecision(std::size_t n);
  bool SetDoublePrecision(std::size_t n);
  void RestoreGlobalModifiedSettings();

  // local setters
  Emitter& SetLocalValue(EMITTER_MANIP value);
  Emitter& SetLocalIndent(const _Indent& indent);
  Emitter& SetLocalPrecision(const _Precision& precision);

  // overloads of write
  Emitter& Write(const std::string& str);
  Emitter& Write(bool b);
  Emitter& Write(char ch);
  Emitter& Write(const _Alias& alias);
  Emitter& Write(const _Anchor& anchor);
  Emitter& Write(const _Tag& tag);
  Emitter& Write(const _Comment& comment);
  Emitter& Write(const _Null& n);
  Emitter& Write(const Binary& binary);

  template <typename T>
  Emitter& WriteIntegralType(T value);

  template <typename T>
  Emitter& WriteStreamable(T value);

 private:
  template <typename T>
  void SetStreamablePrecision(std::stringstream&) {}
  std::size_t GetFloatPrecision() const;
  std::size_t GetDoublePrecision() const;

  void PrepareIntegralStream(std::stringstream& stream) const;
  void StartedScalar();

 private:
  void EmitBeginDoc();
  void EmitEndDoc();
  void EmitBeginSeq();
  void EmitEndSeq();
  void EmitBeginMap();
  void EmitEndMap();
  void EmitNewline();
  void EmitKindTag();
  void EmitTag(bool verbatim, const _Tag& tag);

  void PrepareNode(EmitterNodeType::value child);
  void PrepareTopNode(EmitterNodeType::value child);
  void FlowSeqPrepareNode(EmitterNodeType::value child);
  void BlockSeqPrepareNode(EmitterNodeType::value child);

  void FlowMapPrepareNode(EmitterNodeType::value child);

  void FlowMapPrepareLongKey(EmitterNodeType::value child);
  void FlowMapPrepareLongKeyValue(EmitterNodeType::value child);
  void FlowMapPrepareSimpleKey(EmitterNodeType::value child);
  void FlowMapPrepareSimpleKeyValue(EmitterNodeType::value child);

  void BlockMapPrepareNode(EmitterNodeType::value child);

  void BlockMapPrepareLongKey(EmitterNodeType::value child);
  void BlockMapPrepareLongKeyValue(EmitterNodeType::value child);
  void BlockMapPrepareSimpleKey(EmitterNodeType::value child);
  void BlockMapPrepareSimpleKeyValue(EmitterNodeType::value child);

  void SpaceOrIndentTo(bool requireSpace, std::size_t indent);

  const char* ComputeFullBoolName(bool b) const;
  const char* ComputeNullName() const;
  bool CanEmitNewline() const;

 private:
  std::unique_ptr<EmitterState> m_pState;
  ostream_wrapper m_stream;
};


Discussions (1)

AjmeerKhan 6 months ago 0

Hi, I want to remove some fields(version). I have used remove function but it did not delete that field. #include <iostream> #include <yaml-cpp/yaml.h> #include <fstream> #include<cstring> #define ORIGINAL_FILE "01-network-manager-all.yaml"

using namespace std;

void configureNetplan() {

	YAML::Node config = YAML::LoadFile(ORIGINAL_FILE);
	ofstream fout(ORIGINAL_FILE);
	config["network"]["version"]=2;
	config["network"]["renderer"]="networkd";
	config["network"]["ethernets"]["eth1"]["dhcp4"]="yes";
	config["network"]["ethernets"]["ens33"]["addresses"]="1.2.3.4";
	config["network"]["ethernets"]["ens33"]["gateway4"]="1.2.3.4";
	config["network"]["ethernets"]["ens33"]["nameservers"]["addresses"]= "1.2.34.3";

node.remove(config["network"]["version"]);
    cout<<config;

config["network"]["ethernets"]["ens33"]["dhcp4"]="yes";
fout<<config;
fout.close();	

}

int main(int argc,char** argv) { configureNetplan();

return 0; }




Add Discussion as Guest

Log in