/* * ConfigEntry.h * * Copyright (C) 2008 Matthias Schiffer * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the * Free Software Foundation, either version 3 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along * with this program. If not, see . */ #ifndef MAD_CORE_CONFIGENTRY_H_ #define MAD_CORE_CONFIGENTRY_H_ #include "export.h" #include "String.h" #include #include #include namespace Mad { namespace Core { class ConfigManager; class MAD_CORE_EXPORT ConfigEntry { private: friend class ConfigManager; typedef std::vector > EntryVector; typedef std::map EntryMap; ConfigEntry *parent; std::vector values; EntryMap children; protected: ConfigEntry() : parent(0) {} public: ConfigEntry(ConfigEntry *parent0, const std::vector &values0) : parent(parent0), values(values0) {} void addChild(const String &key, boost::shared_ptr entry); const ConfigEntry* getParent() const { return parent; } ConfigEntry* getParent() { return parent; } const std::vector& getValues() const { return values; } String getValue(const String &defaultValue = String()) const { if(values.empty()) return defaultValue; else return values.front(); } const ConfigEntry* getEntry(const String &key) const; std::vector getEntries(const String &key) const; std::vector getAll(const String &key) const; String get(const String &key, const String &defaultValue = String()) const; }; } } #endif /* MAD_CORE_CONFIGENTRY_H_ */