diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a23ad0..a661204 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,21 @@ cmake_minimum_required(VERSION 3.3 FATAL_ERROR) list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) -project(tawashi_top) +project(tawashi_top VERSION 0.1.3 LANGUAGES NONE) set(TAWASHI_SOURCE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}") +set(TAWASHI_GEN_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/include") +set(TAWASHI_CONFIG_PATH "etc" CACHE STRING "Path where config file will be located, absolute or relative to the install prefix") +set(TAWASHI_CONFIG_FILE "${PROJECT_NAME}.ini" CACHE STRING "Filename of the config file in TAWASHI_CONFIG_PATH") + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/src/tawashiConfig.h.in" + "${TAWASHI_GEN_INCLUDE_DIR}/tawashiConfig.h" +) add_subdirectory(lib/incredis) add_subdirectory(lib/mstch) add_subdirectory(lib/houdini) -add_subdirectory(src) +add_subdirectory(src/tawashi_implem) +add_subdirectory(src/tawashi) install(DIRECTORY html DESTINATION .) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 31931c5..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,76 +0,0 @@ -project(tawashi VERSION 0.1.3 LANGUAGES CXX) - -find_package(Boost 1.53.0 REQUIRED COMPONENTS program_options filesystem system) -find_package(SourceHighlight REQUIRED) - -set(CMAKE_CXX_STANDARD 14) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(TAWASHI_CONFIG_PATH "etc" CACHE STRING "Path where config file will be located, absolute or relative to the install prefix") -set(TAWASHI_CONFIG_FILE "${PROJECT_NAME}.ini" CACHE STRING "Filename of the config file in TAWASHI_CONFIG_PATH") - -add_executable(${PROJECT_NAME} - main.cpp - split_get_vars.cpp - response.cpp - submit_paste_response.cpp - get_env.cpp - cgi_environment_vars.cpp - cgi_env.cpp - num_to_token.cpp - cgi_post.cpp - escapist.cpp - index_response.cpp - pastie_response.cpp - ini_file.cpp - pathname/pathname.cpp - response_factory.cpp - list_highlight_langs.cpp - settings_bag.cpp - sanitized_utf8.cpp -) - -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.h.in" - "${CMAKE_CURRENT_BINARY_DIR}/include/${PROJECT_NAME}Config.h" -) - -target_include_directories(${PROJECT_NAME} - PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include - PRIVATE ${TAWASHI_SOURCE_ROOT}/lib/kakoune - PRIVATE ${TAWASHI_SOURCE_ROOT}/lib/mstch/include -) -target_include_directories(${PROJECT_NAME} SYSTEM - PRIVATE ${Boost_INCLUDE_DIRS} - PRIVATE ${TAWASHI_SOURCE_ROOT}/lib/better-enums - PRIVATE ${SourceHighlight_INCLUDE_DIR} - PRIVATE ${TAWASHI_SOURCE_ROOT}/lib/utf8_v2_3_4/source - PRIVATE ${TAWASHI_SOURCE_ROOT}/lib/spdlog/include -) -target_link_libraries(${PROJECT_NAME} - PRIVATE ${Boost_LIBRARIES} - PRIVATE incredis - PRIVATE ${SourceHighlight_LIBRARIES} - PRIVATE mstch - PRIVATE houdini - PRIVATE pthread -) -target_compile_definitions(${PROJECT_NAME} - PRIVATE BOOST_SPIRIT_USE_PHOENIX_V3=1 - PRIVATE $<$:SPDLOG_DEBUG_ON> - PRIVATE $<$:SPDLOG_TRACE_ON> -) -target_compile_options(${PROJECT_NAME} - PRIVATE -fdiagnostics-color=always -) - -set_target_properties( - ${PROJECT_NAME} - PROPERTIES SUFFIX .cgi -) - -install(TARGETS ${PROJECT_NAME} - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin - ARCHIVE DESTINATION lib/static -) diff --git a/src/tawashi/CMakeLists.txt b/src/tawashi/CMakeLists.txt new file mode 100644 index 0000000..288db4f --- /dev/null +++ b/src/tawashi/CMakeLists.txt @@ -0,0 +1,27 @@ +project(tawashi LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_executable(${PROJECT_NAME} + main.cpp +) +target_link_libraries(${PROJECT_NAME} + PRIVATE tawashi_implem +) + +set_target_properties( + ${PROJECT_NAME} + PROPERTIES SUFFIX .cgi +) + +target_include_directories(${PROJECT_NAME} + PRIVATE ${TAWASHI_GEN_INCLUDE_DIR} + #hack - add duckhandy to the project instead of picking from inside redis + PRIVATE ${TAWASHI_SOURCE_ROOT}/lib/incredis/lib/duckhandy/include +) +install(TARGETS ${PROJECT_NAME} + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin + ARCHIVE DESTINATION lib/static +) diff --git a/src/main.cpp b/src/tawashi/main.cpp similarity index 100% rename from src/main.cpp rename to src/tawashi/main.cpp diff --git a/src/tawashi_implem/CMakeLists.txt b/src/tawashi_implem/CMakeLists.txt new file mode 100644 index 0000000..3b04984 --- /dev/null +++ b/src/tawashi_implem/CMakeLists.txt @@ -0,0 +1,57 @@ +project(tawashi_implem LANGUAGES CXX) + +find_package(Boost 1.53.0 REQUIRED COMPONENTS program_options filesystem system) +find_package(SourceHighlight REQUIRED) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_library(${PROJECT_NAME} STATIC + split_get_vars.cpp + response.cpp + submit_paste_response.cpp + get_env.cpp + cgi_environment_vars.cpp + cgi_env.cpp + num_to_token.cpp + cgi_post.cpp + escapist.cpp + index_response.cpp + pastie_response.cpp + ini_file.cpp + pathname/pathname.cpp + response_factory.cpp + list_highlight_langs.cpp + settings_bag.cpp + sanitized_utf8.cpp +) + +target_include_directories(${PROJECT_NAME} + PRIVATE ${TAWASHI_GEN_INCLUDE_DIR} + PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/kakoune + PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/mstch/include + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} +) +target_include_directories(${PROJECT_NAME} SYSTEM + PUBLIC ${Boost_INCLUDE_DIRS} + PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/better-enums + PRIVATE ${SourceHighlight_INCLUDE_DIR} + PRIVATE ${TAWASHI_SOURCE_ROOT}/lib/utf8_v2_3_4/source + PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/spdlog/include +) +target_link_libraries(${PROJECT_NAME} + PRIVATE ${Boost_LIBRARIES} + PRIVATE incredis + PRIVATE ${SourceHighlight_LIBRARIES} + PUBLIC mstch + PRIVATE houdini + PRIVATE pthread +) +target_compile_definitions(${PROJECT_NAME} + PRIVATE BOOST_SPIRIT_USE_PHOENIX_V3=1 + PUBLIC $<$:SPDLOG_DEBUG_ON> + PUBLIC $<$:SPDLOG_TRACE_ON> +) +target_compile_options(${PROJECT_NAME} + PRIVATE -fdiagnostics-color=always +) diff --git a/src/cgi_env.cpp b/src/tawashi_implem/cgi_env.cpp similarity index 100% rename from src/cgi_env.cpp rename to src/tawashi_implem/cgi_env.cpp diff --git a/src/cgi_env.hpp b/src/tawashi_implem/cgi_env.hpp similarity index 100% rename from src/cgi_env.hpp rename to src/tawashi_implem/cgi_env.hpp diff --git a/src/cgi_environment_vars.cpp b/src/tawashi_implem/cgi_environment_vars.cpp similarity index 100% rename from src/cgi_environment_vars.cpp rename to src/tawashi_implem/cgi_environment_vars.cpp diff --git a/src/cgi_environment_vars.hpp b/src/tawashi_implem/cgi_environment_vars.hpp similarity index 100% rename from src/cgi_environment_vars.hpp rename to src/tawashi_implem/cgi_environment_vars.hpp diff --git a/src/cgi_post.cpp b/src/tawashi_implem/cgi_post.cpp similarity index 100% rename from src/cgi_post.cpp rename to src/tawashi_implem/cgi_post.cpp diff --git a/src/cgi_post.hpp b/src/tawashi_implem/cgi_post.hpp similarity index 100% rename from src/cgi_post.hpp rename to src/tawashi_implem/cgi_post.hpp diff --git a/src/escapist.cpp b/src/tawashi_implem/escapist.cpp similarity index 100% rename from src/escapist.cpp rename to src/tawashi_implem/escapist.cpp diff --git a/src/escapist.hpp b/src/tawashi_implem/escapist.hpp similarity index 100% rename from src/escapist.hpp rename to src/tawashi_implem/escapist.hpp diff --git a/src/get_env.cpp b/src/tawashi_implem/get_env.cpp similarity index 100% rename from src/get_env.cpp rename to src/tawashi_implem/get_env.cpp diff --git a/src/get_env.hpp b/src/tawashi_implem/get_env.hpp similarity index 100% rename from src/get_env.hpp rename to src/tawashi_implem/get_env.hpp diff --git a/src/index_response.cpp b/src/tawashi_implem/index_response.cpp similarity index 100% rename from src/index_response.cpp rename to src/tawashi_implem/index_response.cpp diff --git a/src/index_response.hpp b/src/tawashi_implem/index_response.hpp similarity index 100% rename from src/index_response.hpp rename to src/tawashi_implem/index_response.hpp diff --git a/src/ini_file.cpp b/src/tawashi_implem/ini_file.cpp similarity index 100% rename from src/ini_file.cpp rename to src/tawashi_implem/ini_file.cpp diff --git a/src/ini_file.hpp b/src/tawashi_implem/ini_file.hpp similarity index 100% rename from src/ini_file.hpp rename to src/tawashi_implem/ini_file.hpp diff --git a/src/list_highlight_langs.cpp b/src/tawashi_implem/list_highlight_langs.cpp similarity index 100% rename from src/list_highlight_langs.cpp rename to src/tawashi_implem/list_highlight_langs.cpp diff --git a/src/list_highlight_langs.hpp b/src/tawashi_implem/list_highlight_langs.hpp similarity index 100% rename from src/list_highlight_langs.hpp rename to src/tawashi_implem/list_highlight_langs.hpp diff --git a/src/tawashi_implem/logger.hpp b/src/tawashi_implem/logger.hpp new file mode 100644 index 0000000..8b8a42f --- /dev/null +++ b/src/tawashi_implem/logger.hpp @@ -0,0 +1,52 @@ +/* Copyright 2017, Michele Santullo + * This file is part of "tawashi". + * + * "tawashi" is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * "tawashi" is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with "tawashi". If not, see . + */ + +#include +#include +#include +#include + +namespace tawashi { + class Logger { + public: + explicit Logger (std::ostream* parStream); + ~Logger() noexcept; + + template + void log (int parLevel, const boost::string_ref& parFormat, Args&&... parArgs); + + private: + static const constexpr int LogLevels = 3; + + std::array m_outs; + }; + + template + void Logger::log (int parLevel, const boost::string_ref& parFormat, Args&&... parArgs) { + assert(parLevel >= 0 and parLevel < LogLevels); + if (nullptr == m_outs[parLevel]) + return; + + bool percentage_seq = false; + for (auto chara : parFormat) { + if (percentage_seq) { + } + else { + } + } + } +} //namespace tawashi diff --git a/src/logging_levels.hpp b/src/tawashi_implem/logging_levels.hpp similarity index 100% rename from src/logging_levels.hpp rename to src/tawashi_implem/logging_levels.hpp diff --git a/src/num_to_token.cpp b/src/tawashi_implem/num_to_token.cpp similarity index 100% rename from src/num_to_token.cpp rename to src/tawashi_implem/num_to_token.cpp diff --git a/src/num_to_token.hpp b/src/tawashi_implem/num_to_token.hpp similarity index 100% rename from src/num_to_token.hpp rename to src/tawashi_implem/num_to_token.hpp diff --git a/src/pastie_response.cpp b/src/tawashi_implem/pastie_response.cpp similarity index 100% rename from src/pastie_response.cpp rename to src/tawashi_implem/pastie_response.cpp diff --git a/src/pastie_response.hpp b/src/tawashi_implem/pastie_response.hpp similarity index 100% rename from src/pastie_response.hpp rename to src/tawashi_implem/pastie_response.hpp diff --git a/src/pathname/pathname.cpp b/src/tawashi_implem/pathname/pathname.cpp similarity index 100% rename from src/pathname/pathname.cpp rename to src/tawashi_implem/pathname/pathname.cpp diff --git a/src/pathname/pathname.hpp b/src/tawashi_implem/pathname/pathname.hpp similarity index 100% rename from src/pathname/pathname.hpp rename to src/tawashi_implem/pathname/pathname.hpp diff --git a/src/pathname/stringpool.hpp b/src/tawashi_implem/pathname/stringpool.hpp similarity index 100% rename from src/pathname/stringpool.hpp rename to src/tawashi_implem/pathname/stringpool.hpp diff --git a/src/pathname/stringpool.inl b/src/tawashi_implem/pathname/stringpool.inl similarity index 100% rename from src/pathname/stringpool.inl rename to src/tawashi_implem/pathname/stringpool.inl diff --git a/src/response.cpp b/src/tawashi_implem/response.cpp similarity index 100% rename from src/response.cpp rename to src/tawashi_implem/response.cpp diff --git a/src/response.hpp b/src/tawashi_implem/response.hpp similarity index 100% rename from src/response.hpp rename to src/tawashi_implem/response.hpp diff --git a/src/response_factory.cpp b/src/tawashi_implem/response_factory.cpp similarity index 100% rename from src/response_factory.cpp rename to src/tawashi_implem/response_factory.cpp diff --git a/src/response_factory.hpp b/src/tawashi_implem/response_factory.hpp similarity index 100% rename from src/response_factory.hpp rename to src/tawashi_implem/response_factory.hpp diff --git a/src/safe_stack_object.hpp b/src/tawashi_implem/safe_stack_object.hpp similarity index 100% rename from src/safe_stack_object.hpp rename to src/tawashi_implem/safe_stack_object.hpp diff --git a/src/sanitized_utf8.cpp b/src/tawashi_implem/sanitized_utf8.cpp similarity index 100% rename from src/sanitized_utf8.cpp rename to src/tawashi_implem/sanitized_utf8.cpp diff --git a/src/sanitized_utf8.hpp b/src/tawashi_implem/sanitized_utf8.hpp similarity index 100% rename from src/sanitized_utf8.hpp rename to src/tawashi_implem/sanitized_utf8.hpp diff --git a/src/settings_bag.cpp b/src/tawashi_implem/settings_bag.cpp similarity index 100% rename from src/settings_bag.cpp rename to src/tawashi_implem/settings_bag.cpp diff --git a/src/settings_bag.hpp b/src/tawashi_implem/settings_bag.hpp similarity index 100% rename from src/settings_bag.hpp rename to src/tawashi_implem/settings_bag.hpp diff --git a/src/tawashi_implem/spdlog.hpp b/src/tawashi_implem/spdlog.hpp new file mode 100644 index 0000000..20d1a06 --- /dev/null +++ b/src/tawashi_implem/spdlog.hpp @@ -0,0 +1,28 @@ +/* Copyright 2017, Michele Santullo + * This file is part of "tawashi". + * + * "tawashi" is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * "tawashi" is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with "tawashi". If not, see . + */ + +#pragma once + +#include +#include + +namespace spdlog { + template + inline OStream& operator<< (OStream& parOS, const boost::string_ref& parStr) { + return parOS << parStr; + } +} //namespace spdlog diff --git a/src/split_get_vars.cpp b/src/tawashi_implem/split_get_vars.cpp similarity index 100% rename from src/split_get_vars.cpp rename to src/tawashi_implem/split_get_vars.cpp diff --git a/src/split_get_vars.hpp b/src/tawashi_implem/split_get_vars.hpp similarity index 100% rename from src/split_get_vars.hpp rename to src/tawashi_implem/split_get_vars.hpp diff --git a/src/submit_paste_response.cpp b/src/tawashi_implem/submit_paste_response.cpp similarity index 100% rename from src/submit_paste_response.cpp rename to src/tawashi_implem/submit_paste_response.cpp diff --git a/src/submit_paste_response.hpp b/src/tawashi_implem/submit_paste_response.hpp similarity index 100% rename from src/submit_paste_response.hpp rename to src/tawashi_implem/submit_paste_response.hpp