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 6db03b9dad805863dd70bfda01d371212a004803
parent 71995b9619fec51a9e57635abd4d7ec9efadf91d
author Dimitrije Dobrota < mail@dimitrijedobrota.com >
date Wed, 23 Apr 2025 08:31:01 +0200

Remove streamable as it's unused

Diffstat:
M include/hemplate/attribute.hpp | +++++++++++++++++++++++++++++++ -----
D include/hemplate/streamable.hpp | -------------------------------------------

2 files changed, 31 insertions(+), 48 deletions(-)


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

@@ -1,16 +1,16 @@

#pragma once

#include <format>
#include <string>
#include <utility>
#include <vector>

#include "hemplate/hemplate_export.hpp"
#include "hemplate/streamable.hpp"

namespace hemplate
{

class HEMPLATE_EXPORT attribute : public streamable<attribute>
class HEMPLATE_EXPORT attribute
{
public:
attribute(std::string name) // NOLINT

@@ -45,7 +45,7 @@ private:

std::string m_value;
};

class HEMPLATE_EXPORT attribute_list : public streamable<attribute_list>
class HEMPLATE_EXPORT attribute_list
{
public:
attribute_list() = default;

@@ -93,5 +93,31 @@ private:


} // namespace hemplate

CUSTOM_FORMAT(hemplate::attribute)
CUSTOM_FORMAT(hemplate::attribute_list)
template<>
struct std::formatter<hemplate::attribute>
{
static constexpr auto parse(std::format_parse_context& ctx)
{
return ctx.begin();
}

static auto format(const hemplate::attribute& type, std::format_context& ctx)
{
return std::format_to(ctx.out(), "{}", static_cast<std::string>(type));
}
};

template<>
struct std::formatter<hemplate::attribute_list>
{
static constexpr auto parse(std::format_parse_context& ctx)
{
return ctx.begin();
}

static auto format(const hemplate::attribute_list& type,
std::format_context& ctx)
{
return std::format_to(ctx.out(), "{}", static_cast<std::string>(type));
}
};

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

@@ -1,43 +0,0 @@

#pragma once

#include <format>
#include <ostream>

#include "hemplate/hemplate_export.hpp"

namespace hemplate
{

template<typename D>
class HEMPLATE_EXPORT streamable
{
friend D;

streamable() = default;

public:
bool operator==(const streamable& rhs) const = default;

friend std::ostream& operator<<(std::ostream& out, const streamable& obj)
{
return out << static_cast<std::string>(static_cast<D&>(obj));
}
};

// NOLINTNEXTLINE cppcoreguidelines-macro-usage
#define CUSTOM_FORMAT(Type) \
template<> \
struct std::formatter<Type> \
{ \
constexpr auto parse(std::format_parse_context& ctx) \
{ \
return ctx.begin(); \
} \
\
auto format(const Type& type, std::format_context& ctx) const \
{ \
return std::format_to(ctx.out(), "{}", static_cast<std::string>(type)); \
} \
};

} // namespace hemplate