mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-30 09:04:35 +02:00
parent
de847d0b6f
commit
dd77863910
@ -26,7 +26,7 @@ set(base_SOURCES
|
|||||||
application.cpp application.thpp application-version.cpp array.cpp
|
application.cpp application.thpp application-version.cpp array.cpp
|
||||||
array-script.cpp boolean.cpp boolean-script.cpp console.cpp context.cpp
|
array-script.cpp boolean.cpp boolean-script.cpp console.cpp context.cpp
|
||||||
convert.cpp debuginfo.cpp dictionary.cpp dictionary-script.cpp
|
convert.cpp debuginfo.cpp dictionary.cpp dictionary-script.cpp
|
||||||
configobject.cpp configobject.thpp configobject-script.cpp configtype.cpp dependencygraph.cpp
|
configobject.cpp configobject.thpp configobject-script.cpp configtype.cpp configwriter.cpp dependencygraph.cpp
|
||||||
exception.cpp fifo.cpp filelogger.cpp filelogger.thpp initialize.cpp json.cpp
|
exception.cpp fifo.cpp filelogger.cpp filelogger.thpp initialize.cpp json.cpp
|
||||||
json-script.cpp loader.cpp logger.cpp logger.thpp math-script.cpp
|
json-script.cpp loader.cpp logger.cpp logger.thpp math-script.cpp
|
||||||
netstring.cpp networkstream.cpp number.cpp number-script.cpp object.cpp
|
netstring.cpp networkstream.cpp number.cpp number-script.cpp object.cpp
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "base/debug.hpp"
|
#include "base/debug.hpp"
|
||||||
#include "base/primitivetype.hpp"
|
#include "base/primitivetype.hpp"
|
||||||
#include "base/dictionary.hpp"
|
#include "base/dictionary.hpp"
|
||||||
|
#include "base/configwriter.hpp"
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
@ -211,3 +212,10 @@ Array::Ptr Array::Reverse(void) const
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String Array::ToString(void) const
|
||||||
|
{
|
||||||
|
std::ostringstream msgbuf;
|
||||||
|
ConfigWriter::EmitArray(msgbuf, const_cast<Array *>(this));
|
||||||
|
return msgbuf.str();
|
||||||
|
}
|
||||||
|
@ -122,6 +122,8 @@ public:
|
|||||||
|
|
||||||
Array::Ptr Reverse(void) const;
|
Array::Ptr Reverse(void) const;
|
||||||
|
|
||||||
|
virtual String ToString(void) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Value> m_Data; /**< The data for the array. */
|
std::vector<Value> m_Data; /**< The data for the array. */
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "config/configwriter.hpp"
|
#include "base/configwriter.hpp"
|
||||||
#include "config/configcompiler.hpp"
|
#include "config/configcompiler.hpp"
|
||||||
#include "base/exception.hpp"
|
#include "base/exception.hpp"
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
@ -145,7 +145,7 @@ void ConfigWriter::EmitIdentifier(std::ostream& fp, const String& identifier, bo
|
|||||||
{
|
{
|
||||||
static std::set<String> keywords;
|
static std::set<String> keywords;
|
||||||
if (keywords.empty()) {
|
if (keywords.empty()) {
|
||||||
const std::vector<String>& vkeywords = ConfigCompiler::GetKeywords();
|
const std::vector<String>& vkeywords = GetKeywords();
|
||||||
std::copy(vkeywords.begin(), vkeywords.end(), std::inserter(keywords, keywords.begin()));
|
std::copy(vkeywords.begin(), vkeywords.end(), std::inserter(keywords, keywords.begin()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,3 +204,44 @@ String ConfigWriter::EscapeIcingaString(const String& str)
|
|||||||
boost::algorithm::replace_all(result, "\"", "\\\"");
|
boost::algorithm::replace_all(result, "\"", "\\\"");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<String>& ConfigWriter::GetKeywords(void)
|
||||||
|
{
|
||||||
|
static std::vector<String> keywords;
|
||||||
|
|
||||||
|
if (keywords.empty()) {
|
||||||
|
keywords.push_back("object");
|
||||||
|
keywords.push_back("template");
|
||||||
|
keywords.push_back("include");
|
||||||
|
keywords.push_back("include_recursive");
|
||||||
|
keywords.push_back("include_zones");
|
||||||
|
keywords.push_back("library");
|
||||||
|
keywords.push_back("null");
|
||||||
|
keywords.push_back("true");
|
||||||
|
keywords.push_back("false");
|
||||||
|
keywords.push_back("const");
|
||||||
|
keywords.push_back("var");
|
||||||
|
keywords.push_back("this");
|
||||||
|
keywords.push_back("globals");
|
||||||
|
keywords.push_back("locals");
|
||||||
|
keywords.push_back("use");
|
||||||
|
keywords.push_back("ignore_on_error");
|
||||||
|
keywords.push_back("apply");
|
||||||
|
keywords.push_back("to");
|
||||||
|
keywords.push_back("where");
|
||||||
|
keywords.push_back("import");
|
||||||
|
keywords.push_back("assign");
|
||||||
|
keywords.push_back("ignore");
|
||||||
|
keywords.push_back("function");
|
||||||
|
keywords.push_back("return");
|
||||||
|
keywords.push_back("break");
|
||||||
|
keywords.push_back("continue");
|
||||||
|
keywords.push_back("for");
|
||||||
|
keywords.push_back("if");
|
||||||
|
keywords.push_back("else");
|
||||||
|
keywords.push_back("while");
|
||||||
|
keywords.push_back("throw");
|
||||||
|
}
|
||||||
|
|
||||||
|
return keywords;
|
||||||
|
}
|
@ -20,7 +20,6 @@
|
|||||||
#ifndef CONFIGWRITER_H
|
#ifndef CONFIGWRITER_H
|
||||||
#define CONFIGWRITER_H
|
#define CONFIGWRITER_H
|
||||||
|
|
||||||
#include "config/i2-config.hpp"
|
|
||||||
#include "base/object.hpp"
|
#include "base/object.hpp"
|
||||||
#include "base/array.hpp"
|
#include "base/array.hpp"
|
||||||
#include "base/dictionary.hpp"
|
#include "base/dictionary.hpp"
|
||||||
@ -32,9 +31,9 @@ namespace icinga
|
|||||||
/**
|
/**
|
||||||
* A configuration writer.
|
* A configuration writer.
|
||||||
*
|
*
|
||||||
* @ingroup config
|
* @ingroup base
|
||||||
*/
|
*/
|
||||||
class I2_CONFIG_API ConfigWriter
|
class I2_BASE_API ConfigWriter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void EmitBoolean(std::ostream& fp, bool val);
|
static void EmitBoolean(std::ostream& fp, bool val);
|
||||||
@ -56,6 +55,7 @@ public:
|
|||||||
static void EmitComment(std::ostream& fp, const String& text);
|
static void EmitComment(std::ostream& fp, const String& text);
|
||||||
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);
|
||||||
private:
|
private:
|
||||||
ConfigWriter(void);
|
ConfigWriter(void);
|
||||||
|
|
@ -21,6 +21,7 @@
|
|||||||
#include "base/objectlock.hpp"
|
#include "base/objectlock.hpp"
|
||||||
#include "base/debug.hpp"
|
#include "base/debug.hpp"
|
||||||
#include "base/primitivetype.hpp"
|
#include "base/primitivetype.hpp"
|
||||||
|
#include "base/configwriter.hpp"
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
@ -198,3 +199,10 @@ std::vector<String> Dictionary::GetKeys(void) const
|
|||||||
|
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String Dictionary::ToString(void) const
|
||||||
|
{
|
||||||
|
std::ostringstream msgbuf;
|
||||||
|
ConfigWriter::EmitScope(msgbuf, 0, const_cast<Dictionary *>(this));
|
||||||
|
return msgbuf.str();
|
||||||
|
}
|
||||||
|
@ -115,6 +115,8 @@ public:
|
|||||||
|
|
||||||
virtual Object::Ptr Clone(void) const override;
|
virtual Object::Ptr Clone(void) const override;
|
||||||
|
|
||||||
|
virtual String ToString(void) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<String, Value> m_Data; /**< The data for the dictionary. */
|
std::map<String, Value> m_Data; /**< The data for the dictionary. */
|
||||||
};
|
};
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "cli/consolecommand.hpp"
|
#include "cli/consolecommand.hpp"
|
||||||
#include "config/configcompiler.hpp"
|
#include "config/configcompiler.hpp"
|
||||||
|
#include "base/configwriter.hpp"
|
||||||
#include "base/json.hpp"
|
#include "base/json.hpp"
|
||||||
#include "base/console.hpp"
|
#include "base/console.hpp"
|
||||||
#include "base/application.hpp"
|
#include "base/application.hpp"
|
||||||
@ -80,7 +81,7 @@ static char *ConsoleCompleteHelper(const char *word, int state)
|
|||||||
if (state == 0) {
|
if (state == 0) {
|
||||||
matches.clear();
|
matches.clear();
|
||||||
|
|
||||||
BOOST_FOREACH(const String& keyword, ConfigCompiler::GetKeywords()) {
|
BOOST_FOREACH(const String& keyword, ConfigWriter::GetKeywords()) {
|
||||||
AddSuggestion(matches, word, keyword);
|
AddSuggestion(matches, word, keyword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,6 @@ set(config_SOURCES
|
|||||||
applyrule.cpp
|
applyrule.cpp
|
||||||
configcompilercontext.cpp configcompiler.cpp configitembuilder.cpp
|
configcompilercontext.cpp configcompiler.cpp configitembuilder.cpp
|
||||||
configitem.cpp ${FLEX_config_lexer_OUTPUTS} ${BISON_config_parser_OUTPUTS}
|
configitem.cpp ${FLEX_config_lexer_OUTPUTS} ${BISON_config_parser_OUTPUTS}
|
||||||
configwriter.cpp
|
|
||||||
expression.cpp objectrule.cpp
|
expression.cpp objectrule.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -320,43 +320,3 @@ void ConfigCompiler::RegisterZoneDir(const String& tag, const String& ppath, con
|
|||||||
m_ZoneDirs[zoneName].push_back(zf);
|
m_ZoneDirs[zoneName].push_back(zf);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<String>& ConfigCompiler::GetKeywords(void)
|
|
||||||
{
|
|
||||||
static std::vector<String> keywords;
|
|
||||||
|
|
||||||
if (keywords.empty()) {
|
|
||||||
keywords.push_back("object");
|
|
||||||
keywords.push_back("template");
|
|
||||||
keywords.push_back("include");
|
|
||||||
keywords.push_back("include_recursive");
|
|
||||||
keywords.push_back("include_zones");
|
|
||||||
keywords.push_back("library");
|
|
||||||
keywords.push_back("null");
|
|
||||||
keywords.push_back("true");
|
|
||||||
keywords.push_back("false");
|
|
||||||
keywords.push_back("const");
|
|
||||||
keywords.push_back("var");
|
|
||||||
keywords.push_back("this");
|
|
||||||
keywords.push_back("globals");
|
|
||||||
keywords.push_back("locals");
|
|
||||||
keywords.push_back("use");
|
|
||||||
keywords.push_back("ignore_on_error");
|
|
||||||
keywords.push_back("apply");
|
|
||||||
keywords.push_back("to");
|
|
||||||
keywords.push_back("where");
|
|
||||||
keywords.push_back("import");
|
|
||||||
keywords.push_back("assign");
|
|
||||||
keywords.push_back("ignore");
|
|
||||||
keywords.push_back("function");
|
|
||||||
keywords.push_back("return");
|
|
||||||
keywords.push_back("break");
|
|
||||||
keywords.push_back("continue");
|
|
||||||
keywords.push_back("for");
|
|
||||||
keywords.push_back("if");
|
|
||||||
keywords.push_back("else");
|
|
||||||
keywords.push_back("while");
|
|
||||||
keywords.push_back("throw");
|
|
||||||
}
|
|
||||||
|
|
||||||
return keywords;
|
|
||||||
}
|
|
||||||
|
@ -118,8 +118,6 @@ public:
|
|||||||
static std::vector<ZoneFragment> GetZoneDirs(const String& zone);
|
static std::vector<ZoneFragment> GetZoneDirs(const String& zone);
|
||||||
static void RegisterZoneDir(const String& tag, const String& ppath, const String& zoneName);
|
static void RegisterZoneDir(const String& tag, const String& ppath, const String& zoneName);
|
||||||
|
|
||||||
static const std::vector<String>& GetKeywords(void);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::promise<boost::shared_ptr<Expression> > m_Promise;
|
boost::promise<boost::shared_ptr<Expression> > m_Promise;
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
#include "icinga/icingaapplication.tcpp"
|
#include "icinga/icingaapplication.tcpp"
|
||||||
#include "icinga/cib.hpp"
|
#include "icinga/cib.hpp"
|
||||||
#include "icinga/macroprocessor.hpp"
|
#include "icinga/macroprocessor.hpp"
|
||||||
#include "config/configwriter.hpp"
|
|
||||||
#include "config/configcompiler.hpp"
|
#include "config/configcompiler.hpp"
|
||||||
|
#include "base/configwriter.hpp"
|
||||||
#include "base/configtype.hpp"
|
#include "base/configtype.hpp"
|
||||||
#include "base/logger.hpp"
|
#include "base/logger.hpp"
|
||||||
#include "base/objectlock.hpp"
|
#include "base/objectlock.hpp"
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "remote/configpackageutility.hpp"
|
#include "remote/configpackageutility.hpp"
|
||||||
#include "config/configcompiler.hpp"
|
#include "config/configcompiler.hpp"
|
||||||
#include "config/configitem.hpp"
|
#include "config/configitem.hpp"
|
||||||
#include "config/configwriter.hpp"
|
#include "base/configwriter.hpp"
|
||||||
#include "base/exception.hpp"
|
#include "base/exception.hpp"
|
||||||
#include "base/serializer.hpp"
|
#include "base/serializer.hpp"
|
||||||
#include "base/dependencygraph.hpp"
|
#include "base/dependencygraph.hpp"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user