diff --git a/aegisub/libaegisub/common/hotkey.cpp b/aegisub/libaegisub/common/hotkey.cpp index 6ae8709a2..a5dd05b3b 100644 --- a/aegisub/libaegisub/common/hotkey.cpp +++ b/aegisub/libaegisub/common/hotkey.cpp @@ -95,9 +95,9 @@ void Hotkey::BuildHotkey(std::string const& context, const json::Object& object) for (json::Array::const_iterator arr_mod_index(arr_mod.begin()); arr_mod_index != arr_mod.end(); arr_mod_index++) { const json::String& key_mod = *arr_mod_index; - combo.KeyInsert(key_mod.Value()); + combo.KeyInsert(key_mod); } - combo.KeyInsert(static_cast(obj["key"]).Value()); + combo.KeyInsert(static_cast(obj["key"])); ComboInsert(combo); } // for arr_index } // for index diff --git a/aegisub/libaegisub/common/log.cpp b/aegisub/libaegisub/common/log.cpp index 607c4012d..6a2bcc08d 100644 --- a/aegisub/libaegisub/common/log.cpp +++ b/aegisub/libaegisub/common/log.cpp @@ -80,26 +80,26 @@ LogSink::~LogSink() { for (unsigned int i=0; i < sink.size(); i++) { json::Object entry; - entry["sec"] = json::Number(sink[i]->tv.tv_sec); - entry["usec"] = json::Number(sink[i]->tv.tv_usec); - entry["severity"] = json::Number(sink[i]->severity), - entry["section"] = json::String(sink[i]->section); - entry["file"] = json::String(sink[i]->file); - entry["func"] = json::String(sink[i]->func); - entry["line"] = json::Number(sink[i]->line); - entry["message"] = json::String(std::string(sink[i]->message, sink[i]->len)); + entry["sec"] = (double)sink[i]->tv.tv_sec; + entry["usec"] = (double)sink[i]->tv.tv_usec; + entry["severity"] = (double)sink[i]->severity, + entry["section"] = (std::string)sink[i]->section; + entry["file"] = (std::string)sink[i]->file; + entry["func"] = (std::string)sink[i]->func; + entry["line"] = (double)sink[i]->line; + entry["message"] = std::string(sink[i]->message, sink[i]->len); array.push_back(entry); } json::Array timeval_open; - timeval_open.push_back(json::Number(time_start.tv_sec)); - timeval_open.push_back(json::Number(time_start.tv_usec)); + timeval_open.push_back((double)time_start.tv_sec); + timeval_open.push_back((double)time_start.tv_usec); root["timeval"]["open"] = timeval_open; json::Array timeval_close; - timeval_close.push_back(json::Number(time_close.tv_sec)); - timeval_close.push_back(json::Number(time_close.tv_usec)); + timeval_close.push_back((double)time_close.tv_sec); + timeval_close.push_back((double)time_close.tv_usec); root["timeval"]["close"] = timeval_close; diff --git a/aegisub/libaegisub/common/option_visit.cpp b/aegisub/libaegisub/common/option_visit.cpp index 5dc6dd6cc..305965f0e 100644 --- a/aegisub/libaegisub/common/option_visit.cpp +++ b/aegisub/libaegisub/common/option_visit.cpp @@ -106,29 +106,27 @@ void ConfigVisitor::Visit(const json::Array& array) { void ConfigVisitor::Visit(const json::Number& number) { - double val = number.Value(); - - if (int64_t(val) == ceil(val)) { - OptionValue *opt = new OptionValueInt(name, int64_t(val)); + if (int64_t(number) == ceil(number)) { + OptionValue *opt = new OptionValueInt(name, int64_t(number)); AddOptionValue(opt); } else { - OptionValue *opt = new OptionValueDouble(name, val); + OptionValue *opt = new OptionValueDouble(name, number); AddOptionValue(opt); } } void ConfigVisitor::Visit(const json::String& string) { OptionValue *opt; - if (string.Value().find("rgb(") == 0) { - opt = new OptionValueColour(name, string.Value()); + if (string.find("rgb(") == 0) { + opt = new OptionValueColour(name, string); } else { - opt = new OptionValueString(name, string.Value()); + opt = new OptionValueString(name, string); } AddOptionValue(opt); } void ConfigVisitor::Visit(const json::Boolean& boolean) { - OptionValue *opt = new OptionValueBool(name, boolean.Value()); + OptionValue *opt = new OptionValueBool(name, boolean); AddOptionValue(opt); } diff --git a/aegisub/libaegisub/include/libaegisub/cajun/elements.h b/aegisub/libaegisub/include/libaegisub/cajun/elements.h index 6cdb6d904..a00dc56c4 100644 --- a/aegisub/libaegisub/include/libaegisub/cajun/elements.h +++ b/aegisub/libaegisub/include/libaegisub/cajun/elements.h @@ -13,19 +13,9 @@ Author: Terry Caton #include #include -/* - -TODO: -* better documentation (doxygen?) -* Unicode support -* parent element accessors - -*/ - namespace json { - ///////////////////////////////////////////////// // forward declarations (more info further below) class Visitor; @@ -34,9 +24,9 @@ class ConstVisitor; template class TrivialType_T; -typedef TrivialType_T Number; -typedef TrivialType_T Boolean; -typedef TrivialType_T String; +typedef double Number; +typedef bool Boolean; +typedef std::string String; class Object; class Array; @@ -100,6 +90,8 @@ public: operator Null& (); // provides quick access to children when real element type is object + UnknownElement& operator[] (const char *key) { return operator[](std::string(key)); } + const UnknownElement& operator[] (const char *key) const { return operator[](std::string(key)); } UnknownElement& operator[] (const std::string& key); const UnknownElement& operator[] (const std::string& key) const; @@ -213,44 +205,15 @@ private: Members m_Members; }; - -///////////////////////////////////////////////////////////////////////////////// -// TrivialType_T - class template for encapsulates a simple data type, such as -// a string, number, or boolean. Provides implicit const & noncost cast operators -// for that type, allowing "DataTypeT type = trivialType;" - - -template -class TrivialType_T -{ -public: - TrivialType_T(const DataTypeT& t = DataTypeT()); - - operator DataTypeT&(); - operator const DataTypeT&() const; - - DataTypeT& Value(); - const DataTypeT& Value() const; - - bool operator == (const TrivialType_T& trivial) const; - -private: - DataTypeT m_tValue; -}; - - - ///////////////////////////////////////////////////////////////////////////////// // Null - doesn't do much of anything but satisfy the JSON spec. It is the default // element type of UnknownElement - class Null { public: - bool operator == (const Null& trivial) const; + bool operator == (const Null& trivial) const { return true; } }; - } // end namespace diff --git a/aegisub/libaegisub/include/libaegisub/cajun/elements.inl b/aegisub/libaegisub/include/libaegisub/cajun/elements.inl index 01ecc9c4d..55ca250bd 100644 --- a/aegisub/libaegisub/include/libaegisub/cajun/elements.inl +++ b/aegisub/libaegisub/include/libaegisub/cajun/elements.inl @@ -236,49 +236,4 @@ inline const UnknownElement& Array::operator[] (size_t index) const return m_Elements[index]; } -//////////////////////// -// TrivialType_T members - -template -TrivialType_T::TrivialType_T(const DataTypeT& t) : - m_tValue(t) {} - -template -TrivialType_T::operator DataTypeT&() -{ - return Value(); -} - -template -TrivialType_T::operator const DataTypeT&() const -{ - return Value(); -} - -template -DataTypeT& TrivialType_T::Value() -{ - return m_tValue; -} - -template -const DataTypeT& TrivialType_T::Value() const -{ - return m_tValue; -} - -template -bool TrivialType_T::operator == (const TrivialType_T& trivial) const -{ - return m_tValue == trivial.m_tValue; -} - -////////////////// -// Null members - -inline bool Null::operator == (const Null& trivial) const -{ - return true; -} - } // end namespace diff --git a/aegisub/libaegisub/include/libaegisub/cajun/writer.inl b/aegisub/libaegisub/include/libaegisub/cajun/writer.inl index 445f276a6..6dffce7da 100644 --- a/aegisub/libaegisub/include/libaegisub/cajun/writer.inl +++ b/aegisub/libaegisub/include/libaegisub/cajun/writer.inl @@ -97,21 +97,20 @@ inline void Writer::Write_i(const Object& object) inline void Writer::Write_i(const Number& numberElement) { - m_ostr << std::setprecision(20) << numberElement.Value(); + m_ostr << std::setprecision(20) << numberElement; } inline void Writer::Write_i(const Boolean& booleanElement) { - m_ostr << (booleanElement.Value() ? "true" : "false"); + m_ostr << (booleanElement ? "true" : "false"); } inline void Writer::Write_i(const String& stringElement) { m_ostr << '"'; - const std::string& s = stringElement.Value(); - std::string::const_iterator it(s.begin()), - itend(s.end()); + const std::string& s = stringElement; + std::string::const_iterator it(s.begin()), itend(s.end()); for (; it != itend; ++it) { switch (*it) diff --git a/aegisub/src/toolbar.cpp b/aegisub/src/toolbar.cpp index 7f471f7b9..dcdf68690 100644 --- a/aegisub/src/toolbar.cpp +++ b/aegisub/src/toolbar.cpp @@ -107,16 +107,16 @@ namespace { for (json::Array::const_iterator it = arr.begin(); it != arr.end(); ++it) { json::String const& command_name = *it; - if (command_name.Value().empty()) { + if (command_name.empty()) { AddSeparator(); } else { cmd::Command *command; try { - command = cmd::get(command_name.Value()); + command = cmd::get(command_name); } catch (CommandNotFound const&) { - LOG_W("toolbar/command/not_found") << "Command '" << command_name.Value() << "' not found; skipping"; + LOG_W("toolbar/command/not_found") << "Command '" << command_name << "' not found; skipping"; continue; }