1 /******************************************************************************
3 * Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
20 #ifndef CONFIGWRITER_H
21 #define CONFIGWRITER_H
23 #include "base/object.hpp"
24 #include "base/array.hpp"
25 #include "base/dictionary.hpp"
32 * A config identifier.
36 class ConfigIdentifier final : public Object
39 DECLARE_PTR_TYPEDEFS(ConfigIdentifier);
41 ConfigIdentifier(String name);
43 String GetName() const;
50 * A configuration writer.
57 static void EmitBoolean(std::ostream& fp, bool val);
58 static void EmitNumber(std::ostream& fp, double val);
59 static void EmitString(std::ostream& fp, const String& val);
60 static void EmitEmpty(std::ostream& fp);
61 static void EmitArray(std::ostream& fp, int indentLevel, const Array::Ptr& val);
62 static void EmitArrayItems(std::ostream& fp, int indentLevel, const Array::Ptr& val);
63 static void EmitScope(std::ostream& fp, int indentLevel, const Dictionary::Ptr& val,
64 const Array::Ptr& imports = nullptr, bool splitDot = false);
65 static void EmitValue(std::ostream& fp, int indentLevel, const Value& val);
66 static void EmitRaw(std::ostream& fp, const String& val);
67 static void EmitIndent(std::ostream& fp, int indentLevel);
69 static void EmitIdentifier(std::ostream& fp, const String& identifier, bool inAssignment);
70 static void EmitConfigItem(std::ostream& fp, const String& type, const String& name, bool isTemplate,
71 bool ignoreOnError, const Array::Ptr& imports, const Dictionary::Ptr& attrs);
73 static void EmitComment(std::ostream& fp, const String& text);
74 static void EmitFunctionCall(std::ostream& fp, const String& name, const Array::Ptr& arguments);
76 static const std::vector<String>& GetKeywords();
78 static String EscapeIcingaString(const String& str);
84 #endif /* CONFIGWRITER_H */