diff --git a/include/xlnt/utils/scoped_enum_hash.hpp b/include/xlnt/utils/scoped_enum_hash.hpp new file mode 100644 index 00000000..882e287b --- /dev/null +++ b/include/xlnt/utils/scoped_enum_hash.hpp @@ -0,0 +1,44 @@ +// Copyright (c) 2016 Thomas Fussell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE +// +// @license: http://www.opensource.org/licenses/mit-license.php +// @author: see AUTHORS file + +#pragma once + +#include // for std::hash + +namespace xlnt { + +/// +/// Allows a scoped enum (aka "enum class") to be used as a key +/// in a std::unordered_map. +/// +template +struct scoped_enum_hash +{ + std::size_t operator()(Enum e) const + { + static std::hash hasher; + return hasher(static_cast(e)); + } +}; + +} // namespace xlnt diff --git a/include/xlnt/worksheet/header_footer.hpp b/include/xlnt/worksheet/header_footer.hpp index 95c5c209..8b06fb8c 100644 --- a/include/xlnt/worksheet/header_footer.hpp +++ b/include/xlnt/worksheet/header_footer.hpp @@ -30,6 +30,7 @@ #include #include +#include namespace xlnt { @@ -311,12 +312,14 @@ private: bool different_odd_even_ = false; bool scale_with_doc_ = false; - std::unordered_map odd_headers_; - std::unordered_map even_headers_; - std::unordered_map first_headers_; - std::unordered_map odd_footers_; - std::unordered_map even_footers_; - std::unordered_map first_footers_; + using container = std::unordered_map>; + + container odd_headers_; + container even_headers_; + container first_headers_; + container odd_footers_; + container even_footers_; + container first_footers_; }; } // namespace xlnt diff --git a/source/detail/default_case.hpp b/source/detail/default_case.hpp index d19136fa..2d72e6ac 100644 --- a/source/detail/default_case.hpp +++ b/source/detail/default_case.hpp @@ -1,3 +1,26 @@ +// Copyright (c) 2016 Thomas Fussell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE +// +// @license: http://www.opensource.org/licenses/mit-license.php +// @author: see AUTHORS file + #pragma once #define EXCEPT_ON_UNHANDLED_SWITCH_CASE