From 1e746ad5876c81985b791950504fdd210e5f152b Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Tue, 10 Nov 2015 20:47:07 -0500 Subject: [PATCH] fix windows configuration --- clean.bat | 2 +- cmake/xlnt.cmake | 13 ++- cmake/xlnt.test.cmake | 2 +- configure | 2 + include/xlnt/cell/cell.hpp | 22 ++--- include/xlnt/packaging/relationship.hpp | 4 +- include/xlnt/workbook/workbook.hpp | 4 +- include/xlnt/worksheet/cell_vector.hpp | 2 +- include/xlnt/worksheet/range.hpp | 2 +- source/cell/cell.cpp | 82 +++++++++---------- source/serialization/worksheet_serializer.cpp | 12 +-- source/worksheet/range.cpp | 4 +- 12 files changed, 82 insertions(+), 69 deletions(-) diff --git a/clean.bat b/clean.bat index 44fbe3ee..7aa2ef0a 100644 --- a/clean.bat +++ b/clean.bat @@ -4,4 +4,4 @@ for /f %%i in ('where python') DO (set PYTHON=%%i) & goto :done1 :done1 @where python3 > nul 2>&1 && for /f %%i in ('@where python3') DO (@set PYTHON=%%i) & goto :done2 :done2 -!PYTHON! configure %* \ No newline at end of file +!PYTHON! configure clean \ No newline at end of file diff --git a/cmake/xlnt.cmake b/cmake/xlnt.cmake index 7a6d50be..a9b15dfe 100644 --- a/cmake/xlnt.cmake +++ b/cmake/xlnt.cmake @@ -7,7 +7,11 @@ set(PROJECT_DESCRIPTION "user-friendly xlsx library for C++14") include(VERSION.cmake) 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() 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) endif() +if(NOT BIN_DEST_DIR) + set(BIN_DEST_DIR ${CMAKE_INSTALL_PREFIX}/bin) +endif() + include_directories(../include) include_directories(../include/xlnt) include_directories(../source) @@ -63,7 +71,7 @@ if(SHARED) target_compile_definitions(xlnt PRIVATE XLNT_EXPORT=1) add_definitions(-DXLNT_SHARED) if(MSVC) - set_target_properties(xlnt PROPERTIES COMPILE_FLAGS "/wd\"4251\" /MD") + set_target_properties(xlnt PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\"") endif() else() add_library(xlnt STATIC ${HEADERS} ${SOURCES} ${MINIZ} ${PUGIXML}) @@ -119,6 +127,7 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../include/xlnt install(TARGETS xlnt LIBRARY DESTINATION ${LIB_DEST_DIR} ARCHIVE DESTINATION ${LIB_DEST_DIR} + RUNTIME DESTINATION ${BIN_DEST_DIR} ) install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc" diff --git a/cmake/xlnt.test.cmake b/cmake/xlnt.test.cmake index a69f12de..c1d51493 100644 --- a/cmake/xlnt.test.cmake +++ b/cmake/xlnt.test.cmake @@ -46,7 +46,7 @@ source_group(runner FILES ${RUNNER}) target_link_libraries(xlnt.test xlnt) 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() # Needed for PathFileExists in path_helper (test helper) diff --git a/configure b/configure index 5776ea55..6aeed888 100755 --- a/configure +++ b/configure @@ -26,6 +26,8 @@ def which(program): for path in os.environ["PATH"].split(os.pathsep): path = path.strip('"') exe_file = os.path.join(path, program) + if sys.platform == 'win32': + exe_file += '.exe' if is_exe(exe_file): return exe_file diff --git a/include/xlnt/cell/cell.hpp b/include/xlnt/cell/cell.hpp index ef2e3c2a..09039d4b 100644 --- a/include/xlnt/cell/cell.hpp +++ b/include/xlnt/cell/cell.hpp @@ -380,13 +380,22 @@ public: /// /// Return true if this cell is uninitialized. /// - friend bool operator==(std::nullptr_t, const cell &cell); + friend XLNT_FUNCTION bool operator==(std::nullptr_t, const cell &cell); /// /// Return the result of left.get_reference() < right.get_reference(). /// What's the point of this? /// - friend bool operator<(cell left, cell right); + friend XLNT_FUNCTION bool operator<(cell left, cell right); + + /// + /// Convenience function for writing cell to an ostream. + /// Uses cell::to_string() internally. + /// + friend XLNT_FUNCTION std::ostream &operator<<(std::ostream &stream, const xlnt::cell &cell) + { + return stream << cell.to_string(); + } private: // make these friends so they can use the private constructor @@ -405,13 +414,4 @@ private: detail::cell_impl *d_; }; -/// -/// Convenience function for writing cell to an ostream. -/// Uses cell::to_string() internally. -/// -inline std::ostream & XLNT_FUNCTION operator<<(std::ostream &stream, const xlnt::cell &cell) -{ - return stream << cell.to_string(); -} - } // namespace xlnt diff --git a/include/xlnt/packaging/relationship.hpp b/include/xlnt/packaging/relationship.hpp index 3e45fe77..40205ea0 100644 --- a/include/xlnt/packaging/relationship.hpp +++ b/include/xlnt/packaging/relationship.hpp @@ -25,6 +25,8 @@ #include +#include + namespace xlnt { /// @@ -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 /// resource. /// -class relationship +class XLNT_CLASS relationship { public: enum class type diff --git a/include/xlnt/workbook/workbook.hpp b/include/xlnt/workbook/workbook.hpp index 890c0499..5c31847f 100644 --- a/include/xlnt/workbook/workbook.hpp +++ b/include/xlnt/workbook/workbook.hpp @@ -65,7 +65,7 @@ namespace detail { struct workbook_impl; } // namespace detail class XLNT_CLASS workbook { public: - class iterator + class XLNT_CLASS iterator { public: iterator(workbook &wb, std::size_t index); @@ -85,7 +85,7 @@ class XLNT_CLASS workbook std::size_t index_; }; - class const_iterator + class XLNT_CLASS const_iterator { public: const_iterator(const workbook &wb, std::size_t index); diff --git a/include/xlnt/worksheet/cell_vector.hpp b/include/xlnt/worksheet/cell_vector.hpp index df7621cd..03e20282 100644 --- a/include/xlnt/worksheet/cell_vector.hpp +++ b/include/xlnt/worksheet/cell_vector.hpp @@ -18,7 +18,7 @@ class XLNT_CLASS cell_vector { public: template - class common_iterator : public std::iterator + class XLNT_CLASS common_iterator : public std::iterator { public: common_iterator(worksheet ws, const cell_reference &start_cell, major_order order = major_order::row) diff --git a/include/xlnt/worksheet/range.hpp b/include/xlnt/worksheet/range.hpp index 6011b61e..b3578754 100644 --- a/include/xlnt/worksheet/range.hpp +++ b/include/xlnt/worksheet/range.hpp @@ -40,7 +40,7 @@ class XLNT_CLASS range { public: template - class common_iterator : public std::iterator + class XLNT_CLASS common_iterator : public std::iterator { public: common_iterator(worksheet ws, const range_reference &start_cell, major_order order = major_order::row) diff --git a/source/cell/cell.cpp b/source/cell/cell.cpp index 72430c0d..703854ff 100644 --- a/source/cell/cell.cpp +++ b/source/cell/cell.cpp @@ -817,71 +817,71 @@ bool cell::garbage_collectible() const } template <> -void cell::set_value(bool b) +XLNT_FUNCTION void cell::set_value(bool b) { d_->value_numeric_ = b ? 1 : 0; d_->type_ = type::boolean; } template <> -void cell::set_value(std::int8_t i) +XLNT_FUNCTION void cell::set_value(std::int8_t i) { d_->value_numeric_ = static_cast(i); d_->type_ = type::numeric; } template <> -void cell::set_value(std::int16_t i) +XLNT_FUNCTION void cell::set_value(std::int16_t i) { d_->value_numeric_ = static_cast(i); d_->type_ = type::numeric; } template <> -void cell::set_value(std::int32_t i) +XLNT_FUNCTION void cell::set_value(std::int32_t i) { d_->value_numeric_ = static_cast(i); d_->type_ = type::numeric; } template <> -void cell::set_value(std::int64_t i) +XLNT_FUNCTION void cell::set_value(std::int64_t i) { d_->value_numeric_ = static_cast(i); d_->type_ = type::numeric; } template <> -void cell::set_value(std::uint8_t i) +XLNT_FUNCTION void cell::set_value(std::uint8_t i) { d_->value_numeric_ = static_cast(i); d_->type_ = type::numeric; } template <> -void cell::set_value(std::uint16_t i) +XLNT_FUNCTION void cell::set_value(std::uint16_t i) { d_->value_numeric_ = static_cast(i); d_->type_ = type::numeric; } template <> -void cell::set_value(std::uint32_t i) +XLNT_FUNCTION void cell::set_value(std::uint32_t i) { d_->value_numeric_ = static_cast(i); d_->type_ = type::numeric; } template <> -void cell::set_value(std::uint64_t i) +XLNT_FUNCTION void cell::set_value(std::uint64_t i) { d_->value_numeric_ = static_cast(i); d_->type_ = type::numeric; } -#ifdef _WIN32 +#ifdef _MSC_VER template <> -void cell::set_value(unsigned long i) +XLNT_FUNCTION void cell::set_value(unsigned long i) { d_->value_numeric_ = static_cast(i); d_->type_ = type::numeric; @@ -890,14 +890,14 @@ void cell::set_value(unsigned long i) #ifdef __linux template <> -void cell::set_value(long long i) +XLNT_FUNCTION void cell::set_value(long long i) { d_->value_numeric_ = static_cast(i); d_->type_ = type::numeric; } template <> -void cell::set_value(unsigned long long i) +XLNT_FUNCTION void cell::set_value(unsigned long long i) { d_->value_numeric_ = static_cast(i); d_->type_ = type::numeric; @@ -905,28 +905,28 @@ void cell::set_value(unsigned long long i) #endif template <> -void cell::set_value(float f) +XLNT_FUNCTION void cell::set_value(float f) { d_->value_numeric_ = static_cast(f); d_->type_ = type::numeric; } template <> -void cell::set_value(double d) +XLNT_FUNCTION void cell::set_value(double d) { d_->value_numeric_ = static_cast(d); d_->type_ = type::numeric; } template <> -void cell::set_value(long double d) +XLNT_FUNCTION void cell::set_value(long double d) { d_->value_numeric_ = static_cast(d); d_->type_ = type::numeric; } 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()); @@ -937,13 +937,13 @@ void cell::set_value(std::string s) } template <> -void cell::set_value(char const *c) +XLNT_FUNCTION void cell::set_value(char const *c) { set_value(std::string(c)); } template <> -void cell::set_value(cell c) +XLNT_FUNCTION void cell::set_value(cell c) { d_->type_ = c.d_->type_; d_->value_numeric_ = c.d_->value_numeric_; @@ -956,7 +956,7 @@ void cell::set_value(cell c) } template <> -void cell::set_value(date d) +XLNT_FUNCTION void cell::set_value(date d) { d_->type_ = type::numeric; d_->value_numeric_ = d.to_number(get_base_date()); @@ -964,7 +964,7 @@ void cell::set_value(date d) } template <> -void cell::set_value(datetime d) +XLNT_FUNCTION void cell::set_value(datetime d) { d_->type_ = type::numeric; d_->value_numeric_ = d.to_number(get_base_date()); @@ -972,7 +972,7 @@ void cell::set_value(datetime d) } template <> -void cell::set_value(time t) +XLNT_FUNCTION void cell::set_value(time t) { d_->type_ = type::numeric; d_->value_numeric_ = t.to_number(); @@ -980,7 +980,7 @@ void cell::set_value(time t) } template <> -void cell::set_value(timedelta t) +XLNT_FUNCTION void cell::set_value(timedelta t) { d_->type_ = type::numeric; d_->value_numeric_ = t.to_number(); @@ -1316,105 +1316,105 @@ void cell::clear_value() } template <> -bool cell::get_value() const +XLNT_FUNCTION bool cell::get_value() const { return d_->value_numeric_ != 0; } template <> -std::int8_t cell::get_value() const +XLNT_FUNCTION std::int8_t cell::get_value() const { return static_cast(d_->value_numeric_); } template <> -std::int16_t cell::get_value() const +XLNT_FUNCTION std::int16_t cell::get_value() const { return static_cast(d_->value_numeric_); } template <> -std::int32_t cell::get_value() const +XLNT_FUNCTION std::int32_t cell::get_value() const { return static_cast(d_->value_numeric_); } template <> -std::int64_t cell::get_value() const +XLNT_FUNCTION std::int64_t cell::get_value() const { return static_cast(d_->value_numeric_); } template <> -std::uint8_t cell::get_value() const +XLNT_FUNCTION std::uint8_t cell::get_value() const { return static_cast(d_->value_numeric_); } template <> -std::uint16_t cell::get_value() const +XLNT_FUNCTION std::uint16_t cell::get_value() const { return static_cast(d_->value_numeric_); } template <> -std::uint32_t cell::get_value() const +XLNT_FUNCTION std::uint32_t cell::get_value() const { return static_cast(d_->value_numeric_); } template <> -std::uint64_t cell::get_value() const +XLNT_FUNCTION std::uint64_t cell::get_value() const { return static_cast(d_->value_numeric_); } #ifdef __linux template <> -long long int cell::get_value() const +XLNT_FUNCTION long long int cell::get_value() const { return static_cast(d_->value_numeric_); } #endif template <> -float cell::get_value() const +XLNT_FUNCTION float cell::get_value() const { return static_cast(d_->value_numeric_); } template <> -double cell::get_value() const +XLNT_FUNCTION double cell::get_value() const { return static_cast(d_->value_numeric_); } template <> -long double cell::get_value() const +XLNT_FUNCTION long double cell::get_value() const { return d_->value_numeric_; } template <> -time cell::get_value() const +XLNT_FUNCTION time cell::get_value() const { return time::from_number(d_->value_numeric_); } template <> -datetime cell::get_value() const +XLNT_FUNCTION datetime cell::get_value() const { return datetime::from_number(d_->value_numeric_, get_base_date()); } template <> -date cell::get_value() const +XLNT_FUNCTION date cell::get_value() const { return date::from_number(static_cast(d_->value_numeric_), get_base_date()); } template <> -timedelta cell::get_value() const +XLNT_FUNCTION timedelta cell::get_value() const { return timedelta::from_number(d_->value_numeric_); } @@ -1426,7 +1426,7 @@ void cell::set_number_format(const number_format &number_format_) } template <> -std::string cell::get_value() const +XLNT_FUNCTION std::string cell::get_value() const { return d_->value_string_; } diff --git a/source/serialization/worksheet_serializer.cpp b/source/serialization/worksheet_serializer.cpp index bb5d5a16..0075686b 100644 --- a/source/serialization/worksheet_serializer.cpp +++ b/source/serialization/worksheet_serializer.cpp @@ -85,13 +85,13 @@ bool worksheet_serializer::read_worksheet(const xml_document &xml) if (colon_index != std::string::npos) { - min_column = static_cast(std::stoll(span_string.substr(0, colon_index))); - max_column = static_cast(std::stoll(span_string.substr(colon_index + 1))); + min_column = static_cast(std::stoll(span_string.substr(0, colon_index))); + max_column = static_cast(std::stoll(span_string.substr(colon_index + 1))); } else { - min_column = static_cast(full_range.get_top_left().get_column_index()); - max_column = static_cast(full_range.get_bottom_right().get_column_index()); + min_column = full_range.get_top_left().get_column_index(); + max_column = full_range.get_bottom_right().get_column_index(); } for (column_t i = min_column; i <= max_column; i++) @@ -187,8 +187,8 @@ bool worksheet_serializer::read_worksheet(const xml_document &xml) continue; } - auto min = static_cast(std::stoull(col_node.get_attribute("min"))); - auto max = static_cast(std::stoull(col_node.get_attribute("max"))); + auto min = static_cast(std::stoull(col_node.get_attribute("min"))); + auto max = static_cast(std::stoull(col_node.get_attribute("max"))); auto width = std::stold(col_node.get_attribute("width")); bool custom = col_node.get_attribute("customWidth") == "1"; auto column_style = static_cast(col_node.has_attribute("style") ? std::stoull(col_node.get_attribute("style")) : 0); diff --git a/source/worksheet/range.cpp b/source/worksheet/range.cpp index f4570a1d..2b1e5186 100644 --- a/source/worksheet/range.cpp +++ b/source/worksheet/range.cpp @@ -147,9 +147,9 @@ cell_vector range::get_vector(std::size_t vector_index) } range_reference reference( - static_cast(static_cast(ref_.get_top_left().get_column().index) + vector_index), + static_cast(static_cast(ref_.get_top_left().get_column().index) + vector_index), ref_.get_top_left().get_row(), - static_cast(static_cast(ref_.get_top_left().get_column().index) + vector_index), + static_cast(static_cast(ref_.get_top_left().get_column().index) + vector_index), ref_.get_bottom_right().get_row()); return cell_vector(ws_, reference, order_);