Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ option(WITH_BENCHMARK "enable building benchmark executable" OFF)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
set(CMAKE_BUILD_TYPE Release)

set(mstch_VERSION 1.0.1)

if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -O3")
add_compile_options(-Wall -Wextra)
endif()

add_subdirectory(src)
Expand Down
4 changes: 2 additions & 2 deletions include/mstch/mstch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ using node = boost::make_recursive_variant<
std::nullptr_t, std::string, int, double, bool,
internal::lambda_t<boost::recursive_variant_>,
std::shared_ptr<internal::object_t<boost::recursive_variant_>>,
std::map<const std::string, boost::recursive_variant_>,
std::map<std::string, boost::recursive_variant_>,
std::vector<boost::recursive_variant_>>::type;
using object = internal::object_t<node>;
using lambda = internal::lambda_t<node>;
using map = std::map<const std::string, node>;
using map = std::map<std::string, node>;
using array = std::vector<node>;

std::string render(
Expand Down
4 changes: 2 additions & 2 deletions src/render_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const mstch::node& render_context::find_node(
{&find_node(token.substr(0, token.rfind('.')), current_nodes)});
else
for (auto& node: current_nodes)
if (visit(has_token(token), *node))
return visit(get_token(token, *node), *node);
if (mstch::visit(has_token(token), *node))
return mstch::visit(get_token(token, *node), *node);
return null_node;
}

Expand Down
6 changes: 3 additions & 3 deletions src/state/in_section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ std::string in_section::render(render_context& ctx, const token& token) {
auto& node = ctx.get_node(m_start_token.name());
std::string out;

if (m_type == type::normal && !visit(is_node_empty(), node))
out = visit(render_section(ctx, m_section, m_start_token.delims()), node);
else if (m_type == type::inverted && visit(is_node_empty(), node))
if (m_type == type::normal && !mstch::visit(is_node_empty(), node))
out = mstch::visit(render_section(ctx, m_section, m_start_token.delims()), node);
else if (m_type == type::inverted && mstch::visit(is_node_empty(), node))
out = render_context::push(ctx).render(m_section);

ctx.set_state<outside_section>();
Expand Down
4 changes: 2 additions & 2 deletions src/state/outside_section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ std::string outside_section::render(
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()));
return mstch::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()));
return mstch::visit(render_node(ctx, flag::none), ctx.get_node(token.name()));
case token::type::text:
return token.raw();
case token::type::partial:
Expand Down
2 changes: 1 addition & 1 deletion src/visitor/render_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class render_node: public boost::static_visitor<std::string> {

std::string operator()(const lambda& value) const {
template_type interpreted{value([this](const mstch::node& n) {
return visit(render_node(m_ctx), n);
return mstch::visit(render_node(m_ctx), n);
})};
auto rendered = render_context::push(m_ctx).render(interpreted);
return (m_flag == flag::escape_html) ? html_escape(rendered) : rendered;
Expand Down
4 changes: 2 additions & 2 deletions src/visitor/render_section.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class render_section: public boost::static_visitor<std::string> {
for (auto& token: m_section)
section_str += token.raw();
template_type interpreted{fun([this](const mstch::node& n) {
return visit(render_node(m_ctx), n);
return mstch::visit(render_node(m_ctx), n);
}, section_str), m_delims};
return render_context::push(m_ctx).render(interpreted);
}
Expand All @@ -42,7 +42,7 @@ class render_section: public boost::static_visitor<std::string> {
return render_context::push(m_ctx, array).render(m_section);
else
for (auto& item: array)
out += visit(render_section(
out += mstch::visit(render_section(
m_ctx, m_section, m_delims, flag::keep_array), item);
return out;
}
Expand Down