-/******************************************************************************
- * Icinga 2 *
- * Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/) *
- * *
- * This program is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU General Public License *
- * as published by the Free Software Foundation; either version 2 *
- * of the License, or (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software Foundation *
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
- ******************************************************************************/
+/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
#include "config/configcompiler.hpp"
#include "config/configitem.hpp"
* @param input Input stream for the configuration file.
* @param zone The zone.
*/
-ConfigCompiler::ConfigCompiler(const String& path, std::istream *input,
- const String& zone, const String& package)
- : m_Path(path), m_Input(input), m_Zone(zone), m_Package(package),
- m_Eof(false), m_OpenBraces(0)
+ConfigCompiler::ConfigCompiler(String path, std::istream *input,
+ String zone, String package)
+ : m_Path(std::move(path)), m_Input(input), m_Zone(std::move(zone)),
+ m_Package(std::move(package)), m_Eof(false), m_OpenBraces(0)
{
InitializeScanner();
}
/**
* Destructor for the ConfigCompiler class.
*/
-ConfigCompiler::~ConfigCompiler(void)
+ConfigCompiler::~ConfigCompiler()
{
DestroyScanner();
}
*
* @returns The scanner object.
*/
-void *ConfigCompiler::GetScanner(void) const
+void *ConfigCompiler::GetScanner() const
{
return m_Scanner;
}
*
* @returns The path.
*/
-const char *ConfigCompiler::GetPath(void) const
+const char *ConfigCompiler::GetPath() const
{
return m_Path.CStr();
}
m_Zone = zone;
}
-String ConfigCompiler::GetZone(void) const
+String ConfigCompiler::GetZone() const
{
return m_Zone;
}
m_Package = package;
}
-String ConfigCompiler::GetPackage(void) const
+String ConfigCompiler::GetPackage() const
{
return m_Package;
}
if (!empty) {
std::vector<String> paths;
+ paths.reserve(zoneDirs.size());
+
for (const ZoneFragment& zf : zoneDirs) {
paths.push_back(zf.Path);
}
#endif /* _WIN32 */
}
+void ConfigCompiler::AddImport(const std::shared_ptr<Expression>& import)
+{
+ m_Imports.push_back(import);
+}
+
+std::vector<std::shared_ptr<Expression> > ConfigCompiler::GetImports() const
+{
+ return m_Imports;
+}