Revision control
Copy as Markdown
{{>licenseInfo}}
/**
* Representing a Server Variable for server URL template substitution.
*/
#ifndef {{prefix}}_SERVERVARIABLE_H
#define {{prefix}}_SERVERVARIABLE_H
#include <QtCore/qset.h>
#include <QtCore/qstring.h>
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
class {{prefix}}ServerVariable {
public:
enum class ServerError
{
NoError = 0, // Success
ServerVariableNotFound = -1,
EnumValueNotFound = -2, // The value is not defined in m_enumValues
OperationNotFound = -3,
ServerIndexNotFound = -4,
};
/**
* @param description A description for the server variable.
* @param defaultValue The default value to use for substitution.
* @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
*/
{{prefix}}ServerVariable(const QString &description, const QString &defaultValue, const QSet<QString> &enumValues)
: m_defaultValue(defaultValue),
m_description(description),
m_enumValues(enumValues) {}
{{prefix}}ServerVariable() {}
~{{prefix}}ServerVariable() {}
ServerError setDefaultValue(const QString& value) {
if ( m_enumValues.contains(value)) {
m_defaultValue = value;
return ServerError::NoError;
}
return ServerError::EnumValueNotFound;
}
QString getDefaultValue() { return m_defaultValue; }
QSet<QString> getEnumValues() { return m_enumValues; }
QString m_defaultValue;
QString m_description;
QSet<QString> m_enumValues;
};
{{#cppNamespaceDeclarations}}
} // namespace {{this}}
{{/cppNamespaceDeclarations}}
#endif // {{prefix}}_SERVERVARIABLE_H