/* * 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 namespace Mad { namespace Core { class MAD_CORE_EXPORT ConfigEntry { public: class MAD_CORE_EXPORT Entry { private: String key; std::vector value; String zero, constZero; public: Entry() {} Entry(const std::vector &args) { if(args.empty()) return; key = args.front(); value.assign(args.begin()+1, args.end()); } bool isEmpty() const { return key.isEmpty(); } String &getKey() {return key;} const String &getKey() const {return key;} std::size_t getSize() const {return value.size();} String& operator[] (std::size_t i); const String& operator[] (std::size_t i) const; }; private: std::vector entries; Entry zero, constZero; public: std::size_t getSize() const {return entries.size();} Entry& operator[] (std::size_t i); const Entry& operator[] (std::size_t i) const; void push(const Entry &entry) { entries.push_back(entry); } void pop() { entries.pop_back(); } }; } } #endif /* MAD_CORE_CONFIGENTRY_H_ */