fix clang warnings

This commit is contained in:
Thomas Fussell 2017-04-23 11:53:52 -04:00
parent f38dc4169b
commit be11002a93
8 changed files with 112 additions and 34 deletions

View File

@ -650,4 +650,46 @@ XLNT_API bool operator==(std::nullptr_t, const cell &cell);
/// </summary>
XLNT_API std::ostream &operator<<(std::ostream &stream, const xlnt::cell &cell);
template<>
bool cell::value<bool>() const;
template<>
int cell::value<int>() const;
template<>
unsigned int cell::value<unsigned int>() const;
template<>
long long int cell::value<long long int>() const;
template<>
unsigned long long cell::value<unsigned long long int>() const;
template<>
float cell::value<float>() const;
template<>
double cell::value<double>() const;
template<>
long double cell::value<long double>() const;
template<>
date cell::value<date>() const;
template<>
time cell::value<time>() const;
template<>
datetime cell::value<datetime>() const;
template<>
timedelta cell::value<timedelta>() const;
template<>
std::string cell::value<std::string>() const;
template<>
rich_text cell::value<rich_text>() const;
} // namespace xlnt

View File

@ -98,7 +98,7 @@ public:
/// <summary>
/// Creates a i4-type variant with the given value.
/// </summary>
variant(int value);
variant(std::int32_t value);
/// <summary>
/// Creates a bool-type variant with the given value.
@ -113,12 +113,12 @@ public:
/// <summary>
/// Creates a vector_i4-type variant with the given value.
/// </summary>
variant(const std::initializer_list<int> &value);
variant(const std::initializer_list<std::int32_t> &value);
/// <summary>
/// Creates a vector_i4-type variant with the given value.
/// </summary>
variant(const std::vector<int> &value);
variant(const std::vector<std::int32_t> &value);
/// <summary>
/// Creates a vector_string-type variant with the given value.
@ -169,4 +169,25 @@ private:
std::string lpstr_value_;
};
template<>
bool variant::get() const;
template<>
std::int32_t variant::get() const;
template<>
std::string variant::get() const;
template<>
datetime variant::get() const;
template<>
std::vector<std::int32_t> variant::get() const;
template<>
std::vector<std::string> variant::get() const;
template<>
std::vector<variant> variant::get() const;
} // namespace xlnt

View File

@ -157,8 +157,13 @@ target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR}/../third-party/libstu
if(MSVC)
set_target_properties(xlnt PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\" /wd\"4068\" /MP")
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/detail/serialization/miniz.cpp PROPERTIES COMPILE_FLAGS "/wd\"4244\" /wd\"4334\" /wd\"4127\"")
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/detail/cryptography/aes.cpp PROPERTIES COMPILE_FLAGS "/wd\"4996\"")
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/detail/serialization/miniz.cpp PROPERTIES COMPILE_FLAGS "/wd\"4244\" /wd\"4334\" /wd\"4127\"")
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/detail/cryptography/aes.cpp PROPERTIES COMPILE_FLAGS "/wd\"4996\"")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/detail/serialization/miniz.cpp PROPERTIES COMPILE_FLAGS "-Wno-comma -Wno-undef")
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/detail/serialization/zstream.cpp PROPERTIES COMPILE_FLAGS "-Wno-undef -Wno-shorten-64-to-32")
endif()
source_group(xlnt FILES ${ROOT_HEADERS})

View File

@ -42,6 +42,8 @@ public:
{
}
byte_reader(const byte_reader &other) = default;
byte_reader &operator=(const byte_reader &other)
{
offset_ = other.offset_;
@ -238,7 +240,7 @@ public:
std::vector<byte>::iterator iterator()
{
return bytes_.begin() + offset();
return bytes_.begin() + static_cast<std::ptrdiff_t>(offset());
}
void append(const std::vector<std::uint8_t> &data, std::size_t offset, std::size_t count)

View File

@ -64,13 +64,18 @@ public:
{
data_.resize(newsize, FreeSector);
}
void set(std::size_t index, sector_id value)
/*
void set(sector_id index, sector_id value)
{
if (index >= count()) resize(index + 1);
data_[index] = value;
}
if (static_cast<std::size_t>(index) >= count())
{
resize(static_cast<std::size_t>(index + 1));
}
data_[static_cast<std::size_t>(index)] = value;
}
*/
/*
void setChain(std::vector<sector_id> chain)
{
if (chain.size())
@ -83,7 +88,7 @@ public:
set(chain[chain.size() - 1], EndOfChainSector);
}
}
*/
std::vector<sector_id> follow(sector_id start) const
{
auto chain = std::vector<sector_id>();
@ -95,11 +100,11 @@ public:
auto p = start;
auto already_exists = [](const std::vector<sector_id> &chain, sector_id item)
auto already_exists = [](const std::vector<sector_id> &check, sector_id item)
{
for (std::size_t i = 0; i < chain.size(); i++)
for (std::size_t i = 0; i < check.size(); i++)
{
if (chain[i] == item) return true;
if (check[i] == item) return true;
}
return false;
@ -112,8 +117,8 @@ public:
if (p == MasterAllocationTableSector) break;
if (already_exists(chain, p)) break;
chain.push_back(p);
if (data_[p] >= static_cast<sector_id>(count())) break;
p = data_[p];
if (data_[static_cast<std::size_t>(p)] >= static_cast<sector_id>(count())) break;
p = data_[static_cast<std::size_t>(p)];
}
return chain;
@ -128,12 +133,12 @@ public:
{
return byte_vector::from(data_);
}
/*
std::size_t size_in_bytes()
{
return count() * 4;
}
*/
std::size_t sector_size() const
{
return sector_size_;
@ -157,8 +162,6 @@ const sector_id allocation_table::MasterAllocationTableSector = -4;
class header
{
public:
static const std::uint64_t magic;
header()
{
}
@ -264,7 +267,7 @@ private:
std::uint32_t num_short_sectors_ = 0;
sector_id master_start_ = 0;
std::uint32_t num_master_sectors_ = 0;
std::array<sector_id, 109> first_master_table = { allocation_table::FreeSector };
std::array<sector_id, 109> first_master_table = {{allocation_table::FreeSector}};
};
struct directory_entry
@ -304,7 +307,7 @@ struct directory_entry
class directory_tree
{
public:
static const directory_id End = -1;
//static const directory_id End = -1;
static void entry_name(directory_entry &entry, std::u16string name)
{
@ -336,12 +339,12 @@ public:
directory_entry &entry(directory_id index)
{
return entries[index];
return entries[static_cast<std::size_t>(index)];
}
const directory_entry &entry(directory_id index) const
{
return entries[index];
return entries[static_cast<std::size_t>(index)];
}
const directory_entry &entry(const std::u16string &name) const
@ -374,7 +377,7 @@ public:
return entry(index);
}
/*
directory_id parent(directory_id index)
{
// brute-force, basically we iterate for each entries, find its children
@ -394,7 +397,8 @@ public:
return -1;
}
*/
/*
std::u16string path(directory_id index)
{
// don't use root name ("Root Entry"), just give "/"
@ -422,7 +426,7 @@ public:
return result;
}
*/
std::vector<directory_id> children(directory_id index) const
{
auto result = std::vector<directory_id>();
@ -476,11 +480,12 @@ public:
return result;
}
// return space required to save this dirtree
/*
std::size_t size()
{
return entry_count() * sizeof(directory_entry);
}
*/
directory_entry create_root_entry() const
{
@ -631,7 +636,7 @@ public:
for (auto sector : sectors)
{
auto position = sector_size * sector;
auto position = sector_size * static_cast<std::size_t>(sector);
result.append(sectors_.data(), position, sector_size);
}
@ -672,7 +677,7 @@ public:
for (auto sector : sectors)
{
auto position = sector * short_sector_size;
auto position = short_sector_size * static_cast<std::size_t>(sector);
auto master_allocation_table_index = position / sector_size;
auto sector_data = load_sectors({ short_container_stream_[master_allocation_table_index] });

View File

@ -33,6 +33,7 @@
#include <detail/cryptography/base64.hpp>
#include <detail/cryptography/compound_document.hpp>
#include <detail/cryptography/value_traits.hpp>
#include <detail/cryptography/xlsx_crypto_consumer.hpp>
#include <detail/external/include_libstudxml.hpp>
#include <detail/serialization/vector_streambuf.hpp>
#include <detail/serialization/xlsx_consumer.hpp>

View File

@ -28,6 +28,7 @@
#include <detail/cryptography/compound_document.hpp>
#include <detail/cryptography/encryption_info.hpp>
#include <detail/cryptography/value_traits.hpp>
#include <detail/cryptography/xlsx_crypto_producer.hpp>
#include <detail/external/include_libstudxml.hpp>
#include <detail/serialization/vector_streambuf.hpp>
#include <detail/serialization/xlsx_producer.hpp>

View File

@ -23,9 +23,10 @@
#include <codecvt>
#include <locale>
#include <string>
#include <detail/unicode.hpp>
namespace xlnt {
namespace detail {
@ -75,8 +76,8 @@ std::string latin1_to_utf8(const std::string &latin1)
}
else
{
utf8.push_back(0xc0 | static_cast<std::uint8_t>(character) >> 6);
utf8.push_back(0x80 | (static_cast<std::uint8_t>(character) & 0x3f));
utf8.push_back(static_cast<char>(0xc0 + (character >> 6)));
utf8.push_back(static_cast<char>(0x80 + (character & 0x3f)));
}
}