Archived
1
0

clang format

This commit is contained in:
Jeff Becker
2017-10-17 10:29:56 -04:00
parent 85248787fc
commit 841c5c6afe
69 changed files with 2381 additions and 2448 deletions

View File

@@ -1,19 +1,21 @@
#include "in_section.hpp"
#include "outside_section.hpp"
#include "../visitor/is_node_empty.hpp"
#include "../visitor/render_section.hpp"
#include "outside_section.hpp"
using namespace mstch;
in_section::in_section(type type, const token& start_token):
m_type(type), m_start_token(start_token), m_skipped_openings(0)
in_section::in_section(type type, const token &start_token)
: m_type(type), m_start_token(start_token), m_skipped_openings(0)
{
}
std::string in_section::render(render_context& ctx, const token& token) {
std::string in_section::render(render_context &ctx, const token &token)
{
if (token.token_type() == token::type::section_close)
if (token.name() == m_start_token.name() && m_skipped_openings == 0) {
auto& node = ctx.get_node(m_start_token.name());
if (token.name() == m_start_token.name() && m_skipped_openings == 0)
{
auto &node = ctx.get_node(m_start_token.name());
std::string out;
if (m_type == type::normal && !visit(is_node_empty(), node))
@@ -23,10 +25,10 @@ std::string in_section::render(render_context& ctx, const token& token) {
ctx.set_state<outside_section>();
return out;
} else
}
else
m_skipped_openings--;
else if (token.token_type() == token::type::inverted_section_open ||
token.token_type() == token::type::section_open)
else if (token.token_type() == token::type::inverted_section_open || token.token_type() == token::type::section_open)
m_skipped_openings++;
m_section << token;

View File

@@ -3,22 +3,27 @@
#include <sstream>
#include <vector>
#include "render_state.hpp"
#include "../template_type.hpp"
#include "render_state.hpp"
namespace mstch {
namespace mstch
{
class in_section: public render_state {
public:
enum class type { inverted, normal };
in_section(type type, const token& start_token);
std::string render(render_context& context, const token& token) override;
class in_section : public render_state
{
public:
enum class type
{
inverted,
normal
};
in_section(type type, const token &start_token);
std::string render(render_context &context, const token &token) override;
private:
private:
const type m_type;
const token& m_start_token;
const token &m_start_token;
template_type m_section;
int m_skipped_openings;
};
}

View File

@@ -1,32 +1,32 @@
#include "outside_section.hpp"
#include "../render_context.hpp"
#include "../visitor/render_node.hpp"
#include "in_section.hpp"
#include "../render_context.hpp"
using namespace mstch;
std::string outside_section::render(
render_context& ctx, const token& token)
std::string outside_section::render(render_context &ctx, const token &token)
{
using flag = render_node::flag;
switch (token.token_type()) {
case token::type::section_open:
ctx.set_state<in_section>(in_section::type::normal, token);
break;
case token::type::inverted_section_open:
ctx.set_state<in_section>(in_section::type::inverted, token);
break;
case token::type::variable:
return visit(render_node(ctx, flag::escape_html), ctx.get_node(token.name()));
case token::type::unescaped_variable:
return visit(render_node(ctx, flag::none), ctx.get_node(token.name()));
case token::type::text:
return token.raw();
case token::type::partial:
return ctx.render_partial(token.name(), token.partial_prefix());
default:
break;
switch (token.token_type())
{
case token::type::section_open:
ctx.set_state<in_section>(in_section::type::normal, token);
break;
case token::type::inverted_section_open:
ctx.set_state<in_section>(in_section::type::inverted, token);
break;
case token::type::variable:
return visit(render_node(ctx, flag::escape_html), ctx.get_node(token.name()));
case token::type::unescaped_variable:
return visit(render_node(ctx, flag::none), ctx.get_node(token.name()));
case token::type::text:
return token.raw();
case token::type::partial:
return ctx.render_partial(token.name(), token.partial_prefix());
default:
break;
}
return "";
}

View File

@@ -2,11 +2,12 @@
#include "render_state.hpp"
namespace mstch {
namespace mstch
{
class outside_section: public render_state {
public:
std::string render(render_context& context, const token& token) override;
class outside_section : public render_state
{
public:
std::string render(render_context &context, const token &token) override;
};
}

View File

@@ -4,14 +4,15 @@
#include "../token.hpp"
namespace mstch {
namespace mstch
{
class render_context;
class render_state {
public:
class render_state
{
public:
virtual ~render_state() {}
virtual std::string render(render_context& context, const token& token) = 0;
virtual std::string render(render_context &context, const token &token) = 0;
};
}