forked from mia/Aegisub
Eliminate a pile of duplicated code in elements.cpp
Originally committed to SVN as r6020.
This commit is contained in:
parent
2edc5c41e1
commit
ba1d1596de
3 changed files with 27 additions and 31 deletions
|
@ -346,6 +346,7 @@ AC_SUBST(with_openmp)
|
||||||
AC_SUBST(OPENMP_CXXFLAGS)
|
AC_SUBST(OPENMP_CXXFLAGS)
|
||||||
|
|
||||||
AC_CHECK_HEADERS([sys/time.h])
|
AC_CHECK_HEADERS([sys/time.h])
|
||||||
|
AC_CHECK_SIZEOF([time_t])
|
||||||
|
|
||||||
|
|
||||||
##############################
|
##############################
|
||||||
|
|
|
@ -86,34 +86,26 @@ private:
|
||||||
|
|
||||||
UnknownElement::UnknownElement() : m_pImp(new Imp_T<Null>(Null())) {}
|
UnknownElement::UnknownElement() : m_pImp(new Imp_T<Null>(Null())) {}
|
||||||
UnknownElement::UnknownElement(const UnknownElement& unknown) : m_pImp(unknown.m_pImp->Clone()) {}
|
UnknownElement::UnknownElement(const UnknownElement& unknown) : m_pImp(unknown.m_pImp->Clone()) {}
|
||||||
UnknownElement::UnknownElement(const Object& object) : m_pImp( new Imp_T<Object>(object) ) {}
|
|
||||||
UnknownElement::UnknownElement(const Array& array) : m_pImp( new Imp_T<Array>(array) ) {}
|
|
||||||
UnknownElement::UnknownElement(double number) : m_pImp( new Imp_T<Double>(number) ) {}
|
|
||||||
UnknownElement::UnknownElement(int number) : m_pImp(new Imp_T<Integer>(number)) {}
|
UnknownElement::UnknownElement(int number) : m_pImp(new Imp_T<Integer>(number)) {}
|
||||||
UnknownElement::UnknownElement(int64_t number) : m_pImp( new Imp_T<Integer>(number) ) {}
|
|
||||||
UnknownElement::UnknownElement(long number) : m_pImp( new Imp_T<Integer>(number) ) {}
|
|
||||||
UnknownElement::UnknownElement(bool boolean) : m_pImp( new Imp_T<Boolean>(boolean) ) {}
|
|
||||||
UnknownElement::UnknownElement(const char *string) : m_pImp(new Imp_T<String>(string)) {}
|
UnknownElement::UnknownElement(const char *string) : m_pImp(new Imp_T<String>(string)) {}
|
||||||
UnknownElement::UnknownElement(const String& string) : m_pImp( new Imp_T<String>(string) ) {}
|
#if SIZEOF_TIME_T+0 == 4
|
||||||
UnknownElement::UnknownElement(const Null& null) : m_pImp( new Imp_T<Null>(null) ) {}
|
UnknownElement::UnknownElement(time_t number) : m_pImp(new Imp_T<Integer>(number)) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
UnknownElement::~UnknownElement() { delete m_pImp; }
|
UnknownElement::~UnknownElement() { delete m_pImp; }
|
||||||
|
|
||||||
UnknownElement::operator Object const&() const { return CastTo<Object>(); }
|
#define DEFINE_UE_TYPE(Type) \
|
||||||
UnknownElement::operator Array const&() const { return CastTo<Array>(); }
|
UnknownElement::UnknownElement(Type const& val) : m_pImp(new Imp_T<Type>(val)) { } \
|
||||||
UnknownElement::operator Integer const&() const { return CastTo<Integer>(); }
|
UnknownElement::operator Type const&() const { return CastTo<Type>(); } \
|
||||||
UnknownElement::operator Double const&() const { return CastTo<Double>(); }
|
UnknownElement::operator Type&() { return CastTo<Type>(); }
|
||||||
UnknownElement::operator Boolean const&() const { return CastTo<Boolean>(); }
|
|
||||||
UnknownElement::operator String const&() const { return CastTo<String>(); }
|
|
||||||
UnknownElement::operator Null const&() const { return CastTo<Null>(); }
|
|
||||||
|
|
||||||
UnknownElement::operator Object&() { return CastTo<Object>(); }
|
DEFINE_UE_TYPE(Object);
|
||||||
UnknownElement::operator Array&() { return CastTo<Array>(); }
|
DEFINE_UE_TYPE(Array);
|
||||||
UnknownElement::operator Integer&() { return CastTo<Integer>(); }
|
DEFINE_UE_TYPE(Integer);
|
||||||
UnknownElement::operator Double&() { return CastTo<Double>(); }
|
DEFINE_UE_TYPE(Double);
|
||||||
UnknownElement::operator Boolean&() { return CastTo<Boolean>(); }
|
DEFINE_UE_TYPE(Boolean);
|
||||||
UnknownElement::operator String&() { return CastTo<String>(); }
|
DEFINE_UE_TYPE(String);
|
||||||
UnknownElement::operator Null&() { return CastTo<Null>(); }
|
DEFINE_UE_TYPE(Null);
|
||||||
|
|
||||||
UnknownElement& UnknownElement::operator =(const UnknownElement& unknown)
|
UnknownElement& UnknownElement::operator =(const UnknownElement& unknown)
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,15 +69,18 @@ public:
|
||||||
UnknownElement(const UnknownElement& unknown);
|
UnknownElement(const UnknownElement& unknown);
|
||||||
UnknownElement(const Object& object);
|
UnknownElement(const Object& object);
|
||||||
UnknownElement(const Array& array);
|
UnknownElement(const Array& array);
|
||||||
UnknownElement(double number);
|
UnknownElement(double const& number);
|
||||||
UnknownElement(int number);
|
UnknownElement(int number);
|
||||||
UnknownElement(long number);
|
UnknownElement(int64_t const& number);
|
||||||
UnknownElement(int64_t number);
|
UnknownElement(bool const& boolean);
|
||||||
UnknownElement(bool boolean);
|
|
||||||
UnknownElement(const char *string);
|
UnknownElement(const char *string);
|
||||||
UnknownElement(const String& string);
|
UnknownElement(const String& string);
|
||||||
UnknownElement(const Null& null);
|
UnknownElement(const Null& null);
|
||||||
|
|
||||||
|
#if SIZEOF_TIME_T+0 == 4
|
||||||
|
UnknownElement(time_t number);
|
||||||
|
#endif
|
||||||
|
|
||||||
~UnknownElement();
|
~UnknownElement();
|
||||||
|
|
||||||
UnknownElement& operator = (const UnknownElement& unknown);
|
UnknownElement& operator = (const UnknownElement& unknown);
|
||||||
|
|
Loading…
Reference in a new issue