mirror of https://github.com/Icinga/icinga2.git
parent
abce99daff
commit
2052edff9f
|
@ -73,10 +73,9 @@ 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:
|
||||||
ConfigWriter(void);
|
ConfigWriter(void);
|
||||||
|
|
||||||
static String EscapeIcingaString(const String& str);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "base/logger.hpp"
|
#include "base/logger.hpp"
|
||||||
#include "base/application.hpp"
|
#include "base/application.hpp"
|
||||||
#include "base/convert.hpp"
|
#include "base/convert.hpp"
|
||||||
|
#include "base/configwriter.hpp"
|
||||||
#include "base/scriptglobal.hpp"
|
#include "base/scriptglobal.hpp"
|
||||||
#include "base/json.hpp"
|
#include "base/json.hpp"
|
||||||
#include "base/netstring.hpp"
|
#include "base/netstring.hpp"
|
||||||
|
@ -680,7 +681,7 @@ 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 << " \"" << EscapeIcingaString(name) << "\" {\n";
|
fp << "object " << type << " \"" << ConfigWriter::EscapeIcingaString(name) << "\" {\n";
|
||||||
|
|
||||||
if (!object) {
|
if (!object) {
|
||||||
fp << "}\n";
|
fp << "}\n";
|
||||||
|
@ -709,19 +710,6 @@ void RepositoryUtility::SerializeObject(std::ostream& fp, const String& name, co
|
||||||
fp << "}\n";
|
fp << "}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
String RepositoryUtility::EscapeIcingaString(const String& str)
|
|
||||||
{
|
|
||||||
String result = str;
|
|
||||||
boost::algorithm::replace_all(result, "\\", "\\\\");
|
|
||||||
boost::algorithm::replace_all(result, "\n", "\\n");
|
|
||||||
boost::algorithm::replace_all(result, "\t", "\\t");
|
|
||||||
boost::algorithm::replace_all(result, "\r", "\\r");
|
|
||||||
boost::algorithm::replace_all(result, "\b", "\\b");
|
|
||||||
boost::algorithm::replace_all(result, "\f", "\\f");
|
|
||||||
boost::algorithm::replace_all(result, "\"", "\\\"");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RepositoryUtility::FormatValue(std::ostream& fp, const Value& val)
|
void RepositoryUtility::FormatValue(std::ostream& fp, const Value& val)
|
||||||
{
|
{
|
||||||
if (val.IsObjectType<Array>()) {
|
if (val.IsObjectType<Array>()) {
|
||||||
|
@ -730,11 +718,11 @@ void RepositoryUtility::FormatValue(std::ostream& fp, const Value& val)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val.IsString()) {
|
if (val.IsString()) {
|
||||||
fp << "\"" << EscapeIcingaString(val) << "\"";
|
fp << "\"" << ConfigWriter::EscapeIcingaString(val) << "\"";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp << EscapeIcingaString(val);
|
fp << ConfigWriter::EscapeIcingaString(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepositoryUtility::FormatArray(std::ostream& fp, const Array::Ptr& arr)
|
void RepositoryUtility::FormatArray(std::ostream& fp, const Array::Ptr& arr)
|
||||||
|
|
|
@ -96,7 +96,6 @@ private:
|
||||||
|
|
||||||
/* config print helpers */
|
/* config print helpers */
|
||||||
static void SerializeObject(std::ostream& fp, const String& name, const String& type, const Dictionary::Ptr& object);
|
static void SerializeObject(std::ostream& fp, const String& name, const String& type, const Dictionary::Ptr& object);
|
||||||
static String EscapeIcingaString(const String& str);
|
|
||||||
static void FormatValue(std::ostream& fp, const Value& val);
|
static void FormatValue(std::ostream& fp, const Value& val);
|
||||||
static void FormatArray(std::ostream& fp, const Array::Ptr& arr);
|
static void FormatArray(std::ostream& fp, const Array::Ptr& arr);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue