mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
fix windows build for dll and static lib
This commit is contained in:
parent
7b5246f9dd
commit
6aaf380c26
|
@ -60,6 +60,11 @@ SET(PUGIXML ../third-party/pugixml/src/pugixml.hpp ../third-party/pugixml/src/pu
|
||||||
|
|
||||||
if(SHARED)
|
if(SHARED)
|
||||||
add_library(xlnt SHARED ${HEADERS} ${SOURCES} ${MINIZ} ${PUGIXML})
|
add_library(xlnt SHARED ${HEADERS} ${SOURCES} ${MINIZ} ${PUGIXML})
|
||||||
|
target_compile_definitions(xlnt PRIVATE XLNT_EXPORT=1)
|
||||||
|
add_definitions(-DXLNT_SHARED)
|
||||||
|
if(MSVC)
|
||||||
|
set_target_properties(xlnt PROPERTIES COMPILE_FLAGS "/wd\"4251\"")
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
add_library(xlnt STATIC ${HEADERS} ${SOURCES} ${MINIZ} ${PUGIXML})
|
add_library(xlnt STATIC ${HEADERS} ${SOURCES} ${MINIZ} ${PUGIXML})
|
||||||
endif()
|
endif()
|
||||||
|
@ -106,7 +111,7 @@ configure_file(
|
||||||
IMMEDIATE @ONLY)
|
IMMEDIATE @ONLY)
|
||||||
|
|
||||||
|
|
||||||
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../include/xlnt
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../include/xlnt
|
||||||
DESTINATION include
|
DESTINATION include
|
||||||
PATTERN ".DS_Store" EXCLUDE
|
PATTERN ".DS_Store" EXCLUDE
|
||||||
)
|
)
|
||||||
|
@ -116,7 +121,7 @@ install(TARGETS xlnt
|
||||||
ARCHIVE DESTINATION ${LIB_DEST_DIR}
|
ARCHIVE DESTINATION ${LIB_DEST_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
INSTALL(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc"
|
install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc"
|
||||||
DESTINATION ${LIB_DEST_DIR}/pkgconfig
|
DESTINATION ${LIB_DEST_DIR}/pkgconfig
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,10 @@ source_group(runner FILES ${RUNNER})
|
||||||
|
|
||||||
target_link_libraries(xlnt.test xlnt)
|
target_link_libraries(xlnt.test xlnt)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
set_target_properties(xlnt.test PROPERTIES COMPILE_FLAGS "/wd\"4251\"")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Needed for PathFileExists in path_helper (test helper)
|
# Needed for PathFileExists in path_helper (test helper)
|
||||||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
||||||
target_link_libraries(xlnt.test Shlwapi)
|
target_link_libraries(xlnt.test Shlwapi)
|
||||||
|
|
|
@ -381,13 +381,19 @@ public:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return true if this cell is uninitialized.
|
/// Return true if this cell is uninitialized.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
friend bool operator==(std::nullptr_t, const cell &cell);
|
friend XLNT_FUNCTION bool operator==(std::nullptr_t, const cell &cell);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return the result of left.get_reference() < right.get_reference().
|
/// Return the result of left.get_reference() < right.get_reference().
|
||||||
/// What's the point of this?
|
/// What's the point of this?
|
||||||
/// </summary>
|
/// </summary>
|
||||||
friend bool operator<(cell left, cell right);
|
friend XLNT_FUNCTION bool operator<(const cell left, const cell right);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Convenience function for writing cell to an ostream.
|
||||||
|
/// Uses cell::to_string() internally.
|
||||||
|
/// </summary>
|
||||||
|
friend XLNT_FUNCTION std::ostream &operator<<(std::ostream &stream, const xlnt::cell &cell);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// make these friends so they can use the private constructor
|
// make these friends so they can use the private constructor
|
||||||
|
@ -406,13 +412,4 @@ private:
|
||||||
detail::cell_impl *d_;
|
detail::cell_impl *d_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Convenience function for writing cell to an ostream.
|
|
||||||
/// Uses cell::to_string() internally.
|
|
||||||
/// </summary>
|
|
||||||
inline std::ostream &operator<<(std::ostream &stream, const xlnt::cell &cell)
|
|
||||||
{
|
|
||||||
return stream << std::string(cell.to_string().data());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace xlnt
|
} // namespace xlnt
|
||||||
|
|
|
@ -46,10 +46,10 @@ enum class target_mode
|
||||||
/// Represents an association between a source Package or part, and a target object which can be a part or external
|
/// Represents an association between a source Package or part, and a target object which can be a part or external
|
||||||
/// resource.
|
/// resource.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class relationship
|
class XLNT_CLASS relationship
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class type
|
enum class XLNT_CLASS type
|
||||||
{
|
{
|
||||||
invalid,
|
invalid,
|
||||||
hyperlink,
|
hyperlink,
|
||||||
|
@ -141,10 +141,12 @@ class relationship
|
||||||
}
|
}
|
||||||
|
|
||||||
relationship();
|
relationship();
|
||||||
|
|
||||||
relationship(const string &t, const string &r_id = "", const string &target_uri = "")
|
relationship(const string &t, const string &r_id = "", const string &target_uri = "")
|
||||||
: relationship(type_from_string(t), r_id, target_uri)
|
: relationship(type_from_string(t), r_id, target_uri)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
relationship(type t, const string &r_id = "", const string &target_uri = "");
|
relationship(type t, const string &r_id = "", const string &target_uri = "");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -183,12 +185,13 @@ class relationship
|
||||||
{
|
{
|
||||||
return type_;
|
return type_;
|
||||||
}
|
}
|
||||||
|
|
||||||
string get_type_string() const
|
string get_type_string() const
|
||||||
{
|
{
|
||||||
return type_to_string(type_);
|
return type_to_string(type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator==(const relationship &left, const relationship &right)
|
friend XLNT_FUNCTION bool operator==(const relationship &left, const relationship &right)
|
||||||
{
|
{
|
||||||
return left.type_ == right.type_
|
return left.type_ == right.type_
|
||||||
&& left.id_ == right.id_
|
&& left.id_ == right.id_
|
||||||
|
|
|
@ -278,12 +278,12 @@ public:
|
||||||
|
|
||||||
bool operator<(const string &other) const;
|
bool operator<(const string &other) const;
|
||||||
|
|
||||||
friend void swap(string &left, string &right);
|
friend XLNT_FUNCTION void swap(string &left, string &right);
|
||||||
friend std::ostream &operator<<(std::ostream &left, string &right);
|
friend XLNT_FUNCTION std::ostream & operator<<(std::ostream &left, string &right);
|
||||||
friend string operator+(const char *left, const string &right);
|
friend XLNT_FUNCTION string operator+(const char *left, const string &right);
|
||||||
|
|
||||||
friend bool operator==(const char *left, const string &right) { return right == left; }
|
friend XLNT_FUNCTION bool operator==(const char *left, const string &right) { return right == left; }
|
||||||
friend bool operator!=(const char *left, const string &right) { return right != left; }
|
friend XLNT_FUNCTION bool operator!=(const char *left, const string &right) { return right != left; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit string(size_type initial_size);
|
explicit string(size_type initial_size);
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace detail { struct workbook_impl; } // namespace detail
|
||||||
class XLNT_CLASS workbook
|
class XLNT_CLASS workbook
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class iterator
|
class XLNT_CLASS iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
iterator(workbook &wb, std::size_t index);
|
iterator(workbook &wb, std::size_t index);
|
||||||
|
@ -85,7 +85,7 @@ class XLNT_CLASS workbook
|
||||||
std::size_t index_;
|
std::size_t index_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class const_iterator
|
class XLNT_CLASS const_iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const_iterator(const workbook &wb, std::size_t index);
|
const_iterator(const workbook &wb, std::size_t index);
|
||||||
|
|
|
@ -18,7 +18,7 @@ class XLNT_CLASS cell_vector
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template <bool is_const = true>
|
template <bool is_const = true>
|
||||||
class common_iterator : public std::iterator<std::bidirectional_iterator_tag, cell>
|
class XLNT_CLASS common_iterator : public std::iterator<std::bidirectional_iterator_tag, cell>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
common_iterator(worksheet ws, const cell_reference &start_cell, major_order order = major_order::row)
|
common_iterator(worksheet ws, const cell_reference &start_cell, major_order order = major_order::row)
|
||||||
|
|
|
@ -40,7 +40,7 @@ class XLNT_CLASS range
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template <bool is_const = true>
|
template <bool is_const = true>
|
||||||
class common_iterator : public std::iterator<std::bidirectional_iterator_tag, cell>
|
class XLNT_CLASS common_iterator : public std::iterator<std::bidirectional_iterator_tag, cell>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
common_iterator(worksheet ws, const range_reference &start_cell, major_order order = major_order::row)
|
common_iterator(worksheet ws, const range_reference &start_cell, major_order order = major_order::row)
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
// @author: see AUTHORS file
|
// @author: see AUTHORS file
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
// Change these values for programs using this library.
|
// Change these values for programs using this library.
|
||||||
|
|
||||||
namespace xlnt {
|
namespace xlnt {
|
||||||
|
@ -64,6 +62,8 @@ const limit_style LimitStyle = limit_style::openpyxl;
|
||||||
#else
|
#else
|
||||||
#define XLNT_API __declspec(dllimport)
|
#define XLNT_API __declspec(dllimport)
|
||||||
#endif // XLNT_EXPORT
|
#endif // XLNT_EXPORT
|
||||||
|
#else
|
||||||
|
#define XLNT_API
|
||||||
#endif // XLNT_SHARED
|
#endif // XLNT_SHARED
|
||||||
#else
|
#else
|
||||||
#define XLNT_API
|
#define XLNT_API
|
||||||
|
|
|
@ -810,116 +810,117 @@ bool cell::garbage_collectible() const
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(bool b)
|
XLNT_FUNCTION void cell::set_value(bool b)
|
||||||
{
|
{
|
||||||
d_->value_numeric_ = b ? 1 : 0;
|
d_->value_numeric_ = b ? 1 : 0;
|
||||||
d_->type_ = type::boolean;
|
d_->type_ = type::boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(std::int8_t i)
|
XLNT_FUNCTION void cell::set_value(std::int8_t i)
|
||||||
{
|
{
|
||||||
d_->value_numeric_ = static_cast<long double>(i);
|
d_->value_numeric_ = static_cast<long double>(i);
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(std::int16_t i)
|
XLNT_FUNCTION void cell::set_value(std::int16_t i)
|
||||||
{
|
{
|
||||||
d_->value_numeric_ = static_cast<long double>(i);
|
d_->value_numeric_ = static_cast<long double>(i);
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(std::int32_t i)
|
XLNT_FUNCTION void cell::set_value(std::int32_t i)
|
||||||
{
|
{
|
||||||
d_->value_numeric_ = static_cast<long double>(i);
|
d_->value_numeric_ = static_cast<long double>(i);
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(std::int64_t i)
|
XLNT_FUNCTION void cell::set_value(std::int64_t i)
|
||||||
{
|
{
|
||||||
d_->value_numeric_ = static_cast<long double>(i);
|
d_->value_numeric_ = static_cast<long double>(i);
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(std::uint8_t i)
|
XLNT_FUNCTION void cell::set_value(std::uint8_t i)
|
||||||
{
|
{
|
||||||
d_->value_numeric_ = static_cast<long double>(i);
|
d_->value_numeric_ = static_cast<long double>(i);
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(std::uint16_t i)
|
XLNT_FUNCTION void cell::set_value(std::uint16_t i)
|
||||||
{
|
{
|
||||||
d_->value_numeric_ = static_cast<long double>(i);
|
d_->value_numeric_ = static_cast<long double>(i);
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(std::uint32_t i)
|
XLNT_FUNCTION void cell::set_value(std::uint32_t i)
|
||||||
{
|
{
|
||||||
d_->value_numeric_ = static_cast<long double>(i);
|
d_->value_numeric_ = static_cast<long double>(i);
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(std::uint64_t i)
|
XLNT_FUNCTION void cell::set_value(std::uint64_t i)
|
||||||
{
|
{
|
||||||
d_->value_numeric_ = static_cast<long double>(i);
|
d_->value_numeric_ = static_cast<long double>(i);
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _MSC_VER
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(unsigned long i)
|
XLNT_FUNCTION void cell::set_value(unsigned long i)
|
||||||
{
|
{
|
||||||
d_->value_numeric_ = static_cast<long double>(i);
|
d_->value_numeric_ = static_cast<long double>(i);
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // _MSC_VER
|
||||||
|
|
||||||
|
//TODO: base this on 64-bit model (i.e. LLP64/LP64) rather than system/compiler
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(long long i)
|
XLNT_FUNCTION void cell::set_value(long long i)
|
||||||
{
|
{
|
||||||
d_->value_numeric_ = static_cast<long double>(i);
|
d_->value_numeric_ = static_cast<long double>(i);
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(unsigned long long i)
|
XLNT_FUNCTION void cell::set_value(unsigned long long i)
|
||||||
{
|
{
|
||||||
d_->value_numeric_ = static_cast<long double>(i);
|
d_->value_numeric_ = static_cast<long double>(i);
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // __linux
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(float f)
|
XLNT_FUNCTION void cell::set_value(float f)
|
||||||
{
|
{
|
||||||
d_->value_numeric_ = static_cast<long double>(f);
|
d_->value_numeric_ = static_cast<long double>(f);
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(double d)
|
XLNT_FUNCTION void cell::set_value(double d)
|
||||||
{
|
{
|
||||||
d_->value_numeric_ = static_cast<long double>(d);
|
d_->value_numeric_ = static_cast<long double>(d);
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(long double d)
|
XLNT_FUNCTION void cell::set_value(long double d)
|
||||||
{
|
{
|
||||||
d_->value_numeric_ = static_cast<long double>(d);
|
d_->value_numeric_ = static_cast<long double>(d);
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void XLNT_FUNCTION cell::set_value(string s)
|
XLNT_FUNCTION void cell::set_value(string s)
|
||||||
{
|
{
|
||||||
d_->set_string(s, get_parent().get_parent().get_guess_types());
|
d_->set_string(s, get_parent().get_parent().get_guess_types());
|
||||||
|
|
||||||
|
@ -930,13 +931,13 @@ void XLNT_FUNCTION cell::set_value(string s)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void XLNT_FUNCTION cell::set_value(char const *c)
|
XLNT_FUNCTION void cell::set_value(char const *c)
|
||||||
{
|
{
|
||||||
set_value(string(c));
|
set_value(string(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(cell c)
|
XLNT_FUNCTION void cell::set_value(cell c)
|
||||||
{
|
{
|
||||||
d_->type_ = c.d_->type_;
|
d_->type_ = c.d_->type_;
|
||||||
d_->value_numeric_ = c.d_->value_numeric_;
|
d_->value_numeric_ = c.d_->value_numeric_;
|
||||||
|
@ -949,7 +950,7 @@ void cell::set_value(cell c)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(date d)
|
XLNT_FUNCTION void cell::set_value(date d)
|
||||||
{
|
{
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
d_->value_numeric_ = d.to_number(get_base_date());
|
d_->value_numeric_ = d.to_number(get_base_date());
|
||||||
|
@ -957,7 +958,7 @@ void cell::set_value(date d)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(datetime d)
|
XLNT_FUNCTION void cell::set_value(datetime d)
|
||||||
{
|
{
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
d_->value_numeric_ = d.to_number(get_base_date());
|
d_->value_numeric_ = d.to_number(get_base_date());
|
||||||
|
@ -965,7 +966,7 @@ void cell::set_value(datetime d)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(time t)
|
XLNT_FUNCTION void cell::set_value(time t)
|
||||||
{
|
{
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
d_->value_numeric_ = t.to_number();
|
d_->value_numeric_ = t.to_number();
|
||||||
|
@ -973,13 +974,21 @@ void cell::set_value(time t)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void cell::set_value(timedelta t)
|
XLNT_FUNCTION void cell::set_value(timedelta t)
|
||||||
{
|
{
|
||||||
d_->type_ = type::numeric;
|
d_->type_ = type::numeric;
|
||||||
d_->value_numeric_ = t.to_number();
|
d_->value_numeric_ = t.to_number();
|
||||||
set_number_format(number_format::date_timedelta());
|
set_number_format(number_format::date_timedelta());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef XLNT_STD_STRING
|
||||||
|
template<>
|
||||||
|
XLNT_FUNCTION void cell::set_value(std::string str)
|
||||||
|
{
|
||||||
|
set_value(string(str.data()));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
row_t cell::get_row() const
|
row_t cell::get_row() const
|
||||||
{
|
{
|
||||||
return d_->row_;
|
return d_->row_;
|
||||||
|
@ -1044,11 +1053,21 @@ cell &cell::operator=(const cell &rhs)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator<(cell left, cell right)
|
XLNT_FUNCTION bool operator==(std::nullptr_t, const cell &cell)
|
||||||
|
{
|
||||||
|
return cell == nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
XLNT_FUNCTION bool operator<(const cell left, const cell right)
|
||||||
{
|
{
|
||||||
return left.get_reference() < right.get_reference();
|
return left.get_reference() < right.get_reference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XLNT_FUNCTION std::ostream &operator<<(std::ostream &stream, const xlnt::cell &cell)
|
||||||
|
{
|
||||||
|
return stream << std::string(cell.to_string().data());
|
||||||
|
}
|
||||||
|
|
||||||
string cell::to_repr() const
|
string cell::to_repr() const
|
||||||
{
|
{
|
||||||
return "<Cell " + worksheet(d_->parent_).get_title() + "." + get_reference().to_string() + ">";
|
return "<Cell " + worksheet(d_->parent_).get_title() + "." + get_reference().to_string() + ">";
|
||||||
|
@ -1309,105 +1328,105 @@ void cell::clear_value()
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
bool cell::get_value() const
|
XLNT_FUNCTION bool cell::get_value() const
|
||||||
{
|
{
|
||||||
return d_->value_numeric_ != 0;
|
return d_->value_numeric_ != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
std::int8_t cell::get_value() const
|
XLNT_FUNCTION std::int8_t cell::get_value() const
|
||||||
{
|
{
|
||||||
return static_cast<std::int8_t>(d_->value_numeric_);
|
return static_cast<std::int8_t>(d_->value_numeric_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
std::int16_t cell::get_value() const
|
XLNT_FUNCTION std::int16_t cell::get_value() const
|
||||||
{
|
{
|
||||||
return static_cast<std::int16_t>(d_->value_numeric_);
|
return static_cast<std::int16_t>(d_->value_numeric_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
std::int32_t cell::get_value() const
|
XLNT_FUNCTION std::int32_t cell::get_value() const
|
||||||
{
|
{
|
||||||
return static_cast<std::int32_t>(d_->value_numeric_);
|
return static_cast<std::int32_t>(d_->value_numeric_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
std::int64_t cell::get_value() const
|
XLNT_FUNCTION std::int64_t cell::get_value() const
|
||||||
{
|
{
|
||||||
return static_cast<std::int64_t>(d_->value_numeric_);
|
return static_cast<std::int64_t>(d_->value_numeric_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
std::uint8_t cell::get_value() const
|
XLNT_FUNCTION std::uint8_t cell::get_value() const
|
||||||
{
|
{
|
||||||
return static_cast<std::uint8_t>(d_->value_numeric_);
|
return static_cast<std::uint8_t>(d_->value_numeric_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
std::uint16_t cell::get_value() const
|
XLNT_FUNCTION std::uint16_t cell::get_value() const
|
||||||
{
|
{
|
||||||
return static_cast<std::uint16_t>(d_->value_numeric_);
|
return static_cast<std::uint16_t>(d_->value_numeric_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
std::uint32_t cell::get_value() const
|
XLNT_FUNCTION std::uint32_t cell::get_value() const
|
||||||
{
|
{
|
||||||
return static_cast<std::uint32_t>(d_->value_numeric_);
|
return static_cast<std::uint32_t>(d_->value_numeric_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
std::uint64_t cell::get_value() const
|
XLNT_FUNCTION std::uint64_t cell::get_value() const
|
||||||
{
|
{
|
||||||
return static_cast<std::uint64_t>(d_->value_numeric_);
|
return static_cast<std::uint64_t>(d_->value_numeric_);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
template <>
|
template <>
|
||||||
long long int cell::get_value() const
|
XLNT_FUNCTION long long int cell::get_value() const
|
||||||
{
|
{
|
||||||
return static_cast<long long int>(d_->value_numeric_);
|
return static_cast<long long int>(d_->value_numeric_);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
float cell::get_value() const
|
XLNT_FUNCTION float cell::get_value() const
|
||||||
{
|
{
|
||||||
return static_cast<float>(d_->value_numeric_);
|
return static_cast<float>(d_->value_numeric_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
double cell::get_value() const
|
XLNT_FUNCTION double cell::get_value() const
|
||||||
{
|
{
|
||||||
return static_cast<double>(d_->value_numeric_);
|
return static_cast<double>(d_->value_numeric_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
long double cell::get_value() const
|
XLNT_FUNCTION long double cell::get_value() const
|
||||||
{
|
{
|
||||||
return d_->value_numeric_;
|
return d_->value_numeric_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
time cell::get_value() const
|
XLNT_FUNCTION time cell::get_value() const
|
||||||
{
|
{
|
||||||
return time::from_number(d_->value_numeric_);
|
return time::from_number(d_->value_numeric_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
datetime cell::get_value() const
|
XLNT_FUNCTION datetime cell::get_value() const
|
||||||
{
|
{
|
||||||
return datetime::from_number(d_->value_numeric_, get_base_date());
|
return datetime::from_number(d_->value_numeric_, get_base_date());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
date cell::get_value() const
|
XLNT_FUNCTION date cell::get_value() const
|
||||||
{
|
{
|
||||||
return date::from_number(static_cast<int>(d_->value_numeric_), get_base_date());
|
return date::from_number(static_cast<int>(d_->value_numeric_), get_base_date());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
timedelta cell::get_value() const
|
XLNT_FUNCTION timedelta cell::get_value() const
|
||||||
{
|
{
|
||||||
return timedelta::from_number(d_->value_numeric_);
|
return timedelta::from_number(d_->value_numeric_);
|
||||||
}
|
}
|
||||||
|
@ -1419,11 +1438,19 @@ void cell::set_number_format(const number_format &number_format_)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
string cell::get_value() const
|
XLNT_FUNCTION string cell::get_value() const
|
||||||
{
|
{
|
||||||
return d_->value_string_;
|
return d_->value_string_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef XLNT_STD_STRING
|
||||||
|
template<>
|
||||||
|
XLNT_FUNCTION std::string cell::get_value() const
|
||||||
|
{
|
||||||
|
return std::string(d_->value_string_.data());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool cell::has_value() const
|
bool cell::has_value() const
|
||||||
{
|
{
|
||||||
return d_->type_ != cell::type::null;
|
return d_->type_ != cell::type::null;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace xlnt {
|
namespace xlnt {
|
||||||
|
|
||||||
relationship::relationship(type t, const string &r_id, const string &target_uri)
|
XLNT_FUNCTION relationship::relationship(type t, const string &r_id, const string &target_uri)
|
||||||
: type_(t), id_(r_id), source_uri_(""), target_uri_(target_uri), target_mode_(target_mode::internal)
|
: type_(t), id_(r_id), source_uri_(""), target_uri_(target_uri), target_mode_(target_mode::internal)
|
||||||
{
|
{
|
||||||
if (t == type::hyperlink)
|
if (t == type::hyperlink)
|
||||||
|
@ -11,7 +11,7 @@ relationship::relationship(type t, const string &r_id, const string &target_uri)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
relationship::relationship()
|
XLNT_FUNCTION relationship::relationship()
|
||||||
: type_(type::invalid), id_(""), source_uri_(""), target_uri_(""), target_mode_(target_mode::internal)
|
: type_(type::invalid), id_(""), source_uri_(""), target_uri_(""), target_mode_(target_mode::internal)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,11 +99,13 @@ string string::from(std::uint64_t i)
|
||||||
return string(std::to_string(i).c_str());
|
return string(std::to_string(i).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
template<>
|
template<>
|
||||||
string string::from(std::size_t i)
|
string string::from(std::size_t i)
|
||||||
{
|
{
|
||||||
return string(std::to_string(i).c_str());
|
return string(std::to_string(i).c_str());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
string string::from(float i)
|
string string::from(float i)
|
||||||
|
@ -213,8 +215,8 @@ xlnt::string::const_iterator &xlnt::string::const_iterator::operator++()
|
||||||
|
|
||||||
string::const_iterator &string::const_iterator::operator+=(int offset)
|
string::const_iterator &string::const_iterator::operator+=(int offset)
|
||||||
{
|
{
|
||||||
auto new_index = index_ + offset;
|
auto new_index = static_cast<int>(index_) + offset;
|
||||||
new_index = std::max<int>(0, std::min<int>(parent_->length(), new_index));
|
new_index = std::max<int>(0, std::min<int>(static_cast<int>(parent_->length()), new_index));
|
||||||
index_ = static_cast<std::size_t>(new_index);
|
index_ = static_cast<std::size_t>(new_index);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -224,8 +226,8 @@ xlnt::string::iterator xlnt::string::iterator::operator+(int offset)
|
||||||
{
|
{
|
||||||
iterator copy = *this;
|
iterator copy = *this;
|
||||||
|
|
||||||
auto new_index = index_ + offset;
|
auto new_index = static_cast<int>(index_) + offset;
|
||||||
new_index = std::max<int>(0, std::min<int>(parent_->length(), new_index));
|
new_index = std::max<int>(0, std::min<int>(static_cast<int>(parent_->length()), new_index));
|
||||||
copy.index_ = static_cast<std::size_t>(new_index);
|
copy.index_ = static_cast<std::size_t>(new_index);
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
|
@ -235,8 +237,8 @@ xlnt::string::const_iterator xlnt::string::const_iterator::operator+(int offset)
|
||||||
{
|
{
|
||||||
const_iterator copy = *this;
|
const_iterator copy = *this;
|
||||||
|
|
||||||
auto new_index = index_ + offset;
|
auto new_index = static_cast<int>(index_) + offset;
|
||||||
new_index = std::max<int>(0, std::min<int>(parent_->length(), new_index));
|
new_index = std::max<int>(0, std::min<int>(static_cast<int>(parent_->length()), new_index));
|
||||||
copy.index_ = static_cast<std::size_t>(new_index);
|
copy.index_ = static_cast<std::size_t>(new_index);
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
|
@ -378,10 +380,10 @@ string string::substr(size_type offset, size_type len) const
|
||||||
{
|
{
|
||||||
if(len != npos && offset + len < length())
|
if(len != npos && offset + len < length())
|
||||||
{
|
{
|
||||||
return string(begin() + offset, begin() + (offset + len));
|
return string(begin() + static_cast<int>(offset), begin() + static_cast<int>(offset + len));
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(begin() + offset, end());
|
return string(begin() + static_cast<int>(offset), end());
|
||||||
}
|
}
|
||||||
|
|
||||||
string::code_point string::back() const
|
string::code_point string::back() const
|
||||||
|
@ -411,7 +413,7 @@ string::size_type string::find(const string &str) const
|
||||||
|
|
||||||
string::size_type string::find(code_point c, size_type offset) const
|
string::size_type string::find(code_point c, size_type offset) const
|
||||||
{
|
{
|
||||||
auto iter = begin() + offset;
|
auto iter = begin() + static_cast<int>(offset);
|
||||||
|
|
||||||
while (iter != end())
|
while (iter != end())
|
||||||
{
|
{
|
||||||
|
@ -464,7 +466,7 @@ string::size_type string::find_last_of(const string &str) const
|
||||||
|
|
||||||
string::size_type string::find_last_of(code_point c, size_type offset) const
|
string::size_type string::find_last_of(code_point c, size_type offset) const
|
||||||
{
|
{
|
||||||
auto stop = begin() + offset;
|
auto stop = begin() + static_cast<int>(offset);
|
||||||
auto iter = end() - 1;
|
auto iter = end() - 1;
|
||||||
|
|
||||||
while (iter != stop)
|
while (iter != stop)
|
||||||
|
@ -486,7 +488,7 @@ string::size_type string::find_last_of(char c, size_type offset) const
|
||||||
|
|
||||||
string::size_type string::find_last_of(const string &str, size_type offset) const
|
string::size_type string::find_last_of(const string &str, size_type offset) const
|
||||||
{
|
{
|
||||||
auto stop = begin() + offset;
|
auto stop = begin() + static_cast<int>(offset);
|
||||||
auto iter = end() - 1;
|
auto iter = end() - 1;
|
||||||
|
|
||||||
while (iter != stop)
|
while (iter != stop)
|
||||||
|
@ -509,7 +511,7 @@ string::size_type string::find_first_of(const string &str) const
|
||||||
|
|
||||||
string::size_type string::find_first_of(const string &str, size_type offset) const
|
string::size_type string::find_first_of(const string &str, size_type offset) const
|
||||||
{
|
{
|
||||||
auto iter = begin() + offset;
|
auto iter = begin() + static_cast<int>(offset);
|
||||||
|
|
||||||
while (iter != end())
|
while (iter != end())
|
||||||
{
|
{
|
||||||
|
@ -531,7 +533,7 @@ string::size_type string::find_first_not_of(const string &str) const
|
||||||
|
|
||||||
string::size_type string::find_first_not_of(const string &str, size_type offset) const
|
string::size_type string::find_first_not_of(const string &str, size_type offset) const
|
||||||
{
|
{
|
||||||
auto iter = begin() + offset;
|
auto iter = begin() + static_cast<int>(offset);
|
||||||
|
|
||||||
while (iter != end())
|
while (iter != end())
|
||||||
{
|
{
|
||||||
|
@ -553,7 +555,7 @@ string::size_type string::find_last_not_of(const string &str) const
|
||||||
|
|
||||||
string::size_type string::find_last_not_of(const string &str, size_type offset) const
|
string::size_type string::find_last_not_of(const string &str, size_type offset) const
|
||||||
{
|
{
|
||||||
auto stop = begin() + offset;
|
auto stop = begin() + static_cast<int>(offset);
|
||||||
auto iter = end() - 1;
|
auto iter = end() - 1;
|
||||||
|
|
||||||
while (iter != stop)
|
while (iter != stop)
|
||||||
|
@ -767,8 +769,8 @@ void string::replace(size_type index, utf32_char value)
|
||||||
auto data_start = code_point_byte_offsets_->at(index);
|
auto data_start = code_point_byte_offsets_->at(index);
|
||||||
auto data_end = code_point_byte_offsets_->at(index + 1);
|
auto data_end = code_point_byte_offsets_->at(index + 1);
|
||||||
|
|
||||||
auto previous_len = data_end - data_start;
|
auto previous_len = static_cast<int>(data_end - data_start);
|
||||||
int difference = encoded_len - previous_len;
|
int difference = static_cast<int>(encoded_len) - previous_len;
|
||||||
|
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
{
|
{
|
||||||
|
@ -866,7 +868,7 @@ string &string::operator+=(const string &rhs)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void swap(string &left, string &right)
|
XLNT_FUNCTION void swap(string &left, string &right)
|
||||||
{
|
{
|
||||||
using std::swap;
|
using std::swap;
|
||||||
|
|
||||||
|
@ -874,7 +876,7 @@ void swap(string &left, string &right)
|
||||||
swap(left.code_point_byte_offsets_, right.code_point_byte_offsets_);
|
swap(left.code_point_byte_offsets_, right.code_point_byte_offsets_);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &left, string &right)
|
XLNT_FUNCTION std::ostream &operator<<(std::ostream &left, string &right)
|
||||||
{
|
{
|
||||||
auto d = right.data();
|
auto d = right.data();
|
||||||
std::size_t i = 0;
|
std::size_t i = 0;
|
||||||
|
@ -888,12 +890,12 @@ std::ostream &operator<<(std::ostream &left, string &right)
|
||||||
return left;
|
return left;
|
||||||
}
|
}
|
||||||
|
|
||||||
string operator+(const char *left, const string &right)
|
XLNT_FUNCTION string operator+(const char *left, const string &right)
|
||||||
{
|
{
|
||||||
return string(left) + right;
|
return string(left) + right;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool string::operator<(const string &other) const
|
XLNT_FUNCTION bool string::operator<(const string &other) const
|
||||||
{
|
{
|
||||||
return std::string(data()) < std::string(other.data());
|
return std::string(data()) < std::string(other.data());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user