├── doc
└── logo.png
├── functional_tests
├── ci.cfg
├── lunchtoast.cfg
├── example_3
│ └── test.toast
├── example_1
│ └── test.toast
├── example_2
│ └── test.toast
├── example_4
│ └── test.toast
└── example_5
│ └── test.toast
├── src
├── streamreaderposition.h
├── generated_file_type.h
├── nameutils.h
├── irendered_as_string_part.h
├── idocumentnoderenderer.h
├── inodecollection.h
├── textnode.cpp
├── node_utils.h
├── nodereader.h
├── shared_lib_transpiler_renderer.h
├── nodeextension.h
├── streamreader.h
├── utils.h
├── single_header_transpiler_renderer.h
├── textnode.h
├── errors.h
├── sectionnode.h
├── control_flow_statement_node.cpp
├── itranspiler_renderer.h
├── procedurenode.h
├── control_flow_statement_node.h
├── header_and_source_transpiler_renderer.h
├── transpiler.h
├── tagnode.h
├── document_node_interface_access.h
├── idocumentnode.h
├── node_utils.cpp
├── streamreader.cpp
├── procedurenode.cpp
├── codenode.h
├── nodeextension.cpp
├── nameutils.cpp
├── nodereader.cpp
├── sectionnode.cpp
├── transpiler.cpp
├── single_header_transpiler_renderer.cpp
├── codenode.cpp
├── utils.cpp
├── shared_lib_transpiler_renderer.cpp
├── tagnode.cpp
├── header_and_source_transpiler_renderer.cpp
└── main.cpp
├── examples
├── CMakeLists.txt
├── ex_06
│ ├── todolist_printer.cpp
│ ├── CMakeLists.txt
│ └── todolist.htcpp
├── ex_07
│ ├── todolist_printer.cpp
│ ├── pageparams.h
│ ├── todolist.htcpp
│ └── CMakeLists.txt
├── ex_01
│ ├── todolist.htcpp
│ ├── todolist_printer.cpp
│ └── CMakeLists.txt
├── ex_02
│ ├── todolist.htcpp
│ ├── todolist_printer.cpp
│ └── CMakeLists.txt
├── ex_03
│ ├── todolist.htcpp
│ ├── CMakeLists.txt
│ └── todolist_printer.cpp
├── ex_04
│ ├── todolist.htcpp
│ ├── todolist_printer.cpp
│ └── CMakeLists.txt
└── ex_05
│ ├── CMakeLists.txt
│ ├── todolist.htcpp
│ └── todolist_printer.cpp
├── shared_lib_api
└── include
│ └── hypertextcpp
│ ├── templateloadingerror.h
│ ├── itemplate.h
│ └── templateloader.h
├── external
└── seal_lake
├── tests
├── assert_exception.h
├── CMakeLists.txt
├── test_procedurenode.cpp
├── test_nameutils.cpp
├── test_utils.cpp
├── test_sectionnode.cpp
├── test_tagnode.cpp
└── test_codenode.cpp
├── Dockerfile
├── .github
└── workflows
│ ├── release.yml
│ └── build_and_test.yml
├── .clang-format
├── CMakeLists.txt
├── LICENSE.md
├── CMakePresets.json
├── hypertextcpp.cmake
└── README.md
/doc/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kamchatka-volcano/hypertextcpp/HEAD/doc/logo.png
--------------------------------------------------------------------------------
/functional_tests/ci.cfg:
--------------------------------------------------------------------------------
1 | #actions:
2 | ###
3 | format = Check example #%1
4 | command = ../../examples-build/ex_0%1
5 | checkOutput = %input
6 | ---
--------------------------------------------------------------------------------
/functional_tests/lunchtoast.cfg:
--------------------------------------------------------------------------------
1 | #actions:
2 | ###
3 | format = Check example #%1
4 | command = ../../build/examples/ex_0%1/ex_0%1
5 | checkOutput = %input
6 | ---
--------------------------------------------------------------------------------
/src/streamreaderposition.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace htcpp{
4 |
5 | struct StreamReaderPosition{
6 | int line = 0;
7 | int column = 0;
8 | };
9 |
10 | }
--------------------------------------------------------------------------------
/functional_tests/example_3/test.toast:
--------------------------------------------------------------------------------
1 | -Suite: examples
2 |
3 | -Check example #3:
4 |
5 |
laundrycooking
6 |
7 | ---
--------------------------------------------------------------------------------
/src/generated_file_type.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace htcpp {
4 |
5 | enum class GeneratedFileType {
6 | Header,
7 | Source,
8 | };
9 |
10 | } //namespace htcpp
--------------------------------------------------------------------------------
/examples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory(ex_01)
2 | add_subdirectory(ex_02)
3 | add_subdirectory(ex_03)
4 | add_subdirectory(ex_04)
5 | add_subdirectory(ex_05)
6 | add_subdirectory(ex_06)
7 | add_subdirectory(ex_07)
--------------------------------------------------------------------------------
/examples/ex_06/todolist_printer.cpp:
--------------------------------------------------------------------------------
1 | #include "todolist.h"
2 | #include
3 | #include
4 |
5 | int main()
6 | {
7 | PageParams pageParams;
8 | auto page = TodoList{};
9 | page.print(pageParams);
10 | return 0;
11 | }
12 |
--------------------------------------------------------------------------------
/examples/ex_07/todolist_printer.cpp:
--------------------------------------------------------------------------------
1 | #include "todolist.h"
2 | #include
3 | #include
4 |
5 | int main()
6 | {
7 | PageParams pageParams;
8 | auto page = TodoList{};
9 | page.print(pageParams);
10 | return 0;
11 | }
12 |
--------------------------------------------------------------------------------
/src/nameutils.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | namespace htcpp::utils{
5 |
6 | std::string toPascalCase(const std::string& name);
7 | std::string toSnakeCase(const std::string& name);
8 | std::string toLowerCase(const std::string& name);
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/examples/ex_01/todolist.htcpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | $(cfg.name)'s todo list:
4 | No tasks found
?(cfg.tasks.empty())
5 |
6 | - $(task.name)
@(auto task : cfg.tasks)
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/functional_tests/example_1/test.toast:
--------------------------------------------------------------------------------
1 | -Suite: examples
2 |
3 | -Check example #1:
4 |
5 |
6 | Bob's todo list:
7 |
8 |
11 |
12 |
13 |
14 | ---
--------------------------------------------------------------------------------
/src/irendered_as_string_part.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace htcpp{
6 |
7 | class IRenderedAsStringPart : private sfun::interface {
8 | public:
9 | virtual std::string content() const = 0;
10 | };
11 |
12 | }
--------------------------------------------------------------------------------
/src/idocumentnoderenderer.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace htcpp{
6 |
7 | class IDocumentNodeRenderer : private sfun::interface {
8 | public:
9 | virtual std::string renderingCode() const = 0;
10 | };
11 |
12 | }
--------------------------------------------------------------------------------
/src/inodecollection.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 |
6 | namespace htcpp{
7 |
8 | class INodeCollection : private sfun::interface {
9 | public:
10 | virtual std::vector> flatten() = 0;
11 | };
12 |
13 | }
--------------------------------------------------------------------------------
/functional_tests/example_2/test.toast:
--------------------------------------------------------------------------------
1 | -Suite: examples
2 |
3 | -Check example #2:
4 |
5 |
6 | Bob's todo list:
7 |
8 |
11 |
12 |
13 |
14 | ---
--------------------------------------------------------------------------------
/examples/ex_07/pageparams.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | struct PageParams{
6 | struct Task{
7 | std::string name;
8 | bool isCompleted = false;
9 | };
10 | std::string name = "Bob";
11 | std::vector tasks = {{"laundry", true}, {"cooking", false}};
12 | };
--------------------------------------------------------------------------------
/functional_tests/example_4/test.toast:
--------------------------------------------------------------------------------
1 | -Suite: examples
2 |
3 | -Check example #4:
4 |
5 |
6 |
7 | Bob's todo list:
8 |
9 |
10 |
11 | - laundry
- cooking
12 |
13 |
14 |
15 |
16 | ---
--------------------------------------------------------------------------------
/examples/ex_02/todolist.htcpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | $(cfg.name)'s todo list:
4 | No tasks found
?(cfg.tasks.empty())
5 |
6 | - $(task.name)
@(auto task : cfg.tasks)
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/functional_tests/example_5/test.toast:
--------------------------------------------------------------------------------
1 | -Suite: examples
2 | -Contents: libtodolist.so todolist.dll
3 | -Check example #5:
4 |
5 |
6 |
7 |
8 |
9 | Bob's todo list:
10 |
11 |
12 |
13 | - laundry
- cooking
14 |
15 |
16 |
17 |
18 | ---
--------------------------------------------------------------------------------
/examples/ex_03/todolist.htcpp:
--------------------------------------------------------------------------------
1 | #taskList(){
2 | $(task.name)@(auto task : cfg.tasks)
3 | }
4 |
5 |
6 | $(cfg.name)'s todo list:
7 | No tasks found
?(cfg.tasks.empty())
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/examples/ex_04/todolist.htcpp:
--------------------------------------------------------------------------------
1 | #taskList(){
2 | $(task.name)@(auto task : cfg.tasks)
3 | }
4 |
5 |
6 | $(cfg.name)'s todo list:
7 | No tasks found
?(cfg.tasks.empty())
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/shared_lib_api/include/hypertextcpp/templateloadingerror.h:
--------------------------------------------------------------------------------
1 | #ifndef HYPERTEXTCPP_TEMPLATELOADINGERROR_H
2 | #define HYPERTEXTCPP_TEMPLATELOADINGERROR_H
3 |
4 | #include
5 |
6 | namespace htcpp{
7 |
8 | class TemplateLoadingError: public std::runtime_error
9 | {
10 | using std::runtime_error::runtime_error;
11 | };
12 |
13 | }
14 |
15 | #endif // HYPERTEXTCPP_TEMPLATELOADINGERROR_H
--------------------------------------------------------------------------------
/examples/ex_01/todolist_printer.cpp:
--------------------------------------------------------------------------------
1 | #include "todolist.h"
2 | #include
3 | #include
4 |
5 | int main()
6 | {
7 | struct PageParams{
8 | struct Task{
9 | std::string name;
10 | };
11 | std::string name = "Bob";
12 | std::vector tasks = {{"laundry"}, {"cooking"}};
13 | } pageParams;
14 | auto page = todolist{};
15 | page.print(pageParams);
16 | return 0;
17 | }
18 |
--------------------------------------------------------------------------------
/src/textnode.cpp:
--------------------------------------------------------------------------------
1 | #include "textnode.h"
2 |
3 | namespace htcpp {
4 |
5 | TextNode::TextNode(std::string value)
6 | : content_{std::move(value)}
7 | {
8 | }
9 |
10 | std::string TextNode::renderingCode() const
11 | {
12 | return "out << R\"_htcpp_str_(" + content_ + ")_htcpp_str_\";";
13 | }
14 |
15 | std::string TextNode::content() const
16 | {
17 | return content_;
18 | }
19 |
20 | } //namespace htcpp
21 |
--------------------------------------------------------------------------------
/src/node_utils.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "idocumentnode.h"
3 | #include "inodecollection.h"
4 | #include "textnode.h"
5 | #include
6 | #include
7 |
8 | namespace htcpp{
9 |
10 | std::vector> flattenNodes(std::vector> nodes);
11 | std::vector> optimizeNodes(std::vector> nodes);
12 |
13 | }
--------------------------------------------------------------------------------
/examples/ex_07/todolist.htcpp:
--------------------------------------------------------------------------------
1 | #{
2 | #include "pageparams.h"
3 | }
4 |
5 | #taskList(){
6 | $(task.name)@(auto task : cfg.tasks)
7 | }
8 |
9 |
10 | $(cfg.name)'s todo list:
11 | No tasks found
?(cfg.tasks.empty())
12 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/external/seal_lake:
--------------------------------------------------------------------------------
1 | include(FetchContent)
2 | set(SEAL_LAKE_VERSION v0.2.0)
3 | set(FETCHCONTENT_QUIET FALSE)
4 | FetchContent_Declare(seal_lake_${SEAL_LAKE_VERSION}
5 | SOURCE_DIR seal_lake_${SEAL_LAKE_VERSION}
6 | GIT_REPOSITORY "https://github.com/kamchatka-volcano/seal_lake.git"
7 | GIT_TAG ${SEAL_LAKE_VERSION}
8 | )
9 | FetchContent_MakeAvailable(seal_lake_${SEAL_LAKE_VERSION})
10 | include(${seal_lake_${SEAL_LAKE_VERSION}_SOURCE_DIR}/seal_lake.cmake)
--------------------------------------------------------------------------------
/examples/ex_03/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.18)
2 | project(ex_03)
3 |
4 | include(../../hypertextcpp.cmake)
5 |
6 | hypertextcpp_GenerateHeader(TEMPLATE_FILE todolist.htcpp)
7 |
8 | set(SRC
9 | todolist_printer.cpp
10 | todolist.h)
11 |
12 | add_executable(${PROJECT_NAME} ${SRC})
13 |
14 | target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
15 | set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF)
16 |
17 |
--------------------------------------------------------------------------------
/examples/ex_01/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.18)
2 | project(ex_01)
3 |
4 | include(../../hypertextcpp.cmake)
5 |
6 | hypertextcpp_GenerateHeader(
7 | TEMPLATE_FILE todolist.htcpp)
8 |
9 | set(SRC
10 | todolist_printer.cpp
11 | todolist.h)
12 |
13 | add_executable(${PROJECT_NAME} ${SRC})
14 |
15 | target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
16 | set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF)
17 |
18 |
--------------------------------------------------------------------------------
/examples/ex_04/todolist_printer.cpp:
--------------------------------------------------------------------------------
1 | #include "todolist.h"
2 | #include
3 | #include
4 |
5 | int main()
6 | {
7 | struct PageParams{
8 | struct Task{
9 | std::string name;
10 | bool isCompleted = false;
11 | };
12 | std::string name = "Bob";
13 | std::vector tasks = {{"laundry", true}, {"cooking", false}};
14 | } pageParams;
15 | auto page = TodoList{};
16 | page.print(pageParams);
17 | return 0;
18 | }
19 |
--------------------------------------------------------------------------------
/examples/ex_02/todolist_printer.cpp:
--------------------------------------------------------------------------------
1 | #include "template/todolist.h"
2 | #include
3 | #include
4 |
5 | int main()
6 | {
7 | struct PageParams{
8 | struct Task{
9 | std::string name;
10 | bool isCompleted = false;
11 | };
12 | std::string name = "Bob";
13 | std::vector tasks = {{"laundry", true}, {"cooking", false}};
14 | } pageParams;
15 | auto page = todolist{};
16 | page.print(pageParams);
17 | return 0;
18 | }
19 |
--------------------------------------------------------------------------------
/examples/ex_03/todolist_printer.cpp:
--------------------------------------------------------------------------------
1 | #include "todolist.h"
2 | #include
3 | #include
4 |
5 | int main()
6 | {
7 | struct PageParams{
8 | struct Task{
9 | std::string name;
10 | bool isCompleted = false;
11 | };
12 | std::string name = "Bob";
13 | std::vector tasks = {{"laundry", true}, {"cooking", false}};
14 | } pageParams;
15 | auto page = todolist{};
16 | page.print("taskList", pageParams);
17 | return 0;
18 | }
19 |
--------------------------------------------------------------------------------
/examples/ex_04/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.18)
2 | project(ex_04)
3 |
4 | include(../../hypertextcpp.cmake)
5 |
6 | hypertextcpp_GenerateHeader(
7 | TEMPLATE_FILE todolist.htcpp
8 | CLASS_NAME TodoList
9 | )
10 |
11 | set(SRC
12 | todolist_printer.cpp
13 | todolist.h)
14 |
15 | add_executable(${PROJECT_NAME} ${SRC})
16 |
17 | target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
18 | set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF)
19 |
20 |
--------------------------------------------------------------------------------
/examples/ex_02/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.18)
2 | project(ex_02)
3 |
4 | include(../../hypertextcpp.cmake)
5 |
6 | hypertextcpp_GenerateHeader(
7 | TEMPLATE_FILE todolist.htcpp
8 | OUTPUT_DIR template
9 | )
10 |
11 | set(SRC
12 | todolist_printer.cpp
13 | template/todolist.h)
14 |
15 | add_executable(${PROJECT_NAME} ${SRC})
16 |
17 | target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
18 | set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF)
19 |
20 |
--------------------------------------------------------------------------------
/tests/assert_exception.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | template
6 | void assert_exception(std::function throwingCode, std::function exceptionContentChecker)
7 | {
8 | try{
9 | throwingCode();
10 | FAIL() << "exception wasn't thrown!";
11 | }
12 | catch(const ExceptionType& e){
13 | exceptionContentChecker(e);
14 | }
15 | catch(...){
16 | FAIL() << "Unexpected exception was thrown";
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/examples/ex_06/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.18)
2 | project(ex_06)
3 |
4 | include(../../hypertextcpp.cmake)
5 |
6 | hypertextcpp_GenerateHeaderAndSource(
7 | TEMPLATE_FILE todolist.htcpp
8 | CLASS_NAME TodoList
9 | CONFIG_CLASS_NAME PageParams)
10 |
11 | set(SRC
12 | todolist_printer.cpp
13 | todolist.h
14 | todolist.cpp)
15 |
16 | add_executable(${PROJECT_NAME} ${SRC})
17 |
18 | target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
19 | set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF)
20 |
21 |
--------------------------------------------------------------------------------
/examples/ex_07/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.18)
2 | project(ex_07)
3 |
4 | include(../../hypertextcpp.cmake)
5 |
6 | hypertextcpp_GenerateHeaderAndSource(
7 | TEMPLATE_FILE todolist.htcpp
8 | CLASS_NAME TodoList
9 | CONFIG_CLASS_NAME PageParams)
10 |
11 | set(SRC
12 | todolist_printer.cpp
13 | todolist.h
14 | todolist.cpp)
15 |
16 | add_executable(${PROJECT_NAME} ${SRC})
17 |
18 | target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
19 | set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF)
20 |
21 |
--------------------------------------------------------------------------------
/src/nodereader.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "idocumentnode.h"
3 | #include