-/******************************************************************************\r
- * Icinga 2 *\r
- * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *\r
- * *\r
- * This program is free software; you can redistribute it and/or *\r
- * modify it under the terms of the GNU General Public License *\r
- * as published by the Free Software Foundation; either version 2 *\r
- * of the License, or (at your option) any later version. *\r
- * *\r
- * This program is distributed in the hope that it will be useful, *\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *\r
- * GNU General Public License for more details. *\r
- * *\r
- * You should have received a copy of the GNU General Public License *\r
- * along with this program; if not, write to the Free Software Foundation *\r
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *\r
- ******************************************************************************/\r
-\r
-#include "config/typerulelist.hpp"\r
-#include "config/typerule.hpp"\r
-#include <boost/foreach.hpp>\r
-\r
-using namespace icinga;\r
-\r
-/**\r
- * Sets the validator method for a rule list.\r
- *\r
- * @param validator The validator.\r
- */\r
-void TypeRuleList::SetValidator(const String& validator)\r
-{\r
- m_Validator = validator;\r
-}\r
-\r
-/**\r
- * Retrieves the validator method.\r
- *\r
- * @returns The validator method.\r
- */\r
-String TypeRuleList::GetValidator(void) const\r
-{\r
- return m_Validator;\r
-}\r
-\r
-/**\r
- * Adds an attribute to the list of required attributes.\r
- *\r
- * @param attr The new required attribute.\r
- */\r
-void TypeRuleList::AddRequire(const String& attr)\r
-{\r
- m_Requires.push_back(attr);\r
-}\r
-\r
-/**\r
- * Retrieves the list of required attributes.\r
- *\r
- * @returns The list of required attributes.\r
- */\r
-std::vector<String> TypeRuleList::GetRequires(void) const\r
-{\r
- return m_Requires;\r
-}\r
-\r
-/**\r
- * Adds all requires from the specified rule list.\r
- *\r
- * @param ruleList The rule list to copy requires from.\r
- */\r
-void TypeRuleList::AddRequires(const TypeRuleList::Ptr& ruleList)\r
-{\r
- BOOST_FOREACH(const String& require, ruleList->m_Requires) {\r
- AddRequire(require);\r
- }\r
-}\r
-\r
-/**\r
- * Adds a rule to a rule list.\r
- *\r
- * @param rule The rule that should be added.\r
- */\r
-void TypeRuleList::AddRule(const TypeRule& rule)\r
-{\r
- m_Rules.push_back(rule);\r
-}\r
-\r
-/**\r
- * Adds all rules from the specified rule list.\r
- *\r
- * @param ruleList The rule list to copy rules from.\r
- */\r
-void TypeRuleList::AddRules(const TypeRuleList::Ptr& ruleList)\r
-{\r
- BOOST_FOREACH(const TypeRule& rule, ruleList->m_Rules) {\r
- AddRule(rule);\r
- }\r
-}\r
-\r
-/**\r
- * Returns the number of rules currently contained in the list.\r
- *\r
- * @returns The length of the list.\r
- */\r
-size_t TypeRuleList::GetLength(void) const\r
-{\r
- return m_Rules.size();\r
-}\r
-\r
-/**\r
- * Validates a field.\r
- *\r
- * @param name The name of the attribute.\r
- * @param value The value of the attribute.\r
- * @param[out] subRules The list of sub-rules for the matching rule.\r
- * @param[out] hint A hint describing the validation failure.\r
- * @returns The validation result.\r
- */\r
-TypeValidationResult TypeRuleList::ValidateAttribute(const String& name,\r
- const Value& value, TypeRuleList::Ptr *subRules, String *hint,\r
- const TypeRuleUtilities *utils) const\r
-{\r
- bool foundField = false;\r
- BOOST_FOREACH(const TypeRule& rule, m_Rules) {\r
- if (!rule.MatchName(name))\r
- continue;\r
-\r
- foundField = true;\r
-\r
- if (rule.MatchValue(value, hint, utils)) {\r
- *subRules = rule.GetSubRules();\r
- return ValidationOK;\r
- }\r
- }\r
-\r
- if (foundField)\r
- return ValidationInvalidType;\r
- else\r
- return ValidationUnknownField;\r
-}\r
+/******************************************************************************
+ * Icinga 2 *
+ * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
+ * *
+ * 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. *
+ ******************************************************************************/
+
+#include "config/typerulelist.hpp"
+#include "config/typerule.hpp"
+#include <boost/foreach.hpp>
+
+using namespace icinga;
+
+/**
+ * Adds a validator method for a rule list.
+ *
+ * @param validator The validator.
+ */
+void TypeRuleList::AddValidator(const String& validator)
+{
+ m_Validators.push_back(validator);
+}
+
+/**
+ * Retrieves the validator methods.
+ *
+ * @returns The validator methods.
+ */
+std::vector<String> TypeRuleList::GetValidators(void) const
+{
+ return m_Validators;
+}
+
+/**
+ * Adds an attribute to the list of required attributes.
+ *
+ * @param attr The new required attribute.
+ */
+void TypeRuleList::AddRequire(const String& attr)
+{
+ m_Requires.push_back(attr);
+}
+
+/**
+ * Retrieves the list of required attributes.
+ *
+ * @returns The list of required attributes.
+ */
+std::vector<String> TypeRuleList::GetRequires(void) const
+{
+ return m_Requires;
+}
+
+/**
+ * Adds all requires from the specified rule list.
+ *
+ * @param ruleList The rule list to copy requires from.
+ */
+void TypeRuleList::AddRequires(const TypeRuleList::Ptr& ruleList)
+{
+ BOOST_FOREACH(const String& require, ruleList->m_Requires) {
+ AddRequire(require);
+ }
+}
+
+/**
+ * Adds a rule to a rule list.
+ *
+ * @param rule The rule that should be added.
+ */
+void TypeRuleList::AddRule(const TypeRule& rule)
+{
+ m_Rules.push_back(rule);
+}
+
+/**
+ * Adds all rules from the specified rule list.
+ *
+ * @param ruleList The rule list to copy rules from.
+ */
+void TypeRuleList::AddRules(const TypeRuleList::Ptr& ruleList)
+{
+ BOOST_FOREACH(const TypeRule& rule, ruleList->m_Rules) {
+ AddRule(rule);
+ }
+}
+
+/**
+ * Returns the number of rules currently contained in the list.
+ *
+ * @returns The length of the list.
+ */
+size_t TypeRuleList::GetLength(void) const
+{
+ return m_Rules.size();
+}
+
+/**
+ * Validates a field.
+ *
+ * @param name The name of the attribute.
+ * @param value The value of the attribute.
+ * @param[out] subRules The list of sub-rules for the matching rule.
+ * @param[out] hint A hint describing the validation failure.
+ * @returns The validation result.
+ */
+TypeValidationResult TypeRuleList::ValidateAttribute(const String& name,
+ const Value& value, TypeRuleList::Ptr *subRules, String *hint,
+ const TypeRuleUtilities *utils) const
+{
+ bool foundField = false;
+ BOOST_FOREACH(const TypeRule& rule, m_Rules) {
+ if (!rule.MatchName(name))
+ continue;
+
+ foundField = true;
+
+ if (rule.MatchValue(value, hint, utils)) {
+ *subRules = rule.GetSubRules();
+ return ValidationOK;
+ }
+ }
+
+ if (foundField)
+ return ValidationInvalidType;
+ else
+ return ValidationUnknownField;
+}
-/******************************************************************************\r
- * Icinga 2 *\r
- * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *\r
- * *\r
- * This program is free software; you can redistribute it and/or *\r
- * modify it under the terms of the GNU General Public License *\r
- * as published by the Free Software Foundation; either version 2 *\r
- * of the License, or (at your option) any later version. *\r
- * *\r
- * This program is distributed in the hope that it will be useful, *\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *\r
- * GNU General Public License for more details. *\r
- * *\r
- * You should have received a copy of the GNU General Public License *\r
- * along with this program; if not, write to the Free Software Foundation *\r
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *\r
- ******************************************************************************/\r
-\r
-#ifndef TYPERULELIST_H\r
-#define TYPERULELIST_H\r
-\r
-#include "config/i2-config.hpp"\r
-#include "base/value.hpp"\r
-#include <vector>\r
-\r
-namespace icinga\r
-{\r
-\r
-struct TypeRule;\r
-class TypeRuleUtilities;\r
-\r
-/**\r
- * @ingroup config\r
- */\r
-enum TypeValidationResult\r
-{\r
- ValidationOK,\r
- ValidationInvalidType,\r
- ValidationUnknownField\r
-};\r
-\r
-/**\r
- * A list of configuration type rules.\r
- *\r
- * @ingroup config\r
- */\r
-class I2_CONFIG_API TypeRuleList : public Object\r
-{\r
-public:\r
- DECLARE_PTR_TYPEDEFS(TypeRuleList);\r
-\r
- void SetValidator(const String& validator);\r
- String GetValidator(void) const;\r
-\r
- void AddRequire(const String& attr);\r
- void AddRequires(const TypeRuleList::Ptr& ruleList);\r
- std::vector<String> GetRequires(void) const;\r
-\r
- void AddRule(const TypeRule& rule);\r
- void AddRules(const TypeRuleList::Ptr& ruleList);\r
-\r
- TypeValidationResult ValidateAttribute(const String& name, const Value& value,\r
- TypeRuleList::Ptr *subRules, String *hint, const TypeRuleUtilities *utils) const;\r
-\r
- size_t GetLength(void) const;\r
-\r
-private:\r
- String m_Validator;\r
- std::vector<String> m_Requires;\r
- std::vector<TypeRule> m_Rules;\r
-};\r
-\r
-}\r
-\r
-#endif /* TYPERULELIST_H */\r
+/******************************************************************************
+ * Icinga 2 *
+ * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
+ * *
+ * 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. *
+ ******************************************************************************/
+
+#ifndef TYPERULELIST_H
+#define TYPERULELIST_H
+
+#include "config/i2-config.hpp"
+#include "base/value.hpp"
+#include <vector>
+
+namespace icinga
+{
+
+struct TypeRule;
+class TypeRuleUtilities;
+
+/**
+ * @ingroup config
+ */
+enum TypeValidationResult
+{
+ ValidationOK,
+ ValidationInvalidType,
+ ValidationUnknownField
+};
+
+/**
+ * A list of configuration type rules.
+ *
+ * @ingroup config
+ */
+class I2_CONFIG_API TypeRuleList : public Object
+{
+public:
+ DECLARE_PTR_TYPEDEFS(TypeRuleList);
+
+ void AddValidator(const String& validator);
+ std::vector<String> GetValidators(void) const;
+
+ void AddRequire(const String& attr);
+ void AddRequires(const TypeRuleList::Ptr& ruleList);
+ std::vector<String> GetRequires(void) const;
+
+ void AddRule(const TypeRule& rule);
+ void AddRules(const TypeRuleList::Ptr& ruleList);
+
+ TypeValidationResult ValidateAttribute(const String& name, const Value& value,
+ TypeRuleList::Ptr *subRules, String *hint, const TypeRuleUtilities *utils) const;
+
+ size_t GetLength(void) const;
+
+private:
+ std::vector<String> m_Validators;
+ std::vector<String> m_Requires;
+ std::vector<TypeRule> m_Rules;
+};
+
+}
+
+#endif /* TYPERULELIST_H */