mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-24 22:24:44 +02:00
parent
2052edff9f
commit
3b70bab4d7
@ -73,8 +73,8 @@ public:
|
|||||||
static void EmitFunctionCall(std::ostream& fp, const String& name, const Array::Ptr& arguments);
|
static void EmitFunctionCall(std::ostream& fp, const String& name, const Array::Ptr& arguments);
|
||||||
|
|
||||||
static const std::vector<String>& GetKeywords(void);
|
static const std::vector<String>& GetKeywords(void);
|
||||||
static String EscapeIcingaString(const String& str);
|
|
||||||
private:
|
private:
|
||||||
|
static String EscapeIcingaString(const String& str);
|
||||||
ConfigWriter(void);
|
ConfigWriter(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -670,7 +670,7 @@ void RepositoryUtility::FormatChangelogEntry(std::ostream& fp, const Dictionary:
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
fp << std::setw(4) << " " << ConsoleColorTag(Console_ForegroundGreen) << kv.first << ConsoleColorTag(Console_Normal) << " = ";
|
fp << std::setw(4) << " " << ConsoleColorTag(Console_ForegroundGreen) << kv.first << ConsoleColorTag(Console_Normal) << " = ";
|
||||||
FormatValue(fp, kv.second);
|
ConfigWriter::EmitValue(fp, 0, kv.second);
|
||||||
fp << "\n";
|
fp << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -681,7 +681,9 @@ void RepositoryUtility::FormatChangelogEntry(std::ostream& fp, const Dictionary:
|
|||||||
*/
|
*/
|
||||||
void RepositoryUtility::SerializeObject(std::ostream& fp, const String& name, const String& type, const Dictionary::Ptr& object)
|
void RepositoryUtility::SerializeObject(std::ostream& fp, const String& name, const String& type, const Dictionary::Ptr& object)
|
||||||
{
|
{
|
||||||
fp << "object " << type << " \"" << ConfigWriter::EscapeIcingaString(name) << "\" {\n";
|
fp << "object " << type << " ";
|
||||||
|
ConfigWriter::EmitString(fp, name);
|
||||||
|
fp << " {\n";
|
||||||
|
|
||||||
if (!object) {
|
if (!object) {
|
||||||
fp << "}\n";
|
fp << "}\n";
|
||||||
@ -693,7 +695,9 @@ void RepositoryUtility::SerializeObject(std::ostream& fp, const String& name, co
|
|||||||
|
|
||||||
ObjectLock olock(imports);
|
ObjectLock olock(imports);
|
||||||
BOOST_FOREACH(const String& import, imports) {
|
BOOST_FOREACH(const String& import, imports) {
|
||||||
fp << "\t" << "import \"" << import << "\"\n";
|
fp << "\t" << "import ";
|
||||||
|
ConfigWriter::EmitString(fp, import);
|
||||||
|
fp << '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -702,49 +706,12 @@ void RepositoryUtility::SerializeObject(std::ostream& fp, const String& name, co
|
|||||||
if (kv.first == "import" || kv.first == "name" || kv.first == "__name") {
|
if (kv.first == "import" || kv.first == "name" || kv.first == "__name") {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
fp << "\t" << kv.first << " = ";
|
fp << "\t";
|
||||||
FormatValue(fp, kv.second);
|
ConfigWriter::EmitIdentifier(fp, kv.first, true);
|
||||||
|
fp << " = ";
|
||||||
|
ConfigWriter::EmitValue(fp, 1, kv.second);
|
||||||
}
|
}
|
||||||
fp << "\n";
|
fp << "\n";
|
||||||
}
|
}
|
||||||
fp << "}\n";
|
fp << "}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepositoryUtility::FormatValue(std::ostream& fp, const Value& val)
|
|
||||||
{
|
|
||||||
if (val.IsObjectType<Array>()) {
|
|
||||||
FormatArray(fp, val);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (val.IsString()) {
|
|
||||||
fp << "\"" << ConfigWriter::EscapeIcingaString(val) << "\"";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fp << ConfigWriter::EscapeIcingaString(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RepositoryUtility::FormatArray(std::ostream& fp, const Array::Ptr& arr)
|
|
||||||
{
|
|
||||||
bool first = true;
|
|
||||||
|
|
||||||
fp << "[ ";
|
|
||||||
|
|
||||||
if (arr) {
|
|
||||||
ObjectLock olock(arr);
|
|
||||||
BOOST_FOREACH(const Value& value, arr) {
|
|
||||||
if (first)
|
|
||||||
first = false;
|
|
||||||
else
|
|
||||||
fp << ", ";
|
|
||||||
|
|
||||||
FormatValue(fp, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!first)
|
|
||||||
fp << " ";
|
|
||||||
|
|
||||||
fp << "]";
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user