diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-07-16 02:03:52 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-07-16 02:03:52 +0200 |
commit | 8a56ab6780f525472dce4dccdd53fec41390d586 (patch) | |
tree | f7d2ecf90a404e3ef0768890c85cb2101d948445 /logic/DefaultVariable.h | |
parent | 71575a5022a4e682a9960256ade7ea5672d1210d (diff) | |
download | MultiMC-8a56ab6780f525472dce4dccdd53fec41390d586.tar MultiMC-8a56ab6780f525472dce4dccdd53fec41390d586.tar.gz MultiMC-8a56ab6780f525472dce4dccdd53fec41390d586.tar.lz MultiMC-8a56ab6780f525472dce4dccdd53fec41390d586.tar.xz MultiMC-8a56ab6780f525472dce4dccdd53fec41390d586.zip |
Implement gradle spec reader/writer
Diffstat (limited to 'logic/DefaultVariable.h')
-rw-r--r-- | logic/DefaultVariable.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/logic/DefaultVariable.h b/logic/DefaultVariable.h new file mode 100644 index 00000000..38d7ecc2 --- /dev/null +++ b/logic/DefaultVariable.h @@ -0,0 +1,35 @@ +#pragma once + +template <typename T> +class DefaultVariable +{ +public: + DefaultVariable(const T & value) + { + defaultValue = value; + } + DefaultVariable<T> & operator =(const T & value) + { + currentValue = value; + is_default = currentValue == defaultValue; + is_explicit = true; + return *this; + } + operator const T &() const + { + return is_default ? defaultValue : currentValue; + } + bool isDefault() const + { + return is_default; + } + bool isExplicit() const + { + return is_explicit; + } +private: + T currentValue; + T defaultValue; + bool is_default = true; + bool is_explicit = false; +}; |