diff --git a/build/libaegisub/libaegisub.vcxproj b/build/libaegisub/libaegisub.vcxproj
index 9a70323fa..5d2a6f37a 100644
--- a/build/libaegisub/libaegisub.vcxproj
+++ b/build/libaegisub/libaegisub.vcxproj
@@ -156,6 +156,7 @@
+
diff --git a/build/libaegisub/libaegisub.vcxproj.filters b/build/libaegisub/libaegisub.vcxproj.filters
index 3fb34bf49..4efd142ee 100644
--- a/build/libaegisub/libaegisub.vcxproj.filters
+++ b/build/libaegisub/libaegisub.vcxproj.filters
@@ -253,6 +253,9 @@
Source Files\Common
+
+ Source Files\Common
+
Source Files\Common
diff --git a/libaegisub/Makefile b/libaegisub/Makefile
index 934ee5cf5..20dd6fec0 100644
--- a/libaegisub/Makefile
+++ b/libaegisub/Makefile
@@ -30,6 +30,7 @@ aegisub_OBJ := \
$(d)common/log.o \
$(d)common/mru.o \
$(d)common/option.o \
+ $(d)common/option_value.o \
$(d)common/path.o \
$(d)common/thesaurus.o \
$(d)common/util.o \
diff --git a/libaegisub/common/option_value.cpp b/libaegisub/common/option_value.cpp
new file mode 100644
index 000000000..46aff51a1
--- /dev/null
+++ b/libaegisub/common/option_value.cpp
@@ -0,0 +1,50 @@
+// Copyright (c) 2014, Thomas Goyne
+//
+// Permission to use, copy, modify, and distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+//
+// Aegisub Project http://www.aegisub.org/
+
+#include
+
+namespace agi {
+ std::string OptionValue::TypeToString(OptionType type) const {
+ switch (type) {
+ case OptionType::String: return "String";
+ case OptionType::Int: return "Integer";
+ case OptionType::Double: return "Double";
+ case OptionType::Color: return "Color";
+ case OptionType::Bool: return "Bool";
+ case OptionType::ListString: return "List of Strings";
+ case OptionType::ListInt: return "List of Integers";
+ case OptionType::ListDouble: return "List of Doubles";
+ case OptionType::ListColor: return "List of Colors";
+ case OptionType::ListBool: return "List of Bools";
+ }
+ throw agi::InternalError("Invalid option type");
+ }
+
+ InternalError OptionValue::TypeError(OptionType type) const {
+ return InternalError("Invalid type for option " + name + ": expected " +
+ TypeToString(type) + ", got " + TypeToString(GetType()));
+ }
+
+#define CONFIG_DEFINE_SET(type_name, type) \
+ void OptionValue##type_name::Set(const OptionValue *nv) { SetValue(nv->Get##type_name()); } \
+ void OptionValueList##type_name::Set(const OptionValue *nv) { SetValue(nv->GetList##type_name()); }
+
+CONFIG_DEFINE_SET(String, std::string)
+CONFIG_DEFINE_SET(Int, int64_t)
+CONFIG_DEFINE_SET(Double, double)
+CONFIG_DEFINE_SET(Color, Color)
+CONFIG_DEFINE_SET(Bool, bool)
+}
diff --git a/libaegisub/include/libaegisub/option_value.h b/libaegisub/include/libaegisub/option_value.h
index b70a0d11e..63870419c 100644
--- a/libaegisub/include/libaegisub/option_value.h
+++ b/libaegisub/include/libaegisub/option_value.h
@@ -48,25 +48,8 @@ class OptionValue {
agi::signal::Signal ValueChanged;
std::string name;
- std::string TypeToString(OptionType type) const {
- switch (type) {
- case OptionType::String: return "String";
- case OptionType::Int: return "Integer";
- case OptionType::Double: return "Double";
- case OptionType::Color: return "Color";
- case OptionType::Bool: return "Bool";
- case OptionType::ListString: return "List of Strings";
- case OptionType::ListInt: return "List of Integers";
- case OptionType::ListDouble: return "List of Doubles";
- case OptionType::ListColor: return "List of Colors";
- case OptionType::ListBool: return "List of Bools";
- }
- throw agi::InternalError("Invalid option type");
- }
-
- InternalError TypeError(OptionType type) const {
- return InternalError("Invalid type for option " + name + ": expected " + TypeToString(type) + ", got " + TypeToString(GetType()));
- }
+ std::string TypeToString(OptionType type) const;
+ InternalError TypeError(OptionType type) const;
template
T *As(OptionType type) {
@@ -138,7 +121,7 @@ public:
OptionType GetType() const { return OptionType::type_name; } \
void Reset() { value = value_default; NotifyChanged(); } \
bool IsDefault() const { return value == value_default; } \
- void Set(const OptionValue *new_val) { SetValue(new_val->Get##type_name()); } \
+ void Set(const OptionValue *nv); \
};
CONFIG_OPTIONVALUE(String, std::string)
@@ -162,7 +145,7 @@ CONFIG_OPTIONVALUE(Bool, bool)
OptionType GetType() const { return OptionType::List##type_name; } \
void Reset() { array = array_default; NotifyChanged(); } \
bool IsDefault() const { return array == array_default; } \
- void Set(const OptionValue *nv) { SetValue(nv->GetList##type_name()); } \
+ void Set(const OptionValue *nv); \
};
CONFIG_OPTIONVALUE_LIST(String, std::string)