Add lcf::Span
Using this implementation
MODIFY
CMakeLists.txt
CMakeLists.txt
@@ -208,6 +208,7 @@ set(LCF_HEADERS
src/lcf/reader_xml.h
src/lcf/saveopt.h
src/lcf/scope_guard.h
+ src/lcf/span.h
src/lcf/string_view.h
src/lcf/writer_lcf.h
src/lcf/writer_xml.h
@@ -282,6 +283,7 @@ set(LCF_HEADERS
src/generated/lcf/rpg/trooppage.h
src/generated/lcf/rpg/trooppagecondition.h
src/generated/lcf/rpg/variable.h
+ src/lcf/third_party/span.h
src/lcf/third_party/string_view.h
)

MODIFY
Makefile.am
Makefile.am
@@ -211,6 +211,7 @@ lcfinclude_HEADERS = \
src/lcf/reader_xml.h \
src/lcf/saveopt.h \
src/lcf/scope_guard.h \
+ src/lcf/span.h \
src/lcf/string_view.h \
src/lcf/writer_lcf.h \
src/lcf/writer_xml.h
@@ -301,6 +302,7 @@ lcfrpginclude_HEADERS = \
src/generated/lcf/rpg/variable.h
lcfthirdpartyinclude_HEADERS = \
+ src/lcf/third_party/span.h \
src/lcf/third_party/string_view.h
nodist_lcfinclude_HEADERS = autogen/lcf/config.h

MODIFY
README.md
README.md
@@ -110,7 +110,7 @@ See the file [COPYING] for copying conditions.
### 3rd party software
liblcf code includes a copy of [inih] under New BSD license.
-liblcf code includes a copy of [string-view-lite] under Boost Software License, Version 1.0.
+liblcf code includes a copy of [string-view-lite] and [span-lite] under Boost Software License, Version 1.0.
See the source code comment headers for license details.
@@ -121,3 +121,4 @@ See the source code comment headers for license details.
[COPYING]: COPYING
[inih]: https://github.com/benhoyt/inih
[string-view-lite]: https://github.com/martinmoene/string-view-lite
+[span-lite]: https://github.com/martinmoene/span-lite

ADD
src/lcf/span.h
+/*
+ * This file is part of liblcf. Copyright (c) 2020 liblcf authors.
+ * https://github.com/EasyRPG/liblcf - https://easyrpg.org
+ *
+ * liblcf is Free/Libre Open Source Software, released under the MIT License.
+ * For the full copyright and license information, please view the COPYING
+ * file that was distributed with this source code.
+ */
+
+#ifndef LCF_SPAN_H
+#define LCF_SPAN_H
+#include <cstring>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <ostream>
+#include <algorithm>
+
+#define span_CONFIG_NO_EXCEPTIONS 1
+#define span_FEATURE_WITH_CONTAINER 1
+#define span_FEATURE_CONSTRUCTION_FROM_STDARRAY_ELEMENT_TYPE 1
+#define span_FEATURE_MAKE_SPAN 1
+#include <lcf/third_party/span.h>
+
+namespace lcf {
+
+using ExtentT = nonstd::span_lite::extent_t;
+using nonstd::dynamic_extent;
+
+template <typename T, ExtentT Extent= dynamic_extent>
+ using Span = nonstd::span<T,Extent>;
+
+template <typename... Args>
+constexpr inline auto MakeSpan(Args&&... args) noexcept -> decltype(nonstd::make_span(std::forward<Args>(args)...)) {
+ return nonstd::make_span(std::forward<Args>(args)...);
+}
+
+
+} // namespace lcf
+
+#endif

ADD
src/lcf/third_party/span.h
src/lcf/third_party/span.h
Binary files /dev/null and b/src/lcf/third_party/span.h differ

ADD
tests/span.cpp
+/*
+ * This file is part of liblcf. Copyright (c) 2020 liblcf authors.
+ * https://github.com/EasyRPG/liblcf - https://easyrpg.org
+ *
+ * liblcf is Free/Libre Open Source Software, released under the MIT License.
+ * For the full copyright and license information, please view the COPYING
+ * file that was distributed with this source code.
+ */
+
+#include "lcf/span.h"
+#include "doctest.h"
+
+#include <string>
+#include <vector>
+#include <array>
+
+using namespace lcf;
+
+using arr_t = int[5];
+static_assert(std::is_same<decltype(MakeSpan(std::declval<Span<int>&>())),Span<int>>::value, "MakeSpan Broken");
+
+static_assert(std::is_same<decltype(MakeSpan(std::declval<std::vector<int>>())),Span<const int>>::value, "MakeSpan Broken");
+static_assert(std::is_same<decltype(MakeSpan(std::declval<std::vector<int>&>())),Span<int>>::value, "MakeSpan Broken");
+
+static_assert(std::is_same<decltype(MakeSpan(std::declval<std::array<int,5>>())),Span<const int,5>>::value, "MakeSpan Broken");
+static_assert(std::is_same<decltype(MakeSpan(std::declval<std::array<int,5>&>())),Span<int,5>>::value, "MakeSpan Broken");
+static_assert(std::is_same<decltype(MakeSpan(std::declval<std::array<const int,5>>())),Span<const int,5>>::value, "MakeSpan Broken");
+static_assert(std::is_same<decltype(MakeSpan(std::declval<std::array<const int,5>&>())),Span<const int,5>>::value, "MakeSpan Broken");
+
+static_assert(std::is_same<decltype(MakeSpan(std::declval<int[5]>())),Span<const int>>::value, "MakeSpan Broken");
+static_assert(std::is_same<decltype(MakeSpan(std::declval<int(&)[5]>())),Span<int,5>>::value, "MakeSpan Broken");
+static_assert(std::is_same<decltype(MakeSpan(std::declval<const int[5]>())),Span<const int,5>>::value, "MakeSpan Broken");
+static_assert(std::is_same<decltype(MakeSpan(std::declval<const int(&)[5]>())),Span<const int,5>>::value, "MakeSpan Broken");
+
+TEST_SUITE_BEGIN("Span");
+
+TEST_CASE_TEMPLATE("Construct", T, int, double, std::string) {
+ Span<T> x;
+}
+
+TEST_SUITE_END();

Add lcf::Span

Using this implementation

https://github.com/martinmoene/span-lite