Merge branch 'master' of github.com:tfussell/xlnt

This commit is contained in:
Thomas Fussell 2015-10-02 10:03:00 -04:00
commit 81a242dc71
4 changed files with 70 additions and 0 deletions

View File

@ -124,6 +124,10 @@ public:
void set_value(std::uint64_t i);
#ifdef _WIN32
void set_value(unsigned long i);
#endif
#ifdef __linux__
void set_value(long long i);
void set_value(unsigned long long i);
#endif
void set_value(float f);
void set_value(double d);

View File

@ -39,6 +39,10 @@ public:
explicit value(std::uint64_t i);
#ifdef _WIN32
explicit value(unsigned long i);
#endif
#ifdef __linux__
explicit value(long long i);
explicit value(unsigned long long i);
#endif
explicit value(float f);
explicit value(double d);

View File

@ -262,6 +262,18 @@ void cell::set_value(unsigned long i)
}
#endif
#ifdef __linux__
void cell::set_value(long long i)
{
d_->value_ = value(i);
}
void cell::set_value(unsigned long long i)
{
d_->value_ = value(i);
}
#endif
void cell::set_value(double d)
{
d_->value_ = value(d);

View File

@ -70,6 +70,16 @@ value::value(unsigned long i) : type_(type::numeric), numeric_value_(i)
}
#endif
#ifdef __linux__
value::value(long long i) : type_(type::numeric), numeric_value_(i)
{
}
value::value(unsigned long long i) : type_(type::numeric), numeric_value_(i)
{
}
#endif
value::value(float f) : type_(type::numeric), numeric_value_(f)
{
}
@ -323,6 +333,46 @@ unsigned long value::as() const
}
#endif
#ifdef __linux__
template<>
long long value::as() const
{
switch (type_)
{
case type::boolean:
case type::numeric:
return static_cast<long long>(numeric_value_);
case type::string:
return std::stoi(string_value_);
case type::error:
throw std::runtime_error("invalid");
case type::null:
return 0;
}
return 0;
}
template<>
unsigned long long value::as() const
{
switch (type_)
{
case type::boolean:
case type::numeric:
return static_cast<unsigned long long>(numeric_value_);
case type::string:
return std::stoi(string_value_);
case type::error:
throw std::runtime_error("invalid");
case type::null:
return 0;
}
return 0;
}
#endif
template<>
std::string value::as() const
{