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
@where python3 > nul 2>&1 && for /f %%i in ('@where python3') DO (@set PYTHON=%%i) & goto :done2
:done2
!PYTHON! configure %*
!PYTHON! configure clean

View File

@ -7,8 +7,12 @@ set(PROJECT_DESCRIPTION "user-friendly xlsx library for C++14")
include(VERSION.cmake)
if(NOT CMAKE_INSTALL_PREFIX)
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"

View File

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

2
configure vendored
View File

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

View File

@ -380,13 +380,22 @@ public:
/// <summary>
/// Return true if this cell is uninitialized.
/// </summary>
friend bool operator==(std::nullptr_t, const cell &cell);
friend XLNT_FUNCTION bool operator==(std::nullptr_t, const cell &cell);
/// <summary>
/// Return the result of left.get_reference() < right.get_reference().
/// What's the point of this?
/// </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:
// make these friends so they can use the private constructor
@ -405,13 +414,4 @@ private:
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

View File

@ -25,6 +25,8 @@
#include <string>
#include <xlnt/xlnt_config.hpp>
namespace xlnt {
/// <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
/// resource.
/// </summary>
class relationship
class XLNT_CLASS relationship
{
public:
enum class type

View File

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

View File

@ -18,7 +18,7 @@ class XLNT_CLASS cell_vector
{
public:
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:
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:
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:
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 <>
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<long double>(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<long double>(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<long double>(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<long double>(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<long double>(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<long double>(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<long double>(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<long double>(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<long double>(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<long double>(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<long double>(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<long double>(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<long double>(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<long double>(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<std::int8_t>(d_->value_numeric_);
}
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_);
}
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_);
}
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_);
}
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_);
}
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_);
}
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_);
}
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_);
}
#ifdef __linux
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_);
}
#endif
template <>
float cell::get_value() const
XLNT_FUNCTION float cell::get_value() const
{
return static_cast<float>(d_->value_numeric_);
}
template <>
double cell::get_value() const
XLNT_FUNCTION double cell::get_value() const
{
return static_cast<double>(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<int>(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_;
}

View File

@ -85,13 +85,13 @@ bool worksheet_serializer::read_worksheet(const xml_document &xml)
if (colon_index != std::string::npos)
{
min_column = static_cast<column_t>(std::stoll(span_string.substr(0, colon_index)));
max_column = static_cast<column_t>(std::stoll(span_string.substr(colon_index + 1)));
min_column = static_cast<column_t::index_t>(std::stoll(span_string.substr(0, colon_index)));
max_column = static_cast<column_t::index_t>(std::stoll(span_string.substr(colon_index + 1)));
}
else
{
min_column = static_cast<column_t>(full_range.get_top_left().get_column_index());
max_column = static_cast<column_t>(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<column_t>(std::stoull(col_node.get_attribute("min")));
auto max = static_cast<column_t>(std::stoull(col_node.get_attribute("max")));
auto min = static_cast<column_t::index_t>(std::stoull(col_node.get_attribute("min")));
auto max = static_cast<column_t::index_t>(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<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(
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(),
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());
return cell_vector(ws_, reference, order_);