update copyright, add overloads for all int sizes, fix line ending in zip_file test

This commit is contained in:
Thomas Fussell 2015-10-01 18:14:42 -04:00
parent 5e6ae7ea40
commit 8f669c11db
58 changed files with 548 additions and 265 deletions

BIN
build/premake/premake5.exe Normal file

Binary file not shown.

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -116,18 +116,29 @@ public:
value &get_value();
const value &get_value() const;
void set_value(bool b);
void set_value(int i);
void set_value(double d);
void set_value(long double d);
void set_value(long long int i);
void set_value(const date &d);
void set_value(const datetime &d);
void set_value(const time &t);
void set_value(const timedelta &t);
void set_value(const char *s);
void set_value(const std::string &s);
void set_value(const value &v);
void set_value(bool b);
void set_value(std::int8_t i);
void set_value(std::int16_t i);
void set_value(std::int32_t i);
void set_value(std::int64_t i);
void set_value(std::uint8_t i);
void set_value(std::uint16_t i);
void set_value(std::uint32_t i);
void set_value(std::uint64_t i);
#ifdef _WIN32
void set_value(unsigned long i);
#endif
void set_value(float f);
void set_value(double d);
void set_value(long double d);
void set_value(const char *s);
void set_value(const std::string &s);
void set_value(const date &d);
void set_value(const datetime &d);
void set_value(const time &t);
void set_value(const timedelta &t);
void set_value(const value &v);
cell &operator=(const cell &rhs);

View File

@ -1,4 +1,4 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2015 Thomas Fussell
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -28,27 +28,27 @@ public:
value();
value(value &&v);
value(const value &v);
value(bool b);
value(int8_t i);
value(int16_t i);
value(int32_t i);
value(int64_t i);
value(uint8_t i);
value(uint16_t i);
value(uint32_t i);
value(uint64_t i);
explicit value(bool b);
explicit value(std::int8_t i);
explicit value(std::int16_t i);
explicit value(std::int32_t i);
explicit value(std::int64_t i);
explicit value(std::uint8_t i);
explicit value(std::uint16_t i);
explicit value(std::uint32_t i);
explicit value(std::uint64_t i);
#ifdef _WIN32
value(long long int i);
explicit value(unsigned long i);
#endif
value(float f);
value(double d);
value(long double d);
value(const char *s);
value(const std::string &s);
value(const date &d);
value(const datetime &d);
value(const time &t);
value(const timedelta &t);
explicit value(float f);
explicit value(double d);
explicit value(long double d);
explicit value(const char *s);
explicit value(const std::string &s);
explicit value(const date &d);
explicit value(const datetime &d);
explicit value(const time &t);
explicit value(const timedelta &t);
template<typename T>
T get() const;
@ -65,26 +65,22 @@ public:
value &operator=(value other);
value &operator=(bool b);
value &operator=(int8_t i);
value &operator=(int16_t i);
value &operator=(int32_t i);
value &operator=(int64_t i);
value &operator=(uint8_t i);
value &operator=(uint16_t i);
value &operator=(uint32_t i);
value &operator=(uint64_t i);
value &operator=(const char *s);
value &operator=(const std::string &s);
value &operator=(const date &d);
value &operator=(const datetime &d);
value &operator=(const time &t);
value &operator=(const timedelta &t);
bool operator==(const value &comparand) const;
bool operator==(bool comparand) const;
bool operator==(int comparand) const;
bool operator==(std::int8_t comparand) const;
bool operator==(std::int16_t comparand) const;
bool operator==(std::int32_t comparand) const;
bool operator==(std::int64_t comparand) const;
bool operator==(std::uint8_t comparand) const;
bool operator==(std::uint16_t comparand) const;
bool operator==(std::uint32_t comparand) const;
bool operator==(std::uint64_t comparand) const;
#ifdef _WIN32
bool operator==(unsigned long comparand) const;
#endif
bool operator==(float comparand) const;
bool operator==(double comparand) const;
bool operator==(long double comparand) const;
bool operator==(const std::string &comparand) const;
bool operator==(const char *comparand) const;
bool operator==(const date &comparand) const;
@ -93,8 +89,20 @@ public:
bool operator==(const timedelta &comparand) const;
friend bool operator==(bool comparand, const value &v);
friend bool operator==(int comparand, const value &v);
friend bool operator==(std::int8_t comparand, const value &v);
friend bool operator==(std::int16_t comparand, const value &v);
friend bool operator==(std::int32_t comparand, const value &v);
friend bool operator==(std::int64_t comparand, const value &v);
friend bool operator==(std::uint8_t comparand, const value &v);
friend bool operator==(std::uint16_t comparand, const value &v);
friend bool operator==(std::uint32_t comparand, const value &v);
friend bool operator==(std::uint64_t comparand, const value &v);
#ifdef _WIN32
friend bool operator==(unsigned long comparand, const value &v);
#endif
friend bool operator==(float comparand, const value &v);
friend bool operator==(double comparand, const value &v);
friend bool operator==(long double comparand, const value &v);
friend bool operator==(const std::string &comparand, const value &v);
friend bool operator==(const char *comparand, const value &v);
friend bool operator==(const date &comparand, const value &v);

View File

@ -1,4 +1,4 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2015 Thomas Fussell
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2015 Thomas Fussell
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2015 Thomas Fussell
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2015 Thomas Fussell
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2015 Thomas Fussell
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2015 Thomas Fussell
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -45,19 +45,18 @@ class workbook;
struct date;
namespace detail {
struct worksheet_impl;
struct worksheet_impl;
} // namespace detail
class row_properties
{
public:
void set_height(double height) { this->height = height; }
int row_index;
double height;
bool visible;
int outline_level;
bool collapsed;
int style_index;
public:
int row_index;
double height;
bool visible;
int outline_level;
bool collapsed;
int style_index;
};
class header

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 2014 Thomas Fussell
// Copyright (c) 2010-2014 openpyxl
// Copyright (c) 2015 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -217,16 +217,53 @@ void cell::set_value(bool b)
d_->value_ = value(b);
}
void cell::set_value(int i)
void cell::set_value(std::int8_t i)
{
d_->value_ = value(i);
d_->value_ = value(i);
}
void cell::set_value(long long int i)
void cell::set_value(std::int16_t i)
{
d_->value_ = value(i);
d_->value_ = value(i);
}
void cell::set_value(std::int32_t i)
{
d_->value_ = value(i);
}
void cell::set_value(std::int64_t i)
{
d_->value_ = value(i);
}
void cell::set_value(std::uint8_t i)
{
d_->value_ = value(i);
}
void cell::set_value(std::uint16_t i)
{
d_->value_ = value(i);
}
void cell::set_value(std::uint32_t i)
{
d_->value_ = value(i);
}
void cell::set_value(std::uint64_t i)
{
d_->value_ = value(i);
}
#ifdef _WIN32
void cell::set_value(unsigned long i)
{
d_->value_ = value(i);
}
#endif
void cell::set_value(double d)
{
d_->value_ = value(d);

View File

@ -32,7 +32,45 @@ value::value(bool b) : type_(type::boolean), numeric_value_(b ? 1 : 0)
{
}
value::value(int i) : type_(type::numeric), numeric_value_(i)
value::value(std::int8_t i) : type_(type::numeric), numeric_value_(i)
{
}
value::value(std::int16_t i) : type_(type::numeric), numeric_value_(i)
{
}
value::value(std::int32_t i) : type_(type::numeric), numeric_value_(i)
{
}
value::value(std::int64_t i) : type_(type::numeric), numeric_value_(static_cast<long double>(i))
{
}
value::value(std::uint8_t i) : type_(type::numeric), numeric_value_(i)
{
}
value::value(std::uint16_t i) : type_(type::numeric), numeric_value_(i)
{
}
value::value(std::uint32_t i) : type_(type::numeric), numeric_value_(i)
{
}
value::value(std::uint64_t i) : type_(type::numeric), numeric_value_(static_cast<long double>(i))
{
}
#ifdef _WIN32
value::value(unsigned long i) : type_(type::numeric), numeric_value_(i)
{
}
#endif
value::value(float f) : type_(type::numeric), numeric_value_(f)
{
}
@ -40,7 +78,7 @@ value::value(double d) : type_(type::numeric), numeric_value_(d)
{
}
value::value(int64_t i) : type_(type::numeric), numeric_value_((long double)i)
value::value(long double d) : type_(type::numeric), numeric_value_(d)
{
}
@ -58,26 +96,21 @@ value &value::operator=(value other)
return *this;
}
value &value::operator=(int i)
{
return *this = value(i);
}
bool value::is(type t) const
{
return type_ == t;
}
template<>
std::string value::get() const
template<>
std::string value::get() const
{
if(type_ == type::string)
{
if(type_ == type::string)
{
return string_value_;
}
throw std::runtime_error("not a string");
return string_value_;
}
throw std::runtime_error("not a string");
}
template<>
double value::as() const
@ -98,44 +131,6 @@ double value::as() const
return 0;
}
template<>
int value::as() const
{
switch(type_)
{
case type::boolean:
case type::numeric:
return (int)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<>
int64_t value::as() const
{
switch(type_)
{
case type::boolean:
case type::numeric:
return (int64_t)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<>
bool value::as() const
{
@ -155,15 +150,188 @@ bool value::as() const
return false;
}
bool value::is_integral() const
template<>
std::int8_t value::as() const
{
return type_ == type::numeric && (int64_t)numeric_value_ == numeric_value_;
switch (type_)
{
case type::boolean:
case type::numeric:
return static_cast<std::int8_t>(numeric_value_);
case type::string:
return static_cast<std::int8_t>(std::stoi(string_value_));
case type::error:
throw std::runtime_error("invalid");
case type::null:
return 0;
}
return 0;
}
template<>
std::int16_t value::as() const
{
switch (type_)
{
case type::boolean:
case type::numeric:
return static_cast<std::int16_t>(numeric_value_);
case type::string:
return static_cast<std::int16_t>(std::stoi(string_value_));
case type::error:
throw std::runtime_error("invalid");
case type::null:
return 0;
}
return 0;
}
template<>
std::int32_t value::as() const
{
switch (type_)
{
case type::boolean:
case type::numeric:
return static_cast<std::int32_t>(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<>
std::int64_t value::as() const
{
switch (type_)
{
case type::boolean:
case type::numeric:
return static_cast<std::int64_t>(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<>
std::uint8_t value::as() const
{
switch (type_)
{
case type::boolean:
case type::numeric:
return static_cast<std::uint8_t>(numeric_value_);
case type::string:
return static_cast<std::uint8_t>(std::stoi(string_value_));
case type::error:
throw std::runtime_error("invalid");
case type::null:
return 0;
}
return 0;
}
template<>
std::uint16_t value::as() const
{
switch (type_)
{
case type::boolean:
case type::numeric:
return static_cast<std::uint16_t>(numeric_value_);
case type::string:
return static_cast<std::uint16_t>(std::stoi(string_value_));
case type::error:
throw std::runtime_error("invalid");
case type::null:
return 0;
}
return 0;
}
template<>
std::uint32_t value::as() const
{
switch (type_)
{
case type::boolean:
case type::numeric:
return static_cast<std::uint32_t>(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<>
std::uint64_t value::as() const
{
switch (type_)
{
case type::boolean:
case type::numeric:
return static_cast<std::uint64_t>(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;
}
#ifdef _WIN32
template<>
unsigned long value::as() const
{
switch (type_)
{
case type::boolean:
case type::numeric:
return static_cast<unsigned 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
{
return to_string();
return to_string();
}
bool value::is_integral() const
{
return type_ == type::numeric && (std::int64_t)numeric_value_ == numeric_value_;
}
value value::null()
@ -199,16 +367,68 @@ bool value::operator==(bool value) const
return type_ == type::boolean && (numeric_value_ != 0) == value;
}
bool value::operator==(int comparand) const
bool value::operator==(std::int8_t comparand) const
{
return type_ == type::numeric && numeric_value_ == comparand;
}
bool value::operator==(std::int16_t comparand) const
{
return type_ == type::numeric && numeric_value_ == comparand;
}
bool value::operator==(std::int32_t comparand) const
{
return type_ == type::numeric && numeric_value_ == comparand;
}
bool value::operator==(std::int64_t comparand) const
{
return type_ == type::numeric && numeric_value_ == comparand;
}
bool value::operator==(std::uint8_t comparand) const
{
return type_ == type::numeric && numeric_value_ == comparand;
}
bool value::operator==(std::uint16_t comparand) const
{
return type_ == type::numeric && numeric_value_ == comparand;
}
bool value::operator==(std::uint32_t comparand) const
{
return type_ == type::numeric && numeric_value_ == comparand;
}
bool value::operator==(std::uint64_t comparand) const
{
return type_ == type::numeric && numeric_value_ == comparand;
}
#ifdef _WIN32
bool value::operator==(unsigned long comparand) const
{
return type_ == type::numeric && numeric_value_ == comparand;
}
#endif
bool value::operator==(float comparand) const
{
return type_ == type::numeric && numeric_value_ == comparand;
}
bool value::operator==(double comparand) const
{
return type_ == type::numeric && numeric_value_ == comparand;
}
bool value::operator==(long double comparand) const
{
return type_ == type::numeric && numeric_value_ == comparand;
}
bool value::operator==(const std::string &comparand) const
{
if(type_ == type::string)
@ -257,57 +477,63 @@ bool value::operator==(const value &v) const
return true;
}
/*
value &value::operator=(const time &value)
{
d_->type_ = type::numeric;
d_->numeric_value = value.to_number();
d_->is_date_ = true;
return *this;
}
value &value::operator=(const date &value)
{
d_->type_ = type::numeric;
auto base_year = worksheet(d_->parent_).get_parent().get_properties().excel_base_date;
d_->numeric_value = value.to_number(base_year);
d_->is_date_ = true;
return *this;
}
value &value::operator=(const datetime &value)
{
d_->type_ = type::numeric;
auto base_year = worksheet(d_->parent_).get_parent().get_properties().excel_base_date;
d_->numeric_value = value.to_number(base_year);
d_->is_date_ = true;
return *this;
}
value &value::operator=(const timedelta &value)
{
d_->type_ = type::numeric;
d_->numeric_value = value.to_number();
d_->is_date_ = true;
return *this;
}
*/
bool operator==(bool comparand, const xlnt::value &value)
{
return value == comparand;
}
bool operator==(int comparand, const xlnt::value &value)
bool operator==(std::int8_t comparand, const xlnt::value &value)
{
return value == comparand;
}
bool operator==(std::int16_t comparand, const xlnt::value &value)
{
return value == comparand;
}
bool operator==(std::int32_t comparand, const xlnt::value &value)
{
return value == comparand;
}
bool operator==(std::int64_t comparand, const xlnt::value &value)
{
return value == comparand;
}
bool operator==(std::uint8_t comparand, const xlnt::value &value)
{
return value == comparand;
}
bool operator==(std::uint16_t comparand, const xlnt::value &value)
{
return value == comparand;
}
bool operator==(std::uint32_t comparand, const xlnt::value &value)
{
return value == comparand;
}
bool operator==(std::uint64_t comparand, const xlnt::value &value)
{
return value == comparand;
}
bool operator==(const char *comparand, const xlnt::value &value)
{
return value == comparand;
}
#ifdef _WIN32
bool operator==(unsigned long comparand, const xlnt::value &value)
{
return value == comparand;
}
#endif
bool operator==(const std::string &comparand, const xlnt::value &value)
{
return value == comparand;
@ -337,3 +563,4 @@ void swap(value &left, value &right)
}
} // namespace xlnt

View File

@ -1,5 +1,6 @@
#include <algorithm>
#include <cstring>
#include <iterator>
#include <fstream>
#include <miniz.h>

View File

@ -21,7 +21,7 @@ int main( int argc, char *argv[] ) {
return status;
}
bool suite_test_cell_init = false;
#include "/Users/thomas/Development/xlnt/tests/test_cell.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_cell.hpp"
static test_cell suite_test_cell;
@ -256,7 +256,7 @@ public:
void runTest() { suite_test_cell.test_cell_offset(); }
} testDescription_suite_test_cell_test_cell_offset;
#include "/Users/thomas/Development/xlnt/tests/test_chart.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_chart.hpp"
static test_chart suite_test_chart;
@ -347,7 +347,7 @@ public:
void runTest() { suite_test_chart.test_write_chart_scatter(); }
} testDescription_suite_test_chart_test_write_chart_scatter;
#include "/Users/thomas/Development/xlnt/tests/test_named_range.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_named_range.hpp"
static test_named_range suite_test_named_range;
@ -438,7 +438,7 @@ public:
void runTest() { suite_test_named_range.test_can_be_saved(); }
} testDescription_suite_test_named_range_test_can_be_saved;
#include "/Users/thomas/Development/xlnt/tests/test_number_format.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_number_format.hpp"
static test_number_format suite_test_number_format;
@ -541,7 +541,7 @@ public:
void runTest() { suite_test_number_format.test_mac_date(); }
} testDescription_suite_test_number_format_test_mac_date;
#include "/Users/thomas/Development/xlnt/tests/test_props.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_props.hpp"
static test_props suite_test_props;
@ -584,7 +584,7 @@ public:
void runTest() { suite_test_props.test_write_properties_app(); }
} testDescription_suite_test_props_test_write_properties_app;
#include "/Users/thomas/Development/xlnt/tests/test_read.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_read.hpp"
static test_read suite_test_read;
@ -777,7 +777,7 @@ public:
void runTest() { suite_test_read.test_bad_formats_no(); }
} testDescription_suite_test_read_test_bad_formats_no;
#include "/Users/thomas/Development/xlnt/tests/test_strings.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_strings.hpp"
static test_strings suite_test_strings;
@ -808,7 +808,7 @@ public:
void runTest() { suite_test_strings.test_formatted_string_table(); }
} testDescription_suite_test_strings_test_formatted_string_table;
#include "/Users/thomas/Development/xlnt/tests/test_style.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_style.hpp"
static test_style suite_test_style;
@ -917,7 +917,7 @@ public:
void runTest() { suite_test_style.test_protection(); }
} testDescription_suite_test_style_test_protection;
#include "/Users/thomas/Development/xlnt/tests/test_theme.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_theme.hpp"
static test_theme suite_test_theme;
@ -930,7 +930,7 @@ public:
void runTest() { suite_test_theme.test_write_theme(); }
} testDescription_suite_test_theme_test_write_theme;
#include "/Users/thomas/Development/xlnt/tests/test_workbook.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_workbook.hpp"
static test_workbook suite_test_workbook;
@ -1051,7 +1051,7 @@ public:
void runTest() { suite_test_workbook.test_write_regular_float(); }
} testDescription_suite_test_workbook_test_write_regular_float;
#include "/Users/thomas/Development/xlnt/tests/test_worksheet.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_worksheet.hpp"
static test_worksheet suite_test_worksheet;
@ -1292,7 +1292,7 @@ public:
void runTest() { suite_test_worksheet.test_page_options(); }
} testDescription_suite_test_worksheet_test_page_options;
#include "/Users/thomas/Development/xlnt/tests/test_write.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_write.hpp"
static test_write suite_test_write;
@ -1431,7 +1431,7 @@ public:
void runTest() { suite_test_write.test_short_number(); }
} testDescription_suite_test_write_test_short_number;
#include "/Users/thomas/Development/xlnt/tests/test_zip_file.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_zip_file.hpp"
static test_zip_file suite_test_zip_file;

View File

@ -98,7 +98,7 @@ public:
void test_initial_value()
{
xlnt::worksheet ws = wb.create_sheet();
xlnt::cell cell(ws, "A1", "17.5");
xlnt::cell cell(ws, "A1", xlnt::value("17.5"));
TS_ASSERT(cell.get_value().is(xlnt::value::type::string));
}
@ -114,7 +114,7 @@ public:
void test_null()
{
xlnt::worksheet ws = wb.create_sheet();
xlnt::cell cell(ws, "A1", "17.5");
xlnt::cell cell(ws, "A1", xlnt::value("17.5"));
cell.set_value(xlnt::value::null());
TS_ASSERT(cell.get_value().is(xlnt::value::type::null));

View File

@ -295,7 +295,7 @@ public:
void test_setitem()
{
xlnt::worksheet ws(wb_);
ws[xlnt::cell_reference("A1")].get_value() = 5;
ws[xlnt::cell_reference("A1")].set_value(5);
TS_ASSERT(ws[xlnt::cell_reference("A1")].get_value() == 5);
}

View File

@ -14,10 +14,10 @@ public:
void test_write_empty_workbook()
{
xlnt::workbook wbk;
wbk.get_active_sheet().get_cell("A2").set_value("Thomas Fussell");
wbk.get_active_sheet().get_cell("A2").set_value("xlnt");
wbk.get_active_sheet().get_cell("B5").set_value(88);
wbk.get_active_sheet().get_cell("B5").get_style().set_number_format(xlnt::number_format(xlnt::number_format::format::percentage_00));
wbk.save("/Users/thomas/Desktop/ab.xlsx");
wbk.save(temp_file.GetFilename());
if(PathHelper::FileExists(temp_file.GetFilename()))
{
@ -112,7 +112,7 @@ public:
{
auto ws = wb_.create_sheet();
ws.get_cell("F1").set_value(10);
ws.get_row_properties(ws.get_cell("F1").get_row()).set_height(30);
ws.get_row_properties(ws.get_cell("F1").get_row()).height = 30;
auto content = xlnt::writer::write_worksheet(ws, {}, {});
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_height.xml", content));
}

View File

@ -13,7 +13,7 @@ public:
{
existing_file = PathHelper::GetDataDirectory("/genuine/empty.xlsx");
expected_content_types_string = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\"><Default Extension=\"xml\" ContentType=\"application/xml\"/><Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/><Override PartName=\"/xl/workbook.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\"/><Override PartName=\"/xl/worksheets/sheet1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\"/><Override PartName=\"/xl/worksheets/sheet2.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\"/><Override PartName=\"/xl/worksheets/sheet3.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\"/><Override PartName=\"/xl/worksheets/sheet4.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\"/><Override PartName=\"/xl/theme/theme1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.theme+xml\"/><Override PartName=\"/xl/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml\"/><Override PartName=\"/xl/sharedStrings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml\"/><Override PartName=\"/xl/calcChain.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml\"/><Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\"/><Override PartName=\"/docProps/app.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\"/></Types>";
expected_atxt_string = "<?xml version=\"1.0\" ?>\r\n<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" count=\"3\" uniqueCount=\"2\"><si><t>This is cell A1 in Sheet 1</t></si><si><t>This is cell G5</t></si></sst>";
expected_atxt_string = "<?xml version=\"1.0\" ?>\n<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" count=\"3\" uniqueCount=\"2\"><si><t>This is cell A1 in Sheet 1</t></si><si><t>This is cell G5</t></si></sst>";
expected_printdir_string = " Length Date Time Name\n--------- ---------- ----- ----\n 1704 01/01/1980 00:00 [Content_Types].xml\n 588 01/01/1980 00:00 _rels/.rels\n 1254 01/01/1980 00:00 xl/_rels/workbook.xml.rels\n 898 01/01/1980 00:00 xl/workbook.xml\n 1231 01/01/1980 00:00 xl/worksheets/sheet4.xml\n 4427 01/01/1980 00:00 xl/worksheets/sheet2.xml\n 1032 01/01/1980 00:00 xl/worksheets/sheet3.xml\n 1026 01/01/1980 00:00 xl/worksheets/sheet1.xml\n 6995 01/01/1980 00:00 xl/theme/theme1.xml\n 233 01/01/1980 00:00 xl/sharedStrings.xml\n 1724 01/01/1980 00:00 xl/styles.xml\n 169 01/01/1980 00:00 xl/calcChain.xml\n 917 01/01/1980 00:00 docProps/app.xml\n 609 01/01/1980 00:00 docProps/core.xml\n--------- -------\n 22807 14 files\n";
}