cemplateSimple C++ template engine |
git clone git://git.dimitrijedobrota.com/cemplate.git |
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING | |
commit | 9c7f4ab5de0c9e4042a356a239bb497537b22061 |
parent | 5997059066d9a7acd8b7a593ea86ca1b0a539cb0 |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Sat, 22 Feb 2025 23:03:13 +0100 |
Consolidate warning logic
Diffstat:M | CMakeLists.txt | | | +- |
M | source/cemplate.cpp | | | +++++++++++++++++-------- |
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -4,7 +4,7 @@ include(cmake/prelude.cmake)
project(
cemplate
VERSION 0.1.4
VERSION 0.1.5
DESCRIPTION "Simple C++ template engine"
HOMEPAGE_URL "https://git.dimitrijedobrota.com/cemplate.git"
LANGUAGES CXX
diff --git a/source/cemplate.cpp b/source/cemplate.cpp
@@ -5,6 +5,20 @@
#include "cemplate/cemplate.hpp"
namespace
{
void warning(const std::string& message, const std::string& addition) // NOLINT
{
std::cerr << "Warning: " << message;
if (!addition.empty()) {
std::cerr << " - " + addition;
}
std::cerr << '\n' << std::flush;
}
} // namespace
namespace cemplate
{
@@ -28,9 +42,7 @@ std::string nspace(const std::string& name)
if (stk.empty() || stk.top() != name) {
if (seen.contains(name)) {
std::cerr << "Warning: nesting namespaces of the same name - " << name
<< '\n'
<< std::flush;
warning("nesting namespaces of the same name", name);
}
seen.insert(name);
@@ -78,9 +90,7 @@ std::string func(const std::string& name,
if (last.empty()) {
if (ret.empty()) {
std::cerr << "Warning: function should have a return type - " << name
<< '\n'
<< std::flush;
warning("function should have a return type", name);
}
last = name;
@@ -88,8 +98,7 @@ std::string func(const std::string& name,
}
if (last != name) {
std::cerr << "Warning: function is not closed - " << last << '\n'
<< std::flush;
warning("function is not closed", last);
}
last.clear();