fix windows configuration

This commit is contained in:
Thomas Fussell 2015-11-10 20:47:07 -05:00
parent 990c2a926f
commit 1e746ad587
12 changed files with 82 additions and 69 deletions

View File

@ -4,4 +4,4 @@ for /f %%i in ('where python') DO (set PYTHON=%%i) & goto :done1
:done1 :done1
@where python3 > nul 2>&1 && for /f %%i in ('@where python3') DO (@set PYTHON=%%i) & goto :done2 @where python3 > nul 2>&1 && for /f %%i in ('@where python3') DO (@set PYTHON=%%i) & goto :done2
:done2 :done2
!PYTHON! configure %* !PYTHON! configure clean

View File

@ -7,7 +7,11 @@ set(PROJECT_DESCRIPTION "user-friendly xlsx library for C++14")
include(VERSION.cmake) include(VERSION.cmake)
if(NOT CMAKE_INSTALL_PREFIX) if(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX /usr/local) if(MSVC)
set(CMAKE_INSTALL_PREFIX /c/Program Files/xlnt)
else()
set(CMAKE_INSTALL_PREFIX /usr/local)
endif()
endif() endif()
set(INC_DEST_DIR ${CMAKE_INSTALL_PREFIX}/include) set(INC_DEST_DIR ${CMAKE_INSTALL_PREFIX}/include)
@ -16,6 +20,10 @@ if(NOT LIB_DEST_DIR)
set(LIB_DEST_DIR ${CMAKE_INSTALL_PREFIX}/lib) set(LIB_DEST_DIR ${CMAKE_INSTALL_PREFIX}/lib)
endif() endif()
if(NOT BIN_DEST_DIR)
set(BIN_DEST_DIR ${CMAKE_INSTALL_PREFIX}/bin)
endif()
include_directories(../include) include_directories(../include)
include_directories(../include/xlnt) include_directories(../include/xlnt)
include_directories(../source) include_directories(../source)
@ -63,7 +71,7 @@ if(SHARED)
target_compile_definitions(xlnt PRIVATE XLNT_EXPORT=1) target_compile_definitions(xlnt PRIVATE XLNT_EXPORT=1)
add_definitions(-DXLNT_SHARED) add_definitions(-DXLNT_SHARED)
if(MSVC) if(MSVC)
set_target_properties(xlnt PROPERTIES COMPILE_FLAGS "/wd\"4251\" /MD") set_target_properties(xlnt PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\"")
endif() endif()
else() else()
add_library(xlnt STATIC ${HEADERS} ${SOURCES} ${MINIZ} ${PUGIXML}) add_library(xlnt STATIC ${HEADERS} ${SOURCES} ${MINIZ} ${PUGIXML})
@ -119,6 +127,7 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../include/xlnt
install(TARGETS xlnt install(TARGETS xlnt
LIBRARY DESTINATION ${LIB_DEST_DIR} LIBRARY DESTINATION ${LIB_DEST_DIR}
ARCHIVE DESTINATION ${LIB_DEST_DIR} ARCHIVE DESTINATION ${LIB_DEST_DIR}
RUNTIME DESTINATION ${BIN_DEST_DIR}
) )
install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc" install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc"

View File

@ -46,7 +46,7 @@ source_group(runner FILES ${RUNNER})
target_link_libraries(xlnt.test xlnt) target_link_libraries(xlnt.test xlnt)
if(MSVC) if(MSVC)
set_target_properties(xlnt.test PROPERTIES COMPILE_FLAGS "/wd\"4251\"") set_target_properties(xlnt.test PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\"")
endif() endif()
# Needed for PathFileExists in path_helper (test helper) # Needed for PathFileExists in path_helper (test helper)

2
configure vendored
View File

@ -26,6 +26,8 @@ def which(program):
for path in os.environ["PATH"].split(os.pathsep): for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"') path = path.strip('"')
exe_file = os.path.join(path, program) exe_file = os.path.join(path, program)
if sys.platform == 'win32':
exe_file += '.exe'
if is_exe(exe_file): if is_exe(exe_file):
return exe_file return exe_file

View File

@ -380,13 +380,22 @@ 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<(cell left, 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)
{
return stream << cell.to_string();
}
private: private:
// make these friends so they can use the private constructor // make these friends so they can use the private constructor
@ -405,13 +414,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 & XLNT_FUNCTION operator<<(std::ostream &stream, const xlnt::cell &cell)
{
return stream << cell.to_string();
}
} // namespace xlnt } // namespace xlnt

View File

@ -25,6 +25,8 @@
#include <string> #include <string>
#include <xlnt/xlnt_config.hpp>
namespace xlnt { namespace xlnt {
/// <summary> /// <summary>
@ -46,7 +48,7 @@ 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 type

View File

@ -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);

View File

@ -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)

View File

@ -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)

View File

@ -817,71 +817,71 @@ 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;
@ -890,14 +890,14 @@ void cell::set_value(unsigned long i)
#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;
@ -905,28 +905,28 @@ void cell::set_value(unsigned long long i)
#endif #endif
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 cell::set_value(std::string s) XLNT_FUNCTION void cell::set_value(std::string s)
{ {
d_->set_string(s, get_parent().get_parent().get_guess_types()); d_->set_string(s, get_parent().get_parent().get_guess_types());
@ -937,13 +937,13 @@ void cell::set_value(std::string s)
} }
template <> template <>
void cell::set_value(char const *c) XLNT_FUNCTION void cell::set_value(char const *c)
{ {
set_value(std::string(c)); set_value(std::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_;
@ -956,7 +956,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());
@ -964,7 +964,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());
@ -972,7 +972,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();
@ -980,7 +980,7 @@ 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();
@ -1316,105 +1316,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_);
} }
@ -1426,7 +1426,7 @@ void cell::set_number_format(const number_format &number_format_)
} }
template <> template <>
std::string cell::get_value() const XLNT_FUNCTION std::string cell::get_value() const
{ {
return d_->value_string_; return d_->value_string_;
} }

View File

@ -85,13 +85,13 @@ bool worksheet_serializer::read_worksheet(const xml_document &xml)
if (colon_index != std::string::npos) if (colon_index != std::string::npos)
{ {
min_column = static_cast<column_t>(std::stoll(span_string.substr(0, colon_index))); min_column = static_cast<column_t::index_t>(std::stoll(span_string.substr(0, colon_index)));
max_column = static_cast<column_t>(std::stoll(span_string.substr(colon_index + 1))); max_column = static_cast<column_t::index_t>(std::stoll(span_string.substr(colon_index + 1)));
} }
else else
{ {
min_column = static_cast<column_t>(full_range.get_top_left().get_column_index()); min_column = full_range.get_top_left().get_column_index();
max_column = static_cast<column_t>(full_range.get_bottom_right().get_column_index()); max_column = full_range.get_bottom_right().get_column_index();
} }
for (column_t i = min_column; i <= max_column; i++) for (column_t i = min_column; i <= max_column; i++)
@ -187,8 +187,8 @@ bool worksheet_serializer::read_worksheet(const xml_document &xml)
continue; continue;
} }
auto min = static_cast<column_t>(std::stoull(col_node.get_attribute("min"))); auto min = static_cast<column_t::index_t>(std::stoull(col_node.get_attribute("min")));
auto max = static_cast<column_t>(std::stoull(col_node.get_attribute("max"))); auto max = static_cast<column_t::index_t>(std::stoull(col_node.get_attribute("max")));
auto width = std::stold(col_node.get_attribute("width")); auto width = std::stold(col_node.get_attribute("width"));
bool custom = col_node.get_attribute("customWidth") == "1"; bool custom = col_node.get_attribute("customWidth") == "1";
auto column_style = static_cast<std::size_t>(col_node.has_attribute("style") ? std::stoull(col_node.get_attribute("style")) : 0); auto column_style = static_cast<std::size_t>(col_node.has_attribute("style") ? std::stoull(col_node.get_attribute("style")) : 0);

View File

@ -147,9 +147,9 @@ cell_vector range::get_vector(std::size_t vector_index)
} }
range_reference reference( range_reference reference(
static_cast<column_t>(static_cast<std::size_t>(ref_.get_top_left().get_column().index) + vector_index), static_cast<column_t::index_t>(static_cast<std::size_t>(ref_.get_top_left().get_column().index) + vector_index),
ref_.get_top_left().get_row(), ref_.get_top_left().get_row(),
static_cast<column_t>(static_cast<std::size_t>(ref_.get_top_left().get_column().index) + vector_index), static_cast<column_t::index_t>(static_cast<std::size_t>(ref_.get_top_left().get_column().index) + vector_index),
ref_.get_bottom_right().get_row()); ref_.get_bottom_right().get_row());
return cell_vector(ws_, reference, order_); return cell_vector(ws_, reference, order_);