summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/CRSMConfig.hpp74
-rw-r--r--src/ClientInfo.hpp16
-rw-r--r--src/ConfigBase.cpp68
-rw-r--r--src/ConfigBase.hpp96
-rw-r--r--src/crsm.cpp4
-rw-r--r--src/crsm.hpp38
6 files changed, 148 insertions, 148 deletions
diff --git a/src/CRSMConfig.hpp b/src/CRSMConfig.hpp
index 2b75dad..d0f4cf9 100644
--- a/src/CRSMConfig.hpp
+++ b/src/CRSMConfig.hpp
@@ -2,7 +2,7 @@
#include "ConfigBase.hpp"
-class CRSMConfig : public CRSMConfigBase {
+class CRSMConfig : public ConfigBase {
public:
struct {
Port ManagementPort = 9372;
@@ -80,62 +80,62 @@ public:
Integer RereadLimit = 50;
} Readline;
- explicit CRSMConfig() : CRSMConfigBase({
- ConfigValue(CRSM.ManagementPort),
- ConfigValue(CRSM.ListFolder),
- ConfigValue(CRSM.CommandSign),
+ explicit CRSMConfig() : ConfigBase({
+ ConfigVal(CRSM.ManagementPort),
+ ConfigVal(CRSM.ListFolder),
+ ConfigVal(CRSM.CommandSign),
- ConfigValue(Clonk.Server.Arguments),
- ConfigValue(Clonk.Server.Config),
- ConfigValue(Clonk.Server.Executable),
- ConfigValue(Clonk.Server.EmptyTimer),
- ConfigValue(Clonk.Server.IgnoreFolders),
+ ConfigVal(Clonk.Server.Arguments),
+ ConfigVal(Clonk.Server.Config),
+ ConfigVal(Clonk.Server.Executable),
+ ConfigVal(Clonk.Server.EmptyTimer),
+ ConfigVal(Clonk.Server.IgnoreFolders),
- ConfigValue(Clonk.Chat.AntiFlood.Count),
- ConfigValue(Clonk.Chat.AntiFlood.Time),
+ ConfigVal(Clonk.Chat.AntiFlood.Count),
+ ConfigVal(Clonk.Chat.AntiFlood.Time),
- ConfigValue(Clonk.Chat.Moderators),
- ConfigValue(Clonk.Chat.RegainAdminTime),
+ ConfigVal(Clonk.Chat.Moderators),
+ ConfigVal(Clonk.Chat.RegainAdminTime),
- ConfigValue(Hosting.Auto),
- ConfigValue(Hosting.RandomizeAuto),
- ConfigValue(Hosting.MaxWishesPerScen),
- ConfigValue(Hosting.MaxWishesPerUser),
- ConfigValue(Hosting.UserListLength),
- ConfigValue(Hosting.Alias),
+ ConfigVal(Hosting.Auto),
+ ConfigVal(Hosting.RandomizeAuto),
+ ConfigVal(Hosting.MaxWishesPerScen),
+ ConfigVal(Hosting.MaxWishesPerUser),
+ ConfigVal(Hosting.UserListLength),
+ ConfigVal(Hosting.Alias),
- ConfigValue(IRC.Use),
- ConfigValue(IRC.Server),
- ConfigValue(IRC.Nick),
- ConfigValue(IRC.Password),
- ConfigValue(IRC.RealName),
- ConfigValue(IRC.Channel),
- ConfigValue(IRC.UseIngameChat),
- ConfigValue(IRC.IngameChannel),
- ConfigValue(IRC.QuitMessage),
- ConfigValue(IRC.ReconnectDelay),
- ConfigValue(IRC.ScenListMessage),
- ConfigValue(IRC.Moderators),
+ ConfigVal(IRC.Use),
+ ConfigVal(IRC.Server),
+ ConfigVal(IRC.Nick),
+ ConfigVal(IRC.Password),
+ ConfigVal(IRC.RealName),
+ ConfigVal(IRC.Channel),
+ ConfigVal(IRC.UseIngameChat),
+ ConfigVal(IRC.IngameChannel),
+ ConfigVal(IRC.QuitMessage),
+ ConfigVal(IRC.ReconnectDelay),
+ ConfigVal(IRC.ScenListMessage),
+ ConfigVal(IRC.Moderators),
- ConfigValue(Auto.ProcessManager.ReattachId),
+ ConfigVal(Auto.ProcessManager.ReattachId),
- ConfigValue(Auto.Hosting.AliasWishes),
+ ConfigVal(Auto.Hosting.AliasWishes),
- ConfigValue(Readline.ServerUses),
- ConfigValue(Readline.PromptEnabled),
- ConfigValue(Readline.RereadLimit)
+ ConfigVal(Readline.ServerUses),
+ ConfigVal(Readline.PromptEnabled),
+ ConfigVal(Readline.RereadLimit)
}) {}
void clear()
diff --git a/src/ClientInfo.hpp b/src/ClientInfo.hpp
index d223932..1334e71 100644
--- a/src/ClientInfo.hpp
+++ b/src/ClientInfo.hpp
@@ -134,11 +134,11 @@ public:
};
template<>
-class CRSMConfigValue<ClientInfo> : public CRSMConfigValueBase {
+class ConfigValue<ClientInfo> : public ConfigValueBase {
ClientInfo& info;
public:
- CRSMConfigValue(ClientInfo& info) : info(info) {}
+ ConfigValue(ClientInfo& info) : info(info) {}
void setValue(const QString& string)
{
@@ -148,29 +148,29 @@ public:
ClientInterface interface = static_cast<ClientInterface>(parts.first().toUInt(0, 36));
if(interface > ClientInterface::Last || interface < ClientInterface::First)
{
- throw CRSMConfigException("Cannot read ClientInfo with unknown ClientInterface: " + string.toStdString());
+ throw ConfigException("Cannot read ClientInfo with unknown ClientInterface: " + string.toStdString());
}
switch(interface)
{
case Auto: break;
case Clonk:
{
- if(parts.length() != 5) throw CRSMConfigException("Cannot read corrupt ClientInfo with Clonk-ClientInterface: " + string.toStdString());
+ if(parts.length() != 5) throw ConfigException("Cannot read corrupt ClientInfo with Clonk-ClientInterface: " + string.toStdString());
info.pcName = parts.at(1);
info.CUID = parts.at(2).toUInt();
info.nick = parts.at(3);
- info.activated = CRSMConfigValueBase::getValue<bool>(parts.at(4));
+ info.activated = ConfigValueBase::getValue<bool>(parts.at(4));
break;
}
case IRC:
{
- if(parts.length() != 2) throw CRSMConfigException("Cannot read corrupt ClientInfo with IRC-ClientInterface: " + string.toStdString());
+ if(parts.length() != 2) throw ConfigException("Cannot read corrupt ClientInfo with IRC-ClientInterface: " + string.toStdString());
info.nick = parts.at(1);
break;
}
case Management:
{
- if(parts.length() != 2) throw CRSMConfigException("Cannot read corrupt ClientInfo with Management-ClientInterface: " + string.toStdString());
+ if(parts.length() != 2) throw ConfigException("Cannot read corrupt ClientInfo with Management-ClientInterface: " + string.toStdString());
info.management.name = parts.at(1);
break;
}
@@ -186,7 +186,7 @@ public:
switch(info.interface)
{
case Auto: break;
- case Clonk: ret.append(info.pcName); ret.append(QString::number(info.CUID)); ret.append(info.nick); ret.append(CRSMConfigValueBase::getStringValue(info.activated)); break;
+ case Clonk: ret.append(info.pcName); ret.append(QString::number(info.CUID)); ret.append(info.nick); ret.append(ConfigValueBase::getStringValue(info.activated)); break;
case IRC: ret.append(info.nick); break;
case Management: ret.append(info.management.name); break;
}
diff --git a/src/ConfigBase.cpp b/src/ConfigBase.cpp
index ea1f874..d895e80 100644
--- a/src/ConfigBase.cpp
+++ b/src/ConfigBase.cpp
@@ -2,28 +2,28 @@
#include <QFile>
-void CRSMConfigBase::addConfigValue(QString name, CRSMConfigValueBase* value)
+void ConfigBase::addConfigValue(QString name, ConfigValueBase* value)
{
configValues[name] = value;
}
-void CRSMConfigBase::setConfigValue(const QString &name, const QString &value)
+void ConfigBase::setConfigValue(const QString &name, const QString &value)
{
- CRSMConfigValueBase& configValue = getConfigValue(name);
+ ConfigValueBase& configValue = getConfigValue(name);
configValue.setValue(value);
}
-QString CRSMConfigBase::getConfigValueLine(const QString &name)
+QString ConfigBase::getConfigValueLine(const QString &name)
{
if(configValues.contains(name))
{
- CRSMConfigValueBase& value = *configValues[name];
+ ConfigValueBase& value = *configValues[name];
switch(value.type())
{
- case CRSMConfigValueType::Map:
+ case ConfigValueType::Map:
{
QString ret;
- const QMap<QString, QString>& values = (dynamic_cast<CRSMConfigValueMap*>(&value))->getValues();
+ const QMap<QString, QString>& values = (dynamic_cast<ConfigValueMap*>(&value))->getValues();
foreach(const QString& mapKey, values.keys())
{
ret += name + "[" + mapKey + "]" + " = " + values.value(mapKey) + "\n";
@@ -31,10 +31,10 @@ QString CRSMConfigBase::getConfigValueLine(const QString &name)
return ret;
break;
}
- case CRSMConfigValueType::List:
+ case ConfigValueType::List:
{
QString ret;
- foreach(const QString& val, (dynamic_cast<CRSMConfigValueList*>(&value))->getValues())
+ foreach(const QString& val, (dynamic_cast<ConfigValueList*>(&value))->getValues())
{
ret += name + " += " + val + "\n";
}
@@ -47,52 +47,52 @@ QString CRSMConfigBase::getConfigValueLine(const QString &name)
}
else
{
- throw CRSMConfigException("Unknown config value \"" + name.toStdString() + "\"");
+ throw ConfigException("Unknown config value \"" + name.toStdString() + "\"");
}
}
-void CRSMConfigBase::addConfigListEntry(const QString &name, const QString &value)
+void ConfigBase::addConfigListEntry(const QString &name, const QString &value)
{
- CRSMConfigValueBase& configValue = getConfigValue(name);
- if(configValue.type() != CRSMConfigValueType::List)
+ ConfigValueBase& configValue = getConfigValue(name);
+ if(configValue.type() != ConfigValueType::List)
{
- throw CRSMConfigException("Cannot add a list entry to a non-list-config value \"" + name.toStdString() + "\"");
+ throw ConfigException("Cannot add a list entry to a non-list-config value \"" + name.toStdString() + "\"");
}
- ((CRSMConfigValueList*)&configValue)->append(value);
+ ((ConfigValueList*)&configValue)->append(value);
}
-void CRSMConfigBase::removeConfigMapListEntry(const QString &name, const QString &value)
+void ConfigBase::removeConfigMapListEntry(const QString &name, const QString &value)
{
- CRSMConfigValueBase& configValue = getConfigValue(name);
- if(configValue.type() == CRSMConfigValueType::List)
+ ConfigValueBase& configValue = getConfigValue(name);
+ if(configValue.type() == ConfigValueType::List)
{
- ((CRSMConfigValueList*)&configValue)->remove(value);
+ ((ConfigValueList*)&configValue)->remove(value);
}
- else if(configValue.type() == CRSMConfigValueType::Map)
+ else if(configValue.type() == ConfigValueType::Map)
{
- ((CRSMConfigValueMap*)&configValue)->remove(value);
+ ((ConfigValueMap*)&configValue)->remove(value);
}
else
{
- throw CRSMConfigException("Cannot remove a list entry from a value which is neither a list nor a map \"" + name.toStdString() + "\"");
+ throw ConfigException("Cannot remove a list entry from a value which is neither a list nor a map \"" + name.toStdString() + "\"");
}
}
-void CRSMConfigBase::setConfigMapValue(const QString &name, const QString &key, const QString &value)
+void ConfigBase::setConfigMapValue(const QString &name, const QString &key, const QString &value)
{
- CRSMConfigValueBase& configValue = getConfigValue(name);
- if(configValue.type() != CRSMConfigValueType::Map)
+ ConfigValueBase& configValue = getConfigValue(name);
+ if(configValue.type() != ConfigValueType::Map)
{
- throw CRSMConfigException("Cannot set a map value on a non-map-config value \"" + name.toStdString() + "\"");
+ throw ConfigException("Cannot set a map value on a non-map-config value \"" + name.toStdString() + "\"");
}
- ((CRSMConfigValueMap*)&configValue)->setKeyValue(key, value);
+ ((ConfigValueMap*)&configValue)->setKeyValue(key, value);
}
-CRSMConfigValueBase& CRSMConfigBase::getConfigValue(const QString& name)
+ConfigValueBase& ConfigBase::getConfigValue(const QString& name)
{
if(!configValues.contains(name))
{
- throw CRSMConfigException("Unknown config value \"" + name.toStdString() + "\"");
+ throw ConfigException("Unknown config value \"" + name.toStdString() + "\"");
}
else
{
@@ -100,7 +100,7 @@ CRSMConfigValueBase& CRSMConfigBase::getConfigValue(const QString& name)
}
}
-QString CRSMConfigBase::read(const QString &fileName, bool writeDefault)
+QString ConfigBase::read(const QString &fileName, bool writeDefault)
{
QString ret = "";
@@ -133,7 +133,7 @@ QString CRSMConfigBase::read(const QString &fileName, bool writeDefault)
line = config.readLine().trimmed();
setConfigLine(line);
}
- catch(CRSMConfigException e)
+ catch(ConfigException e)
{
ret += fileName + ":" + QString::number(lineNr) + ": " + e.what() + "\n";
}
@@ -147,7 +147,7 @@ QString CRSMConfigBase::read(const QString &fileName, bool writeDefault)
return ret;
}
-bool CRSMConfigBase::write(const QString &fileName)
+bool ConfigBase::write(const QString &fileName)
{
QFile config(fileName);
if(config.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate))
@@ -165,7 +165,7 @@ bool CRSMConfigBase::write(const QString &fileName)
}
}
-void CRSMConfigBase::setConfigLine(const QString &line)
+void ConfigBase::setConfigLine(const QString &line)
{
static QRegExp valueExp(R"(^([^=]+)=(.*)$)");
static QRegExp listExp(R"(^([^=]+)\+=(.*)$)");
@@ -190,6 +190,6 @@ void CRSMConfigBase::setConfigLine(const QString &line)
}
else
{
- throw CRSMConfigException("Syntax error: unkown syntax");
+ throw ConfigException("Syntax error: unkown syntax");
}
}
diff --git a/src/ConfigBase.hpp b/src/ConfigBase.hpp
index 5e2a50f..d25861c 100644
--- a/src/ConfigBase.hpp
+++ b/src/ConfigBase.hpp
@@ -10,9 +10,9 @@
#include <type_traits>
#include <limits>
-using CRSMConfigException = std::logic_error;
+using ConfigException = std::logic_error;
-namespace CRSMConfigValueType {
+namespace ConfigValueType {
enum Type {
None,
String,
@@ -23,12 +23,12 @@ enum Type {
};
}
-class CRSMConfigValueBase {
+class ConfigValueBase {
public:
virtual void setValue(const QString&) { }
virtual QString value() { return ""; }
- virtual CRSMConfigValueType::Type type() { return CRSMConfigValueType::Type::None; }
+ virtual ConfigValueType::Type type() { return ConfigValueType::Type::None; }
@@ -40,12 +40,12 @@ public:
};
template<typename Type, typename = void>
-class CRSMConfigValue : public CRSMConfigValueBase {
+class ConfigValue : public ConfigValueBase {
public:
// CRSMConfigValue(Type&) { }
- virtual void setValue(const QString&) { throw CRSMConfigException("Cannot assign"); }
- virtual QString value() { throw CRSMConfigException("Cannot get the value"); }
+ virtual void setValue(const QString&) { throw ConfigException("Cannot assign"); }
+ virtual QString value() { throw ConfigException("Cannot get the value"); }
};
using String = QString;
@@ -56,16 +56,16 @@ using Boolean = bool;
#define Map(KeyType, ValueType) QMap<KeyType, ValueType>
-#define ConfigValue(Value) {#Value, mkConfigValue(Value)}
-#define ConfigValueEx(Value, ...) {#Value, mkConfigValue(Value, __VA_ARGS__)}
+#define ConfigVal(Value) {#Value, mkConfigValue(Value)}
+#define ConfigValEx(Value, ...) {#Value, mkConfigValue(Value, __VA_ARGS__)}
template<>
-class CRSMConfigValue<String> : public CRSMConfigValueBase {
+class ConfigValue<String> : public ConfigValueBase {
String& config;
bool trimmedQuotes = false;
public:
- CRSMConfigValue(String& config) : config(config) { }
+ ConfigValue(String& config) : config(config) { }
virtual void setValue(const QString& value) { config = trimQuotes(QString(value), trimmedQuotes); }
virtual QString value()
@@ -79,7 +79,7 @@ public:
return config;
}
}
- virtual CRSMConfigValueType::Type type() { return CRSMConfigValueType::Type::String; }
+ virtual ConfigValueType::Type type() { return ConfigValueType::Type::String; }
private:
QString& trimQuotes(QString&& string, bool& trimmed)
@@ -97,30 +97,30 @@ private:
};
template<typename Type>
-class CRSMConfigValue<Type, typename std::enable_if<std::is_integral<Type>::value>::type> : public CRSMConfigValueBase {
+class ConfigValue<Type, typename std::enable_if<std::is_integral<Type>::value>::type> : public ConfigValueBase {
Type& config;
public:
- CRSMConfigValue(Type& config) : config(config) { }
+ ConfigValue(Type& config) : config(config) { }
virtual void setValue(const QString& value)
{
bool ok = true;
long long longLongVal = value.toLongLong(&ok, 0);
- if(!ok) throw CRSMConfigException("\"" + value.toStdString() + "\" could not be parsed as an Integer");
- if(longLongVal < std::numeric_limits<Type>::min() || longLongVal > std::numeric_limits<Type>::max()) throw CRSMConfigException((QString::number(longLongVal) + " is out of range (" + QString::number(std::numeric_limits<Type>::min()) + " - " + QString::number(std::numeric_limits<Type>::max()) + ")").toStdString());
+ if(!ok) throw ConfigException("\"" + value.toStdString() + "\" could not be parsed as an Integer");
+ if(longLongVal < std::numeric_limits<Type>::min() || longLongVal > std::numeric_limits<Type>::max()) throw ConfigException((QString::number(longLongVal) + " is out of range (" + QString::number(std::numeric_limits<Type>::min()) + " - " + QString::number(std::numeric_limits<Type>::max()) + ")").toStdString());
config = static_cast<Type>(longLongVal);
}
virtual QString value() { return QString::number(config); }
- virtual CRSMConfigValueType::Type type() { return CRSMConfigValueType::Type::Integer; }
+ virtual ConfigValueType::Type type() { return ConfigValueType::Type::Integer; }
};
template<>
-class CRSMConfigValue<Boolean> : public CRSMConfigValueBase {
+class ConfigValue<Boolean> : public ConfigValueBase {
Boolean& config;
public:
- CRSMConfigValue(Boolean& config) : config(config) { }
+ ConfigValue(Boolean& config) : config(config) { }
virtual void setValue(const QString& value)
{
@@ -134,21 +134,21 @@ public:
}
else
{
- throw CRSMConfigException("\"" + value.toStdString() + "\" could not be parsed as a Boolean");
+ throw ConfigException("\"" + value.toStdString() + "\" could not be parsed as a Boolean");
}
}
virtual QString value() { return config ? "true" : "false"; }
- virtual CRSMConfigValueType::Type type() { return CRSMConfigValueType::Type::Boolean; }
+ virtual ConfigValueType::Type type() { return ConfigValueType::Type::Boolean; }
};
-class CRSMConfigValueList : public CRSMConfigValueBase {
+class ConfigValueList : public ConfigValueBase {
public:
virtual void append(const QString& entry) = 0;
virtual void remove(const QString& entry) = 0;
virtual QStringList getValues() = 0;
};
-class CRSMConfigValueMap : public CRSMConfigValueBase {
+class ConfigValueMap : public ConfigValueBase {
public:
virtual void setKeyValue(const QString& key, const QString& value) = 0;
virtual void remove(const QString& key) = 0;
@@ -156,28 +156,28 @@ public:
};
template<typename Type>
-class CRSMConfigValue<QList<Type>> : public CRSMConfigValueList {
+class ConfigValue<QList<Type>> : public ConfigValueList {
using ListType = QList<Type>;
ListType& config;
const bool deduplicate;
public:
- CRSMConfigValue(ListType& config, bool deduplicate = true) : config(config), deduplicate(deduplicate) {}
+ ConfigValue(ListType& config, bool deduplicate = true) : config(config), deduplicate(deduplicate) {}
virtual ListType& list() { return config; }
- virtual CRSMConfigValueType::Type type() { return CRSMConfigValueType::Type::List; }
+ virtual ConfigValueType::Type type() { return ConfigValueType::Type::List; }
virtual void append(const QString &entry)
{
- Type val = CRSMConfigValueBase::getValue<Type>(entry);
+ Type val = ConfigValueBase::getValue<Type>(entry);
if(!deduplicate || !config.contains(val))
{
config.append(val);
}
}
- virtual void remove(const QString &entry) { config.removeAll(CRSMConfigValueBase::getValue<Type>(entry)); }
+ virtual void remove(const QString &entry) { config.removeAll(ConfigValueBase::getValue<Type>(entry)); }
virtual QStringList getValues()
{
@@ -185,7 +185,7 @@ public:
foreach(Type val, config)
{
- ret.append(CRSMConfigValueBase::getStringValue(val));
+ ret.append(ConfigValueBase::getStringValue(val));
}
return ret;
@@ -193,20 +193,20 @@ public:
};
template<typename KeyType, typename ValueType>
-class CRSMConfigValue<QMap<KeyType, ValueType>> : public CRSMConfigValueMap {
+class ConfigValue<QMap<KeyType, ValueType>> : public ConfigValueMap {
using MapType = QMap<KeyType, ValueType>;
MapType& config;
public:
- CRSMConfigValue(MapType& config) : config(config) {}
+ ConfigValue(MapType& config) : config(config) {}
virtual MapType& map() { return config; }
- virtual CRSMConfigValueType::Type type() { return CRSMConfigValueType::Type::Map; }
+ virtual ConfigValueType::Type type() { return ConfigValueType::Type::Map; }
virtual void setKeyValue(const QString& key, const QString& value)
{
- config[CRSMConfigValueBase::getValue<KeyType>(key)] = CRSMConfigValueBase::getValue<ValueType>(value);
+ config[ConfigValueBase::getValue<KeyType>(key)] = ConfigValueBase::getValue<ValueType>(value);
}
virtual QMap<QString, QString> getValues()
@@ -215,7 +215,7 @@ public:
foreach(KeyType key, config.keys())
{
- ret[CRSMConfigValueBase::getStringValue(key)] = CRSMConfigValueBase::getStringValue(config[key]);
+ ret[ConfigValueBase::getStringValue(key)] = ConfigValueBase::getStringValue(config[key]);
}
return ret;
@@ -223,43 +223,43 @@ public:
virtual void remove(const QString &key)
{
- config.remove(CRSMConfigValueBase::getValue<KeyType>(key));
+ config.remove(ConfigValueBase::getValue<KeyType>(key));
}
};
template<typename Type>
-class CRSMConfigValue<Type, typename std::enable_if<std::is_enum<Type>::value>::type> : public CRSMConfigValue<typename std::underlying_type<Type>::type> {
+class ConfigValue<Type, typename std::enable_if<std::is_enum<Type>::value>::type> : public ConfigValue<typename std::underlying_type<Type>::type> {
using UndType = typename std::underlying_type<Type>::type;
public:
- CRSMConfigValue(Type& config) : CRSMConfigValue<UndType>::CRSMConfigValue((UndType&)config) {}
+ ConfigValue(Type& config) : ConfigValue<UndType>::ConfigValue((UndType&)config) {}
};
template<typename Type, typename... Types>
-CRSMConfigValue<Type>* mkConfigValue(Type& Value, Types... values)
+ConfigValue<Type>* mkConfigValue(Type& Value, Types... values)
{
- return new CRSMConfigValue<Type>(Value, values...);
+ return new ConfigValue<Type>(Value, values...);
}
template<typename Type>
-Type CRSMConfigValueBase::getValue(const QString& value)
+Type ConfigValueBase::getValue(const QString& value)
{
Type ret;
- CRSMConfigValue<Type> val(ret);
+ ConfigValue<Type> val(ret);
val.setValue(value);
return ret;
}
template<typename Type>
-QString CRSMConfigValueBase::getStringValue(Type value)
+QString ConfigValueBase::getStringValue(Type value)
{
- CRSMConfigValue<Type> val(value);
+ ConfigValue<Type> val(value);
return val.value();
}
-class CRSMConfigBase
+class ConfigBase
{
public:
- explicit CRSMConfigBase(QMap<QString, CRSMConfigValueBase*> configValues) : configValues(configValues) {}
+ explicit ConfigBase(QMap<QString, ConfigValueBase*> configValues) : configValues(configValues) {}
void setConfigValue(const QString& name, const QString& value);
QString getConfigValueLine(const QString& name);
@@ -273,10 +273,10 @@ public:
void setConfigLine(const QString& line);
protected:
- void addConfigValue(QString name, CRSMConfigValueBase *value);
- CRSMConfigValueBase& getConfigValue(const QString &name);
+ void addConfigValue(QString name, ConfigValueBase *value);
+ ConfigValueBase& getConfigValue(const QString &name);
- QMap<QString, CRSMConfigValueBase*> configValues;
+ QMap<QString, ConfigValueBase*> configValues;
};
#endif // CONFIGBASE
diff --git a/src/crsm.cpp b/src/crsm.cpp
index f85ca52..614a085 100644
--- a/src/crsm.cpp
+++ b/src/crsm.cpp
@@ -2225,7 +2225,7 @@ CMD_FUNCTION_IMPL(getConfigValue)
{
respond(client, Config.getConfigValueLine(args));
}
- catch(CRSMConfigException)
+ catch(ConfigException)
{
respond(client, "Es existiert kein Wert mit dem Namen \"" + args + "\"\n");
}
@@ -2238,7 +2238,7 @@ CMD_FUNCTION_IMPL(setConfigValue)
applyConfig();
respond(client, "Wert wurde erfolgreich übernommen.\n");
}
- catch(CRSMConfigException e)
+ catch(ConfigException e)
{
respond(client, QString("Fehler beim Setzen: ") + e.what() + "\n");
}
diff --git a/src/crsm.hpp b/src/crsm.hpp
index fca0d9b..cdce0d1 100644
--- a/src/crsm.hpp
+++ b/src/crsm.hpp
@@ -57,31 +57,31 @@ public:
};
template<>
-class CRSMConfigValue<ScenarioSettings> : public CRSMConfigValueBase {
+class ConfigValue<ScenarioSettings> : public ConfigValueBase {
ScenarioSettings& config;
public:
- CRSMConfigValue(ScenarioSettings& config) : config(config) { }
+ ConfigValue(ScenarioSettings& config) : config(config) { }
void setValue(const QString& val)
{
QStringList parts = val.split(':', QString::KeepEmptyParts);
if(parts.length() < 3)
{
- throw CRSMConfigException("Cannot read corrupt ScenarioSettings");
+ throw ConfigException("Cannot read corrupt ScenarioSettings");
}
else
{
- config.name = CRSMConfigValueBase::getValue<QString>(parts.first());
+ config.name = ConfigValueBase::getValue<QString>(parts.first());
parts.removeFirst();
- config.league = CRSMConfigValueBase::getValue<bool>(parts.first());
+ config.league = ConfigValueBase::getValue<bool>(parts.first());
parts.removeFirst();
config.randomLeague = false;
- config.wishClient = CRSMConfigValueBase::getValue<ClientInfo>(parts.join(':'));
+ config.wishClient = ConfigValueBase::getValue<ClientInfo>(parts.join(':'));
}
}
- QString value() { return CRSMConfigValueBase::getStringValue(config.name) + ":" + CRSMConfigValueBase::getStringValue(config.league) + ":" + CRSMConfigValueBase::getStringValue(config.wishClient); }
+ QString value() { return ConfigValueBase::getStringValue(config.name) + ":" + ConfigValueBase::getStringValue(config.league) + ":" + ConfigValueBase::getStringValue(config.wishClient); }
};
class CRSM : public QObject
@@ -140,7 +140,7 @@ private:
CRSMConfig Config;
- struct CRSMSession : public CRSMConfigBase {
+ struct CRSMSession : public ConfigBase {
Boolean League = false;
enum {None = -1, Lobby = 0, Loading = 1, Running = 2} State = None;
Boolean UserWish = false;
@@ -166,19 +166,19 @@ private:
configValues = configVals;
}
- CRSMSession() : CRSMConfigBase::CRSMConfigBase({
- ConfigValue(League),
- ConfigValue(State),
- ConfigValue(UserWish),
- ConfigValue(CountDown),
- ConfigValue(ScenarioName),
+ CRSMSession() : ConfigBase::ConfigBase({
+ ConfigVal(League),
+ ConfigVal(State),
+ ConfigVal(UserWish),
+ ConfigVal(CountDown),
+ ConfigVal(ScenarioName),
- ConfigValue(Clonk.Admin),
- ConfigValue(Clonk.Clients),
- ConfigValue(Clonk.Clients),
+ ConfigVal(Clonk.Admin),
+ ConfigVal(Clonk.Clients),
+ ConfigVal(Clonk.Clients),
- ConfigValue(IRC.Admin),
- ConfigValue(IRC.UseIngameChat),
+ ConfigVal(IRC.Admin),
+ ConfigVal(IRC.UseIngameChat),
}) {}
CRSMSession(CRSM* crsm) : CRSMSession()