From 0e03940802cebefdf6b0597a154bd9395e1af4d2 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Wed, 18 Jun 2014 15:45:45 +0200 Subject: Add the vanilla version of the project This version can still be found here: http://www.roland-riegel.de/nload/index.html --- src/settingfilter.h | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 src/settingfilter.h (limited to 'src/settingfilter.h') diff --git a/src/settingfilter.h b/src/settingfilter.h new file mode 100644 index 0000000..c306667 --- /dev/null +++ b/src/settingfilter.h @@ -0,0 +1,128 @@ +/*************************************************************************** + settingfilter.h + ------------------- + begin : Wed Nov 28 2007 + copyright : (C) 2007 - 2012 by Roland Riegel + email : feedback@roland-riegel.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef SETTINGFILTER_H +#define SETTINGFILTER_H + +#include +#include + +class SettingFilter +{ + public: + virtual ~SettingFilter() {} + + virtual std::string getId() const = 0; + + virtual bool filterWrite(std::string& valueNew) = 0; + virtual void filterRead(std::string& value) = 0; +}; + +class SettingFilterDefault : public SettingFilter +{ + public: + SettingFilterDefault(const std::string& def); + ~SettingFilterDefault(); + + std::string getId() const; + + void setDefault(const std::string& def); + const std::string& getDefault() const; + + bool filterWrite(std::string& valueNew); + void filterRead(std::string& value); + + private: + std::string m_default; +}; + +class SettingFilterExclusive : public SettingFilter +{ + public: + SettingFilterExclusive(const std::string& exclusive); + ~SettingFilterExclusive(); + + std::string getId() const; + + void setExclusive(const std::string& exclusive); + const std::string& getExclusive() const; + + bool filterWrite(std::string& valueNew); + void filterRead(std::string& value); + + private: + void substituteExclusive(std::string& value); + + std::string m_exclusive; +}; + +class SettingFilterMap : public SettingFilter +{ + public: + SettingFilterMap(const std::map& filterMap); + ~SettingFilterMap(); + + std::string getId() const; + + void setMap(const std::map& filterMap); + const std::map& getMap() const; + + bool filterWrite(std::string& valueNew); + void filterRead(std::string& value); + + private: + std::map m_filterMap; +}; + +class SettingFilterMin : public SettingFilter +{ + public: + SettingFilterMin(int min); + ~SettingFilterMin(); + + std::string getId() const; + + void setMin(int min); + int getMin() const; + + bool filterWrite(std::string& valueNew); + void filterRead(std::string& value); + + private: + int m_min; +}; + +class SettingFilterMax : public SettingFilter +{ + public: + SettingFilterMax(int max); + ~SettingFilterMax(); + + std::string getId() const; + + void setMax(int max); + int getMax() const; + + bool filterWrite(std::string& valueNew); + void filterRead(std::string& value); + + private: + int m_max; +}; + +#endif + -- cgit v1.2.3