Skip to content

Commit 310bdb0

Browse files
committed
Add lcf::Span
Using this implementation https://github.com/martinmoene/span-lite
1 parent d936e62 commit 310bdb0

6 files changed

Lines changed: 1724 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ set(LCF_HEADERS
208208
src/lcf/reader_xml.h
209209
src/lcf/saveopt.h
210210
src/lcf/scope_guard.h
211+
src/lcf/span.h
211212
src/lcf/string_view.h
212213
src/lcf/writer_lcf.h
213214
src/lcf/writer_xml.h
@@ -282,6 +283,7 @@ set(LCF_HEADERS
282283
src/generated/lcf/rpg/trooppage.h
283284
src/generated/lcf/rpg/trooppagecondition.h
284285
src/generated/lcf/rpg/variable.h
286+
src/lcf/third_party/span.h
285287
src/lcf/third_party/string_view.h
286288
)
287289

Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ lcfinclude_HEADERS = \
211211
src/lcf/reader_xml.h \
212212
src/lcf/saveopt.h \
213213
src/lcf/scope_guard.h \
214+
src/lcf/span.h \
214215
src/lcf/string_view.h \
215216
src/lcf/writer_lcf.h \
216217
src/lcf/writer_xml.h
@@ -301,6 +302,7 @@ lcfrpginclude_HEADERS = \
301302
src/generated/lcf/rpg/variable.h
302303

303304
lcfthirdpartyinclude_HEADERS = \
305+
src/lcf/third_party/span.h \
304306
src/lcf/third_party/string_view.h
305307

306308
nodist_lcfinclude_HEADERS = autogen/lcf/config.h

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ See the file [COPYING] for copying conditions.
110110
### 3rd party software
111111

112112
liblcf code includes a copy of [inih] under New BSD license.
113-
liblcf code includes a copy of [string-view-lite] under Boost Software License, Version 1.0.
113+
liblcf code includes a copy of [string-view-lite] and [span-lite] under Boost Software License, Version 1.0.
114114
See the source code comment headers for license details.
115115

116116

@@ -121,3 +121,4 @@ See the source code comment headers for license details.
121121
[COPYING]: COPYING
122122
[inih]: https://github.com/benhoyt/inih
123123
[string-view-lite]: https://github.com/martinmoene/string-view-lite
124+
[span-lite]: https://github.com/martinmoene/span-lite

src/lcf/span.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* This file is part of liblcf. Copyright (c) 2020 liblcf authors.
3+
* https://github.com/EasyRPG/liblcf - https://easyrpg.org
4+
*
5+
* liblcf is Free/Libre Open Source Software, released under the MIT License.
6+
* For the full copyright and license information, please view the COPYING
7+
* file that was distributed with this source code.
8+
*/
9+
10+
#ifndef LCF_SPAN_H
11+
#define LCF_SPAN_H
12+
#include <cstring>
13+
#include <string>
14+
#include <cassert>
15+
#include <iterator>
16+
#include <ostream>
17+
#include <algorithm>
18+
19+
#define span_CONFIG_NO_EXCEPTIONS 1
20+
#define span_FEATURE_WITH_CONTAINER 1
21+
#define span_FEATURE_CONSTRUCTION_FROM_STDARRAY_ELEMENT_TYPE 1
22+
#define span_FEATURE_MAKE_SPAN 1
23+
#include <lcf/third_party/span.h>
24+
25+
namespace lcf {
26+
27+
using ExtentT = nonstd::span_lite::extent_t;
28+
using nonstd::dynamic_extent;
29+
30+
template <typename T, ExtentT Extent= dynamic_extent>
31+
using Span = nonstd::span<T,Extent>;
32+
33+
template <typename... Args>
34+
constexpr inline auto MakeSpan(Args&&... args) noexcept -> decltype(nonstd::make_span(std::forward<Args>(args)...)) {
35+
return nonstd::make_span(std::forward<Args>(args)...);
36+
}
37+
38+
39+
} // namespace lcf
40+
41+
#endif

0 commit comments

Comments
 (0)