hemplate

Simple XML template engine
git clone git://git.dimitrijedobrota.com/hemplate.git
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING

commit c55146c0f8bd570c95dbd40b1891cd34556a2ca7
parent faaee8fde5745e50fdb31fb1ca804c6876956b1a
author Dimitrije Dobrota <mail@dimitrijedobrota.com>
date Wed, 23 Apr 2025 09:17:16 +0200

Rely on based library, fix exports

Diffstat:
M include/hemplate/atom.hpp | +++ -
M include/hemplate/classes.hpp | +++++++++ -----------------------
M include/hemplate/rss.hpp | ++++ --
M include/hemplate/sitemap.hpp | +++ -

4 files changed, 19 insertions(+), 27 deletions(-)


diff --git a/ include/hemplate/atom.hpp b/ include/hemplate/atom.hpp

@@ -1,6 +1,7 @@ #pragma once #include "hemplate/classes.hpp"
#include "hemplate/hemplate_export.hpp"
namespace hemplate::atom {

@@ -8,7 +9,8 @@ namespace hemplate::atom std::string format_time(std::int64_t sec); std::string format_time_now();
class feed : public element_builder<tag<"feed">, element::Type::Boolean>
class HEMPLATE_EXPORT feed
: public element_builder<tag<"feed">, element::Type::Boolean>
{ public: static constexpr const auto default_xmlns = "http://www.w3.org/2005/Atom";

diff --git a/ include/hemplate/classes.hpp b/ include/hemplate/classes.hpp

@@ -1,7 +1,9 @@ #pragma once #include <array>
#include <cstdint>
#include <based/string.hpp>
#include <based/type_traits.hpp>
#include "hemplate/element.hpp" #include "hemplate/hemplate_export.hpp"

@@ -9,30 +11,17 @@ namespace hemplate {
template<std::size_t N>
struct string_literal
{
// NOLINTNEXTLINE
constexpr string_literal(const char (&str)[N])
: m_value(std::to_array(str))
{
}
constexpr std::size_t size() const { return N; }
constexpr const char* data() const { return m_value.data(); }
std::array<char, N> m_value;
};
template<string_literal Name>
template<based::string_literal Name>
struct tag {
static char const* get_name() { return Name.data(); }
static auto get_name() { return Name.data(); }
static auto get_size() { return Name.size(); }
}; using comment = element_builder<tag<"comment">, element::Type::Comment>;
class xml : public element_builder<tag<"xml">, element::Type::Xml>
class HEMPLATE_EXPORT xml
: public element_builder<tag<"xml">, element::Type::Xml>
{ public: static constexpr const auto default_version = "1.0";

@@ -49,12 +38,9 @@ public: using transparent = element_builder<tag<"transparent">, element::Type::Transparent>;
template<typename P, typename T>
concept procedure = requires { requires(std::invocable<P, const T&>); };
template<std::ranges::forward_range R> transparent transform(const R& range,
procedure<std::ranges::range_value_t<R>> auto proc)
based::Procedure<std::ranges::range_value_t<R>> auto proc)
{ std::vector<element> res;

diff --git a/ include/hemplate/rss.hpp b/ include/hemplate/rss.hpp

@@ -1,6 +1,7 @@ #pragma once #include "hemplate/classes.hpp"
#include "hemplate/hemplate_export.hpp"
namespace hemplate::rss {

@@ -8,7 +9,8 @@ namespace hemplate::rss std::string format_time(std::int64_t sec); std::string format_time_now();
class rss : public element_builder<tag<"rss">, element::Type::Boolean>
class HEMPLATE_EXPORT rss
: public element_builder<tag<"rss">, element::Type::Boolean>
{ public: static constexpr const auto default_version = "2.0";

@@ -43,7 +45,7 @@ public: } };
class atomLink // NOLINT *-identifier-naming
class HEMPLATE_EXPORT atomLink // NOLINT *-identifier-naming
: public element_builder<tag<"atom:link">, element::Type::Boolean> { public:

diff --git a/ include/hemplate/sitemap.hpp b/ include/hemplate/sitemap.hpp

@@ -1,11 +1,13 @@ #pragma once #include "hemplate/classes.hpp"
#include "hemplate/hemplate_export.hpp"
namespace hemplate::sitemap {
class urlset : public element_builder<tag<"urlset">, element::Type::Boolean>
class HEMPLATE_EXPORT urlset
: public element_builder<tag<"urlset">, element::Type::Boolean>
{ public: static constexpr const auto default_xmlns =