Mercurial > ~dholland > hg > ag > index.cgi
view anagram/agcore/configparam.h @ 14:a02e9434072e
Fix friend declaration for gcc10.
XXX: did not check it against the IBM compiler, might end up needing
XXX: to be conditional.
author | David A. Holland |
---|---|
date | Tue, 31 May 2022 00:59:42 -0400 |
parents | 13d2b8934445 |
children |
line wrap: on
line source
/* * AnaGram, A System for Syntax Directed Programming * Copyright 1993-2002 Parsifal Software. All Rights Reserved. * See the file COPYING for license and usage terms. * * configparam.h - configuration parameter mechanism */ #ifndef CONFIGPARAM_H #define CONFIGPARAM_H class ConfigParam { public: class ErrorHandler { public: ErrorHandler() {} virtual ~ErrorHandler() {} virtual void badParam(const char *) = 0; }; const char *name; ConfigParam(const char *n); virtual ~ConfigParam() {} virtual void setIntegerValue(const int, ErrorHandler &); virtual void setStringValue(const AgString, ErrorHandler &); virtual void init() {} virtual void reset() = 0; virtual AgString asString() = 0; static ConfigParam *table[]; static int paramCount; static void initAll(); static void resetAll(); static void set(int, ErrorHandler &); static void set(ErrorHandler &); }; template <class T> class Param : public ConfigParam { protected: T ¶meter; T defaultValue; public: Param(const char *, T &); virtual void init(); void reset(); }; template <class T> void Param<T>::init() { defaultValue = parameter; } template <class T> Param<T>::Param(const char *n, T &p) : ConfigParam(n), parameter(p), defaultValue(p) {} template <class T> void Param<T>::reset() { parameter = defaultValue; } class IntegerParam : public Param<int> { public: IntegerParam(const char *n, int &p) : Param<int>(n, p) {} virtual void setIntegerValue(const int, ErrorHandler &); virtual AgString asString(); }; class StringParam : public Param<AgString> { public: StringParam(const char *n, AgString &p) : Param<AgString>(n, p) {} virtual void setStringValue(const AgString, ErrorHandler &); virtual AgString asString(); }; class ConfigSwitch : public Param<int> { public: ConfigSwitch(const char *n, int &p) : Param<int>(n, p) {} virtual void setIntegerValue(const int, ErrorHandler &); virtual void setStringValue(const AgString, ErrorHandler &); virtual AgString asString(); }; class TextParam : public Param<AgString> { public: TextParam(const char *n, AgString &p) : Param<AgString>(n, p) {} virtual void setStringValue(const AgString, ErrorHandler &); virtual AgString asString(); }; class CastParam : public Param<int> { public: CastParam(const char *, int &); virtual void setStringValue(const AgString, ErrorHandler &e); virtual AgString asString(); }; class TokenParam : public Param<int> { public: TokenParam(const char *, int &); virtual void setStringValue(const AgString, ErrorHandler &e); virtual AgString asString(); }; #endif /* CONFIGPARAM_H */