32 #include <yaml-cpp/emitter.h> 49 std::ofstream out(qPrintable(filename));
57 message_ =
"Failed to open " + filename +
" for writing.";
60 catch (std::exception ex)
72 std::stringstream out;
76 return QString::fromStdString(out.str());
90 YAML::Emitter emitter;
94 out << emitter.c_str() << std::endl;
115 emitter << YAML::BeginSeq;
120 emitter << YAML::EndSeq;
125 emitter << YAML::BeginMap;
131 emitter << YAML::Key;
132 emitter << map_iter.
currentKey().toStdString();
133 emitter << YAML::Value;
138 emitter << YAML::EndMap;
143 QString value = config.
getValue().toString();
144 if (value.size() == 0)
146 emitter << YAML::DoubleQuoted <<
"";
150 emitter << value.toStdString();
155 emitter << YAML::Null;
QVariant getValue() const
If this config object is valid and is a Value type, this returns its value. Otherwise it returns an i...
QString errorMessage()
Return an error message if the latest write call had an error, or the empty string if there was no er...
QString writeString(const Config &config, const QString &filename="data string")
Write config data to a string, and return it. This potentially changes the return values of error() a...
int listLength() const
Returns the length of the List in this Node, or 0 if this Node does not have type List...
bool isValid()
Return true if the iterator currently points to a valid entry, false if not.
bool error()
Return true if the latest write operation had an error.
Configuration data storage class.
QString currentKey()
Return the name of the current map entry.
Iterator class for looping over all entries in a Map type Config Node.
Type getType() const
Return the Type of the referenced Node, or Invalid if this Config does not refer to a Node at all...
void writeFile(const Config &config, const QString &filename)
Write config data to a file. This potentially changes the return values of error() and statusMessage(...
YamlConfigWriter()
Constructor. Writer starts in a non-error state.
Config listChildAt(int i) const
Return the i'th child in the list, if the referenced Node has type List. Returns an Invalid Config if...
Config currentChild()
Return a Config reference to the current map entry.
void writeConfigNode(const Config &config, YAML::Emitter &emitter)
MapIterator mapIterator() const
Return a new iterator for looping over key/value pairs.
void writeStream(const Config &config, std::ostream &out, const QString &filename="data stream")
Write config data to a std::ostream. This potentially changes the return values of error() and status...
void advance()
Advance iterator to next entry.