diff --git a/CMakeLists.txt b/CMakeLists.txt index 316659d..74dfa15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.14 FATAL_ERROR) -project(fhiclcpp VERSION 23.06 LANGUAGES CXX) +project(fhiclcppsimple VERSION 23.06 LANGUAGES CXX) if(NOT DEFINED CMAKE_INSTALL_PREFIX OR "${CMAKE_INSTALL_PREFIX}x" STREQUAL "x" OR @@ -25,44 +25,44 @@ if(NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 14) set(CMAKE_CXX_STANDARD 14) endif() -include (${PROJECT_SOURCE_DIR}/cmake/Modules/fhiclcppDependencies.cmake) +include (${PROJECT_SOURCE_DIR}/cmake/Modules/fhiclcppsimpleDependencies.cmake) -add_library(fhiclcpp_includes INTERFACE) -target_include_directories(fhiclcpp_includes INTERFACE +add_library(fhiclcppsimple_includes INTERFACE) +target_include_directories(fhiclcppsimple_includes INTERFACE $ $) -target_link_libraries(fhiclcpp_includes INTERFACE linedoc::includes) -set_target_properties(fhiclcpp_includes PROPERTIES EXPORT_NAME fhiclcpp::includes) +target_link_libraries(fhiclcppsimple_includes INTERFACE linedoc::includes) +set_target_properties(fhiclcppsimple_includes PROPERTIES EXPORT_NAME fhiclcppsimple::includes) -install(TARGETS fhiclcpp_includes EXPORT fhiclcppTargets) +install(TARGETS fhiclcppsimple_includes EXPORT fhiclcppsimpleTargets) -add_library(fhiclcpp::includes ALIAS fhiclcpp_includes) +add_library(fhiclcppsimple::includes ALIAS fhiclcppsimple_includes) -add_subdirectory(fhiclcpp) +add_subdirectory(fhiclcppsimple) include(CMakePackageConfigHelpers) write_basic_package_version_file( - "${PROJECT_BINARY_DIR}/fhiclcppConfigVersion.cmake" + "${PROJECT_BINARY_DIR}/fhiclcppsimpleConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion ) configure_package_config_file( - "${CMAKE_CURRENT_LIST_DIR}/cmake/Templates/fhiclcppConfig.cmake.in" - "${PROJECT_BINARY_DIR}/fhiclcppConfig.cmake" + "${CMAKE_CURRENT_LIST_DIR}/cmake/Templates/fhiclcppsimpleConfig.cmake.in" + "${PROJECT_BINARY_DIR}/fhiclcppsimpleConfig.cmake" INSTALL_DESTINATION cmake NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO ) -install(EXPORT fhiclcppTargets - DESTINATION lib/cmake/fhiclcpp ) +install(EXPORT fhiclcppsimpleTargets + DESTINATION lib/cmake/fhiclcppsimple ) -install(FILES "${PROJECT_BINARY_DIR}/fhiclcppConfigVersion.cmake" - "${PROJECT_BINARY_DIR}/fhiclcppConfig.cmake" - DESTINATION lib/cmake/fhiclcpp) +install(FILES "${PROJECT_BINARY_DIR}/fhiclcppsimpleConfigVersion.cmake" + "${PROJECT_BINARY_DIR}/fhiclcppsimpleConfig.cmake" + DESTINATION lib/cmake/fhiclcppsimple) -configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/Templates/setup.fhiclcpp.sh.in ${PROJECT_BINARY_DIR}/setup.fhiclcpp.sh @ONLY) -install(PROGRAMS ${PROJECT_BINARY_DIR}/setup.fhiclcpp.sh DESTINATION bin) +configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/Templates/setup.fhiclcppsimple.sh.in ${PROJECT_BINARY_DIR}/setup.fhiclcppsimple.sh @ONLY) +install(PROGRAMS ${PROJECT_BINARY_DIR}/setup.fhiclcppsimple.sh DESTINATION bin) if(DOTEST) file(GLOB EXAMPLE_FCL fcl/*.fcl) diff --git a/cmake/Modules/fhiclcppDependencies.cmake b/cmake/Modules/fhiclcppsimpleDependencies.cmake similarity index 100% rename from cmake/Modules/fhiclcppDependencies.cmake rename to cmake/Modules/fhiclcppsimpleDependencies.cmake diff --git a/cmake/Templates/fhiclcppConfig.cmake.in b/cmake/Templates/fhiclcppConfig.cmake.in deleted file mode 100644 index 1921d59..0000000 --- a/cmake/Templates/fhiclcppConfig.cmake.in +++ /dev/null @@ -1,37 +0,0 @@ -@PACKAGE_INIT@ - -find_package(linedoc REQUIRED) - -set(fhiclcpp_VERSION @PROJECT_VERSION@) - -include(${CMAKE_CURRENT_LIST_DIR}/fhiclcppTargets.cmake) -if(NOT TARGET fhiclcpp::includes) - message(WARNING "Expected to find target fhiclcpp::includes in ${CMAKE_CURRENT_LIST_DIR}/fhiclcppTargets.cmake") - set(fhiclcpp_FOUND FALSE) - return() -endif() - -get_filename_component(fhiclcpp_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) - -find_path(fhiclcpp_INCLUDE_DIR - NAMES fhiclcpp/fhicl_doc.hxx - PATHS ${fhiclcpp_CMAKE_DIR}/../../../include -) - -find_path(fhiclcpp_PREFIX - NAMES bin/setup.fhiclcpp.sh - PATHS ${fhiclcpp_CMAKE_DIR}/../../../ -) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(fhiclcpp - REQUIRED_VARS - fhiclcpp_INCLUDE_DIR - fhiclcpp_PREFIX - VERSION_VAR - fhiclcpp_VERSION -) - -message(STATUS "Found fhiclcpp Version: ${fhiclcpp_VERSION} in \"${fhiclcpp_CMAKE_DIR}\"") -message(STATUS " fhiclcpp_INCLUDE_DIR: ${fhiclcpp_INCLUDE_DIR}") -message(STATUS " fhiclcpp_PREFIX: ${fhiclcpp_PREFIX}") diff --git a/cmake/Templates/fhiclcppsimpleConfig.cmake.in b/cmake/Templates/fhiclcppsimpleConfig.cmake.in new file mode 100644 index 0000000..b8867d0 --- /dev/null +++ b/cmake/Templates/fhiclcppsimpleConfig.cmake.in @@ -0,0 +1,37 @@ +@PACKAGE_INIT@ + +find_package(linedoc REQUIRED) + +set(fhiclcppsimple_VERSION @PROJECT_VERSION@) + +include(${CMAKE_CURRENT_LIST_DIR}/fhiclcppsimpleTargets.cmake) +if(NOT TARGET fhiclcppsimple::includes) + message(WARNING "Expected to find target fhiclcppsimple::includes in ${CMAKE_CURRENT_LIST_DIR}/fhiclcppsimpleTargets.cmake") + set(fhiclcppsimple_FOUND FALSE) + return() +endif() + +get_filename_component(fhiclcppsimple_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + +find_path(fhiclcppsimple_INCLUDE_DIR + NAMES fhiclcppsimple/fhicl_doc.hxx + PATHS ${fhiclcppsimple_CMAKE_DIR}/../../../include +) + +find_path(fhiclcppsimple_PREFIX + NAMES bin/setup.fhiclcppsimple.sh + PATHS ${fhiclcppsimple_CMAKE_DIR}/../../../ +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(fhiclcppsimple + REQUIRED_VARS + fhiclcppsimple_INCLUDE_DIR + fhiclcppsimple_PREFIX + VERSION_VAR + fhiclcppsimple_VERSION +) + +message(STATUS "Found fhiclcppsimple Version: ${fhiclcppsimple_VERSION} in \"${fhiclcppsimple_CMAKE_DIR}\"") +message(STATUS " fhiclcppsimple_INCLUDE_DIR: ${fhiclcppsimple_INCLUDE_DIR}") +message(STATUS " fhiclcppsimple_PREFIX: ${fhiclcppsimple_PREFIX}") diff --git a/cmake/Templates/setup.fhiclcpp.sh.in b/cmake/Templates/setup.fhiclcppsimple.sh.in similarity index 92% rename from cmake/Templates/setup.fhiclcpp.sh.in rename to cmake/Templates/setup.fhiclcppsimple.sh.in index acad95f..d3f6f22 100644 --- a/cmake/Templates/setup.fhiclcpp.sh.in +++ b/cmake/Templates/setup.fhiclcppsimple.sh.in @@ -90,11 +90,11 @@ function add_to_FHICL_FILE_PATH () { fi -export fhiclcpp_ROOT="@CMAKE_INSTALL_PREFIX@" -export fhiclcpp_VERSION="@PROJECT_VERSION@" +export fhiclcppsimple_ROOT="@CMAKE_INSTALL_PREFIX@" +export fhiclcppsimple_VERSION="@PROJECT_VERSION@" -add_to_PATH "${fhiclcpp_ROOT}/bin" +add_to_PATH "${fhiclcppsimple_ROOT}/bin" if [ "@DOTEST_CONFIG@" == "TRUE" ]; then - add_to_FHICL_FILE_PATH "${fhiclcpp_ROOT}/fcl" + add_to_FHICL_FILE_PATH "${fhiclcppsimple_ROOT}/fcl" fi diff --git a/fhiclcpp/ParameterSet.h b/fhiclcpp/ParameterSet.h deleted file mode 100644 index f1f60cc..0000000 --- a/fhiclcpp/ParameterSet.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include "fhiclcpp/types/ParameterSet.hxx" -#include "fhiclcpp/types/Sequence.hxx" - -#include "fhiclcpp/types/CompositeTypesSharedImpl.hxx" diff --git a/fhiclcpp/make_ParameterSet.h b/fhiclcpp/make_ParameterSet.h deleted file mode 100644 index 430588d..0000000 --- a/fhiclcpp/make_ParameterSet.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include "fhiclcpp/ParameterSet.h" -#include "fhiclcpp/recursive_build_fhicl.hxx" - -namespace fhicl { - -inline ParameterSet make_ParameterSet(std::string const &filename) { - ParameterSet prolog; - ParameterSet working_doc; - - fhicl::fhicl_doc doc = fhicl::read_doc(filename); - doc.resolve_includes(); - - return parse_fhicl_document(doc); -} - -inline void make_ParameterSet(std::string const &filename, ParameterSet& pset){ - pset = make_ParameterSet(filename); -} - -} // namespace fhicl diff --git a/fhiclcpp/CMakeLists.txt b/fhiclcppsimple/CMakeLists.txt similarity index 70% rename from fhiclcpp/CMakeLists.txt rename to fhiclcppsimple/CMakeLists.txt index 1aee443..6f3fc80 100644 --- a/fhiclcpp/CMakeLists.txt +++ b/fhiclcppsimple/CMakeLists.txt @@ -2,12 +2,12 @@ add_subdirectory(string_parsers) add_subdirectory(types) add_executable(fhicl-dump fhicl-dump.cxx) -target_link_libraries(fhicl-dump fhiclcpp_includes linedoc::includes) +target_link_libraries(fhicl-dump fhiclcppsimple_includes linedoc::includes) install(TARGETS fhicl-dump DESTINATION bin) if(DOTEST) add_executable(fhiclcpp_tests tests.cxx) - target_link_libraries(fhiclcpp_tests fhiclcpp_includes linedoc::includes) + target_link_libraries(fhiclcpp_tests fhiclcppsimple_includes linedoc::includes) install(TARGETS fhiclcpp_tests DESTINATION test) add_test(NAME fhiclcpp_tests COMMAND fhiclcpp_tests) @@ -19,4 +19,4 @@ install(FILES make_ParameterSet.h ParameterSet.h recursive_build_fhicl.hxx -DESTINATION include/fhiclcpp) +DESTINATION include/fhiclcppsimple) diff --git a/fhiclcppsimple/ParameterSet.h b/fhiclcppsimple/ParameterSet.h new file mode 100644 index 0000000..e70ea57 --- /dev/null +++ b/fhiclcppsimple/ParameterSet.h @@ -0,0 +1,6 @@ +#pragma once + +#include "fhiclcppsimple/types/ParameterSet.hxx" +#include "fhiclcppsimple/types/Sequence.hxx" + +#include "fhiclcppsimple/types/CompositeTypesSharedImpl.hxx" diff --git a/fhiclcpp/exception.hxx b/fhiclcppsimple/exception.hxx similarity index 92% rename from fhiclcpp/exception.hxx rename to fhiclcppsimple/exception.hxx index 5fa722b..8d37815 100644 --- a/fhiclcpp/exception.hxx +++ b/fhiclcppsimple/exception.hxx @@ -1,11 +1,11 @@ #pragma once -#include "fhiclcpp/types/exception.hxx" +#include "fhiclcppsimple/types/exception.hxx" #include #include -namespace fhicl { +namespace fhiclsimple { #define NEW_EXCEPT(EXCEPT_NAME) \ struct EXCEPT_NAME : public fhicl_cpp_simple_except { \ @@ -36,4 +36,4 @@ struct unexpected_newline : public malformed_document { } }; -} // namespace fhicl +} // namespace fhiclsimple diff --git a/fhiclcpp/fhicl-dump.cxx b/fhiclcppsimple/fhicl-dump.cxx similarity index 81% rename from fhiclcpp/fhicl-dump.cxx rename to fhiclcppsimple/fhicl-dump.cxx index e201a03..1882fdf 100644 --- a/fhiclcpp/fhicl-dump.cxx +++ b/fhiclcppsimple/fhicl-dump.cxx @@ -11,6 +11,6 @@ int main(int argc, char const *argv[]) { return 1; } - fhicl::ParameterSet ps = fhicl::make_ParameterSet(argv[1]); + fhiclsimple::ParameterSet ps = fhiclsimple::make_ParameterSet(argv[1]); std::cout << ps.to_indented_string() << std::endl; } diff --git a/fhiclcpp/fhicl_doc.hxx b/fhiclcppsimple/fhicl_doc.hxx similarity index 97% rename from fhiclcpp/fhicl_doc.hxx rename to fhiclcppsimple/fhicl_doc.hxx index 9cb4034..1a8dae8 100644 --- a/fhiclcpp/fhicl_doc.hxx +++ b/fhiclcppsimple/fhicl_doc.hxx @@ -1,9 +1,9 @@ #pragma once -#include "fhiclcpp/exception.hxx" +#include "fhiclcppsimple/exception.hxx" -#include "fhiclcpp/string_parsers/traits.hxx" -#include "fhiclcpp/string_parsers/utility.hxx" +#include "fhiclcppsimple/string_parsers/traits.hxx" +#include "fhiclcppsimple/string_parsers/utility.hxx" #include "linedoc/doc.hxx" @@ -12,6 +12,8 @@ #include #include #include +#include + #include #include @@ -19,11 +21,12 @@ #include #include -namespace fhicl { +namespace fhiclsimple { class fhicl_doc; inline fhicl_doc read_doc(std::string const &filename); +inline fhicl_doc convert_from_string(std::string const &str); inline linedoc::doc_line_point find_matching_bracket( fhicl_doc const &doc, char open_bracket = '{', char close_bracket = '}', linedoc::doc_line_point begin = linedoc::doc_line_point::begin()); @@ -613,4 +616,21 @@ inline fhicl_doc read_doc(std::string const &filename) { return doc; } -} // namespace fhicl +inline fhicl_doc convert_from_string(std::string const &str){ + + std::istringstream iss(str); + + std::string line; + fhicl_doc doc; + size_t ctr = 0; + + while (std::getline(iss, line)) { + string_parsers::trim(line); + doc.push_back(line, "", ctr); + ctr++; + } + return doc; + +} + +} // namespace fhiclsimple diff --git a/fhiclcppsimple/make_ParameterSet.h b/fhiclcppsimple/make_ParameterSet.h new file mode 100644 index 0000000..46c7b61 --- /dev/null +++ b/fhiclcppsimple/make_ParameterSet.h @@ -0,0 +1,33 @@ +#pragma once + +#include "fhiclcppsimple/ParameterSet.h" +#include "fhiclcppsimple/recursive_build_fhicl.hxx" + +namespace fhiclsimple { + +inline ParameterSet make_ParameterSet(std::string const &filename) { + ParameterSet prolog; + ParameterSet working_doc; + + fhiclsimple::fhicl_doc doc = fhiclsimple::read_doc(filename); + doc.resolve_includes(); + + return parse_fhicl_document(doc); +} + +inline ParameterSet make_ParameterSet_from_string(std::string const &str) { + ParameterSet prolog; + ParameterSet working_doc; + + fhiclsimple::fhicl_doc doc = fhiclsimple::convert_from_string(str); + + doc.resolve_includes(); + + return parse_fhicl_document(doc); +} + +inline void make_ParameterSet(std::string const &filename, ParameterSet& pset){ + pset = make_ParameterSet(filename); +} + +} // namespace fhiclsimple diff --git a/fhiclcpp/recursive_build_fhicl.hxx b/fhiclcppsimple/recursive_build_fhicl.hxx similarity index 99% rename from fhiclcpp/recursive_build_fhicl.hxx rename to fhiclcppsimple/recursive_build_fhicl.hxx index dcda306..7df2787 100644 --- a/fhiclcpp/recursive_build_fhicl.hxx +++ b/fhiclcppsimple/recursive_build_fhicl.hxx @@ -1,12 +1,12 @@ #pragma once -#include "fhiclcpp/ParameterSet.h" +#include "fhiclcppsimple/ParameterSet.h" -#include "fhiclcpp/fhicl_doc.hxx" +#include "fhiclcppsimple/fhicl_doc.hxx" #include -namespace fhicl { +namespace fhiclsimple { inline ParameterSet parse_fhicl_document(fhicl_doc const &, ParameterSet const &, @@ -222,7 +222,8 @@ parse_object(fhicl_doc const &doc, linedoc::doc_range range, << ". N.B. quoted strings cannot span multiple lines."; } - std::string value = doc.substr(first_string_point, matching_quote); + std::string value = "\""+doc.substr(first_string_point, matching_quote)+"\""; + next_character = doc.advance(matching_quote); #ifdef FHICLCPP_SIMPLE_PARSERS_DEBUG std::cout << indent << "[INFO]: Found KV: {" << std::quoted(current_key) @@ -620,4 +621,4 @@ parse_fhicl_document(fhicl_doc const &doc, return (*ps); } -} // namespace fhicl +} // namespace fhiclsimple diff --git a/fhiclcpp/string_parsers/CMakeLists.txt b/fhiclcppsimple/string_parsers/CMakeLists.txt similarity index 67% rename from fhiclcpp/string_parsers/CMakeLists.txt rename to fhiclcppsimple/string_parsers/CMakeLists.txt index c534ac7..3798f23 100644 --- a/fhiclcpp/string_parsers/CMakeLists.txt +++ b/fhiclcppsimple/string_parsers/CMakeLists.txt @@ -1,6 +1,6 @@ if(DOTEST) add_executable(string_parsers_tests tests.cxx) - target_link_libraries(string_parsers_tests fhiclcpp_includes linedoc::includes) + target_link_libraries(string_parsers_tests fhiclcppsimple_includes linedoc::includes) install(TARGETS string_parsers_tests DESTINATION test) add_test(NAME string_parsers_tests COMMAND string_parsers_tests) @@ -13,4 +13,4 @@ install(FILES to_string.hxx traits.hxx utility.hxx - DESTINATION include/fhiclcpp/string_parsers) + DESTINATION include/fhiclcppsimple/string_parsers) diff --git a/fhiclcpp/string_parsers/exception.hxx b/fhiclcppsimple/string_parsers/exception.hxx similarity index 96% rename from fhiclcpp/string_parsers/exception.hxx rename to fhiclcppsimple/string_parsers/exception.hxx index 61c4194..600bb9b 100644 --- a/fhiclcpp/string_parsers/exception.hxx +++ b/fhiclcppsimple/string_parsers/exception.hxx @@ -3,7 +3,7 @@ #include #include -namespace fhicl { +namespace fhiclsimple { namespace string_parsers { struct fhicl_cpp_simple_except : public std::exception { @@ -42,4 +42,4 @@ NEW_EXCEPT(wrong_number_of_elements); #undef NEW_EXCEPT } // namespace string_parsers -} // namespace fhicl +} // namespace fhiclsimple diff --git a/fhiclcpp/string_parsers/from_string.hxx b/fhiclcppsimple/string_parsers/from_string.hxx similarity index 98% rename from fhiclcpp/string_parsers/from_string.hxx rename to fhiclcppsimple/string_parsers/from_string.hxx index 6f1df2b..d372d10 100644 --- a/fhiclcpp/string_parsers/from_string.hxx +++ b/fhiclcppsimple/string_parsers/from_string.hxx @@ -1,7 +1,7 @@ #pragma once -#include "fhiclcpp/string_parsers/traits.hxx" -#include "fhiclcpp/string_parsers/utility.hxx" +#include "fhiclcppsimple/string_parsers/traits.hxx" +#include "fhiclcppsimple/string_parsers/utility.hxx" #include #include @@ -10,7 +10,7 @@ #include #include -namespace fhicl { +namespace fhiclsimple { namespace string_parsers { @@ -410,4 +410,4 @@ str2T(std::string const &str) { } } // namespace string_parsers -} // namespace fhicl +} // namespace fhiclsimple diff --git a/fhiclcpp/string_parsers/md5.hxx b/fhiclcppsimple/string_parsers/md5.hxx similarity index 99% rename from fhiclcpp/string_parsers/md5.hxx rename to fhiclcppsimple/string_parsers/md5.hxx index 9f135ce..d35206f 100644 --- a/fhiclcpp/string_parsers/md5.hxx +++ b/fhiclcppsimple/string_parsers/md5.hxx @@ -33,8 +33,7 @@ documentation and/or software. */ -#ifndef BZF_MD5_H -#define BZF_MD5_H +#pragma once #include #include @@ -52,6 +51,8 @@ documentation and/or software. // // assumes that char is 8 bit and int is 32 bit +namespace fhiclsimple{ + class MD5 { typedef uint8_t uint1; // 8bit typedef uint32_t uint4; // 32bit @@ -407,4 +408,4 @@ std::string md5(const std::string str) { return md5.hexdigest(); } -#endif +} diff --git a/fhiclcpp/string_parsers/tests.cxx b/fhiclcppsimple/string_parsers/tests.cxx similarity index 99% rename from fhiclcpp/string_parsers/tests.cxx rename to fhiclcppsimple/string_parsers/tests.cxx index 6235e5f..05e5aba 100644 --- a/fhiclcpp/string_parsers/tests.cxx +++ b/fhiclcppsimple/string_parsers/tests.cxx @@ -6,7 +6,7 @@ #include "string_parsers/to_string.hxx" #include "string_parsers/utility.hxx" -using namespace fhicl; +using namespace fhiclsimple; using namespace string_parsers; #define operator_assert(L, OP, R) \ diff --git a/fhiclcpp/string_parsers/to_string.hxx b/fhiclcppsimple/string_parsers/to_string.hxx similarity index 95% rename from fhiclcpp/string_parsers/to_string.hxx rename to fhiclcppsimple/string_parsers/to_string.hxx index 1ef8d60..de0818b 100644 --- a/fhiclcpp/string_parsers/to_string.hxx +++ b/fhiclcppsimple/string_parsers/to_string.hxx @@ -1,13 +1,13 @@ #pragma once -#include "fhiclcpp/string_parsers/traits.hxx" +#include "fhiclcppsimple/string_parsers/traits.hxx" #include #include #include #include -namespace fhicl { +namespace fhiclsimple { namespace string_parsers { template @@ -88,4 +88,4 @@ T2Str(typename std::enable_if::value, T>::type const &t) { } } // namespace string_parsers -} // namespace fhicl +} // namespace fhiclsimple diff --git a/fhiclcpp/string_parsers/traits.hxx b/fhiclcppsimple/string_parsers/traits.hxx similarity index 98% rename from fhiclcpp/string_parsers/traits.hxx rename to fhiclcppsimple/string_parsers/traits.hxx index ea43832..e0b4014 100644 --- a/fhiclcpp/string_parsers/traits.hxx +++ b/fhiclcppsimple/string_parsers/traits.hxx @@ -7,7 +7,7 @@ #include #include -namespace fhicl { +namespace fhiclsimple { template struct is_vect { static constexpr bool value = false; }; template struct is_vect> { static constexpr bool value = true; @@ -102,4 +102,4 @@ template struct string_rep_delim> { return rtn; } }; -} // namespace fhicl +} // namespace fhiclsimple diff --git a/fhiclcpp/string_parsers/utility.hxx b/fhiclcppsimple/string_parsers/utility.hxx similarity index 95% rename from fhiclcpp/string_parsers/utility.hxx rename to fhiclcppsimple/string_parsers/utility.hxx index 3d05d0f..d2537ae 100644 --- a/fhiclcpp/string_parsers/utility.hxx +++ b/fhiclcppsimple/string_parsers/utility.hxx @@ -1,13 +1,13 @@ #pragma once -#include "fhiclcpp/string_parsers/exception.hxx" +#include "fhiclcppsimple/string_parsers/exception.hxx" #include #include #include #include -namespace fhicl { +namespace fhiclsimple { namespace string_parsers { // trim from start (in place) @@ -35,7 +35,7 @@ inline bool well_bracket_wrapped(std::string str, char open_bracket = '{', trim(str); if ((str.front() == open_bracket) || (str.back() == close_bracket)) { if (!((str.front() == open_bracket) && (str.back() == close_bracket))) { - throw fhicl::string_parsers::mismatched_brackets() + throw fhiclsimple::string_parsers::mismatched_brackets() << "[ERROR]: Malformed bracketed string: " << std::quoted(str) << ", expected to find it bounded by " << open_bracket << close_bracket; @@ -136,4 +136,4 @@ inline std::string ensure_trailing_slash(std::string const &str) { } } // namespace string_parsers -} // namespace fhicl +} // namespace fhiclsimple diff --git a/fhiclcpp/tests.cxx b/fhiclcppsimple/tests.cxx similarity index 98% rename from fhiclcpp/tests.cxx rename to fhiclcppsimple/tests.cxx index 3a9ae1a..63cd75f 100644 --- a/fhiclcpp/tests.cxx +++ b/fhiclcppsimple/tests.cxx @@ -1,10 +1,10 @@ #include #include -#include "fhiclcpp/exception.hxx" -#include "fhiclcpp/make_ParameterSet.h" +#include "fhiclcppsimple/exception.hxx" +#include "fhiclcppsimple/make_ParameterSet.h" -using namespace fhicl; +using namespace fhiclsimple; using namespace linedoc; #define operator_assert(L, OP, R) \ @@ -253,7 +253,7 @@ int main() { ParameterSet ps; try { ps = ParameterSet("{a: b c: \"d:e\" f: g}"); - } catch (fhicl::parser_fail) { + } catch (fhiclsimple::parser_fail) { threw = true; } assert(!threw); diff --git a/fhiclcpp/types/Atom.hxx b/fhiclcppsimple/types/Atom.hxx similarity index 88% rename from fhiclcpp/types/Atom.hxx rename to fhiclcppsimple/types/Atom.hxx index 77bb300..fb5c1f8 100644 --- a/fhiclcpp/types/Atom.hxx +++ b/fhiclcppsimple/types/Atom.hxx @@ -1,14 +1,14 @@ #pragma once -#include "fhiclcpp/types/Base.hxx" +#include "fhiclcppsimple/types/Base.hxx" -#include "fhiclcpp/string_parsers/from_string.hxx" -#include "fhiclcpp/string_parsers/traits.hxx" +#include "fhiclcppsimple/string_parsers/from_string.hxx" +#include "fhiclcppsimple/string_parsers/traits.hxx" #include #include -namespace fhicl { +namespace fhiclsimple { class Atom : public Base { void from(std::string const &str) { internal_rep = str; } void from(std::string &&str) { internal_rep = std::move(str); } @@ -22,13 +22,18 @@ public: return T{}; } return string_parsers::str2T(internal_rep); - }; + } template typename std::enable_if::value, T>::type as() const { + if (is_nil()) { return "@nil"; } + else{ + return internal_rep; + } +/* std::string stringified = string_parsers::str2T(internal_rep); size_t first_period = stringified.find_first_of("."); if (first_period != @@ -45,6 +50,7 @@ public: } } + size_t first_punct = stringified.find_first_of(" ,\"\':;*&%$#@!~{}[]()/."); if (first_punct != std::string::npos) { std::stringstream ss(""); @@ -52,7 +58,9 @@ public: return ss.str(); } return stringified; - }; +*/ + + } Atom(std::string const &str) { from(str); } Atom(std::string &&str) { from(std::move(str)); } Atom(Atom const &other) : Base() { internal_rep = other.internal_rep; } @@ -68,4 +76,4 @@ public: bool is_nil() const { return internal_rep == "@nil"; } }; -} // namespace fhicl +} // namespace fhiclsimple diff --git a/fhiclcpp/types/Base.hxx b/fhiclcppsimple/types/Base.hxx similarity index 93% rename from fhiclcpp/types/Base.hxx rename to fhiclcppsimple/types/Base.hxx index 081b6ff..fa986c6 100644 --- a/fhiclcpp/types/Base.hxx +++ b/fhiclcppsimple/types/Base.hxx @@ -3,7 +3,7 @@ #include #include -namespace fhicl { +namespace fhiclsimple { class Base { protected: static std::shared_ptr &empty() { @@ -26,4 +26,4 @@ public: virtual std::string to_indented_string_with_src_info(size_t indent_level) const = 0; }; -} // namespace fhicl +} // namespace fhiclsimple diff --git a/fhiclcpp/types/CMakeLists.txt b/fhiclcppsimple/types/CMakeLists.txt similarity index 71% rename from fhiclcpp/types/CMakeLists.txt rename to fhiclcppsimple/types/CMakeLists.txt index 8ec9118..23e24b6 100644 --- a/fhiclcpp/types/CMakeLists.txt +++ b/fhiclcppsimple/types/CMakeLists.txt @@ -1,6 +1,6 @@ if(DOTEST) add_executable(types_tests tests.cxx) - target_link_libraries(types_tests fhiclcpp_includes linedoc::includes) + target_link_libraries(types_tests fhiclcppsimple_includes linedoc::includes) install(TARGETS types_tests DESTINATION test) add_test(NAME types_tests COMMAND types_tests) @@ -15,4 +15,4 @@ install(FILES Sequence.hxx traits.hxx utility.hxx - DESTINATION include/fhiclcpp/types) + DESTINATION include/fhiclcppsimple/types) diff --git a/fhiclcpp/types/CompositeTypesSharedImpl.hxx b/fhiclcppsimple/types/CompositeTypesSharedImpl.hxx similarity index 96% rename from fhiclcpp/types/CompositeTypesSharedImpl.hxx rename to fhiclcppsimple/types/CompositeTypesSharedImpl.hxx index bd212d4..a5edb69 100644 --- a/fhiclcpp/types/CompositeTypesSharedImpl.hxx +++ b/fhiclcppsimple/types/CompositeTypesSharedImpl.hxx @@ -1,21 +1,21 @@ #pragma once -#include "fhiclcpp/types/Atom.hxx" -#include "fhiclcpp/types/Base.hxx" -#include "fhiclcpp/types/ParameterSet.hxx" -#include "fhiclcpp/types/Sequence.hxx" -#include "fhiclcpp/types/exception.hxx" -#include "fhiclcpp/types/traits.hxx" -#include "fhiclcpp/types/utility.hxx" - -#include "fhiclcpp/string_parsers/exception.hxx" -#include "fhiclcpp/string_parsers/from_string.hxx" -#include "fhiclcpp/string_parsers/to_string.hxx" +#include "fhiclcppsimple/types/Atom.hxx" +#include "fhiclcppsimple/types/Base.hxx" +#include "fhiclcppsimple/types/ParameterSet.hxx" +#include "fhiclcppsimple/types/Sequence.hxx" +#include "fhiclcppsimple/types/exception.hxx" +#include "fhiclcppsimple/types/traits.hxx" +#include "fhiclcppsimple/types/utility.hxx" + +#include "fhiclcppsimple/string_parsers/exception.hxx" +#include "fhiclcppsimple/string_parsers/from_string.hxx" +#include "fhiclcppsimple/string_parsers/to_string.hxx" #include #include -namespace fhicl { +namespace fhiclsimple { void Sequence::from(std::string const &str) { if (!str.size()) { @@ -426,4 +426,4 @@ ParameterSet::get_value_recursive(key_t const &key) const { #endif } -} // namespace fhicl +} // namespace fhiclsimple diff --git a/fhiclcpp/types/ParameterSet.hxx b/fhiclcppsimple/types/ParameterSet.hxx similarity index 94% rename from fhiclcpp/types/ParameterSet.hxx rename to fhiclcppsimple/types/ParameterSet.hxx index 95abfbf..f2126f0 100644 --- a/fhiclcpp/types/ParameterSet.hxx +++ b/fhiclcppsimple/types/ParameterSet.hxx @@ -1,13 +1,13 @@ #pragma once -#include "fhiclcpp/types/Atom.hxx" -#include "fhiclcpp/types/Base.hxx" -#include "fhiclcpp/types/exception.hxx" +#include "fhiclcppsimple/types/Atom.hxx" +#include "fhiclcppsimple/types/Base.hxx" +#include "fhiclcppsimple/types/exception.hxx" -#include "fhiclcpp/string_parsers/from_string.hxx" -#include "fhiclcpp/string_parsers/md5.hxx" -#include "fhiclcpp/string_parsers/to_string.hxx" -#include "fhiclcpp/string_parsers/traits.hxx" +#include "fhiclcppsimple/string_parsers/from_string.hxx" +#include "fhiclcppsimple/string_parsers/md5.hxx" +#include "fhiclcppsimple/string_parsers/to_string.hxx" +#include "fhiclcppsimple/string_parsers/traits.hxx" #include #include @@ -22,17 +22,17 @@ typedef doc_range_ doc_range; // These declarations must be here before the first instantation that would use // str2T/T2Str in a given translation unit -namespace fhicl { +namespace fhiclsimple { class ParameterSet; namespace string_parsers { template <> -inline fhicl::ParameterSet str2T(std::string const &); +inline fhiclsimple::ParameterSet str2T(std::string const &); template <> -inline std::string T2Str(fhicl::ParameterSet const &); +inline std::string T2Str(fhiclsimple::ParameterSet const &); } // namespace string_parsers -} // namespace fhicl +} // namespace fhiclsimple -namespace fhicl { +namespace fhiclsimple { enum class fhicl_category; // Forward declarations of functions found in utility.hxx @@ -196,7 +196,7 @@ class ParameterSet : public Base { std::string get_fhicl_category_string(key_t const &key) const { check_key(key, true); - return fhicl::get_fhicl_category_string(get_value_recursive(key)); + return fhiclsimple::get_fhicl_category_string(get_value_recursive(key)); } public: @@ -462,21 +462,21 @@ public: } return string_parsers::str2T(get_value_recursive(key)->to_string()); - }; + } template T get(key_t const &key, T def) const { try { return get(key); - } catch (fhicl::string_parsers::fhicl_cpp_simple_except &e) { // parser fail + } catch (fhiclsimple::string_parsers::fhicl_cpp_simple_except &e) { // parser fail return def; - } catch (fhicl::fhicl_cpp_simple_except &e) { // type fail + } catch (fhiclsimple::fhicl_cpp_simple_except &e) { // type fail return def; } catch (std::exception &e) { throw bizare_error() << "[ERROR]: Caught unexpected exception in ParameterSet::get: " << std::quoted(e.what()); } - }; + } template bool get_if_present(key_t const &key, T &rtn) const { if (!check_key(key)) { @@ -484,9 +484,9 @@ public: } try { rtn = get(key); - } catch (fhicl::string_parsers::fhicl_cpp_simple_except &e) { // parser fail + } catch (fhiclsimple::string_parsers::fhicl_cpp_simple_except &e) { // parser fail return false; - } catch (fhicl::fhicl_cpp_simple_except &e) { // type fail + } catch (fhiclsimple::fhicl_cpp_simple_except &e) { // type fail return false; } catch (std::exception &e) { throw bizare_error() @@ -494,7 +494,7 @@ public: << std::quoted(e.what()); } return true; - }; + } template void put(key_t const &key, T const &value) { if (has_key(key)) { @@ -604,17 +604,17 @@ public: } }; -} // namespace fhicl +} // namespace fhiclsimple -namespace fhicl { +namespace fhiclsimple { namespace string_parsers { template <> -inline fhicl::ParameterSet str2T(std::string const &str) { - return fhicl::ParameterSet(str); +inline fhiclsimple::ParameterSet str2T(std::string const &str) { + return fhiclsimple::ParameterSet(str); } template <> -inline std::string T2Str(fhicl::ParameterSet const &ps) { +inline std::string T2Str(fhiclsimple::ParameterSet const &ps) { return std::string("{") + ps.to_string() + "}"; } } // namespace string_parsers -} // namespace fhicl +} // namespace fhiclsimple diff --git a/fhiclcpp/types/Sequence.hxx b/fhiclcppsimple/types/Sequence.hxx similarity index 96% rename from fhiclcpp/types/Sequence.hxx rename to fhiclcppsimple/types/Sequence.hxx index ef4490f..ba0ca81 100644 --- a/fhiclcpp/types/Sequence.hxx +++ b/fhiclcppsimple/types/Sequence.hxx @@ -1,14 +1,14 @@ #pragma once -#include "fhiclcpp/types/Base.hxx" +#include "fhiclcppsimple/types/Base.hxx" -#include "fhiclcpp/string_parsers/from_string.hxx" -#include "fhiclcpp/string_parsers/traits.hxx" +#include "fhiclcppsimple/string_parsers/from_string.hxx" +#include "fhiclcppsimple/string_parsers/traits.hxx" #include #include -namespace fhicl { +namespace fhiclsimple { class ParameterSet; // forward declaration for functions found in utility.hxx std::shared_ptr deep_copy_value(std::shared_ptr const original); @@ -56,11 +56,11 @@ public: throw; } return string_parsers::str2T(internal_rep[index]->to_string()); - }; + } template typename std::enable_if::value, T>::type as() const { return string_parsers::str2T(to_string()); - }; + } Sequence() : internal_rep() {} Sequence(std::string const &str) : internal_rep() { from(str); } Sequence(Sequence &&other) : internal_rep(std::move(other.internal_rep)) {} @@ -198,4 +198,4 @@ public: } } }; -} // namespace fhicl +} // namespace fhiclsimple diff --git a/fhiclcpp/types/exception.hxx b/fhiclcppsimple/types/exception.hxx similarity index 96% rename from fhiclcpp/types/exception.hxx rename to fhiclcppsimple/types/exception.hxx index 6cb22be..930267a 100644 --- a/fhiclcpp/types/exception.hxx +++ b/fhiclcppsimple/types/exception.hxx @@ -3,7 +3,7 @@ #include #include -namespace fhicl { +namespace fhiclsimple { struct fhicl_cpp_simple_except : public std::exception { std::stringstream msgstrm; @@ -44,4 +44,4 @@ NEW_EXCEPT(bizare_error); #undef NEW_EXCEPT -} // namespace fhicl +} // namespace fhiclsimple diff --git a/fhiclcpp/types/tests.cxx b/fhiclcppsimple/types/tests.cxx similarity index 95% rename from fhiclcpp/types/tests.cxx rename to fhiclcppsimple/types/tests.cxx index 9cab0c3..cec65da 100644 --- a/fhiclcpp/types/tests.cxx +++ b/fhiclcppsimple/types/tests.cxx @@ -1,13 +1,13 @@ #include #include -#include "fhiclcpp/types/Atom.hxx" -#include "fhiclcpp/types/ParameterSet.hxx" -#include "fhiclcpp/types/Sequence.hxx" +#include "fhiclcppsimple/types/Atom.hxx" +#include "fhiclcppsimple/types/ParameterSet.hxx" +#include "fhiclcppsimple/types/Sequence.hxx" -#include "fhiclcpp/types/CompositeTypesSharedImpl.hxx" +#include "fhiclcppsimple/types/CompositeTypesSharedImpl.hxx" -using namespace fhicl; +using namespace fhiclsimple; int main() { { diff --git a/fhiclcpp/types/traits.hxx b/fhiclcppsimple/types/traits.hxx similarity index 84% rename from fhiclcpp/types/traits.hxx rename to fhiclcppsimple/types/traits.hxx index 8eed95a..17ebb96 100644 --- a/fhiclcpp/types/traits.hxx +++ b/fhiclcppsimple/types/traits.hxx @@ -1,12 +1,12 @@ #pragma once -#include "fhiclcpp/types/Atom.hxx" -#include "fhiclcpp/types/ParameterSet.hxx" -#include "fhiclcpp/types/Sequence.hxx" +#include "fhiclcppsimple/types/Atom.hxx" +#include "fhiclcppsimple/types/ParameterSet.hxx" +#include "fhiclcppsimple/types/Sequence.hxx" -#include "fhiclcpp/string_parsers/traits.hxx" +#include "fhiclcppsimple/string_parsers/traits.hxx" -namespace fhicl { +namespace fhiclsimple { #define VARLIST \ Y(kNil, 1) \ @@ -50,23 +50,23 @@ template struct fhicl_type { typename std::conditional::value, Sequence, Atom>::type type; }; -template <> struct fhicl_type { +template <> struct fhicl_type { static fhicl_category category() { return fhicl_category::kTable; } static std::string const category_string() { return "kTable"; } static constexpr bool is_table = true; typedef ParameterSet type; }; -template <> struct fhicl_type { +template <> struct fhicl_type { static fhicl_category category() { return fhicl_category::kAtom; } static std::string const category_string() { return "kAtom"; } static constexpr bool is_table = false; typedef Atom type; }; -template <> struct fhicl_type { +template <> struct fhicl_type { static fhicl_category category() { return fhicl_category::kSequence; } static std::string const category_string() { return "kSequence"; } static constexpr bool is_table = false; typedef Sequence type; }; -} // namespace fhicl +} // namespace fhiclsimple diff --git a/fhiclcpp/types/utility.hxx b/fhiclcppsimple/types/utility.hxx similarity index 90% rename from fhiclcpp/types/utility.hxx rename to fhiclcppsimple/types/utility.hxx index d23fb6e..f689fd1 100644 --- a/fhiclcpp/types/utility.hxx +++ b/fhiclcppsimple/types/utility.hxx @@ -1,15 +1,15 @@ #pragma once -#include "fhiclcpp/types/ParameterSet.hxx" -#include "fhiclcpp/types/Sequence.hxx" -#include "fhiclcpp/types/exception.hxx" -#include "fhiclcpp/types/traits.hxx" +#include "fhiclcppsimple/types/ParameterSet.hxx" +#include "fhiclcppsimple/types/Sequence.hxx" +#include "fhiclcppsimple/types/exception.hxx" +#include "fhiclcppsimple/types/traits.hxx" #include #include #include -namespace fhicl { +namespace fhiclsimple { fhicl_category inline get_fhicl_category(std::shared_ptr const el) { if (!el) { @@ -88,4 +88,4 @@ deep_copy_value(std::shared_ptr const original) { "backtrace to the maintainer."; } -} // namespace fhicl +} // namespace fhiclsimple