From 2626ce4efee6f16af1ef4b7b76b5a21fbfaafbbd Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Fri, 28 Feb 2020 07:27:16 +0100 Subject: [PATCH] Make more headers private and remove unnecessary #includes. --- TODO.md | 1 - include/lol/base/core.h | 1 + include/lol/base/{ => private}/features.h | 0 .../lol/base => include/lol/base/private}/map.h | 16 ++++++++-------- include/lol/base/{ => private}/string.h | 7 +++---- include/lol/base/thread.h | 3 +-- include/lol/base/utils.h | 17 +++++++++++++++++ include/lol/math/polynomial.h | 4 ++-- include/lol/math/private/matrix.h | 2 +- include/lol/math/private/ops.h | 1 - include/lol/math/rand.h | 2 +- include/lol/math/real.h | 10 +++++----- 12 files changed, 39 insertions(+), 25 deletions(-) rename include/lol/base/{ => private}/features.h (100%) rename {legacy/lol/base => include/lol/base/private}/map.h (73%) rename include/lol/base/{ => private}/string.h (97%) create mode 100644 include/lol/base/utils.h diff --git a/TODO.md b/TODO.md index 1f972025..3d77cae7 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,6 @@ ## `lol` headers to keep - src/lol/base/map.h (map utilities) src/lol/base/types.h (vec_t shortcuts eg. vec2, ivec2, u8vec3 etc.) src/lol/math/bigint.h src/lol/math/constants.h diff --git a/include/lol/base/core.h b/include/lol/base/core.h index bdbd4ba1..807cb1a7 100644 --- a/include/lol/base/core.h +++ b/include/lol/base/core.h @@ -12,6 +12,7 @@ #pragma once +#include // std::string #include // _dupenv_s / std::getenv namespace lol diff --git a/include/lol/base/features.h b/include/lol/base/private/features.h similarity index 100% rename from include/lol/base/features.h rename to include/lol/base/private/features.h diff --git a/legacy/lol/base/map.h b/include/lol/base/private/map.h similarity index 73% rename from legacy/lol/base/map.h rename to include/lol/base/private/map.h index 986bfca9..8a7171b9 100644 --- a/legacy/lol/base/map.h +++ b/include/lol/base/private/map.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2018 Sam Hocevar +// Copyright © 2010—2020 Sam Hocevar // © 2013—2015 Guillaume Bittoun // // Lol Engine is free software. It comes without any warranty, to @@ -14,12 +14,12 @@ #pragma once // -// Simple map utilities -// -------------------- +// The map utilities +// ————————————————— +// Contains some utilities to work with std::map objects. // -#include - +#include #include namespace lol @@ -43,11 +43,11 @@ static inline bool try_get(T const &m, typename T::key_type const &key, } template -static inline array keys(T const &m) +static inline std::vector keys(T const &m) { - array ret; + std::vector ret; for (auto const &it : m) - ret << it.first; + ret.push_back(it.first); return ret; } diff --git a/include/lol/base/string.h b/include/lol/base/private/string.h similarity index 97% rename from include/lol/base/string.h rename to include/lol/base/private/string.h index 94c6e632..f21f8f1f 100644 --- a/include/lol/base/string.h +++ b/include/lol/base/private/string.h @@ -19,11 +19,10 @@ // Contains some utilities to work with std::string objects. // -#include -#include +#include "features.h" -#include -#include +#include // std::vector +#include // std::basic_string #include // std::transform #include // va_list #include // size_t diff --git a/include/lol/base/thread.h b/include/lol/base/thread.h index 25e48d74..6965fed5 100644 --- a/include/lol/base/thread.h +++ b/include/lol/base/thread.h @@ -17,8 +17,7 @@ // ————————————————————— // -#include -#include +#include // os::getenv #include // std::function #include diff --git a/include/lol/base/utils.h b/include/lol/base/utils.h new file mode 100644 index 00000000..20e35f6e --- /dev/null +++ b/include/lol/base/utils.h @@ -0,0 +1,17 @@ +// +// Lol Engine +// +// Copyright © 2010—2020 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. +// + +#pragma once + +#include "private/string.h" +#include "private/map.h" + diff --git a/include/lol/math/polynomial.h b/include/lol/math/polynomial.h index deee1ee4..aad91347 100644 --- a/include/lol/math/polynomial.h +++ b/include/lol/math/polynomial.h @@ -19,9 +19,9 @@ // added guarantee that the leading coefficient is always non-zero. // -#include -#include +#include "../base/private/features.h" +#include // std::vector #include // std::function #include // std::tuple #include // assert() diff --git a/include/lol/math/private/matrix.h b/include/lol/math/private/matrix.h index bf9b7eeb..e1606cf1 100644 --- a/include/lol/math/private/matrix.h +++ b/include/lol/math/private/matrix.h @@ -19,7 +19,7 @@ #include -#include +#include "ops.h" #include #if _WIN32 diff --git a/include/lol/math/private/ops.h b/include/lol/math/private/ops.h index a2fed51c..5e480f99 100644 --- a/include/lol/math/private/ops.h +++ b/include/lol/math/private/ops.h @@ -21,7 +21,6 @@ #include #include -#include namespace lol { diff --git a/include/lol/math/rand.h b/include/lol/math/rand.h index 5e8580d0..d42e5d28 100644 --- a/include/lol/math/rand.h +++ b/include/lol/math/rand.h @@ -17,7 +17,7 @@ // ———————————————————————————— // -#include +#include "../base/private/features.h" #include #include diff --git a/include/lol/math/real.h b/include/lol/math/real.h index 4c48afee..a6b1d9a1 100644 --- a/include/lol/math/real.h +++ b/include/lol/math/real.h @@ -17,12 +17,12 @@ // ————————————————————— // -#include -#include +#include "../base/private/features.h" -#include -#include -#include +#include // std::numeric_limits +#include // std::vector +#include // std::string +#include // int64_t etc. #if _MSC_VER # pragma push_macro("min")