From 78f063f37de2906907c4a2978e3a412e4f2d9496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Gu=C3=A9nette?= Date: Sat, 20 Feb 2021 13:04:58 -0500 Subject: [PATCH 001/124] refactor: Drop support for yaml-cpp old API Breaking changes: - Use the new yaml-cpp API, i.e. version 0.5+. - No longer provide sources in the contrib directory. --- CMakeLists.txt | 50 +- contrib/CMakeLists.txt | 5 - contrib/yaml-cpp-pm/CMakeLists.txt | 129 --- .../include/yaml-cpp-pm/aliasmanager.h | 34 - .../yaml-cpp-pm/include/yaml-cpp-pm/anchor.h | 16 - .../yaml-cpp-pm/include/yaml-cpp-pm/binary.h | 66 -- .../include/yaml-cpp-pm/conversion.h | 75 -- contrib/yaml-cpp-pm/include/yaml-cpp-pm/dll.h | 28 - .../include/yaml-cpp-pm/emitfromevents.h | 45 - .../yaml-cpp-pm/include/yaml-cpp-pm/emitter.h | 186 ---- .../include/yaml-cpp-pm/emittermanip.h | 149 --- .../include/yaml-cpp-pm/eventhandler.h | 36 - .../include/yaml-cpp-pm/exceptions.h | 164 ---- .../include/yaml-cpp-pm/iterator.h | 40 - .../yaml-cpp-pm/include/yaml-cpp-pm/ltnode.h | 18 - .../yaml-cpp-pm/include/yaml-cpp-pm/mark.h | 26 - .../yaml-cpp-pm/include/yaml-cpp-pm/node.h | 135 --- .../include/yaml-cpp-pm/nodeimpl.h | 85 -- .../include/yaml-cpp-pm/nodereadimpl.h | 86 -- .../include/yaml-cpp-pm/nodeutil.h | 62 -- .../include/yaml-cpp-pm/noncopyable.h | 25 - .../yaml-cpp-pm/include/yaml-cpp-pm/null.h | 25 - .../yaml-cpp-pm/include/yaml-cpp-pm/ostream.h | 40 - .../yaml-cpp-pm/include/yaml-cpp-pm/parser.h | 51 - .../include/yaml-cpp-pm/stlemitter.h | 51 - .../yaml-cpp-pm/include/yaml-cpp-pm/stlnode.h | 38 - .../yaml-cpp-pm/include/yaml-cpp-pm/traits.h | 57 -- .../yaml-cpp-pm/include/yaml-cpp-pm/yaml.h | 17 - contrib/yaml-cpp-pm/license.txt | 19 - contrib/yaml-cpp-pm/src/aliasmanager.cpp | 29 - contrib/yaml-cpp-pm/src/binary.cpp | 102 -- contrib/yaml-cpp-pm/src/collectionstack.h | 35 - .../yaml-cpp-pm/src/contrib/graphbuilder.cpp | 16 - .../src/contrib/graphbuilderadapter.cpp | 96 -- .../src/contrib/graphbuilderadapter.h | 73 -- contrib/yaml-cpp-pm/src/conversion.cpp | 89 -- contrib/yaml-cpp-pm/src/directives.cpp | 24 - contrib/yaml-cpp-pm/src/directives.h | 29 - contrib/yaml-cpp-pm/src/emitfromevents.cpp | 105 --- contrib/yaml-cpp-pm/src/emitter.cpp | 882 ------------------ contrib/yaml-cpp-pm/src/emitterstate.cpp | 284 ------ contrib/yaml-cpp-pm/src/emitterstate.h | 217 ----- contrib/yaml-cpp-pm/src/emitterutils.cpp | 378 -------- contrib/yaml-cpp-pm/src/emitterutils.h | 32 - contrib/yaml-cpp-pm/src/exp.cpp | 113 --- contrib/yaml-cpp-pm/src/exp.h | 196 ---- contrib/yaml-cpp-pm/src/indentation.h | 38 - contrib/yaml-cpp-pm/src/iterator.cpp | 103 -- contrib/yaml-cpp-pm/src/iterpriv.h | 33 - contrib/yaml-cpp-pm/src/node.cpp | 269 ------ contrib/yaml-cpp-pm/src/nodebuilder.cpp | 145 --- contrib/yaml-cpp-pm/src/nodebuilder.h | 61 -- contrib/yaml-cpp-pm/src/nodeownership.cpp | 31 - contrib/yaml-cpp-pm/src/nodeownership.h | 39 - contrib/yaml-cpp-pm/src/null.cpp | 12 - contrib/yaml-cpp-pm/src/ostream.cpp | 63 -- contrib/yaml-cpp-pm/src/parser.cpp | 152 --- contrib/yaml-cpp-pm/src/ptr_stack.h | 46 - contrib/yaml-cpp-pm/src/ptr_vector.h | 47 - contrib/yaml-cpp-pm/src/regex.cpp | 60 -- contrib/yaml-cpp-pm/src/regex.h | 67 -- contrib/yaml-cpp-pm/src/regeximpl.h | 186 ---- contrib/yaml-cpp-pm/src/scanner.cpp | 387 -------- contrib/yaml-cpp-pm/src/scanner.h | 132 --- contrib/yaml-cpp-pm/src/scanscalar.cpp | 214 ----- contrib/yaml-cpp-pm/src/scanscalar.h | 45 - contrib/yaml-cpp-pm/src/scantag.cpp | 84 -- contrib/yaml-cpp-pm/src/scantag.h | 20 - contrib/yaml-cpp-pm/src/scantoken.cpp | 439 --------- contrib/yaml-cpp-pm/src/setting.h | 105 --- contrib/yaml-cpp-pm/src/simplekey.cpp | 139 --- contrib/yaml-cpp-pm/src/singledocparser.cpp | 381 -------- contrib/yaml-cpp-pm/src/singledocparser.h | 65 -- contrib/yaml-cpp-pm/src/stream.cpp | 448 --------- contrib/yaml-cpp-pm/src/stream.h | 79 -- contrib/yaml-cpp-pm/src/streamcharsource.h | 48 - contrib/yaml-cpp-pm/src/stringsource.h | 47 - contrib/yaml-cpp-pm/src/tag.cpp | 52 -- contrib/yaml-cpp-pm/src/tag.h | 28 - contrib/yaml-cpp-pm/src/token.h | 85 -- contrib/yaml-cpp-pm/util/CMakeLists.txt | 2 - contrib/yaml-cpp-pm/util/api.cpp | 129 --- contrib/yaml-cpp-pm/util/parse.cpp | 65 -- examples/demo_cmake/CMakeLists.txt | 10 +- libpointmatcherConfig.cmake.in | 2 +- pointmatcher/DataPointsFilter.cpp | 15 +- pointmatcher/ICP.cpp | 39 +- pointmatcher/PointMatcher.h | 9 +- pointmatcher/Registrar.cpp | 20 +- pointmatcher/Registrar.h | 21 +- 90 files changed, 55 insertions(+), 8865 deletions(-) delete mode 100644 contrib/yaml-cpp-pm/CMakeLists.txt delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/aliasmanager.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/anchor.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/binary.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/conversion.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/dll.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/emitfromevents.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/emitter.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/emittermanip.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/eventhandler.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/exceptions.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/iterator.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/ltnode.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/mark.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/node.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/nodeimpl.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/nodereadimpl.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/nodeutil.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/noncopyable.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/null.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/ostream.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/parser.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/stlemitter.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/stlnode.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/traits.h delete mode 100644 contrib/yaml-cpp-pm/include/yaml-cpp-pm/yaml.h delete mode 100644 contrib/yaml-cpp-pm/license.txt delete mode 100644 contrib/yaml-cpp-pm/src/aliasmanager.cpp delete mode 100644 contrib/yaml-cpp-pm/src/binary.cpp delete mode 100644 contrib/yaml-cpp-pm/src/collectionstack.h delete mode 100644 contrib/yaml-cpp-pm/src/contrib/graphbuilder.cpp delete mode 100644 contrib/yaml-cpp-pm/src/contrib/graphbuilderadapter.cpp delete mode 100644 contrib/yaml-cpp-pm/src/contrib/graphbuilderadapter.h delete mode 100644 contrib/yaml-cpp-pm/src/conversion.cpp delete mode 100644 contrib/yaml-cpp-pm/src/directives.cpp delete mode 100644 contrib/yaml-cpp-pm/src/directives.h delete mode 100644 contrib/yaml-cpp-pm/src/emitfromevents.cpp delete mode 100644 contrib/yaml-cpp-pm/src/emitter.cpp delete mode 100644 contrib/yaml-cpp-pm/src/emitterstate.cpp delete mode 100644 contrib/yaml-cpp-pm/src/emitterstate.h delete mode 100644 contrib/yaml-cpp-pm/src/emitterutils.cpp delete mode 100644 contrib/yaml-cpp-pm/src/emitterutils.h delete mode 100644 contrib/yaml-cpp-pm/src/exp.cpp delete mode 100644 contrib/yaml-cpp-pm/src/exp.h delete mode 100644 contrib/yaml-cpp-pm/src/indentation.h delete mode 100644 contrib/yaml-cpp-pm/src/iterator.cpp delete mode 100644 contrib/yaml-cpp-pm/src/iterpriv.h delete mode 100644 contrib/yaml-cpp-pm/src/node.cpp delete mode 100644 contrib/yaml-cpp-pm/src/nodebuilder.cpp delete mode 100644 contrib/yaml-cpp-pm/src/nodebuilder.h delete mode 100644 contrib/yaml-cpp-pm/src/nodeownership.cpp delete mode 100644 contrib/yaml-cpp-pm/src/nodeownership.h delete mode 100644 contrib/yaml-cpp-pm/src/null.cpp delete mode 100644 contrib/yaml-cpp-pm/src/ostream.cpp delete mode 100644 contrib/yaml-cpp-pm/src/parser.cpp delete mode 100644 contrib/yaml-cpp-pm/src/ptr_stack.h delete mode 100644 contrib/yaml-cpp-pm/src/ptr_vector.h delete mode 100644 contrib/yaml-cpp-pm/src/regex.cpp delete mode 100644 contrib/yaml-cpp-pm/src/regex.h delete mode 100644 contrib/yaml-cpp-pm/src/regeximpl.h delete mode 100644 contrib/yaml-cpp-pm/src/scanner.cpp delete mode 100644 contrib/yaml-cpp-pm/src/scanner.h delete mode 100644 contrib/yaml-cpp-pm/src/scanscalar.cpp delete mode 100644 contrib/yaml-cpp-pm/src/scanscalar.h delete mode 100644 contrib/yaml-cpp-pm/src/scantag.cpp delete mode 100644 contrib/yaml-cpp-pm/src/scantag.h delete mode 100644 contrib/yaml-cpp-pm/src/scantoken.cpp delete mode 100644 contrib/yaml-cpp-pm/src/setting.h delete mode 100644 contrib/yaml-cpp-pm/src/simplekey.cpp delete mode 100644 contrib/yaml-cpp-pm/src/singledocparser.cpp delete mode 100644 contrib/yaml-cpp-pm/src/singledocparser.h delete mode 100644 contrib/yaml-cpp-pm/src/stream.cpp delete mode 100644 contrib/yaml-cpp-pm/src/stream.h delete mode 100644 contrib/yaml-cpp-pm/src/streamcharsource.h delete mode 100644 contrib/yaml-cpp-pm/src/stringsource.h delete mode 100644 contrib/yaml-cpp-pm/src/tag.cpp delete mode 100644 contrib/yaml-cpp-pm/src/tag.h delete mode 100644 contrib/yaml-cpp-pm/src/token.h delete mode 100644 contrib/yaml-cpp-pm/util/CMakeLists.txt delete mode 100644 contrib/yaml-cpp-pm/util/api.cpp delete mode 100644 contrib/yaml-cpp-pm/util/parse.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d78484a8..398faeb4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,7 +108,7 @@ endforeach() # initially set(EXTERNAL_LIBS "") -# compile local version of gtest and yaml-cpp +# compile local version of gtest add_subdirectory(contrib) #--------------------------- @@ -206,41 +206,19 @@ endif() #-------------------- -# DEPENDENCY: yaml-cpp (local or system, optional) +# DEPENDENCY: yaml-cpp #-------------------- -option(USE_SYSTEM_YAML_CPP "Use system version of yaml-cpp rather than one packaged with libpointmatcher" FALSE) - -if(USE_SYSTEM_YAML_CPP) - message(STATUS "Looking for yaml-cpp on system") - find_path(yaml-cpp_INCLUDE_DIRS yaml-cpp/yaml.h - /usr/local/include - ) - find_library(yaml-cpp_LIBRARIES yaml-cpp PATHS - /usr/local/lib - ) - if(yaml-cpp_INCLUDE_DIRS AND yaml-cpp_LIBRARIES) - set(yamlcpp_FOUND) - message("-- yaml-cpp found, text-based configuration enabled") - else() - message("-- yaml-cpp not found, text-based configuration and related applications disabled") - endif() -else() - include_directories(contrib/yaml-cpp-pm/include) -#note: this is not working.... - #get_property(yaml-cpp-pm_INCLUDE TARGET yaml-cpp-pm PROPERTY INCLUDE_DIRECTORIES) - #include_directories(${yaml-cpp-pm_INCLUDE}) +message(STATUS "Looking for yaml-cpp on system...") - list(APPEND EXTERNAL_LIBS $) - list(APPEND EXTRA_DEPS yaml-cpp-pm) - set(yamlcpp_FOUND) +find_package(yaml-cpp QUIET) - get_property(yaml-cpp-pm_VERSION TARGET yaml-cpp-pm PROPERTY VERSION) - message("-- using built-in yaml-cpp, version ${yaml-cpp-pm_VERSION}") - message(" -- text-based configuration enabled") +if(yaml-cpp_FOUND) + message(STATUS "yaml-cpp version ${yaml-cpp_VERSION} found, text-based configuration enabled") +else() + message(STATUS "yaml-cpp not found, text-based configuration and related applications disabled") endif() - #-------------------- # DEPENDENCY: rt (optional) #-------------------- @@ -382,13 +360,9 @@ if (NOT MSVC) target_compile_options(pointmatcher PRIVATE -Wall) endif() -if(yaml-cpp_INCLUDE_DIRS AND yaml-cpp_LIBRARIES) - target_link_libraries(pointmatcher PRIVATE ${yaml-cpp_LIBRARIES}) - target_include_directories(pointmatcher PRIVATE ${yaml-cpp_INCLUDE_DIRS}) -else() # embedded version: - # This could be enabled if yaml-cpp-pm was in the "export set" - #target_link_libraries(pointmatcher PRIVATE yaml-cpp-pm) - # For now, let's add yaml-cpp-pm output to EXTERNAL_LIBS +if(yaml-cpp_FOUND) + target_link_libraries(pointmatcher PRIVATE ${YAML_CPP_LIBRARIES}) + target_include_directories(pointmatcher PRIVATE ${YAML_CPP_INCLUDE_DIR}) endif() target_link_libraries(pointmatcher PUBLIC ${Boost_LIBRARIES}) @@ -527,7 +501,7 @@ set(CONF_INCLUDE_DIRS ${INSTALL_INCLUDE_DIR} ${CONF_INCLUDE_DIRS} ) #FIXME: this will only be applied to installed files. Confirm that we want that. # gather all the includes but remove ones in the source tree # because we added an include for the local yaml-cpp-pm we should also remove it -list(REMOVE_ITEM CONF_INCLUDE_DIRS ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/contrib/yaml-cpp-pm/include) +list(REMOVE_ITEM CONF_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}) # We put the generated file for installation in a different repository (i.e., ./CMakeFiles/) configure_file(libpointmatcherConfig.cmake.in diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index cc8b13684..b6bb6b1c2 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -3,8 +3,3 @@ # GTest include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_library(gtest gtest/gtest-all.cc) - -# Wrapped yaml-cpp -if(NOT USE_SYSTEM_YAML_CPP) -add_subdirectory(yaml-cpp-pm) -endif() diff --git a/contrib/yaml-cpp-pm/CMakeLists.txt b/contrib/yaml-cpp-pm/CMakeLists.txt deleted file mode 100644 index 268985664..000000000 --- a/contrib/yaml-cpp-pm/CMakeLists.txt +++ /dev/null @@ -1,129 +0,0 @@ -include(CheckCXXCompilerFlag) - -set(YAML_CPP_VERSION_MAJOR "0") -set(YAML_CPP_VERSION_MINOR "3") -set(YAML_CPP_VERSION_PATCH "0") -set(YAML_CPP_VERSION "${YAML_CPP_VERSION_MAJOR}.${YAML_CPP_VERSION_MINOR}.${YAML_CPP_VERSION_PATCH}") - -enable_testing() - - -### -### Project options -### -## Project stuff -set(YAML_CPP_BUILD_TOOLS OFF) -set(YAML_CPP_BUILD_CONTRIB OFF) - -## Build options -# --> General -# see http://www.cmake.org/cmake/help/cmake2.6docs.html#variable:BUILD_SHARED_LIBS -# http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_library -set(BUILD_SHARED_LIBS OFF) - -# --> Apple -option(APPLE_UNIVERSAL_BIN "Apple: Build universal binary" OFF) - - -### -### Sources, headers, directories and libs -### -set(header_directory "include/yaml-cpp-pm/") - -file(GLOB sources "src/[a-zA-Z]*.cpp") -file(GLOB public_headers "include/yaml-cpp-pm/[a-zA-Z]*.h") -file(GLOB private_headers "src/[a-zA-Z]*.h") - -add_definitions(-DYAML_CPP_NO_CONTRIB) - -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) -### -### General compilation settings -### -if(BUILD_SHARED_LIBS) - set(LABEL_SUFFIX "shared") -else() - set(LABEL_SUFFIX "static") -endif() - -if(APPLE) - if(APPLE_UNIVERSAL_BIN) - set(CMAKE_OSX_ARCHITECTURES ppc;i386) - endif() -endif() - -if(WIN32) - if(BUILD_SHARED_LIBS) - add_definitions(-D${PROJECT_NAME}_DLL) # use or build Windows DLL - endif() - if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "C:/") - endif() -endif() - -# GCC / Clang specialities -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - ### General stuff - if(WIN32) - set(CMAKE_SHARED_LIBRARY_PREFIX "") # DLLs do not have a "lib" prefix - set(CMAKE_IMPORT_LIBRARY_PREFIX "") # same for DLL import libs - set(CMAKE_LINK_DEF_FILE_FLAG "") # CMake workaround (2.8.3) - endif() - - ### Project stuff - if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) - endif() - # - set(CMAKE_CXX_FLAGS_RELEASE "-O2") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") - set(CMAKE_CXX_FLAGS_DEBUG "-g") - set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os") - # - set(GCC_EXTRA_OPTIONS "") - # - set(FLAG_TESTED "-Wextra") - check_cxx_compiler_flag(${FLAG_TESTED} FLAG_WEXTRA) - if(FLAG_WEXTRA) - set(GCC_EXTRA_OPTIONS "${GCC_EXTRA_OPTIONS} ${FLAG_TESTED}") - endif() - # - set(CMAKE_CXX_FLAGS "-Wall ${GCC_EXTRA_OPTIONS} -fPIC -pedantic -Wno-long-long ${CMAKE_CXX_FLAGS}") - # - add_custom_target(debuggable $(MAKE) clean - COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} - COMMENT "Adjusting settings for debug compilation" - VERBATIM) - add_custom_target(releasable $(MAKE) clean - COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} - COMMENT "Adjusting settings for release compilation" - VERBATIM) -endif() - - -### -### Library -### -add_library(yaml-cpp-pm - ${sources} - ${public_headers} - ${private_headers} - ${contrib_sources} - ${contrib_public_headers} - ${contrib_private_headers} -) - -set_target_properties(yaml-cpp-pm PROPERTIES - VERSION "${YAML_CPP_VERSION}" - SOVERSION "${YAML_CPP_VERSION_MAJOR}.${YAML_CPP_VERSION_MINOR}" - PROJECT_LABEL "yaml-cpp ${LABEL_SUFFIX}" -) - -install(TARGETS yaml-cpp-pm EXPORT yaml-cpp-pm-targets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) - -install(EXPORT yaml-cpp-pm-targets DESTINATION share/${PROJECT_NAME}/cmake) diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/aliasmanager.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/aliasmanager.h deleted file mode 100644 index 3c703c23e..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/aliasmanager.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef ALIASMANAGER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define ALIASMANAGER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp-pm/anchor.h" -#include - -namespace YAML_PM -{ - class Node; - - class AliasManager - { - public: - AliasManager(); - - void RegisterReference(const Node& node); - anchor_t LookupAnchor(const Node& node) const; - - private: - anchor_t _CreateNewAnchor(); - - private: - typedef std::map AnchorByIdentity; - AnchorByIdentity m_anchorByIdentity; - - anchor_t m_curAnchor; - }; -} - -#endif // ALIASMANAGER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/anchor.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/anchor.h deleted file mode 100644 index 75ac33bc6..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/anchor.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include - -namespace YAML_PM -{ - typedef std::size_t anchor_t; - const anchor_t NullAnchor = 0; -} - -#endif // ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/binary.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/binary.h deleted file mode 100644 index 5863e20c3..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/binary.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include - -namespace YAML_PM -{ - class Node; - - std::string EncodeBase64(const unsigned char *data, std::size_t size); - std::vector DecodeBase64(const std::string& input); - - class Binary { - public: - Binary(): m_unownedData(0), m_unownedSize(0) {} - Binary(const unsigned char *data, std::size_t size): m_unownedData(data), m_unownedSize(size) {} - - bool owned() const { return !m_unownedData; } - std::size_t size() const { return owned() ? m_data.size() : m_unownedSize; } - const unsigned char *data() const { return owned() ? &m_data[0] : m_unownedData; } - - void swap(std::vector& rhs) { - if(m_unownedData) { - m_data.swap(rhs); - rhs.clear(); - rhs.resize(m_unownedSize); - std::copy(m_unownedData, m_unownedData + m_unownedSize, &rhs[0]); - m_unownedData = 0; - m_unownedSize = 0; - } else { - m_data.swap(rhs); - } - } - - bool operator == (const Binary& rhs) const { - const std::size_t s = size(); - if(s != rhs.size()) - return false; - const unsigned char *d1 = data(); - const unsigned char *d2 = rhs.data(); - for(std::size_t i=0;i m_data; - const unsigned char *m_unownedData; - std::size_t m_unownedSize; - }; - - void operator >> (const Node& node, Binary& binary); -} - -#endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/conversion.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/conversion.h deleted file mode 100644 index 9ed83cb00..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/conversion.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp-pm/null.h" -#include "yaml-cpp-pm/traits.h" -#include -#include -#include - -namespace YAML_PM -{ - // traits for conversion - - template - struct is_scalar_convertible { enum { value = is_numeric::value }; }; - - template<> struct is_scalar_convertible { enum { value = true }; }; - template<> struct is_scalar_convertible { enum { value = true }; }; - template<> struct is_scalar_convertible<_Null> { enum { value = true }; }; - - // actual conversion - - inline bool Convert(const std::string& input, std::string& output) { - output = input; - return true; - } - - YAML_CPP_API bool Convert(const std::string& input, bool& output); - YAML_CPP_API bool Convert(const std::string& input, _Null& output); - - inline bool IsInfinity(const std::string& input) { - return input == ".inf" || input == ".Inf" || input == ".INF" || input == "+.inf" || input == "+.Inf" || input == "+.INF"; - } - - inline bool IsNegativeInfinity(const std::string& input) { - return input == "-.inf" || input == "-.Inf" || input == "-.INF"; - } - - inline bool IsNaN(const std::string& input) { - return input == ".nan" || input == ".NaN" || input == ".NAN"; - } - - - template - inline bool Convert(const std::string& input, T& output, typename enable_if >::type * = 0) { - std::stringstream stream(input); - stream.unsetf(std::ios::dec); - if((stream >> output) && (stream >> std::ws).eof()) - return true; - - if(std::numeric_limits::has_infinity) { - if(IsInfinity(input)) { - output = std::numeric_limits::infinity(); - return true; - } else if(IsNegativeInfinity(input)) { - output = -std::numeric_limits::infinity(); - return true; - } - } - - if(std::numeric_limits::has_quiet_NaN && IsNaN(input)) { - output = std::numeric_limits::quiet_NaN(); - return true; - } - - return false; - } -} - -#endif // CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/dll.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/dll.h deleted file mode 100644 index 10c26c959..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/dll.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -// The following ifdef block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the yaml_cpp_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// YAML_CPP_API functions as being imported from a DLL, whereas this DLL sees symbols -// defined with this macro as being exported. -#undef YAML_CPP_API - -#ifdef YAML_CPP_DLL // Using or Building YAML-CPP DLL (definition defined manually) - #ifdef yaml_cpp_EXPORTS // Building YAML-CPP DLL (definition created by CMake or defined manually) - // #pragma message( "Defining YAML_CPP_API for DLL export" ) - #define YAML_CPP_API __declspec(dllexport) - #else // yaml_cpp_EXPORTS - // #pragma message( "Defining YAML_CPP_API for DLL import" ) - #define YAML_CPP_API __declspec(dllimport) - #endif // yaml_cpp_EXPORTS -#else //YAML_CPP_DLL -#define YAML_CPP_API -#endif // YAML_CPP_DLL - -#endif // DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/emitfromevents.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/emitfromevents.h deleted file mode 100644 index 8793674c6..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/emitfromevents.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp-pm/eventhandler.h" -#include - -namespace YAML_PM -{ - class Emitter; - - class EmitFromEvents: public EventHandler - { - public: - EmitFromEvents(Emitter& emitter); - - virtual void OnDocumentStart(const Mark& mark); - virtual void OnDocumentEnd(); - - virtual void OnNull(const Mark& mark, anchor_t anchor); - virtual void OnAlias(const Mark& mark, anchor_t anchor); - virtual void OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value); - - virtual void OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor); - virtual void OnSequenceEnd(); - - virtual void OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor); - virtual void OnMapEnd(); - - private: - void BeginNode(); - void EmitProps(const std::string& tag, anchor_t anchor); - - private: - Emitter& m_emitter; - - struct State { enum value { WaitingForSequenceEntry, WaitingForKey, WaitingForValue }; }; - std::stack m_stateStack; - }; -} - -#endif // EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/emitter.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/emitter.h deleted file mode 100644 index f0c1d85e4..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/emitter.h +++ /dev/null @@ -1,186 +0,0 @@ -#ifndef EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp-pm/dll.h" -#include "yaml-cpp-pm/binary.h" -#include "yaml-cpp-pm/emittermanip.h" -#include "yaml-cpp-pm/ostream.h" -#include "yaml-cpp-pm/noncopyable.h" -#include "yaml-cpp-pm/null.h" -#include -#include -#include - -namespace YAML_PM -{ - class EmitterState; - - class YAML_CPP_API Emitter: private noncopyable - { - public: - Emitter(); - ~Emitter(); - - // output - const char *c_str() const; - unsigned size() const; - - // state checking - bool good() const; - const std::string GetLastError() const; - - // global setters - bool SetOutputCharset(EMITTER_MANIP value); - bool SetStringFormat(EMITTER_MANIP value); - bool SetBoolFormat(EMITTER_MANIP value); - bool SetIntBase(EMITTER_MANIP value); - bool SetSeqFormat(EMITTER_MANIP value); - bool SetMapFormat(EMITTER_MANIP value); - bool SetIndent(unsigned n); - bool SetPreCommentIndent(unsigned n); - bool SetPostCommentIndent(unsigned n); - bool SetFloatPrecision(unsigned n); - bool SetDoublePrecision(unsigned n); - - // local setters - Emitter& SetLocalValue(EMITTER_MANIP value); - Emitter& SetLocalIndent(const _Indent& indent); - Emitter& SetLocalPrecision(const _Precision& precision); - - // overloads of write - Emitter& Write(const std::string& str); - Emitter& Write(bool b); - Emitter& Write(char ch); - Emitter& Write(const _Alias& alias); - Emitter& Write(const _Anchor& anchor); - Emitter& Write(const _Tag& tag); - Emitter& Write(const _Comment& comment); - Emitter& Write(const _Null& null); - Emitter& Write(const Binary& binary); - - template - Emitter& WriteIntegralType(T value); - - template - Emitter& WriteStreamable(T value); - - private: - void PreWriteIntegralType(std::stringstream& str); - void PreWriteStreamable(std::stringstream& str); - void PostWriteIntegralType(const std::stringstream& str); - void PostWriteStreamable(const std::stringstream& str); - - template void SetStreamablePrecision(std::stringstream&) {} - unsigned GetFloatPrecision() const; - unsigned GetDoublePrecision() const; - - private: - void PreAtomicWrite(); - bool GotoNextPreAtomicState(); - void PostAtomicWrite(); - void EmitSeparationIfNecessary(); - - void EmitBeginDoc(); - void EmitEndDoc(); - void EmitBeginSeq(); - void EmitEndSeq(); - void EmitBeginMap(); - void EmitEndMap(); - void EmitKey(); - void EmitValue(); - void EmitNewline(); - void EmitKindTag(); - void EmitTag(bool verbatim, const _Tag& tag); - - const char *ComputeFullBoolName(bool b) const; - bool CanEmitNewline() const; - - private: - ostream m_stream; - std::auto_ptr m_pState; - }; - - template - inline Emitter& Emitter::WriteIntegralType(T value) - { - if(!good()) - return *this; - - std::stringstream str; - PreWriteIntegralType(str); - str << value; - PostWriteIntegralType(str); - return *this; - } - - template - inline Emitter& Emitter::WriteStreamable(T value) - { - if(!good()) - return *this; - - std::stringstream str; - PreWriteStreamable(str); - SetStreamablePrecision(str); - str << value; - PostWriteStreamable(str); - return *this; - } - - template<> - inline void Emitter::SetStreamablePrecision(std::stringstream& str) - { - str.precision(GetFloatPrecision()); - } - - template<> - inline void Emitter::SetStreamablePrecision(std::stringstream& str) - { - str.precision(GetDoublePrecision()); - } - - // overloads of insertion - inline Emitter& operator << (Emitter& emitter, const std::string& v) { return emitter.Write(v); } - inline Emitter& operator << (Emitter& emitter, bool v) { return emitter.Write(v); } - inline Emitter& operator << (Emitter& emitter, char v) { return emitter.Write(v); } - inline Emitter& operator << (Emitter& emitter, unsigned char v) { return emitter.Write(static_cast(v)); } - inline Emitter& operator << (Emitter& emitter, const _Alias& v) { return emitter.Write(v); } - inline Emitter& operator << (Emitter& emitter, const _Anchor& v) { return emitter.Write(v); } - inline Emitter& operator << (Emitter& emitter, const _Tag& v) { return emitter.Write(v); } - inline Emitter& operator << (Emitter& emitter, const _Comment& v) { return emitter.Write(v); } - inline Emitter& operator << (Emitter& emitter, const _Null& v) { return emitter.Write(v); } - inline Emitter& operator << (Emitter& emitter, const Binary& b) { return emitter.Write(b); } - - inline Emitter& operator << (Emitter& emitter, const char *v) { return emitter.Write(std::string(v)); } - - inline Emitter& operator << (Emitter& emitter, int v) { return emitter.WriteIntegralType(v); } - inline Emitter& operator << (Emitter& emitter, unsigned int v) { return emitter.WriteIntegralType(v); } - inline Emitter& operator << (Emitter& emitter, short v) { return emitter.WriteIntegralType(v); } - inline Emitter& operator << (Emitter& emitter, unsigned short v) { return emitter.WriteIntegralType(v); } - inline Emitter& operator << (Emitter& emitter, long v) { return emitter.WriteIntegralType(v); } - inline Emitter& operator << (Emitter& emitter, unsigned long v) { return emitter.WriteIntegralType(v); } - inline Emitter& operator << (Emitter& emitter, long long v) { return emitter.WriteIntegralType(v); } - inline Emitter& operator << (Emitter& emitter, unsigned long long v) { return emitter.WriteIntegralType(v); } - - inline Emitter& operator << (Emitter& emitter, float v) { return emitter.WriteStreamable(v); } - inline Emitter& operator << (Emitter& emitter, double v) { return emitter.WriteStreamable(v); } - - inline Emitter& operator << (Emitter& emitter, EMITTER_MANIP value) { - return emitter.SetLocalValue(value); - } - - inline Emitter& operator << (Emitter& emitter, _Indent indent) { - return emitter.SetLocalIndent(indent); - } - - inline Emitter& operator << (Emitter& emitter, _Precision precision) { - return emitter.SetLocalPrecision(precision); - } -} - -#endif // EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/emittermanip.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/emittermanip.h deleted file mode 100644 index 62a23909e..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/emittermanip.h +++ /dev/null @@ -1,149 +0,0 @@ -#ifndef EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include - -namespace YAML_PM -{ - enum EMITTER_MANIP { - // general manipulators - Auto, - TagByKind, - Newline, - - // output character set - EmitNonAscii, - EscapeNonAscii, - - // string manipulators - // Auto, // duplicate - SingleQuoted, - DoubleQuoted, - Literal, - - // bool manipulators - YesNoBool, // yes, no - TrueFalseBool, // true, false - OnOffBool, // on, off - UpperCase, // TRUE, N - LowerCase, // f, yes - CamelCase, // No, Off - LongBool, // yes, On - ShortBool, // y, t - - // int manipulators - Dec, - Hex, - Oct, - - // document manipulators - BeginDoc, - EndDoc, - - // sequence manipulators - BeginSeq, - EndSeq, - Flow, - Block, - - // map manipulators - BeginMap, - EndMap, - Key, - Value, - // Flow, // duplicate - // Block, // duplicate - // Auto, // duplicate - LongKey - }; - - struct _Indent { - _Indent(int value_): value(value_) {} - int value; - }; - - inline _Indent Indent(int value) { - return _Indent(value); - } - - struct _Alias { - _Alias(const std::string& content_): content(content_) {} - std::string content; - }; - - inline _Alias Alias(const std::string content) { - return _Alias(content); - } - - struct _Anchor { - _Anchor(const std::string& content_): content(content_) {} - std::string content; - }; - - inline _Anchor Anchor(const std::string content) { - return _Anchor(content); - } - - struct _Tag { - struct Type { enum value { Verbatim, PrimaryHandle, NamedHandle }; }; - - explicit _Tag(const std::string& prefix_, const std::string& content_, Type::value type_) - : prefix(prefix_), content(content_), type(type_) - { - } - std::string prefix; - std::string content; - Type::value type; - }; - - inline _Tag VerbatimTag(const std::string content) { - return _Tag("", content, _Tag::Type::Verbatim); - } - - inline _Tag LocalTag(const std::string content) { - return _Tag("", content, _Tag::Type::PrimaryHandle); - } - - inline _Tag LocalTag(const std::string& prefix, const std::string content) { - return _Tag(prefix, content, _Tag::Type::NamedHandle); - } - - inline _Tag SecondaryTag(const std::string content) { - return _Tag("", content, _Tag::Type::NamedHandle); - } - - struct _Comment { - _Comment(const std::string& content_): content(content_) {} - std::string content; - }; - - inline _Comment Comment(const std::string content) { - return _Comment(content); - } - - struct _Precision { - _Precision(int floatPrecision_, int doublePrecision_): floatPrecision(floatPrecision_), doublePrecision(doublePrecision_) {} - - int floatPrecision; - int doublePrecision; - }; - - inline _Precision FloatPrecision(int n) { - return _Precision(n, -1); - } - - inline _Precision DoublePrecision(int n) { - return _Precision(-1, n); - } - - inline _Precision Precision(int n) { - return _Precision(n, n); - } -} - -#endif // EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/eventhandler.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/eventhandler.h deleted file mode 100644 index 59ec03f5f..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/eventhandler.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp-pm/anchor.h" -#include - -namespace YAML_PM -{ - struct Mark; - - class EventHandler - { - public: - virtual ~EventHandler() {} - - virtual void OnDocumentStart(const Mark& mark) = 0; - virtual void OnDocumentEnd() = 0; - - virtual void OnNull(const Mark& mark, anchor_t anchor) = 0; - virtual void OnAlias(const Mark& mark, anchor_t anchor) = 0; - virtual void OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value) = 0; - - virtual void OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor) = 0; - virtual void OnSequenceEnd() = 0; - - virtual void OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor) = 0; - virtual void OnMapEnd() = 0; - }; -} - -#endif // EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/exceptions.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/exceptions.h deleted file mode 100644 index 1cd080a69..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/exceptions.h +++ /dev/null @@ -1,164 +0,0 @@ -#ifndef EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp-pm/mark.h" -#include "yaml-cpp-pm/traits.h" -#include -#include -#include - -namespace YAML_PM -{ - // error messages - namespace ErrorMsg - { - const char * const YAML_DIRECTIVE_ARGS = "YAML directives must have exactly one argument"; - const char * const YAML_VERSION = "bad YAML version: "; - const char * const YAML_MAJOR_VERSION = "YAML major version too large"; - const char * const REPEATED_YAML_DIRECTIVE= "repeated YAML directive"; - const char * const TAG_DIRECTIVE_ARGS = "TAG directives must have exactly two arguments"; - const char * const REPEATED_TAG_DIRECTIVE = "repeated TAG directive"; - const char * const CHAR_IN_TAG_HANDLE = "illegal character found while scanning tag handle"; - const char * const TAG_WITH_NO_SUFFIX = "tag handle with no suffix"; - const char * const END_OF_VERBATIM_TAG = "end of verbatim tag not found"; - const char * const END_OF_MAP = "end of map not found"; - const char * const END_OF_MAP_FLOW = "end of map flow not found"; - const char * const END_OF_SEQ = "end of sequence not found"; - const char * const END_OF_SEQ_FLOW = "end of sequence flow not found"; - const char * const MULTIPLE_TAGS = "cannot assign multiple tags to the same node"; - const char * const MULTIPLE_ANCHORS = "cannot assign multiple anchors to the same node"; - const char * const MULTIPLE_ALIASES = "cannot assign multiple aliases to the same node"; - const char * const ALIAS_CONTENT = "aliases can't have any content, *including* tags"; - const char * const INVALID_HEX = "bad character found while scanning hex number"; - const char * const INVALID_UNICODE = "invalid unicode: "; - const char * const INVALID_ESCAPE = "unknown escape character: "; - const char * const UNKNOWN_TOKEN = "unknown token"; - const char * const DOC_IN_SCALAR = "illegal document indicator in scalar"; - const char * const EOF_IN_SCALAR = "illegal EOF in scalar"; - const char * const CHAR_IN_SCALAR = "illegal character in scalar"; - const char * const TAB_IN_INDENTATION = "illegal tab when looking for indentation"; - const char * const FLOW_END = "illegal flow end"; - const char * const BLOCK_ENTRY = "illegal block entry"; - const char * const MAP_KEY = "illegal map key"; - const char * const MAP_VALUE = "illegal map value"; - const char * const ALIAS_NOT_FOUND = "alias not found after *"; - const char * const ANCHOR_NOT_FOUND = "anchor not found after &"; - const char * const CHAR_IN_ALIAS = "illegal character found while scanning alias"; - const char * const CHAR_IN_ANCHOR = "illegal character found while scanning anchor"; - const char * const ZERO_INDENT_IN_BLOCK = "cannot set zero indentation for a block scalar"; - const char * const CHAR_IN_BLOCK = "unexpected character in block scalar"; - const char * const AMBIGUOUS_ANCHOR = "cannot assign the same alias to multiple nodes"; - const char * const UNKNOWN_ANCHOR = "the referenced anchor is not defined"; - - const char * const INVALID_SCALAR = "invalid scalar"; - const char * const KEY_NOT_FOUND = "key not found"; - const char * const BAD_DEREFERENCE = "bad dereference"; - - const char * const UNMATCHED_GROUP_TAG = "unmatched group tag"; - const char * const UNEXPECTED_END_SEQ = "unexpected end sequence token"; - const char * const UNEXPECTED_END_MAP = "unexpected end map token"; - const char * const SINGLE_QUOTED_CHAR = "invalid character in single-quoted string"; - const char * const INVALID_ANCHOR = "invalid anchor"; - const char * const INVALID_ALIAS = "invalid alias"; - const char * const INVALID_TAG = "invalid tag"; - const char * const EXPECTED_KEY_TOKEN = "expected key token"; - const char * const EXPECTED_VALUE_TOKEN = "expected value token"; - const char * const UNEXPECTED_KEY_TOKEN = "unexpected key token"; - const char * const UNEXPECTED_VALUE_TOKEN = "unexpected value token"; - - template - inline const std::string KEY_NOT_FOUND_WITH_KEY(const T&, typename disable_if >::type * = 0) { - return KEY_NOT_FOUND; - } - - inline const std::string KEY_NOT_FOUND_WITH_KEY(const std::string& key) { - std::stringstream stream; - stream << KEY_NOT_FOUND << ": " << key; - return stream.str(); - } - - template - inline const std::string KEY_NOT_FOUND_WITH_KEY(const T& key, typename enable_if >::type * = 0) { - std::stringstream stream; - stream << KEY_NOT_FOUND << ": " << key; - return stream.str(); - } - } - - class Exception: public std::runtime_error { - public: - Exception(const Mark& mark_, const std::string& msg_) - : std::runtime_error(build_what(mark_, msg_)), mark(mark_), msg(msg_) {} - virtual ~Exception() throw() {} - - Mark mark; - std::string msg; - - private: - static const std::string build_what(const Mark& mark, const std::string& msg) { - std::stringstream output; - output << "yaml-cpp: error at line " << mark.line+1 << ", column " << mark.column+1 << ": " << msg; - return output.str(); - } - }; - - class ParserException: public Exception { - public: - ParserException(const Mark& mark_, const std::string& msg_) - : Exception(mark_, msg_) {} - }; - - class RepresentationException: public Exception { - public: - RepresentationException(const Mark& mark_, const std::string& msg_) - : Exception(mark_, msg_) {} - }; - - // representation exceptions - class InvalidScalar: public RepresentationException { - public: - InvalidScalar(const Mark& mark_) - : RepresentationException(mark_, ErrorMsg::INVALID_SCALAR) {} - }; - - class KeyNotFound: public RepresentationException { - public: - template - KeyNotFound(const Mark& mark_, const T& key_) - : RepresentationException(mark_, ErrorMsg::KEY_NOT_FOUND_WITH_KEY(key_)) {} - }; - - template - class TypedKeyNotFound: public KeyNotFound { - public: - TypedKeyNotFound(const Mark& mark_, const T& key_) - : KeyNotFound(mark_, key_), key(key_) {} - virtual ~TypedKeyNotFound() throw() {} - - T key; - }; - - template - inline TypedKeyNotFound MakeTypedKeyNotFound(const Mark& mark, const T& key) { - return TypedKeyNotFound (mark, key); - } - - class BadDereference: public RepresentationException { - public: - BadDereference() - : RepresentationException(Mark::null(), ErrorMsg::BAD_DEREFERENCE) {} - }; - - class EmitterException: public Exception { - public: - EmitterException(const std::string& msg_) - : Exception(Mark::null(), msg_) {} - }; -} - -#endif // EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/iterator.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/iterator.h deleted file mode 100644 index 33d34dc52..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/iterator.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp-pm/dll.h" -#include - -namespace YAML_PM -{ - class Node; - struct IterPriv; - - class YAML_CPP_API Iterator - { - public: - Iterator(); - Iterator(std::auto_ptr pData); - Iterator(const Iterator& rhs); - ~Iterator(); - - Iterator& operator = (const Iterator& rhs); - Iterator& operator ++ (); - Iterator operator ++ (int); - const Node& operator * () const; - const Node *operator -> () const; - const Node& first() const; - const Node& second() const; - - friend YAML_CPP_API bool operator == (const Iterator& it, const Iterator& jt); - friend YAML_CPP_API bool operator != (const Iterator& it, const Iterator& jt); - - private: - std::auto_ptr m_pData; - }; -} - -#endif // ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/ltnode.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/ltnode.h deleted file mode 100644 index 6aeb7f281..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/ltnode.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef LTNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define LTNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -namespace YAML_PM -{ - class Node; - - struct ltnode { - bool operator()(const Node *pNode1, const Node *pNode2) const; - }; -} - -#endif // LTNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/mark.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/mark.h deleted file mode 100644 index 73b97a3a2..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/mark.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp-pm/dll.h" - -namespace YAML_PM -{ - struct YAML_CPP_API Mark { - Mark(): pos(0), line(0), column(0) {} - - static const Mark null() { return Mark(-1, -1, -1); } - - int pos; - int line, column; - - private: - Mark(int pos_, int line_, int column_): pos(pos_), line(line_), column(column_) {} - }; -} - -#endif // MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/node.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/node.h deleted file mode 100644 index abe6ec347..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/node.h +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp-pm/dll.h" -#include "yaml-cpp-pm/exceptions.h" -#include "yaml-cpp-pm/mark.h" -#include "yaml-cpp-pm/noncopyable.h" -#include "yaml-cpp-pm/conversion.h" -#include "yaml-cpp-pm/iterator.h" -#include "yaml-cpp-pm/ltnode.h" -#include -#include -#include -#include -#include - -namespace YAML_PM -{ - class AliasManager; - class Content; - class NodeOwnership; - class Scanner; - class Emitter; - class EventHandler; - - struct NodeType { enum value { Null, Scalar, Sequence, Map }; }; - - class YAML_CPP_API Node: private noncopyable - { - public: - friend class NodeOwnership; - friend class NodeBuilder; - - Node(); - ~Node(); - - void Clear(); - std::auto_ptr Clone() const; - void EmitEvents(EventHandler& eventHandler) const; - void EmitEvents(AliasManager& am, EventHandler& eventHandler) const; - - NodeType::value Type() const { return m_type; } - bool IsAliased() const; - - // file location of start of this node - const Mark GetMark() const { return m_mark; } - - // accessors - Iterator begin() const; - Iterator end() const; - std::size_t size() const; - - // extraction of scalars - bool GetScalar(std::string& s) const; - - // we can specialize this for other values - template - bool Read(T& value) const; - - template - const T to() const; - - template - friend YAML_CPP_API typename enable_if >::type operator >> (const Node& node, T& value); - - // retrieval for maps and sequences - template - const Node *FindValue(const T& key) const; - - template - const Node& operator [] (const T& key) const; - - // specific to maps - const Node *FindValue(const char *key) const; - const Node *FindValue(char *key) const; - const Node& operator [] (const char *key) const; - const Node& operator [] (char *key) const; - - // for tags - const std::string& Tag() const { return m_tag; } - - // emitting - friend YAML_CPP_API Emitter& operator << (Emitter& out, const Node& node); - - // ordering - int Compare(const Node& rhs) const; - friend bool operator < (const Node& n1, const Node& n2); - - private: - explicit Node(NodeOwnership& owner); - Node& CreateNode(); - - void Init(NodeType::value type, const Mark& mark, const std::string& tag); - - void MarkAsAliased(); - void SetScalarData(const std::string& data); - void Append(Node& node); - void Insert(Node& key, Node& value); - - // helper for sequences - template friend struct _FindFromNodeAtIndex; - const Node *FindAtIndex(std::size_t i) const; - - // helper for maps - template - const Node& GetValue(const T& key) const; - - template - const Node *FindValueForKey(const T& key) const; - - private: - std::auto_ptr m_pOwnership; - - Mark m_mark; - std::string m_tag; - - typedef std::vector node_seq; - typedef std::map node_map; - - NodeType::value m_type; - std::string m_scalarData; - node_seq m_seqData; - node_map m_mapData; - }; -} - -#include "yaml-cpp-pm/nodeimpl.h" -#include "yaml-cpp-pm/nodereadimpl.h" - -#endif // NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/nodeimpl.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/nodeimpl.h deleted file mode 100644 index ba8cb6ca0..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/nodeimpl.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp-pm/nodeutil.h" -#include - -namespace YAML_PM -{ - // implementation of templated things - template - inline const T Node::to() const { - T value; - *this >> value; - return value; - } - - template - inline typename enable_if >::type operator >> (const Node& node, T& value) { - if(!ConvertScalar(node, value)) - throw InvalidScalar(node.m_mark); - } - - template - inline const Node *Node::FindValue(const T& key) const { - switch(m_type) { - case NodeType::Null: - case NodeType::Scalar: - throw BadDereference(); - case NodeType::Sequence: - return FindFromNodeAtIndex(*this, key); - case NodeType::Map: - return FindValueForKey(key); - } - assert(false); - throw BadDereference(); - } - - template - inline const Node *Node::FindValueForKey(const T& key) const { - for(Iterator it=begin();it!=end();++it) { - T t; - if(it.first().Read(t)) { - if(key == t) - return &it.second(); - } - } - - return 0; - } - - template - inline const Node& Node::GetValue(const T& key) const { - if(const Node *pValue = FindValue(key)) - return *pValue; - throw MakeTypedKeyNotFound(m_mark, key); - } - - template - inline const Node& Node::operator [] (const T& key) const { - return GetValue(key); - } - - inline const Node *Node::FindValue(const char *key) const { - return FindValue(std::string(key)); - } - - inline const Node *Node::FindValue(char *key) const { - return FindValue(std::string(key)); - } - - inline const Node& Node::operator [] (const char *key) const { - return GetValue(std::string(key)); - } - - inline const Node& Node::operator [] (char *key) const { - return GetValue(std::string(key)); - } -} - -#endif // NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/nodereadimpl.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/nodereadimpl.h deleted file mode 100644 index 094d50ce9..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/nodereadimpl.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef NODEREADIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define NODEREADIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -namespace YAML_PM -{ - // implementation for Node::Read - // (the goal is to call ConvertScalar if we can, and fall back to operator >> if not) - // thanks to litb from stackoverflow.com - // http://stackoverflow.com/questions/1386183/how-to-call-a-templated-function-if-it-exists-and-something-else-otherwise/1386390#1386390 - - // Note: this doesn't work on gcc 3.2, but does on gcc 3.4 and above. I'm not sure about 3.3. - -#if __GNUC__ && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ <= 3)) - // trick doesn't work? Just fall back to ConvertScalar. - // This means that we can't use any user-defined types as keys in a map - template - inline bool Node::Read(T& value) const { - return ConvertScalar(*this, value); - } -#else - // usual case: the trick! - template - struct read_impl; - - // ConvertScalar available - template<> - struct read_impl { - template - static bool read(const Node& node, T& value) { - return ConvertScalar(node, value); - } - }; - - // ConvertScalar not available - template<> - struct read_impl { - template - static bool read(const Node& node, T& value) { - try { - node >> value; - } catch(const Exception&) { - return false; - } - return true; - } - }; - - namespace fallback { - // sizeof > 1 - struct flag { char c[2]; }; - flag Convert(...); - - int operator,(flag, flag); - - template - char operator,(flag, T const&); - - char operator,(int, flag); - int operator,(char, flag); - } - - template - inline bool Node::Read(T& value) const { - using namespace fallback; - - return read_impl::read(*this, value); - } -#endif // done with trick - - // the main conversion function - template - inline bool ConvertScalar(const Node& node, T& value) { - std::string scalar; - if(!node.GetScalar(scalar)) - return false; - - return Convert(scalar, value); - } -} - -#endif // NODEREADIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/nodeutil.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/nodeutil.h deleted file mode 100644 index 658c69b74..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/nodeutil.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -namespace YAML_PM -{ - template - struct is_same_type { - enum { value = false }; - }; - - template - struct is_same_type { - enum { value = true }; - }; - - template - struct is_index_type_with_check { - enum { value = false }; - }; - - template <> struct is_index_type_with_check { enum { value = true }; }; - -#define MAKE_INDEX_TYPE(Type) \ - template <> struct is_index_type_with_check::value> { enum { value = true }; } - - MAKE_INDEX_TYPE(int); - MAKE_INDEX_TYPE(unsigned); - MAKE_INDEX_TYPE(short); - MAKE_INDEX_TYPE(unsigned short); - MAKE_INDEX_TYPE(long); - MAKE_INDEX_TYPE(unsigned long); - -#undef MAKE_INDEX_TYPE - - template - struct is_index_type: public is_index_type_with_check {}; - - // messing around with template stuff to get the right overload for operator [] for a sequence - template - struct _FindFromNodeAtIndex { - const Node *pRet; - _FindFromNodeAtIndex(const Node&, const T&): pRet(0) {} - }; - - template - struct _FindFromNodeAtIndex { - const Node *pRet; - _FindFromNodeAtIndex(const Node& node, const T& key): pRet(node.FindAtIndex(static_cast(key))) {} - }; - - template - inline const Node *FindFromNodeAtIndex(const Node& node, const T& key) { - return _FindFromNodeAtIndex::value>(node, key).pRet; - } -} - -#endif // NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/noncopyable.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/noncopyable.h deleted file mode 100644 index be6b45fef..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/noncopyable.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp-pm/dll.h" - -namespace YAML_PM -{ - // this is basically boost::noncopyable - class YAML_CPP_API noncopyable - { - protected: - noncopyable() {} - ~noncopyable() {} - - private: - noncopyable(const noncopyable&); - const noncopyable& operator = (const noncopyable&); - }; -} - -#endif // NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/null.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/null.h deleted file mode 100644 index c5c0030df..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/null.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp-pm/dll.h" - -namespace YAML_PM -{ - class Node; - - struct YAML_CPP_API _Null {}; - inline bool operator == (const _Null&, const _Null&) { return true; } - inline bool operator != (const _Null&, const _Null&) { return false; } - - YAML_CPP_API bool IsNull(const Node& node); // old API only - - extern YAML_CPP_API _Null Null; -} - -#endif // NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/ostream.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/ostream.h deleted file mode 100644 index 23ff9b5f5..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/ostream.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include - -namespace YAML_PM -{ - class ostream - { - public: - ostream(); - ~ostream(); - - void reserve(unsigned size); - void put(char ch); - const char *str() const { return m_buffer; } - - unsigned row() const { return m_row; } - unsigned col() const { return m_col; } - unsigned pos() const { return m_pos; } - - private: - char *m_buffer; - unsigned m_pos; - unsigned m_size; - - unsigned m_row, m_col; - }; - - ostream& operator << (ostream& out, const char *str); - ostream& operator << (ostream& out, const std::string& str); - ostream& operator << (ostream& out, char ch); -} - -#endif // OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/parser.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/parser.h deleted file mode 100644 index 501cdfb38..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/parser.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp-pm/dll.h" -#include "yaml-cpp-pm/noncopyable.h" -#include -#include - -namespace YAML_PM -{ - struct Directives; - struct Mark; - struct Token; - class EventHandler; - class Node; - class Scanner; - - class YAML_CPP_API Parser: private noncopyable - { - public: - Parser(); - Parser(std::istream& in); - ~Parser(); - - operator bool() const; - - void Load(std::istream& in); - bool HandleNextDocument(EventHandler& eventHandler); - - bool GetNextDocument(Node& document); // old API only - - void PrintTokens(std::ostream& out); - - private: - void ParseDirectives(); - void HandleDirective(const Token& token); - void HandleYamlDirective(const Token& token); - void HandleTagDirective(const Token& token); - - private: - std::auto_ptr m_pScanner; - std::auto_ptr m_pDirectives; - }; -} - -#endif // PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/stlemitter.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/stlemitter.h deleted file mode 100644 index 00f3eaf33..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/stlemitter.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include -#include -#include -#include - -namespace YAML_PM -{ - template - inline Emitter& EmitSeq(Emitter& emitter, const Seq& seq) { - emitter << BeginSeq; - for(typename Seq::const_iterator it=seq.begin();it!=seq.end();++it) - emitter << *it; - emitter << EndSeq; - return emitter; - } - - template - inline Emitter& operator << (Emitter& emitter, const std::vector& v) { - return EmitSeq(emitter, v); - } - - template - inline Emitter& operator << (Emitter& emitter, const std::list& v) { - return EmitSeq(emitter, v); - } - - template - inline Emitter& operator << (Emitter& emitter, const std::set& v) { - return EmitSeq(emitter, v); - } - - template - inline Emitter& operator << (Emitter& emitter, const std::map& m) { - typedef typename std::map map; - emitter << BeginMap; - for(typename map::const_iterator it=m.begin();it!=m.end();++it) - emitter << Key << it->first << Value << it->second; - emitter << EndMap; - return emitter; - } -} - -#endif // STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/stlnode.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/stlnode.h deleted file mode 100644 index 588cd9c5c..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/stlnode.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef STLNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define STLNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include -#include - -namespace YAML_PM -{ - template - void operator >> (const Node& node, std::vector& v) - { - v.clear(); - v.resize(node.size()); - for(unsigned i=0;i> v[i]; - } - - - template - void operator >> (const Node& node, std::map& m) - { - m.clear(); - for(Iterator it=node.begin();it!=node.end();++it) { - K k; - V v; - it.first() >> k; - it.second() >> v; - m[k] = v; - } - } -} - -#endif // STLNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/traits.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/traits.h deleted file mode 100644 index bf73322d4..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/traits.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -namespace YAML_PM -{ - template - struct is_numeric { enum { value = false }; }; - - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; -#if defined(_MSC_VER) && (_MSC_VER < 1310) - template <> struct is_numeric <__int64> { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; -#else - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; -#endif - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; - - template - struct enable_if_c { - typedef T type; - }; - - template - struct enable_if_c {}; - - template - struct enable_if : public enable_if_c {}; - - template - struct disable_if_c { - typedef T type; - }; - - template - struct disable_if_c {}; - - template - struct disable_if : public disable_if_c {}; -} - -#endif // TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - diff --git a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/yaml.h b/contrib/yaml-cpp-pm/include/yaml-cpp-pm/yaml.h deleted file mode 100644 index a1cddd0cd..000000000 --- a/contrib/yaml-cpp-pm/include/yaml-cpp-pm/yaml.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp-pm/parser.h" -#include "yaml-cpp-pm/emitter.h" -#include "yaml-cpp-pm/stlemitter.h" -#include "yaml-cpp-pm/exceptions.h" - -#include "yaml-cpp-pm/node.h" -#include "yaml-cpp-pm/stlnode.h" -#include "yaml-cpp-pm/iterator.h" - -#endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/license.txt b/contrib/yaml-cpp-pm/license.txt deleted file mode 100644 index 5bd9e1a12..000000000 --- a/contrib/yaml-cpp-pm/license.txt +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2008 Jesse Beder. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/contrib/yaml-cpp-pm/src/aliasmanager.cpp b/contrib/yaml-cpp-pm/src/aliasmanager.cpp deleted file mode 100644 index 5b3ac5dd7..000000000 --- a/contrib/yaml-cpp-pm/src/aliasmanager.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "yaml-cpp-pm/aliasmanager.h" -#include "yaml-cpp-pm/node.h" -#include -#include - -namespace YAML_PM -{ - AliasManager::AliasManager(): m_curAnchor(0) - { - } - - void AliasManager::RegisterReference(const Node& node) - { - m_anchorByIdentity.insert(std::make_pair(&node, _CreateNewAnchor())); - } - - anchor_t AliasManager::LookupAnchor(const Node& node) const - { - AnchorByIdentity::const_iterator it = m_anchorByIdentity.find(&node); - if(it == m_anchorByIdentity.end()) - return 0; - return it->second; - } - - anchor_t AliasManager::_CreateNewAnchor() - { - return ++m_curAnchor; - } -} diff --git a/contrib/yaml-cpp-pm/src/binary.cpp b/contrib/yaml-cpp-pm/src/binary.cpp deleted file mode 100644 index d02bc3efc..000000000 --- a/contrib/yaml-cpp-pm/src/binary.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include "yaml-cpp-pm/binary.h" -#include "yaml-cpp-pm/node.h" - -namespace YAML_PM -{ - static const char encoding[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - std::string EncodeBase64(const unsigned char *data, std::size_t size) - { - const char PAD = '='; - - std::string ret; - ret.resize(4 * size / 3 + 3); - char *out = &ret[0]; - - std::size_t chunks = size / 3; - std::size_t remainder = size % 3; - - for(std::size_t i=0;i> 2]; - *out++ = encoding[((data[0] & 0x3) << 4) | (data[1] >> 4)]; - *out++ = encoding[((data[1] & 0xf) << 2) | (data[2] >> 6)]; - *out++ = encoding[data[2] & 0x3f]; - } - - switch(remainder) { - case 0: - break; - case 1: - *out++ = encoding[data[0] >> 2]; - *out++ = encoding[((data[0] & 0x3) << 4)]; - *out++ = PAD; - *out++ = PAD; - break; - case 2: - *out++ = encoding[data[0] >> 2]; - *out++ = encoding[((data[0] & 0x3) << 4) | (data[1] >> 4)]; - *out++ = encoding[((data[1] & 0xf) << 2)]; - *out++ = PAD; - break; - } - - ret.resize(out - &ret[0]); - return ret; - } - - static const unsigned char decoding[] = { - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255, 62,255,255,255, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,255,255,255, 0,255,255, - 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,255,255,255,255,255, - 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - }; - - std::vector DecodeBase64(const std::string& input) - { - typedef std::vector ret_type; - if(input.empty()) - return ret_type(); - - ret_type ret(3 * input.size() / 4 + 1); - unsigned char *out = &ret[0]; - - unsigned value = 0; - for(std::size_t i=0;i(input[i])]; - if(d == 255) - return ret_type(); - - value = (value << 6) | d; - if(i % 4 == 3) { - *out++ = value >> 16; - if(i > 0 && input[i - 1] != '=') - *out++ = value >> 8; - if(input[i] != '=') - *out++ = value; - } - } - - ret.resize(out - &ret[0]); - return ret; - } - - void operator >> (const Node& node, Binary& binary) - { - std::string scalar; - node.GetScalar(scalar); - std::vector data = DecodeBase64(scalar); - binary.swap(data); - } -} diff --git a/contrib/yaml-cpp-pm/src/collectionstack.h b/contrib/yaml-cpp-pm/src/collectionstack.h deleted file mode 100644 index fddf14741..000000000 --- a/contrib/yaml-cpp-pm/src/collectionstack.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include -#include - -namespace YAML_PM -{ - struct CollectionType { - enum value { None, BlockMap, BlockSeq, FlowMap, FlowSeq, CompactMap }; - }; - - class CollectionStack - { - public: - CollectionType::value GetCurCollectionType() const { - if(collectionStack.empty()) - return CollectionType::None; - return collectionStack.top(); - } - - void PushCollectionType(CollectionType::value type) { collectionStack.push(type); } - void PopCollectionType(CollectionType::value type) { assert(type == GetCurCollectionType()); collectionStack.pop(); } - - private: - std::stack collectionStack; - }; -} - -#endif // COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/contrib/graphbuilder.cpp b/contrib/yaml-cpp-pm/src/contrib/graphbuilder.cpp deleted file mode 100644 index 4179838df..000000000 --- a/contrib/yaml-cpp-pm/src/contrib/graphbuilder.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "yaml-cpp-pm/parser.h" -#include "yaml-cpp-pm/contrib/graphbuilder.h" -#include "graphbuilderadapter.h" - -namespace YAML_PM -{ - void *BuildGraphOfNextDocument(Parser& parser, GraphBuilderInterface& graphBuilder) - { - GraphBuilderAdapter eventHandler(graphBuilder); - if (parser.HandleNextDocument(eventHandler)) { - return eventHandler.RootNode(); - } else { - return NULL; - } - } -} diff --git a/contrib/yaml-cpp-pm/src/contrib/graphbuilderadapter.cpp b/contrib/yaml-cpp-pm/src/contrib/graphbuilderadapter.cpp deleted file mode 100644 index facaadee6..000000000 --- a/contrib/yaml-cpp-pm/src/contrib/graphbuilderadapter.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "graphbuilderadapter.h" - -namespace YAML_PM -{ - int GraphBuilderAdapter::ContainerFrame::sequenceMarker; - - void GraphBuilderAdapter::OnNull(const Mark& mark, anchor_t anchor) - { - void *pParent = GetCurrentParent(); - void *pNode = m_builder.NewNull(mark, pParent); - RegisterAnchor(anchor, pNode); - - DispositionNode(pNode); - } - - void GraphBuilderAdapter::OnAlias(const Mark& mark, anchor_t anchor) - { - void *pReffedNode = m_anchors.Get(anchor); - DispositionNode(m_builder.AnchorReference(mark, pReffedNode)); - } - - void GraphBuilderAdapter::OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value) - { - void *pParent = GetCurrentParent(); - void *pNode = m_builder.NewScalar(mark, tag, pParent, value); - RegisterAnchor(anchor, pNode); - - DispositionNode(pNode); - } - - void GraphBuilderAdapter::OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor) - { - void *pNode = m_builder.NewSequence(mark, tag, GetCurrentParent()); - m_containers.push(ContainerFrame(pNode)); - RegisterAnchor(anchor, pNode); - } - - void GraphBuilderAdapter::OnSequenceEnd() - { - void *pSequence = m_containers.top().pContainer; - m_containers.pop(); - - DispositionNode(pSequence); - } - - void GraphBuilderAdapter::OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor) - { - void *pNode = m_builder.NewMap(mark, tag, GetCurrentParent()); - m_containers.push(ContainerFrame(pNode, m_pKeyNode)); - m_pKeyNode = NULL; - RegisterAnchor(anchor, pNode); - } - - void GraphBuilderAdapter::OnMapEnd() - { - void *pMap = m_containers.top().pContainer; - m_pKeyNode = m_containers.top().pPrevKeyNode; - m_containers.pop(); - DispositionNode(pMap); - } - - void *GraphBuilderAdapter::GetCurrentParent() const - { - if (m_containers.empty()) { - return NULL; - } - return m_containers.top().pContainer; - } - - void GraphBuilderAdapter::RegisterAnchor(anchor_t anchor, void *pNode) - { - if (anchor) { - m_anchors.Register(anchor, pNode); - } - } - - void GraphBuilderAdapter::DispositionNode(void *pNode) - { - if (m_containers.empty()) { - m_pRootNode = pNode; - return; - } - - void *pContainer = m_containers.top().pContainer; - if (m_containers.top().isMap()) { - if (m_pKeyNode) { - m_builder.AssignInMap(pContainer, m_pKeyNode, pNode); - m_pKeyNode = NULL; - } else { - m_pKeyNode = pNode; - } - } else { - m_builder.AppendToSequence(pContainer, pNode); - } - } -} diff --git a/contrib/yaml-cpp-pm/src/contrib/graphbuilderadapter.h b/contrib/yaml-cpp-pm/src/contrib/graphbuilderadapter.h deleted file mode 100644 index 2d879368c..000000000 --- a/contrib/yaml-cpp-pm/src/contrib/graphbuilderadapter.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include -#include -#include "yaml-cpp-pm/eventhandler.h" -#include "yaml-cpp-pm/contrib/anchordict.h" -#include "yaml-cpp-pm/contrib/graphbuilder.h" - -namespace YAML_PM -{ - class GraphBuilderAdapter : public EventHandler - { - public: - GraphBuilderAdapter(GraphBuilderInterface& builder) - : m_builder(builder), m_pRootNode(NULL), m_pKeyNode(NULL) - { - } - - virtual void OnDocumentStart(const Mark& mark) {(void)mark;} - virtual void OnDocumentEnd() {} - - virtual void OnNull(const Mark& mark, anchor_t anchor); - virtual void OnAlias(const Mark& mark, anchor_t anchor); - virtual void OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value); - - virtual void OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor); - virtual void OnSequenceEnd(); - - virtual void OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor); - virtual void OnMapEnd(); - - void *RootNode() const {return m_pRootNode;} - - private: - struct ContainerFrame - { - ContainerFrame(void *pSequence) - : pContainer(pSequence), pPrevKeyNode(&sequenceMarker) - {} - ContainerFrame(void *pMap, void* pPrevKeyNode) - : pContainer(pMap), pPrevKeyNode(pPrevKeyNode) - {} - - void *pContainer; - void *pPrevKeyNode; - - bool isMap() const {return pPrevKeyNode != &sequenceMarker;} - - private: - static int sequenceMarker; - }; - typedef std::stack ContainerStack; - typedef AnchorDict AnchorMap; - - GraphBuilderInterface& m_builder; - ContainerStack m_containers; - AnchorMap m_anchors; - void *m_pRootNode; - void *m_pKeyNode; - - void *GetCurrentParent() const; - void RegisterAnchor(anchor_t anchor, void *pNode); - void DispositionNode(void *pNode); - }; -} - -#endif // GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/conversion.cpp b/contrib/yaml-cpp-pm/src/conversion.cpp deleted file mode 100644 index 4ce0395b8..000000000 --- a/contrib/yaml-cpp-pm/src/conversion.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include "yaml-cpp-pm/conversion.h" -#include - -//////////////////////////////////////////////////////////////// -// Specializations for converting a string to specific types - -namespace -{ - // we're not gonna mess with the mess that is all the isupper/etc. functions - bool IsLower(char ch) { return 'a' <= ch && ch <= 'z'; } - bool IsUpper(char ch) { return 'A' <= ch && ch <= 'Z'; } - char ToLower(char ch) { return IsUpper(ch) ? ch + 'a' - 'A' : ch; } - - std::string tolower(const std::string& str) - { - std::string s(str); - std::transform(s.begin(), s.end(), s.begin(), ToLower); - return s; - } - - template - bool IsEntirely(const std::string& str, T func) - { - for(std::size_t i=0;i::const_iterator it = tags.find(handle); - if(it == tags.end()) { - if(handle == "!!") - return "tag:yaml.org,2002:"; - return handle; - } - - return it->second; - } -} diff --git a/contrib/yaml-cpp-pm/src/directives.h b/contrib/yaml-cpp-pm/src/directives.h deleted file mode 100644 index 14d0a2fd2..000000000 --- a/contrib/yaml-cpp-pm/src/directives.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include -#include - -namespace YAML_PM -{ - struct Version { - bool isDefault; - int major, minor; - }; - - struct Directives { - Directives(); - - const std::string TranslateTagHandle(const std::string& handle) const; - - Version version; - std::map tags; - }; -} - -#endif // DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/emitfromevents.cpp b/contrib/yaml-cpp-pm/src/emitfromevents.cpp deleted file mode 100644 index 1ce9dd8ee..000000000 --- a/contrib/yaml-cpp-pm/src/emitfromevents.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include "yaml-cpp-pm/emitfromevents.h" -#include "yaml-cpp-pm/emitter.h" -#include "yaml-cpp-pm/null.h" -#include -#include - -namespace { - std::string ToString(YAML_PM::anchor_t anchor) { - std::stringstream stream; - stream << anchor; - return stream.str(); - } -} - -namespace YAML_PM -{ - EmitFromEvents::EmitFromEvents(Emitter& emitter): m_emitter(emitter) - { - } - - void EmitFromEvents::OnDocumentStart(const Mark&) - { - } - - void EmitFromEvents::OnDocumentEnd() - { - } - - void EmitFromEvents::OnNull(const Mark&, anchor_t anchor) - { - BeginNode(); - EmitProps("", anchor); - m_emitter << Null; - } - - void EmitFromEvents::OnAlias(const Mark&, anchor_t anchor) - { - BeginNode(); - m_emitter << Alias(ToString(anchor)); - } - - void EmitFromEvents::OnScalar(const Mark&, const std::string& tag, anchor_t anchor, const std::string& value) - { - BeginNode(); - EmitProps(tag, anchor); - m_emitter << value; - } - - void EmitFromEvents::OnSequenceStart(const Mark&, const std::string& tag, anchor_t anchor) - { - BeginNode(); - EmitProps(tag, anchor); - m_emitter << BeginSeq; - m_stateStack.push(State::WaitingForSequenceEntry); - } - - void EmitFromEvents::OnSequenceEnd() - { - m_emitter << EndSeq; - assert(m_stateStack.top() == State::WaitingForSequenceEntry); - m_stateStack.pop(); - } - - void EmitFromEvents::OnMapStart(const Mark&, const std::string& tag, anchor_t anchor) - { - BeginNode(); - EmitProps(tag, anchor); - m_emitter << BeginMap; - m_stateStack.push(State::WaitingForKey); - } - - void EmitFromEvents::OnMapEnd() - { - m_emitter << EndMap; - assert(m_stateStack.top() == State::WaitingForKey); - m_stateStack.pop(); - } - - void EmitFromEvents::BeginNode() - { - if(m_stateStack.empty()) - return; - - switch(m_stateStack.top()) { - case State::WaitingForKey: - m_emitter << Key; - m_stateStack.top() = State::WaitingForValue; - break; - case State::WaitingForValue: - m_emitter << Value; - m_stateStack.top() = State::WaitingForKey; - break; - default: - break; - } - } - - void EmitFromEvents::EmitProps(const std::string& tag, anchor_t anchor) - { - if(!tag.empty() && tag != "?") - m_emitter << VerbatimTag(tag); - if(anchor) - m_emitter << Anchor(ToString(anchor)); - } -} diff --git a/contrib/yaml-cpp-pm/src/emitter.cpp b/contrib/yaml-cpp-pm/src/emitter.cpp deleted file mode 100644 index 44511e94f..000000000 --- a/contrib/yaml-cpp-pm/src/emitter.cpp +++ /dev/null @@ -1,882 +0,0 @@ -#include "yaml-cpp-pm/emitter.h" -#include "emitterstate.h" -#include "emitterutils.h" -#include "indentation.h" -#include "yaml-cpp-pm/exceptions.h" -#include - -namespace YAML_PM -{ - Emitter::Emitter(): m_pState(new EmitterState) - { - } - - Emitter::~Emitter() - { - } - - const char *Emitter::c_str() const - { - return m_stream.str(); - } - - unsigned Emitter::size() const - { - return m_stream.pos(); - } - - // state checking - bool Emitter::good() const - { - return m_pState->good(); - } - - const std::string Emitter::GetLastError() const - { - return m_pState->GetLastError(); - } - - // global setters - bool Emitter::SetOutputCharset(EMITTER_MANIP value) - { - return m_pState->SetOutputCharset(value, GLOBAL); - } - - bool Emitter::SetStringFormat(EMITTER_MANIP value) - { - return m_pState->SetStringFormat(value, GLOBAL); - } - - bool Emitter::SetBoolFormat(EMITTER_MANIP value) - { - bool ok = false; - if(m_pState->SetBoolFormat(value, GLOBAL)) - ok = true; - if(m_pState->SetBoolCaseFormat(value, GLOBAL)) - ok = true; - if(m_pState->SetBoolLengthFormat(value, GLOBAL)) - ok = true; - return ok; - } - - bool Emitter::SetIntBase(EMITTER_MANIP value) - { - return m_pState->SetIntFormat(value, GLOBAL); - } - - bool Emitter::SetSeqFormat(EMITTER_MANIP value) - { - return m_pState->SetFlowType(GT_SEQ, value, GLOBAL); - } - - bool Emitter::SetMapFormat(EMITTER_MANIP value) - { - bool ok = false; - if(m_pState->SetFlowType(GT_MAP, value, GLOBAL)) - ok = true; - if(m_pState->SetMapKeyFormat(value, GLOBAL)) - ok = true; - return ok; - } - - bool Emitter::SetIndent(unsigned n) - { - return m_pState->SetIndent(n, GLOBAL); - } - - bool Emitter::SetPreCommentIndent(unsigned n) - { - return m_pState->SetPreCommentIndent(n, GLOBAL); - } - - bool Emitter::SetPostCommentIndent(unsigned n) - { - return m_pState->SetPostCommentIndent(n, GLOBAL); - } - - bool Emitter::SetFloatPrecision(unsigned n) - { - return m_pState->SetFloatPrecision(n, GLOBAL); - } - - bool Emitter::SetDoublePrecision(unsigned n) - { - return m_pState->SetDoublePrecision(n, GLOBAL); - } - - // SetLocalValue - // . Either start/end a group, or set a modifier locally - Emitter& Emitter::SetLocalValue(EMITTER_MANIP value) - { - if(!good()) - return *this; - - switch(value) { - case BeginDoc: - EmitBeginDoc(); - break; - case EndDoc: - EmitEndDoc(); - break; - case BeginSeq: - EmitBeginSeq(); - break; - case EndSeq: - EmitEndSeq(); - break; - case BeginMap: - EmitBeginMap(); - break; - case EndMap: - EmitEndMap(); - break; - case Key: - EmitKey(); - break; - case Value: - EmitValue(); - break; - case TagByKind: - EmitKindTag(); - break; - case Newline: - EmitNewline(); - break; - default: - m_pState->SetLocalValue(value); - break; - } - return *this; - } - - Emitter& Emitter::SetLocalIndent(const _Indent& indent) - { - m_pState->SetIndent(indent.value, LOCAL); - return *this; - } - - Emitter& Emitter::SetLocalPrecision(const _Precision& precision) - { - if(precision.floatPrecision >= 0) - m_pState->SetFloatPrecision(precision.floatPrecision, LOCAL); - if(precision.doublePrecision >= 0) - m_pState->SetDoublePrecision(precision.doublePrecision, LOCAL); - return *this; - } - - // GotoNextPreAtomicState - // . Runs the state machine, emitting if necessary, and returns 'true' if done (i.e., ready to emit an atom) - bool Emitter::GotoNextPreAtomicState() - { - if(!good()) - return true; - - unsigned curIndent = m_pState->GetCurIndent(); - - EMITTER_STATE curState = m_pState->GetCurState(); - switch(curState) { - // document-level - case ES_WAITING_FOR_DOC: - m_pState->SwitchState(ES_WRITING_DOC); - return true; - case ES_WRITING_DOC: - return true; - case ES_DONE_WITH_DOC: - EmitBeginDoc(); - return false; - - // block sequence - case ES_WAITING_FOR_BLOCK_SEQ_ENTRY: - m_stream << IndentTo(curIndent) << "-"; - m_pState->RequireSoftSeparation(); - m_pState->SwitchState(ES_WRITING_BLOCK_SEQ_ENTRY); - return true; - case ES_WRITING_BLOCK_SEQ_ENTRY: - return true; - case ES_DONE_WITH_BLOCK_SEQ_ENTRY: - m_stream << '\n'; - m_pState->SwitchState(ES_WAITING_FOR_BLOCK_SEQ_ENTRY); - return false; - - // flow sequence - case ES_WAITING_FOR_FLOW_SEQ_ENTRY: - m_pState->SwitchState(ES_WRITING_FLOW_SEQ_ENTRY); - return true; - case ES_WRITING_FLOW_SEQ_ENTRY: - return true; - case ES_DONE_WITH_FLOW_SEQ_ENTRY: - EmitSeparationIfNecessary(); - m_stream << ','; - m_pState->RequireSoftSeparation(); - m_pState->SwitchState(ES_WAITING_FOR_FLOW_SEQ_ENTRY); - return false; - - // block map - case ES_WAITING_FOR_BLOCK_MAP_ENTRY: - m_pState->SetError(ErrorMsg::EXPECTED_KEY_TOKEN); - return true; - case ES_WAITING_FOR_BLOCK_MAP_KEY: - if(m_pState->CurrentlyInLongKey()) { - m_stream << IndentTo(curIndent) << '?'; - m_pState->RequireSoftSeparation(); - } - m_pState->SwitchState(ES_WRITING_BLOCK_MAP_KEY); - return true; - case ES_WRITING_BLOCK_MAP_KEY: - return true; - case ES_DONE_WITH_BLOCK_MAP_KEY: - m_pState->SetError(ErrorMsg::EXPECTED_VALUE_TOKEN); - return true; - case ES_WAITING_FOR_BLOCK_MAP_VALUE: - m_pState->SwitchState(ES_WRITING_BLOCK_MAP_VALUE); - return true; - case ES_WRITING_BLOCK_MAP_VALUE: - return true; - case ES_DONE_WITH_BLOCK_MAP_VALUE: - m_pState->SetError(ErrorMsg::EXPECTED_KEY_TOKEN); - return true; - - // flow map - case ES_WAITING_FOR_FLOW_MAP_ENTRY: - m_pState->SetError(ErrorMsg::EXPECTED_KEY_TOKEN); - return true; - case ES_WAITING_FOR_FLOW_MAP_KEY: - EmitSeparationIfNecessary(); - m_pState->SwitchState(ES_WRITING_FLOW_MAP_KEY); - if(m_pState->CurrentlyInLongKey()) { - m_stream << '?'; - m_pState->RequireSoftSeparation(); - } - return true; - case ES_WRITING_FLOW_MAP_KEY: - return true; - case ES_DONE_WITH_FLOW_MAP_KEY: - m_pState->SetError(ErrorMsg::EXPECTED_VALUE_TOKEN); - return true; - case ES_WAITING_FOR_FLOW_MAP_VALUE: - EmitSeparationIfNecessary(); - m_stream << ':'; - m_pState->RequireSoftSeparation(); - m_pState->SwitchState(ES_WRITING_FLOW_MAP_VALUE); - return true; - case ES_WRITING_FLOW_MAP_VALUE: - return true; - case ES_DONE_WITH_FLOW_MAP_VALUE: - m_pState->SetError(ErrorMsg::EXPECTED_KEY_TOKEN); - return true; - default: - assert(false); - } - - assert(false); - return true; - } - - // PreAtomicWrite - // . Depending on the emitter state, write to the stream to get it - // in position to do an atomic write (e.g., scalar, sequence, or map) - void Emitter::PreAtomicWrite() - { - if(!good()) - return; - - while(!GotoNextPreAtomicState()) - ; - } - - // PostAtomicWrite - // . Clean up - void Emitter::PostAtomicWrite() - { - if(!good()) - return; - - EMITTER_STATE curState = m_pState->GetCurState(); - switch(curState) { - // document-level - case ES_WRITING_DOC: - m_pState->SwitchState(ES_DONE_WITH_DOC); - break; - - // block seq - case ES_WRITING_BLOCK_SEQ_ENTRY: - m_pState->SwitchState(ES_DONE_WITH_BLOCK_SEQ_ENTRY); - break; - - // flow seq - case ES_WRITING_FLOW_SEQ_ENTRY: - m_pState->SwitchState(ES_DONE_WITH_FLOW_SEQ_ENTRY); - break; - - // block map - case ES_WRITING_BLOCK_MAP_KEY: - if(!m_pState->CurrentlyInLongKey()) { - m_stream << ':'; - m_pState->RequireSoftSeparation(); - } - m_pState->SwitchState(ES_DONE_WITH_BLOCK_MAP_KEY); - break; - case ES_WRITING_BLOCK_MAP_VALUE: - m_pState->SwitchState(ES_DONE_WITH_BLOCK_MAP_VALUE); - break; - - // flow map - case ES_WRITING_FLOW_MAP_KEY: - m_pState->SwitchState(ES_DONE_WITH_FLOW_MAP_KEY); - break; - case ES_WRITING_FLOW_MAP_VALUE: - m_pState->SwitchState(ES_DONE_WITH_FLOW_MAP_VALUE); - break; - default: - assert(false); - }; - - m_pState->ClearModifiedSettings(); - } - - // EmitSeparationIfNecessary - void Emitter::EmitSeparationIfNecessary() - { - if(!good()) - return; - - if(m_pState->RequiresSoftSeparation()) - m_stream << ' '; - else if(m_pState->RequiresHardSeparation()) - m_stream << '\n'; - m_pState->UnsetSeparation(); - } - - // EmitBeginDoc - void Emitter::EmitBeginDoc() - { - if(!good()) - return; - - EMITTER_STATE curState = m_pState->GetCurState(); - if(curState != ES_WAITING_FOR_DOC && curState != ES_WRITING_DOC && curState != ES_DONE_WITH_DOC) { - m_pState->SetError("Unexpected begin document"); - return; - } - - if(curState == ES_WRITING_DOC || curState == ES_DONE_WITH_DOC) - m_stream << '\n'; - m_stream << "---\n"; - - m_pState->UnsetSeparation(); - m_pState->SwitchState(ES_WAITING_FOR_DOC); - } - - // EmitEndDoc - void Emitter::EmitEndDoc() - { - if(!good()) - return; - - - EMITTER_STATE curState = m_pState->GetCurState(); - if(curState != ES_WAITING_FOR_DOC && curState != ES_WRITING_DOC && curState != ES_DONE_WITH_DOC) { - m_pState->SetError("Unexpected end document"); - return; - } - - if(curState == ES_WRITING_DOC || curState == ES_DONE_WITH_DOC) - m_stream << '\n'; - m_stream << "...\n"; - - m_pState->UnsetSeparation(); - m_pState->SwitchState(ES_WAITING_FOR_DOC); - } - - // EmitBeginSeq - void Emitter::EmitBeginSeq() - { - if(!good()) - return; - - // must have a long key if we're emitting a sequence - m_pState->StartLongKey(); - - PreAtomicWrite(); - - EMITTER_STATE curState = m_pState->GetCurState(); - EMITTER_MANIP flowType = m_pState->GetFlowType(GT_SEQ); - if(flowType == Block) { - if(curState == ES_WRITING_BLOCK_SEQ_ENTRY || - curState == ES_WRITING_BLOCK_MAP_KEY || curState == ES_WRITING_BLOCK_MAP_VALUE || - curState == ES_WRITING_DOC - ) { - if(m_pState->RequiresHardSeparation() || curState != ES_WRITING_DOC) { - m_stream << "\n"; - m_pState->UnsetSeparation(); - } - } - m_pState->PushState(ES_WAITING_FOR_BLOCK_SEQ_ENTRY); - } else if(flowType == Flow) { - EmitSeparationIfNecessary(); - m_stream << "["; - m_pState->PushState(ES_WAITING_FOR_FLOW_SEQ_ENTRY); - } else - assert(false); - - m_pState->BeginGroup(GT_SEQ); - } - - // EmitEndSeq - void Emitter::EmitEndSeq() - { - if(!good()) - return; - - if(m_pState->GetCurGroupType() != GT_SEQ) - return m_pState->SetError(ErrorMsg::UNEXPECTED_END_SEQ); - - EMITTER_STATE curState = m_pState->GetCurState(); - FLOW_TYPE flowType = m_pState->GetCurGroupFlowType(); - if(flowType == FT_BLOCK) { - // Note: block sequences are *not* allowed to be empty, but we convert it - // to a flow sequence if it is - assert(curState == ES_DONE_WITH_BLOCK_SEQ_ENTRY || curState == ES_WAITING_FOR_BLOCK_SEQ_ENTRY); - if(curState == ES_WAITING_FOR_BLOCK_SEQ_ENTRY) { - // Note: only one of these will actually output anything for a given situation - EmitSeparationIfNecessary(); - unsigned curIndent = m_pState->GetCurIndent(); - m_stream << IndentTo(curIndent); - - m_stream << "[]"; - } - } else if(flowType == FT_FLOW) { - // Note: flow sequences are allowed to be empty - assert(curState == ES_DONE_WITH_FLOW_SEQ_ENTRY || curState == ES_WAITING_FOR_FLOW_SEQ_ENTRY); - m_stream << "]"; - } else - assert(false); - - m_pState->PopState(); - m_pState->EndGroup(GT_SEQ); - - PostAtomicWrite(); - } - - // EmitBeginMap - void Emitter::EmitBeginMap() - { - if(!good()) - return; - - // must have a long key if we're emitting a map - m_pState->StartLongKey(); - - PreAtomicWrite(); - - EMITTER_STATE curState = m_pState->GetCurState(); - EMITTER_MANIP flowType = m_pState->GetFlowType(GT_MAP); - if(flowType == Block) { - if(curState == ES_WRITING_BLOCK_SEQ_ENTRY || - curState == ES_WRITING_BLOCK_MAP_KEY || curState == ES_WRITING_BLOCK_MAP_VALUE || - curState == ES_WRITING_DOC - ) { - if(m_pState->RequiresHardSeparation() || (curState != ES_WRITING_DOC && curState != ES_WRITING_BLOCK_SEQ_ENTRY)) { - m_stream << "\n"; - m_pState->UnsetSeparation(); - } - } - m_pState->PushState(ES_WAITING_FOR_BLOCK_MAP_ENTRY); - } else if(flowType == Flow) { - EmitSeparationIfNecessary(); - m_stream << "{"; - m_pState->PushState(ES_WAITING_FOR_FLOW_MAP_ENTRY); - } else - assert(false); - - m_pState->BeginGroup(GT_MAP); - } - - // EmitEndMap - void Emitter::EmitEndMap() - { - if(!good()) - return; - - if(m_pState->GetCurGroupType() != GT_MAP) - return m_pState->SetError(ErrorMsg::UNEXPECTED_END_MAP); - - EMITTER_STATE curState = m_pState->GetCurState(); - FLOW_TYPE flowType = m_pState->GetCurGroupFlowType(); - if(flowType == FT_BLOCK) { - // Note: block sequences are *not* allowed to be empty, but we convert it - // to a flow sequence if it is - assert(curState == ES_DONE_WITH_BLOCK_MAP_VALUE || curState == ES_WAITING_FOR_BLOCK_MAP_ENTRY); - if(curState == ES_WAITING_FOR_BLOCK_MAP_ENTRY) { - // Note: only one of these will actually output anything for a given situation - EmitSeparationIfNecessary(); - unsigned curIndent = m_pState->GetCurIndent(); - m_stream << IndentTo(curIndent); - m_stream << "{}"; - } - } else if(flowType == FT_FLOW) { - // Note: flow maps are allowed to be empty - assert(curState == ES_DONE_WITH_FLOW_MAP_VALUE || curState == ES_WAITING_FOR_FLOW_MAP_ENTRY); - EmitSeparationIfNecessary(); - m_stream << "}"; - } else - assert(false); - - m_pState->PopState(); - m_pState->EndGroup(GT_MAP); - - PostAtomicWrite(); - } - - // EmitKey - void Emitter::EmitKey() - { - if(!good()) - return; - - EMITTER_STATE curState = m_pState->GetCurState(); - FLOW_TYPE flowType = m_pState->GetCurGroupFlowType(); - if(curState != ES_WAITING_FOR_BLOCK_MAP_ENTRY && curState != ES_DONE_WITH_BLOCK_MAP_VALUE - && curState != ES_WAITING_FOR_FLOW_MAP_ENTRY && curState != ES_DONE_WITH_FLOW_MAP_VALUE) - return m_pState->SetError(ErrorMsg::UNEXPECTED_KEY_TOKEN); - - if(flowType == FT_BLOCK) { - if(curState == ES_DONE_WITH_BLOCK_MAP_VALUE) - m_stream << '\n'; - unsigned curIndent = m_pState->GetCurIndent(); - m_stream << IndentTo(curIndent); - m_pState->UnsetSeparation(); - m_pState->SwitchState(ES_WAITING_FOR_BLOCK_MAP_KEY); - } else if(flowType == FT_FLOW) { - EmitSeparationIfNecessary(); - if(curState == ES_DONE_WITH_FLOW_MAP_VALUE) { - m_stream << ','; - m_pState->RequireSoftSeparation(); - } - m_pState->SwitchState(ES_WAITING_FOR_FLOW_MAP_KEY); - } else - assert(false); - - if(m_pState->GetMapKeyFormat() == LongKey) - m_pState->StartLongKey(); - else if(m_pState->GetMapKeyFormat() == Auto) - m_pState->StartSimpleKey(); - else - assert(false); - } - - // EmitValue - void Emitter::EmitValue() - { - if(!good()) - return; - - EMITTER_STATE curState = m_pState->GetCurState(); - FLOW_TYPE flowType = m_pState->GetCurGroupFlowType(); - if(curState != ES_DONE_WITH_BLOCK_MAP_KEY && curState != ES_DONE_WITH_FLOW_MAP_KEY) - return m_pState->SetError(ErrorMsg::UNEXPECTED_VALUE_TOKEN); - - if(flowType == FT_BLOCK) { - if(m_pState->CurrentlyInLongKey()) { - m_stream << '\n'; - m_stream << IndentTo(m_pState->GetCurIndent()); - m_stream << ':'; - m_pState->RequireSoftSeparation(); - } - m_pState->SwitchState(ES_WAITING_FOR_BLOCK_MAP_VALUE); - } else if(flowType == FT_FLOW) { - m_pState->SwitchState(ES_WAITING_FOR_FLOW_MAP_VALUE); - } else - assert(false); - } - - // EmitNewline - void Emitter::EmitNewline() - { - if(!good()) - return; - - if(CanEmitNewline()) { - m_stream << '\n'; - m_pState->UnsetSeparation(); - } - } - - bool Emitter::CanEmitNewline() const - { - FLOW_TYPE flowType = m_pState->GetCurGroupFlowType(); - if(flowType == FT_BLOCK && m_pState->CurrentlyInLongKey()) - return true; - - EMITTER_STATE curState = m_pState->GetCurState(); - return curState != ES_DONE_WITH_BLOCK_MAP_KEY && curState != ES_WAITING_FOR_BLOCK_MAP_VALUE && curState != ES_WRITING_BLOCK_MAP_VALUE; - } - - // ******************************************************************************************* - // overloads of Write - - Emitter& Emitter::Write(const std::string& str) - { - if(!good()) - return *this; - - // literal scalars must use long keys - if(m_pState->GetStringFormat() == Literal && m_pState->GetCurGroupFlowType() != FT_FLOW) - m_pState->StartLongKey(); - - PreAtomicWrite(); - EmitSeparationIfNecessary(); - - bool escapeNonAscii = m_pState->GetOutputCharset() == EscapeNonAscii; - EMITTER_MANIP strFmt = m_pState->GetStringFormat(); - FLOW_TYPE flowType = m_pState->GetCurGroupFlowType(); - unsigned curIndent = m_pState->GetCurIndent(); - - switch(strFmt) { - case Auto: - Utils::WriteString(m_stream, str, flowType == FT_FLOW, escapeNonAscii); - break; - case SingleQuoted: - if(!Utils::WriteSingleQuotedString(m_stream, str)) { - m_pState->SetError(ErrorMsg::SINGLE_QUOTED_CHAR); - return *this; - } - break; - case DoubleQuoted: - Utils::WriteDoubleQuotedString(m_stream, str, escapeNonAscii); - break; - case Literal: - if(flowType == FT_FLOW) - Utils::WriteString(m_stream, str, flowType == FT_FLOW, escapeNonAscii); - else - Utils::WriteLiteralString(m_stream, str, curIndent + m_pState->GetIndent()); - break; - default: - assert(false); - } - - PostAtomicWrite(); - return *this; - } - - void Emitter::PreWriteIntegralType(std::stringstream& str) - { - PreAtomicWrite(); - EmitSeparationIfNecessary(); - - EMITTER_MANIP intFmt = m_pState->GetIntFormat(); - switch(intFmt) { - case Dec: - str << std::dec; - break; - case Hex: - str << "0x"; - str << std::hex; - break; - case Oct: - str << "0"; - str << std::oct; - break; - default: - assert(false); - } - } - - void Emitter::PreWriteStreamable(std::stringstream&) - { - PreAtomicWrite(); - EmitSeparationIfNecessary(); - } - - unsigned Emitter::GetFloatPrecision() const - { - return m_pState->GetFloatPrecision(); - } - - unsigned Emitter::GetDoublePrecision() const - { - return m_pState->GetDoublePrecision(); - } - - void Emitter::PostWriteIntegralType(const std::stringstream& str) - { - m_stream << str.str(); - PostAtomicWrite(); - } - - void Emitter::PostWriteStreamable(const std::stringstream& str) - { - m_stream << str.str(); - PostAtomicWrite(); - } - - const char *Emitter::ComputeFullBoolName(bool b) const - { - const EMITTER_MANIP mainFmt = (m_pState->GetBoolLengthFormat() == ShortBool ? YesNoBool : m_pState->GetBoolFormat()); - const EMITTER_MANIP caseFmt = m_pState->GetBoolCaseFormat(); - switch(mainFmt) { - case YesNoBool: - switch(caseFmt) { - case UpperCase: return b ? "YES" : "NO"; - case CamelCase: return b ? "Yes" : "No"; - case LowerCase: return b ? "yes" : "no"; - default: break; - } - break; - case OnOffBool: - switch(caseFmt) { - case UpperCase: return b ? "ON" : "OFF"; - case CamelCase: return b ? "On" : "Off"; - case LowerCase: return b ? "on" : "off"; - default: break; - } - break; - case TrueFalseBool: - switch(caseFmt) { - case UpperCase: return b ? "TRUE" : "FALSE"; - case CamelCase: return b ? "True" : "False"; - case LowerCase: return b ? "true" : "false"; - default: break; - } - break; - default: - break; - } - return b ? "y" : "n"; // should never get here, but it can't hurt to give these answers - } - - Emitter& Emitter::Write(bool b) - { - if(!good()) - return *this; - - PreAtomicWrite(); - EmitSeparationIfNecessary(); - - const char *name = ComputeFullBoolName(b); - if(m_pState->GetBoolLengthFormat() == ShortBool) - m_stream << name[0]; - else - m_stream << name; - - PostAtomicWrite(); - return *this; - } - - Emitter& Emitter::Write(char ch) - { - if(!good()) - return *this; - - PreAtomicWrite(); - EmitSeparationIfNecessary(); - - Utils::WriteChar(m_stream, ch); - - PostAtomicWrite(); - return *this; - } - - Emitter& Emitter::Write(const _Alias& alias) - { - if(!good()) - return *this; - - PreAtomicWrite(); - EmitSeparationIfNecessary(); - if(!Utils::WriteAlias(m_stream, alias.content)) { - m_pState->SetError(ErrorMsg::INVALID_ALIAS); - return *this; - } - PostAtomicWrite(); - return *this; - } - - Emitter& Emitter::Write(const _Anchor& anchor) - { - if(!good()) - return *this; - - PreAtomicWrite(); - EmitSeparationIfNecessary(); - if(!Utils::WriteAnchor(m_stream, anchor.content)) { - m_pState->SetError(ErrorMsg::INVALID_ANCHOR); - return *this; - } - m_pState->RequireHardSeparation(); - // Note: no PostAtomicWrite() because we need another value for this node - return *this; - } - - Emitter& Emitter::Write(const _Tag& tag) - { - if(!good()) - return *this; - - PreAtomicWrite(); - EmitSeparationIfNecessary(); - - bool success = false; - if(tag.type == _Tag::Type::Verbatim) - success = Utils::WriteTag(m_stream, tag.content, true); - else if(tag.type == _Tag::Type::PrimaryHandle) - success = Utils::WriteTag(m_stream, tag.content, false); - else - success = Utils::WriteTagWithPrefix(m_stream, tag.prefix, tag.content); - - if(!success) { - m_pState->SetError(ErrorMsg::INVALID_TAG); - return *this; - } - - m_pState->RequireHardSeparation(); - // Note: no PostAtomicWrite() because we need another value for this node - return *this; - } - - void Emitter::EmitKindTag() - { - Write(LocalTag("")); - } - - Emitter& Emitter::Write(const _Comment& comment) - { - if(!good()) - return *this; - - if(m_stream.col() > 0) - m_stream << Indentation(m_pState->GetPreCommentIndent()); - Utils::WriteComment(m_stream, comment.content, m_pState->GetPostCommentIndent()); - m_pState->RequireHardSeparation(); - m_pState->ForceHardSeparation(); - - return *this; - } - - Emitter& Emitter::Write(const _Null& /*null*/) - { - if(!good()) - return *this; - - PreAtomicWrite(); - EmitSeparationIfNecessary(); - m_stream << "~"; - PostAtomicWrite(); - return *this; - } - - Emitter& Emitter::Write(const Binary& binary) - { - Write(SecondaryTag("binary")); - - if(!good()) - return *this; - - PreAtomicWrite(); - EmitSeparationIfNecessary(); - Utils::WriteBinary(m_stream, binary); - PostAtomicWrite(); - return *this; - } -} - diff --git a/contrib/yaml-cpp-pm/src/emitterstate.cpp b/contrib/yaml-cpp-pm/src/emitterstate.cpp deleted file mode 100644 index 7bc514ab5..000000000 --- a/contrib/yaml-cpp-pm/src/emitterstate.cpp +++ /dev/null @@ -1,284 +0,0 @@ -#include "emitterstate.h" -#include "yaml-cpp-pm/exceptions.h" -#include - -namespace YAML_PM -{ - EmitterState::EmitterState(): m_isGood(true), m_curIndent(0), m_requiresSoftSeparation(false), m_requiresHardSeparation(false) - { - // start up - m_stateStack.push(ES_WAITING_FOR_DOC); - - // set default global manipulators - m_charset.set(EmitNonAscii); - m_strFmt.set(Auto); - m_boolFmt.set(TrueFalseBool); - m_boolLengthFmt.set(LongBool); - m_boolCaseFmt.set(LowerCase); - m_intFmt.set(Dec); - m_indent.set(2); - m_preCommentIndent.set(2); - m_postCommentIndent.set(1); - m_seqFmt.set(Block); - m_mapFmt.set(Block); - m_mapKeyFmt.set(Auto); - m_floatPrecision.set(6); - m_doublePrecision.set(15); - } - - EmitterState::~EmitterState() - { - } - - // SetLocalValue - // . We blindly tries to set all possible formatters to this value - // . Only the ones that make sense will be accepted - void EmitterState::SetLocalValue(EMITTER_MANIP value) - { - SetOutputCharset(value, LOCAL); - SetStringFormat(value, LOCAL); - SetBoolFormat(value, LOCAL); - SetBoolCaseFormat(value, LOCAL); - SetBoolLengthFormat(value, LOCAL); - SetIntFormat(value, LOCAL); - SetFlowType(GT_SEQ, value, LOCAL); - SetFlowType(GT_MAP, value, LOCAL); - SetMapKeyFormat(value, LOCAL); - } - - void EmitterState::BeginGroup(GROUP_TYPE type) - { - unsigned lastIndent = (m_groups.empty() ? 0 : m_groups.top().indent); - m_curIndent += lastIndent; - - std::auto_ptr pGroup(new Group(type)); - - // transfer settings (which last until this group is done) - pGroup->modifiedSettings = m_modifiedSettings; - - // set up group - pGroup->flow = GetFlowType(type); - pGroup->indent = GetIndent(); - pGroup->usingLongKey = (GetMapKeyFormat() == LongKey ? true : false); - - m_groups.push(pGroup); - } - - void EmitterState::EndGroup(GROUP_TYPE type) - { - if(m_groups.empty()) - return SetError(ErrorMsg::UNMATCHED_GROUP_TAG); - - // get rid of the current group - { - std::auto_ptr pFinishedGroup = m_groups.pop(); - if(pFinishedGroup->type != type) - return SetError(ErrorMsg::UNMATCHED_GROUP_TAG); - } - - // reset old settings - unsigned lastIndent = (m_groups.empty() ? 0 : m_groups.top().indent); - assert(m_curIndent >= lastIndent); - m_curIndent -= lastIndent; - - // some global settings that we changed may have been overridden - // by a local setting we just popped, so we need to restore them - m_globalModifiedSettings.restore(); - } - - GROUP_TYPE EmitterState::GetCurGroupType() const - { - if(m_groups.empty()) - return GT_NONE; - - return m_groups.top().type; - } - - FLOW_TYPE EmitterState::GetCurGroupFlowType() const - { - if(m_groups.empty()) - return FT_NONE; - - return (m_groups.top().flow == Flow ? FT_FLOW : FT_BLOCK); - } - - bool EmitterState::CurrentlyInLongKey() - { - if(m_groups.empty()) - return false; - return m_groups.top().usingLongKey; - } - - void EmitterState::StartLongKey() - { - if(!m_groups.empty()) - m_groups.top().usingLongKey = true; - } - - void EmitterState::StartSimpleKey() - { - if(!m_groups.empty()) - m_groups.top().usingLongKey = false; - } - - void EmitterState::ClearModifiedSettings() - { - m_modifiedSettings.clear(); - } - - bool EmitterState::SetOutputCharset(EMITTER_MANIP value, FMT_SCOPE scope) - { - switch(value) { - case EmitNonAscii: - case EscapeNonAscii: - _Set(m_charset, value, scope); - return true; - default: - return false; - } - } - - bool EmitterState::SetStringFormat(EMITTER_MANIP value, FMT_SCOPE scope) - { - switch(value) { - case Auto: - case SingleQuoted: - case DoubleQuoted: - case Literal: - _Set(m_strFmt, value, scope); - return true; - default: - return false; - } - } - - bool EmitterState::SetBoolFormat(EMITTER_MANIP value, FMT_SCOPE scope) - { - switch(value) { - case OnOffBool: - case TrueFalseBool: - case YesNoBool: - _Set(m_boolFmt, value, scope); - return true; - default: - return false; - } - } - - bool EmitterState::SetBoolLengthFormat(EMITTER_MANIP value, FMT_SCOPE scope) - { - switch(value) { - case LongBool: - case ShortBool: - _Set(m_boolLengthFmt, value, scope); - return true; - default: - return false; - } - } - - bool EmitterState::SetBoolCaseFormat(EMITTER_MANIP value, FMT_SCOPE scope) - { - switch(value) { - case UpperCase: - case LowerCase: - case CamelCase: - _Set(m_boolCaseFmt, value, scope); - return true; - default: - return false; - } - } - - bool EmitterState::SetIntFormat(EMITTER_MANIP value, FMT_SCOPE scope) - { - switch(value) { - case Dec: - case Hex: - case Oct: - _Set(m_intFmt, value, scope); - return true; - default: - return false; - } - } - - bool EmitterState::SetIndent(unsigned value, FMT_SCOPE scope) - { - if(value == 0) - return false; - - _Set(m_indent, value, scope); - return true; - } - - bool EmitterState::SetPreCommentIndent(unsigned value, FMT_SCOPE scope) - { - if(value == 0) - return false; - - _Set(m_preCommentIndent, value, scope); - return true; - } - - bool EmitterState::SetPostCommentIndent(unsigned value, FMT_SCOPE scope) - { - if(value == 0) - return false; - - _Set(m_postCommentIndent, value, scope); - return true; - } - - bool EmitterState::SetFlowType(GROUP_TYPE groupType, EMITTER_MANIP value, FMT_SCOPE scope) - { - switch(value) { - case Block: - case Flow: - _Set(groupType == GT_SEQ ? m_seqFmt : m_mapFmt, value, scope); - return true; - default: - return false; - } - } - - EMITTER_MANIP EmitterState::GetFlowType(GROUP_TYPE groupType) const - { - // force flow style if we're currently in a flow - FLOW_TYPE flowType = GetCurGroupFlowType(); - if(flowType == FT_FLOW) - return Flow; - - // otherwise, go with what's asked of use - return (groupType == GT_SEQ ? m_seqFmt.get() : m_mapFmt.get()); - } - - bool EmitterState::SetMapKeyFormat(EMITTER_MANIP value, FMT_SCOPE scope) - { - switch(value) { - case Auto: - case LongKey: - _Set(m_mapKeyFmt, value, scope); - return true; - default: - return false; - } - } - - bool EmitterState::SetFloatPrecision(int value, FMT_SCOPE scope) - { - if(value < 0 || value > std::numeric_limits::digits10) - return false; - _Set(m_floatPrecision, value, scope); - return true; - } - - bool EmitterState::SetDoublePrecision(int value, FMT_SCOPE scope) - { - if(value < 0 || value > std::numeric_limits::digits10) - return false; - _Set(m_doublePrecision, value, scope); - return true; - } -} - diff --git a/contrib/yaml-cpp-pm/src/emitterstate.h b/contrib/yaml-cpp-pm/src/emitterstate.h deleted file mode 100644 index 1b62630ff..000000000 --- a/contrib/yaml-cpp-pm/src/emitterstate.h +++ /dev/null @@ -1,217 +0,0 @@ -#ifndef EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "ptr_stack.h" -#include "setting.h" -#include "yaml-cpp-pm/emittermanip.h" -#include -#include -#include -#include - -namespace YAML_PM -{ - enum FMT_SCOPE { - LOCAL, - GLOBAL - }; - - enum GROUP_TYPE { - GT_NONE, - GT_SEQ, - GT_MAP - }; - - enum FLOW_TYPE { - FT_NONE, - FT_FLOW, - FT_BLOCK - }; - - enum NODE_STATE { - NS_START, - NS_READY_FOR_ATOM, - NS_END - }; - - enum EMITTER_STATE { - ES_WAITING_FOR_DOC, - ES_WRITING_DOC, - ES_DONE_WITH_DOC, - - // block seq - ES_WAITING_FOR_BLOCK_SEQ_ENTRY, - ES_WRITING_BLOCK_SEQ_ENTRY, - ES_DONE_WITH_BLOCK_SEQ_ENTRY, - - // flow seq - ES_WAITING_FOR_FLOW_SEQ_ENTRY, - ES_WRITING_FLOW_SEQ_ENTRY, - ES_DONE_WITH_FLOW_SEQ_ENTRY, - - // block map - ES_WAITING_FOR_BLOCK_MAP_ENTRY, - ES_WAITING_FOR_BLOCK_MAP_KEY, - ES_WRITING_BLOCK_MAP_KEY, - ES_DONE_WITH_BLOCK_MAP_KEY, - ES_WAITING_FOR_BLOCK_MAP_VALUE, - ES_WRITING_BLOCK_MAP_VALUE, - ES_DONE_WITH_BLOCK_MAP_VALUE, - - // flow map - ES_WAITING_FOR_FLOW_MAP_ENTRY, - ES_WAITING_FOR_FLOW_MAP_KEY, - ES_WRITING_FLOW_MAP_KEY, - ES_DONE_WITH_FLOW_MAP_KEY, - ES_WAITING_FOR_FLOW_MAP_VALUE, - ES_WRITING_FLOW_MAP_VALUE, - ES_DONE_WITH_FLOW_MAP_VALUE - }; - - class EmitterState - { - public: - EmitterState(); - ~EmitterState(); - - // basic state checking - bool good() const { return m_isGood; } - const std::string GetLastError() const { return m_lastError; } - void SetError(const std::string& error) { m_isGood = false; m_lastError = error; } - - // main state of the machine - EMITTER_STATE GetCurState() const { return m_stateStack.top(); } - void SwitchState(EMITTER_STATE state) { PopState(); PushState(state); } - void PushState(EMITTER_STATE state) { m_stateStack.push(state); } - void PopState() { m_stateStack.pop(); } - - void SetLocalValue(EMITTER_MANIP value); - - // group handling - void BeginGroup(GROUP_TYPE type); - void EndGroup(GROUP_TYPE type); - - GROUP_TYPE GetCurGroupType() const; - FLOW_TYPE GetCurGroupFlowType() const; - int GetCurIndent() const { return m_curIndent; } - - bool CurrentlyInLongKey(); - void StartLongKey(); - void StartSimpleKey(); - - bool RequiresSoftSeparation() const { return m_requiresSoftSeparation; } - bool RequiresHardSeparation() const { return m_requiresHardSeparation; } - void RequireSoftSeparation() { m_requiresSoftSeparation = true; } - void RequireHardSeparation() { m_requiresSoftSeparation = true; m_requiresHardSeparation = true; } - void ForceHardSeparation() { m_requiresSoftSeparation = false; } - void UnsetSeparation() { m_requiresSoftSeparation = false; m_requiresHardSeparation = false; } - - void ClearModifiedSettings(); - - // formatters - bool SetOutputCharset(EMITTER_MANIP value, FMT_SCOPE scope); - EMITTER_MANIP GetOutputCharset() const { return m_charset.get(); } - - bool SetStringFormat(EMITTER_MANIP value, FMT_SCOPE scope); - EMITTER_MANIP GetStringFormat() const { return m_strFmt.get(); } - - bool SetBoolFormat(EMITTER_MANIP value, FMT_SCOPE scope); - EMITTER_MANIP GetBoolFormat() const { return m_boolFmt.get(); } - - bool SetBoolLengthFormat(EMITTER_MANIP value, FMT_SCOPE scope); - EMITTER_MANIP GetBoolLengthFormat() const { return m_boolLengthFmt.get(); } - - bool SetBoolCaseFormat(EMITTER_MANIP value, FMT_SCOPE scope); - EMITTER_MANIP GetBoolCaseFormat() const { return m_boolCaseFmt.get(); } - - bool SetIntFormat(EMITTER_MANIP value, FMT_SCOPE scope); - EMITTER_MANIP GetIntFormat() const { return m_intFmt.get(); } - - bool SetIndent(unsigned value, FMT_SCOPE scope); - int GetIndent() const { return m_indent.get(); } - - bool SetPreCommentIndent(unsigned value, FMT_SCOPE scope); - int GetPreCommentIndent() const { return m_preCommentIndent.get(); } - bool SetPostCommentIndent(unsigned value, FMT_SCOPE scope); - int GetPostCommentIndent() const { return m_postCommentIndent.get(); } - - bool SetFlowType(GROUP_TYPE groupType, EMITTER_MANIP value, FMT_SCOPE scope); - EMITTER_MANIP GetFlowType(GROUP_TYPE groupType) const; - - bool SetMapKeyFormat(EMITTER_MANIP value, FMT_SCOPE scope); - EMITTER_MANIP GetMapKeyFormat() const { return m_mapKeyFmt.get(); } - - bool SetFloatPrecision(int value, FMT_SCOPE scope); - unsigned GetFloatPrecision() const { return m_floatPrecision.get(); } - bool SetDoublePrecision(int value, FMT_SCOPE scope); - unsigned GetDoublePrecision() const { return m_doublePrecision.get(); } - - private: - template - void _Set(Setting& fmt, T value, FMT_SCOPE scope); - - private: - // basic state ok? - bool m_isGood; - std::string m_lastError; - - // other state - std::stack m_stateStack; - - Setting m_charset; - Setting m_strFmt; - Setting m_boolFmt; - Setting m_boolLengthFmt; - Setting m_boolCaseFmt; - Setting m_intFmt; - Setting m_indent; - Setting m_preCommentIndent, m_postCommentIndent; - Setting m_seqFmt; - Setting m_mapFmt; - Setting m_mapKeyFmt; - Setting m_floatPrecision; - Setting m_doublePrecision; - - SettingChanges m_modifiedSettings; - SettingChanges m_globalModifiedSettings; - - struct Group { - Group(GROUP_TYPE type_): type(type_), usingLongKey(false), indent(0) {} - - GROUP_TYPE type; - EMITTER_MANIP flow; - bool usingLongKey; - int indent; - - SettingChanges modifiedSettings; - }; - - ptr_stack m_groups; - unsigned m_curIndent; - bool m_requiresSoftSeparation; - bool m_requiresHardSeparation; - }; - - template - void EmitterState::_Set(Setting& fmt, T value, FMT_SCOPE scope) { - switch(scope) { - case LOCAL: - m_modifiedSettings.push(fmt.set(value)); - break; - case GLOBAL: - fmt.set(value); - m_globalModifiedSettings.push(fmt.set(value)); // this pushes an identity set, so when we restore, - // it restores to the value here, and not the previous one - break; - default: - assert(false); - } - } -} - -#endif // EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/emitterutils.cpp b/contrib/yaml-cpp-pm/src/emitterutils.cpp deleted file mode 100644 index 508c495ad..000000000 --- a/contrib/yaml-cpp-pm/src/emitterutils.cpp +++ /dev/null @@ -1,378 +0,0 @@ -#include "emitterutils.h" -#include "exp.h" -#include "indentation.h" -#include "yaml-cpp-pm/binary.h" -#include "yaml-cpp-pm/exceptions.h" -#include "stringsource.h" -#include -#include - -namespace YAML_PM -{ - namespace Utils - { - namespace { - enum {REPLACEMENT_CHARACTER = 0xFFFD}; - - bool IsAnchorChar(int ch) { // test for ns-anchor-char - switch (ch) { - case ',': case '[': case ']': case '{': case '}': // c-flow-indicator - case ' ': case '\t': // s-white - case 0xFEFF: // c-byte-order-mark - case 0xA: case 0xD: // b-char - return false; - case 0x85: - return true; - } - - if (ch < 0x20) - return false; - - if (ch < 0x7E) - return true; - - if (ch < 0xA0) - return false; - if (ch >= 0xD800 && ch <= 0xDFFF) - return false; - if ((ch & 0xFFFE) == 0xFFFE) - return false; - if ((ch >= 0xFDD0) && (ch <= 0xFDEF)) - return false; - if (ch > 0x10FFFF) - return false; - - return true; - } - - int Utf8BytesIndicated(char ch) { - int byteVal = static_cast(ch); - switch (byteVal >> 4) { - case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: - return 1; - case 12: case 13: - return 2; - case 14: - return 3; - case 15: - return 4; - default: - return -1; - } - } - - bool IsTrailingByte(char ch) { - return (ch & 0xC0) == 0x80; - } - - bool GetNextCodePointAndAdvance(int& codePoint, std::string::const_iterator& first, std::string::const_iterator last) { - if (first == last) - return false; - - int nBytes = Utf8BytesIndicated(*first); - if (nBytes < 1) { - // Bad lead byte - ++first; - codePoint = REPLACEMENT_CHARACTER; - return true; - } - - if (nBytes == 1) { - codePoint = *first++; - return true; - } - - // Gather bits from trailing bytes - codePoint = static_cast(*first) & ~(0xFF << (7 - nBytes)); - ++first; - --nBytes; - for (; nBytes > 0; ++first, --nBytes) { - if ((first == last) || !IsTrailingByte(*first)) { - codePoint = REPLACEMENT_CHARACTER; - break; - } - codePoint <<= 6; - codePoint |= *first & 0x3F; - } - - // Check for illegal code points - if (codePoint > 0x10FFFF) - codePoint = REPLACEMENT_CHARACTER; - else if (codePoint >= 0xD800 && codePoint <= 0xDFFF) - codePoint = REPLACEMENT_CHARACTER; - else if ((codePoint & 0xFFFE) == 0xFFFE) - codePoint = REPLACEMENT_CHARACTER; - else if (codePoint >= 0xFDD0 && codePoint <= 0xFDEF) - codePoint = REPLACEMENT_CHARACTER; - return true; - } - - void WriteCodePoint(ostream& out, int codePoint) { - if (codePoint < 0 || codePoint > 0x10FFFF) { - codePoint = REPLACEMENT_CHARACTER; - } - if (codePoint < 0x7F) { - out << static_cast(codePoint); - } else if (codePoint < 0x7FF) { - out << static_cast(0xC0 | (codePoint >> 6)) - << static_cast(0x80 | (codePoint & 0x3F)); - } else if (codePoint < 0xFFFF) { - out << static_cast(0xE0 | (codePoint >> 12)) - << static_cast(0x80 | ((codePoint >> 6) & 0x3F)) - << static_cast(0x80 | (codePoint & 0x3F)); - } else { - out << static_cast(0xF0 | (codePoint >> 18)) - << static_cast(0x80 | ((codePoint >> 12) & 0x3F)) - << static_cast(0x80 | ((codePoint >> 6) & 0x3F)) - << static_cast(0x80 | (codePoint & 0x3F)); - } - } - - bool IsValidPlainScalar(const std::string& str, bool inFlow, bool allowOnlyAscii) { - if(str.empty()) - return false; - - // first check the start - const RegEx& start = (inFlow ? Exp::PlainScalarInFlow() : Exp::PlainScalar()); - if(!start.Matches(str)) - return false; - - // and check the end for plain whitespace (which can't be faithfully kept in a plain scalar) - if(!str.empty() && *str.rbegin() == ' ') - return false; - - // then check until something is disallowed - const RegEx& disallowed = (inFlow ? Exp::EndScalarInFlow() : Exp::EndScalar()) - || (Exp::BlankOrBreak() + Exp::Comment()) - || Exp::NotPrintable() - || Exp::Utf8_ByteOrderMark() - || Exp::Break() - || Exp::Tab(); - StringCharSource buffer(str.c_str(), str.size()); - while(buffer) { - if(disallowed.Matches(buffer)) - return false; - if(allowOnlyAscii && (0x7F < static_cast(buffer[0]))) - return false; - ++buffer; - } - - return true; - } - - void WriteDoubleQuoteEscapeSequence(ostream& out, int codePoint) { - static const char hexDigits[] = "0123456789abcdef"; - - char escSeq[] = "\\U00000000"; - int digits = 8; - if (codePoint < 0xFF) { - escSeq[1] = 'x'; - digits = 2; - } else if (codePoint < 0xFFFF) { - escSeq[1] = 'u'; - digits = 4; - } - - // Write digits into the escape sequence - int i = 2; - for (; digits > 0; --digits, ++i) { - escSeq[i] = hexDigits[(codePoint >> (4 * (digits - 1))) & 0xF]; - } - - escSeq[i] = 0; // terminate with NUL character - out << escSeq; - } - - bool WriteAliasName(ostream& out, const std::string& str) { - int codePoint; - for(std::string::const_iterator i = str.begin(); - GetNextCodePointAndAdvance(codePoint, i, str.end()); - ) - { - if (!IsAnchorChar(codePoint)) - return false; - - WriteCodePoint(out, codePoint); - } - return true; - } - } - - bool WriteString(ostream& out, const std::string& str, bool inFlow, bool escapeNonAscii) - { - if(IsValidPlainScalar(str, inFlow, escapeNonAscii)) { - out << str; - return true; - } else - return WriteDoubleQuotedString(out, str, escapeNonAscii); - } - - bool WriteSingleQuotedString(ostream& out, const std::string& str) - { - out << "'"; - int codePoint; - for(std::string::const_iterator i = str.begin(); - GetNextCodePointAndAdvance(codePoint, i, str.end()); - ) - { - if (codePoint == '\n') - return false; // We can't handle a new line and the attendant indentation yet - - if (codePoint == '\'') - out << "''"; - else - WriteCodePoint(out, codePoint); - } - out << "'"; - return true; - } - - bool WriteDoubleQuotedString(ostream& out, const std::string& str, bool escapeNonAscii) - { - out << "\""; - int codePoint; - for(std::string::const_iterator i = str.begin(); - GetNextCodePointAndAdvance(codePoint, i, str.end()); - ) - { - if (codePoint == '\"') - out << "\\\""; - else if (codePoint == '\\') - out << "\\\\"; - else if (codePoint < 0x20 || (codePoint >= 0x80 && codePoint <= 0xA0)) // Control characters and non-breaking space - WriteDoubleQuoteEscapeSequence(out, codePoint); - else if (codePoint == 0xFEFF) // Byte order marks (ZWNS) should be escaped (YAML 1.2, sec. 5.2) - WriteDoubleQuoteEscapeSequence(out, codePoint); - else if (escapeNonAscii && codePoint > 0x7E) - WriteDoubleQuoteEscapeSequence(out, codePoint); - else - WriteCodePoint(out, codePoint); - } - out << "\""; - return true; - } - - bool WriteLiteralString(ostream& out, const std::string& str, int indent) - { - out << "|\n"; - out << IndentTo(indent); - int codePoint; - for(std::string::const_iterator i = str.begin(); - GetNextCodePointAndAdvance(codePoint, i, str.end()); - ) - { - if (codePoint == '\n') - out << "\n" << IndentTo(indent); - else - WriteCodePoint(out, codePoint); - } - return true; - } - - bool WriteChar(ostream& out, char ch) - { - if(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z')) - out << ch; - else if((0x20 <= ch && ch <= 0x7e) || ch == ' ') - out << "\"" << ch << "\""; - else if(ch == '\t') - out << "\"\\t\""; - else if(ch == '\n') - out << "\"\\n\""; - else if(ch == '\b') - out << "\"\\b\""; - else { - out << "\""; - WriteDoubleQuoteEscapeSequence(out, ch); - out << "\""; - } - return true; - } - - bool WriteComment(ostream& out, const std::string& str, int postCommentIndent) - { - const unsigned curIndent = out.col(); - out << "#" << Indentation(postCommentIndent); - int codePoint; - for(std::string::const_iterator i = str.begin(); - GetNextCodePointAndAdvance(codePoint, i, str.end()); - ) - { - if(codePoint == '\n') - out << "\n" << IndentTo(curIndent) << "#" << Indentation(postCommentIndent); - else - WriteCodePoint(out, codePoint); - } - return true; - } - - bool WriteAlias(ostream& out, const std::string& str) - { - out << "*"; - return WriteAliasName(out, str); - } - - bool WriteAnchor(ostream& out, const std::string& str) - { - out << "&"; - return WriteAliasName(out, str); - } - - bool WriteTag(ostream& out, const std::string& str, bool verbatim) - { - out << (verbatim ? "!<" : "!"); - StringCharSource buffer(str.c_str(), str.size()); - const RegEx& reValid = verbatim ? Exp::URI() : Exp::Tag(); - while(buffer) { - int n = reValid.Match(buffer); - if(n <= 0) - return false; - - while(--n >= 0) { - out << buffer[0]; - ++buffer; - } - } - if (verbatim) - out << ">"; - return true; - } - - bool WriteTagWithPrefix(ostream& out, const std::string& prefix, const std::string& tag) - { - out << "!"; - StringCharSource prefixBuffer(prefix.c_str(), prefix.size()); - while(prefixBuffer) { - int n = Exp::URI().Match(prefixBuffer); - if(n <= 0) - return false; - - while(--n >= 0) { - out << prefixBuffer[0]; - ++prefixBuffer; - } - } - - out << "!"; - StringCharSource tagBuffer(tag.c_str(), tag.size()); - while(tagBuffer) { - int n = Exp::Tag().Match(tagBuffer); - if(n <= 0) - return false; - - while(--n >= 0) { - out << tagBuffer[0]; - ++tagBuffer; - } - } - return true; - } - - bool WriteBinary(ostream& out, const Binary& binary) - { - WriteDoubleQuotedString(out, EncodeBase64(binary.data(), binary.size()), false); - return true; - } - } -} - diff --git a/contrib/yaml-cpp-pm/src/emitterutils.h b/contrib/yaml-cpp-pm/src/emitterutils.h deleted file mode 100644 index ed9a42fe0..000000000 --- a/contrib/yaml-cpp-pm/src/emitterutils.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp-pm/ostream.h" -#include - -namespace YAML_PM -{ - class Binary; - - namespace Utils - { - bool WriteString(ostream& out, const std::string& str, bool inFlow, bool escapeNonAscii); - bool WriteSingleQuotedString(ostream& out, const std::string& str); - bool WriteDoubleQuotedString(ostream& out, const std::string& str, bool escapeNonAscii); - bool WriteLiteralString(ostream& out, const std::string& str, int indent); - bool WriteChar(ostream& out, char ch); - bool WriteComment(ostream& out, const std::string& str, int postCommentIndent); - bool WriteAlias(ostream& out, const std::string& str); - bool WriteAnchor(ostream& out, const std::string& str); - bool WriteTag(ostream& out, const std::string& str, bool verbatim); - bool WriteTagWithPrefix(ostream& out, const std::string& prefix, const std::string& tag); - bool WriteBinary(ostream& out, const Binary& binary); - } -} - -#endif // EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/exp.cpp b/contrib/yaml-cpp-pm/src/exp.cpp deleted file mode 100644 index a6b01af05..000000000 --- a/contrib/yaml-cpp-pm/src/exp.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include "exp.h" -#include "yaml-cpp-pm/exceptions.h" -#include - -namespace YAML_PM -{ - namespace Exp - { - unsigned ParseHex(const std::string& str, const Mark& mark) - { - unsigned value = 0; - for(std::size_t i=0;i(ch)); - } - - // Escape - // . Translates the next 'codeLength' characters into a hex number and returns the result. - // . Throws if it's not actually hex. - std::string Escape(Stream& in, int codeLength) - { - // grab string - std::string str; - for(int i=0;i= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF) { - std::stringstream msg; - msg << ErrorMsg::INVALID_UNICODE << value; - throw ParserException(in.mark(), msg.str()); - } - - // now break it up into chars - if(value <= 0x7F) - return Str(value); - else if(value <= 0x7FF) - return Str(0xC0 + (value >> 6)) + Str(0x80 + (value & 0x3F)); - else if(value <= 0xFFFF) - return Str(0xE0 + (value >> 12)) + Str(0x80 + ((value >> 6) & 0x3F)) + Str(0x80 + (value & 0x3F)); - else - return Str(0xF0 + (value >> 18)) + Str(0x80 + ((value >> 12) & 0x3F)) + - Str(0x80 + ((value >> 6) & 0x3F)) + Str(0x80 + (value & 0x3F)); - } - - // Escape - // . Escapes the sequence starting 'in' (it must begin with a '\' or single quote) - // and returns the result. - // . Throws if it's an unknown escape character. - std::string Escape(Stream& in) - { - // eat slash - char escape = in.get(); - - // switch on escape character - char ch = in.get(); - - // first do single quote, since it's easier - if(escape == '\'' && ch == '\'') - return "\'"; - - // now do the slash (we're not gonna check if it's a slash - you better pass one!) - switch(ch) { - case '0': return std::string(1, '\x00'); - case 'a': return "\x07"; - case 'b': return "\x08"; - case 't': - case '\t': return "\x09"; - case 'n': return "\x0A"; - case 'v': return "\x0B"; - case 'f': return "\x0C"; - case 'r': return "\x0D"; - case 'e': return "\x1B"; - case ' ': return "\x20"; - case '\"': return "\""; - case '\'': return "\'"; - case '\\': return "\\"; - case '/': return "/"; - case 'N': return "\x85"; - case '_': return "\xA0"; - case 'L': return "\xE2\x80\xA8"; // LS (#x2028) - case 'P': return "\xE2\x80\xA9"; // PS (#x2029) - case 'x': return Escape(in, 2); - case 'u': return Escape(in, 4); - case 'U': return Escape(in, 8); - } - - std::stringstream msg; - throw ParserException(in.mark(), std::string(ErrorMsg::INVALID_ESCAPE) + ch); - } - } -} diff --git a/contrib/yaml-cpp-pm/src/exp.h b/contrib/yaml-cpp-pm/src/exp.h deleted file mode 100644 index e05adf7d3..000000000 --- a/contrib/yaml-cpp-pm/src/exp.h +++ /dev/null @@ -1,196 +0,0 @@ -#ifndef EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "regex.h" -#include -#include -#include "stream.h" - -namespace YAML_PM -{ - //////////////////////////////////////////////////////////////////////////////// - // Here we store a bunch of expressions for matching different parts of the file. - - namespace Exp - { - // misc - inline const RegEx& Space() { - static const RegEx e = RegEx(' '); - return e; - } - inline const RegEx& Tab() { - static const RegEx e = RegEx('\t'); - return e; - } - inline const RegEx& Blank() { - static const RegEx e = Space() || Tab(); - return e; - } - inline const RegEx& Break() { - static const RegEx e = RegEx('\n') || RegEx("\r\n"); - return e; - } - inline const RegEx& BlankOrBreak() { - static const RegEx e = Blank() || Break(); - return e; - } - inline const RegEx& Digit() { - static const RegEx e = RegEx('0', '9'); - return e; - } - inline const RegEx& Alpha() { - static const RegEx e = RegEx('a', 'z') || RegEx('A', 'Z'); - return e; - } - inline const RegEx& AlphaNumeric() { - static const RegEx e = Alpha() || Digit(); - return e; - } - inline const RegEx& Word() { - static const RegEx e = AlphaNumeric() || RegEx('-'); - return e; - } - inline const RegEx& Hex() { - static const RegEx e = Digit() || RegEx('A', 'F') || RegEx('a', 'f'); - return e; - } - // Valid Unicode code points that are not part of c-printable (YAML 1.2, sec. 5.1) - inline const RegEx& NotPrintable() { - static const RegEx e = RegEx(0) || - RegEx("\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x7F", REGEX_OR) || - RegEx(0x0E, 0x1F) || - (RegEx('\xC2') + (RegEx('\x80', '\x84') || RegEx('\x86', '\x9F'))); - return e; - } - inline const RegEx& Utf8_ByteOrderMark() { - static const RegEx e = RegEx("\xEF\xBB\xBF"); - return e; - } - - // actual tags - - inline const RegEx& DocStart() { - static const RegEx e = RegEx("---") + (BlankOrBreak() || RegEx()); - return e; - } - inline const RegEx& DocEnd() { - static const RegEx e = RegEx("...") + (BlankOrBreak() || RegEx()); - return e; - } - inline const RegEx& DocIndicator() { - static const RegEx e = DocStart() || DocEnd(); - return e; - } - inline const RegEx& BlockEntry() { - static const RegEx e = RegEx('-') + (BlankOrBreak() || RegEx()); - return e; - } - inline const RegEx& Key() { - static const RegEx e = RegEx('?'); - return e; - } - inline const RegEx& KeyInFlow() { - static const RegEx e = RegEx('?') + BlankOrBreak(); - return e; - } - inline const RegEx& Value() { - static const RegEx e = RegEx(':') + (BlankOrBreak() || RegEx()); - return e; - } - inline const RegEx& ValueInFlow() { - static const RegEx e = RegEx(':') + (BlankOrBreak() || RegEx(",}", REGEX_OR)); - return e; - } - inline const RegEx& ValueInJSONFlow() { - static const RegEx e = RegEx(':'); - return e; - } - inline const RegEx Comment() { - static const RegEx e = RegEx('#'); - return e; - } - inline const RegEx& Anchor() { - static const RegEx e = !(RegEx("[]{},", REGEX_OR) || BlankOrBreak()); - return e; - } - inline const RegEx& AnchorEnd() { - static const RegEx e = RegEx("?:,]}%@`", REGEX_OR) || BlankOrBreak(); - return e; - } - inline const RegEx& URI() { - static const RegEx e = Word() || RegEx("#;/?:@&=+$,_.!~*'()[]", REGEX_OR) || (RegEx('%') + Hex() + Hex()); - return e; - } - inline const RegEx& Tag() { - static const RegEx e = Word() || RegEx("#;/?:@&=+$_.~*'", REGEX_OR) || (RegEx('%') + Hex() + Hex()); - return e; - } - - // Plain scalar rules: - // . Cannot start with a blank. - // . Can never start with any of , [ ] { } # & * ! | > \' \" % @ ` - // . In the block context - ? : must be not be followed with a space. - // . In the flow context ? is illegal and : and - must not be followed with a space. - inline const RegEx& PlainScalar() { - static const RegEx e = !(BlankOrBreak() || RegEx(",[]{}#&*!|>\'\"%@`", REGEX_OR) || (RegEx("-?:", REGEX_OR) + (BlankOrBreak() || RegEx()))); - return e; - } - inline const RegEx& PlainScalarInFlow() { - static const RegEx e = !(BlankOrBreak() || RegEx("?,[]{}#&*!|>\'\"%@`", REGEX_OR) || (RegEx("-:", REGEX_OR) + Blank())); - return e; - } - inline const RegEx& EndScalar() { - static const RegEx e = RegEx(':') + (BlankOrBreak() || RegEx()); - return e; - } - inline const RegEx& EndScalarInFlow() { - static const RegEx e = (RegEx(':') + (BlankOrBreak() || RegEx() || RegEx(",]}", REGEX_OR))) || RegEx(",?[]{}", REGEX_OR); - return e; - } - - inline const RegEx& EscSingleQuote() { - static const RegEx e = RegEx("\'\'"); - return e; - } - inline const RegEx& EscBreak() { - static const RegEx e = RegEx('\\') + Break(); - return e; - } - - inline const RegEx& ChompIndicator() { - static const RegEx e = RegEx("+-", REGEX_OR); - return e; - } - inline const RegEx& Chomp() { - static const RegEx e = (ChompIndicator() + Digit()) || (Digit() + ChompIndicator()) || ChompIndicator() || Digit(); - return e; - } - - // and some functions - std::string Escape(Stream& in); - } - - namespace Keys - { - const char Directive = '%'; - const char FlowSeqStart = '['; - const char FlowSeqEnd = ']'; - const char FlowMapStart = '{'; - const char FlowMapEnd = '}'; - const char FlowEntry = ','; - const char Alias = '*'; - const char Anchor = '&'; - const char Tag = '!'; - const char LiteralScalar = '|'; - const char FoldedScalar = '>'; - const char VerbatimTagStart = '<'; - const char VerbatimTagEnd = '>'; - } -} - -#endif // EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/indentation.h b/contrib/yaml-cpp-pm/src/indentation.h deleted file mode 100644 index 62f11ed5b..000000000 --- a/contrib/yaml-cpp-pm/src/indentation.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp-pm/ostream.h" -#include - -namespace YAML_PM -{ - struct Indentation { - Indentation(unsigned n_): n(n_) {} - unsigned n; - }; - - inline ostream& operator << (ostream& out, const Indentation& indent) { - for(unsigned i=0;i pData): m_pData(pData) - { - } - - Iterator::Iterator(const Iterator& rhs): m_pData(new IterPriv(*rhs.m_pData)) - { - } - - Iterator& Iterator::operator = (const Iterator& rhs) - { - if(this == &rhs) - return *this; - - m_pData.reset(new IterPriv(*rhs.m_pData)); - return *this; - } - - Iterator::~Iterator() - { - } - - Iterator& Iterator::operator ++ () - { - if(m_pData->type == IterPriv::IT_SEQ) - ++m_pData->seqIter; - else if(m_pData->type == IterPriv::IT_MAP) - ++m_pData->mapIter; - - return *this; - } - - Iterator Iterator::operator ++ (int) - { - Iterator temp = *this; - - if(m_pData->type == IterPriv::IT_SEQ) - ++m_pData->seqIter; - else if(m_pData->type == IterPriv::IT_MAP) - ++m_pData->mapIter; - - return temp; - } - - const Node& Iterator::operator * () const - { - if(m_pData->type == IterPriv::IT_SEQ) - return **m_pData->seqIter; - - throw BadDereference(); - } - - const Node *Iterator::operator -> () const - { - if(m_pData->type == IterPriv::IT_SEQ) - return *m_pData->seqIter; - - throw BadDereference(); - } - - const Node& Iterator::first() const - { - if(m_pData->type == IterPriv::IT_MAP) - return *m_pData->mapIter->first; - - throw BadDereference(); - } - - const Node& Iterator::second() const - { - if(m_pData->type == IterPriv::IT_MAP) - return *m_pData->mapIter->second; - - throw BadDereference(); - } - - bool operator == (const Iterator& it, const Iterator& jt) - { - if(it.m_pData->type != jt.m_pData->type) - return false; - - if(it.m_pData->type == IterPriv::IT_SEQ) - return it.m_pData->seqIter == jt.m_pData->seqIter; - else if(it.m_pData->type == IterPriv::IT_MAP) - return it.m_pData->mapIter == jt.m_pData->mapIter; - - return true; - } - - bool operator != (const Iterator& it, const Iterator& jt) - { - return !(it == jt); - } -} diff --git a/contrib/yaml-cpp-pm/src/iterpriv.h b/contrib/yaml-cpp-pm/src/iterpriv.h deleted file mode 100644 index fe70d79e1..000000000 --- a/contrib/yaml-cpp-pm/src/iterpriv.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef ITERPRIV_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define ITERPRIV_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp-pm/ltnode.h" -#include -#include - -namespace YAML_PM -{ - class Node; - - // IterPriv - // . The implementation for iterators - essentially a union of sequence and map iterators. - struct IterPriv - { - IterPriv(): type(IT_NONE) {} - IterPriv(std::vector ::const_iterator it): type(IT_SEQ), seqIter(it) {} - IterPriv(std::map ::const_iterator it): type(IT_MAP), mapIter(it) {} - - enum ITER_TYPE { IT_NONE, IT_SEQ, IT_MAP }; - ITER_TYPE type; - - std::vector ::const_iterator seqIter; - std::map ::const_iterator mapIter; - }; -} - -#endif // ITERPRIV_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/node.cpp b/contrib/yaml-cpp-pm/src/node.cpp deleted file mode 100644 index ceae83d76..000000000 --- a/contrib/yaml-cpp-pm/src/node.cpp +++ /dev/null @@ -1,269 +0,0 @@ -#include "yaml-cpp-pm/node.h" -#include "yaml-cpp-pm/aliasmanager.h" -#include "yaml-cpp-pm/emitfromevents.h" -#include "yaml-cpp-pm/emitter.h" -#include "yaml-cpp-pm/eventhandler.h" -#include "iterpriv.h" -#include "nodebuilder.h" -#include "nodeownership.h" -#include "scanner.h" -#include "tag.h" -#include "token.h" -#include -#include - -namespace YAML_PM -{ - bool ltnode::operator()(const Node *pNode1, const Node *pNode2) const { - return *pNode1 < *pNode2; - } - - Node::Node(): m_pOwnership(new NodeOwnership), m_type(NodeType::Null) - { - } - - Node::Node(NodeOwnership& owner): m_pOwnership(new NodeOwnership(&owner)), m_type(NodeType::Null) - { - } - - Node::~Node() - { - Clear(); - } - - void Node::Clear() - { - m_pOwnership.reset(new NodeOwnership); - m_type = NodeType::Null; - m_tag.clear(); - m_scalarData.clear(); - m_seqData.clear(); - m_mapData.clear(); - } - - bool Node::IsAliased() const - { - return m_pOwnership->IsAliased(*this); - } - - Node& Node::CreateNode() - { - return m_pOwnership->Create(); - } - - std::auto_ptr Node::Clone() const - { - std::auto_ptr pNode(new Node); - NodeBuilder nodeBuilder(*pNode); - EmitEvents(nodeBuilder); - return pNode; - } - - void Node::EmitEvents(EventHandler& eventHandler) const - { - eventHandler.OnDocumentStart(m_mark); - AliasManager am; - EmitEvents(am, eventHandler); - eventHandler.OnDocumentEnd(); - } - - void Node::EmitEvents(AliasManager& am, EventHandler& eventHandler) const - { - anchor_t anchor = NullAnchor; - if(IsAliased()) { - anchor = am.LookupAnchor(*this); - if(anchor) { - eventHandler.OnAlias(m_mark, anchor); - return; - } - - am.RegisterReference(*this); - anchor = am.LookupAnchor(*this); - } - - switch(m_type) { - case NodeType::Null: - eventHandler.OnNull(m_mark, anchor); - break; - case NodeType::Scalar: - eventHandler.OnScalar(m_mark, m_tag, anchor, m_scalarData); - break; - case NodeType::Sequence: - eventHandler.OnSequenceStart(m_mark, m_tag, anchor); - for(std::size_t i=0;iEmitEvents(am, eventHandler); - eventHandler.OnSequenceEnd(); - break; - case NodeType::Map: - eventHandler.OnMapStart(m_mark, m_tag, anchor); - for(node_map::const_iterator it=m_mapData.begin();it!=m_mapData.end();++it) { - it->first->EmitEvents(am, eventHandler); - it->second->EmitEvents(am, eventHandler); - } - eventHandler.OnMapEnd(); - break; - } - } - - void Node::Init(NodeType::value type, const Mark& mark, const std::string& tag) - { - Clear(); - m_mark = mark; - m_type = type; - m_tag = tag; - } - - void Node::MarkAsAliased() - { - m_pOwnership->MarkAsAliased(*this); - } - - void Node::SetScalarData(const std::string& data) - { - assert(m_type == NodeType::Scalar); // TODO: throw? - m_scalarData = data; - } - - void Node::Append(Node& node) - { - assert(m_type == NodeType::Sequence); // TODO: throw? - m_seqData.push_back(&node); - } - - void Node::Insert(Node& key, Node& value) - { - assert(m_type == NodeType::Map); // TODO: throw? - m_mapData[&key] = &value; - } - - // begin - // Returns an iterator to the beginning of this (sequence or map). - Iterator Node::begin() const - { - switch(m_type) { - case NodeType::Null: - case NodeType::Scalar: - return Iterator(); - case NodeType::Sequence: - return Iterator(std::auto_ptr(new IterPriv(m_seqData.begin()))); - case NodeType::Map: - return Iterator(std::auto_ptr(new IterPriv(m_mapData.begin()))); - } - - assert(false); - return Iterator(); - } - - // end - // . Returns an iterator to the end of this (sequence or map). - Iterator Node::end() const - { - switch(m_type) { - case NodeType::Null: - case NodeType::Scalar: - return Iterator(); - case NodeType::Sequence: - return Iterator(std::auto_ptr(new IterPriv(m_seqData.end()))); - case NodeType::Map: - return Iterator(std::auto_ptr(new IterPriv(m_mapData.end()))); - } - - assert(false); - return Iterator(); - } - - // size - // . Returns the size of a sequence or map node - // . Otherwise, returns zero. - std::size_t Node::size() const - { - switch(m_type) { - case NodeType::Null: - case NodeType::Scalar: - return 0; - case NodeType::Sequence: - return m_seqData.size(); - case NodeType::Map: - return m_mapData.size(); - } - - assert(false); - return 0; - } - - const Node *Node::FindAtIndex(std::size_t i) const - { - if(m_type == NodeType::Sequence) - return m_seqData[i]; - return 0; - } - - bool Node::GetScalar(std::string& s) const - { - switch(m_type) { - case NodeType::Null: - s = "~"; - return true; - case NodeType::Scalar: - s = m_scalarData; - return true; - case NodeType::Sequence: - case NodeType::Map: - return false; - } - - assert(false); - return false; - } - - Emitter& operator << (Emitter& out, const Node& node) - { - EmitFromEvents emitFromEvents(out); - node.EmitEvents(emitFromEvents); - return out; - } - - int Node::Compare(const Node& rhs) const - { - if(m_type != rhs.m_type) - return rhs.m_type - m_type; - - switch(m_type) { - case NodeType::Null: - return 0; - case NodeType::Scalar: - return m_scalarData.compare(rhs.m_scalarData); - case NodeType::Sequence: - if(m_seqData.size() < rhs.m_seqData.size()) - return 1; - else if(m_seqData.size() > rhs.m_seqData.size()) - return -1; - for(std::size_t i=0;iCompare(*rhs.m_seqData[i])) - return cmp; - return 0; - case NodeType::Map: - if(m_mapData.size() < rhs.m_mapData.size()) - return 1; - else if(m_mapData.size() > rhs.m_mapData.size()) - return -1; - node_map::const_iterator it = m_mapData.begin(); - node_map::const_iterator jt = rhs.m_mapData.begin(); - for(;it!=m_mapData.end() && jt!=rhs.m_mapData.end();it++, jt++) { - if(int cmp = it->first->Compare(*jt->first)) - return cmp; - if(int cmp = it->second->Compare(*jt->second)) - return cmp; - } - return 0; - } - - assert(false); - return 0; - } - - bool operator < (const Node& n1, const Node& n2) - { - return n1.Compare(n2) < 0; - } -} diff --git a/contrib/yaml-cpp-pm/src/nodebuilder.cpp b/contrib/yaml-cpp-pm/src/nodebuilder.cpp deleted file mode 100644 index bc95fb9df..000000000 --- a/contrib/yaml-cpp-pm/src/nodebuilder.cpp +++ /dev/null @@ -1,145 +0,0 @@ -#include "nodebuilder.h" -#include "yaml-cpp-pm/mark.h" -#include "yaml-cpp-pm/node.h" -#include - -namespace YAML_PM -{ - NodeBuilder::NodeBuilder(Node& root): m_root(root), m_initializedRoot(false), m_finished(false) - { - m_root.Clear(); - m_anchors.push_back(0); // since the anchors start at 1 - } - - NodeBuilder::~NodeBuilder() - { - } - - void NodeBuilder::OnDocumentStart(const Mark&) - { - } - - void NodeBuilder::OnDocumentEnd() - { - assert(m_finished); - } - - void NodeBuilder::OnNull(const Mark& mark, anchor_t anchor) - { - Node& node = Push(anchor); - node.Init(NodeType::Null, mark, ""); - Pop(); - } - - void NodeBuilder::OnAlias(const Mark& /*mark*/, anchor_t anchor) - { - Node& node = *m_anchors[anchor]; - Insert(node); - node.MarkAsAliased(); - } - - void NodeBuilder::OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value) - { - Node& node = Push(anchor); - node.Init(NodeType::Scalar, mark, tag); - node.SetScalarData(value); - Pop(); - } - - void NodeBuilder::OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor) - { - Node& node = Push(anchor); - node.Init(NodeType::Sequence, mark, tag); - } - - void NodeBuilder::OnSequenceEnd() - { - Pop(); - } - - void NodeBuilder::OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor) - { - Node& node = Push(anchor); - node.Init(NodeType::Map, mark, tag); - m_didPushKey.push(false); - } - - void NodeBuilder::OnMapEnd() - { - m_didPushKey.pop(); - Pop(); - } - - Node& NodeBuilder::Push(anchor_t anchor) - { - Node& node = Push(); - RegisterAnchor(anchor, node); - return node; - } - - Node& NodeBuilder::Push() - { - if(!m_initializedRoot) { - m_initializedRoot = true; - return m_root; - } - - Node& node = m_root.CreateNode(); - m_stack.push(&node); - return node; - } - - Node& NodeBuilder::Top() - { - return m_stack.empty() ? m_root : *m_stack.top(); - } - - void NodeBuilder::Pop() - { - assert(!m_finished); - if(m_stack.empty()) { - m_finished = true; - return; - } - - Node& node = *m_stack.top(); - m_stack.pop(); - Insert(node); - } - - void NodeBuilder::Insert(Node& node) - { - Node& curTop = Top(); - switch(curTop.Type()) { - case NodeType::Null: - case NodeType::Scalar: - assert(false); - break; - case NodeType::Sequence: - curTop.Append(node); - break; - case NodeType::Map: - assert(!m_didPushKey.empty()); - if(m_didPushKey.top()) { - assert(!m_pendingKeys.empty()); - - Node& key = *m_pendingKeys.top(); - m_pendingKeys.pop(); - curTop.Insert(key, node); - m_didPushKey.top() = false; - } else { - m_pendingKeys.push(&node); - m_didPushKey.top() = true; - } - break; - } - } - - void NodeBuilder::RegisterAnchor(anchor_t anchor, Node& node) - { - if(anchor) { - assert(anchor == m_anchors.size()); - m_anchors.push_back(&node); - } - } -} diff --git a/contrib/yaml-cpp-pm/src/nodebuilder.h b/contrib/yaml-cpp-pm/src/nodebuilder.h deleted file mode 100644 index 5c0f704a3..000000000 --- a/contrib/yaml-cpp-pm/src/nodebuilder.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp-pm/eventhandler.h" -#include -#include -#include -#include - -namespace YAML_PM -{ - class Node; - - class NodeBuilder: public EventHandler - { - public: - explicit NodeBuilder(Node& root); - virtual ~NodeBuilder(); - - virtual void OnDocumentStart(const Mark& mark); - virtual void OnDocumentEnd(); - - virtual void OnNull(const Mark& mark, anchor_t anchor); - virtual void OnAlias(const Mark& mark, anchor_t anchor); - virtual void OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value); - - virtual void OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor); - virtual void OnSequenceEnd(); - - virtual void OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor); - virtual void OnMapEnd(); - - private: - Node& Push(anchor_t anchor); - Node& Push(); - Node& Top(); - void Pop(); - - void Insert(Node& node); - void RegisterAnchor(anchor_t anchor, Node& node); - - private: - Node& m_root; - bool m_initializedRoot; - bool m_finished; - - std::stack m_stack; - std::stack m_pendingKeys; - std::stack m_didPushKey; - - typedef std::vector Anchors; - Anchors m_anchors; - }; -} - -#endif // NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - diff --git a/contrib/yaml-cpp-pm/src/nodeownership.cpp b/contrib/yaml-cpp-pm/src/nodeownership.cpp deleted file mode 100644 index e49d249a9..000000000 --- a/contrib/yaml-cpp-pm/src/nodeownership.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "nodeownership.h" -#include "yaml-cpp-pm/node.h" - -namespace YAML_PM -{ - NodeOwnership::NodeOwnership(NodeOwnership *pOwner): m_pOwner(pOwner) - { - if(!m_pOwner) - m_pOwner = this; - } - - NodeOwnership::~NodeOwnership() - { - } - - Node& NodeOwnership::_Create() - { - m_nodes.push_back(std::auto_ptr(new Node)); - return m_nodes.back(); - } - - void NodeOwnership::_MarkAsAliased(const Node& node) - { - m_aliasedNodes.insert(&node); - } - - bool NodeOwnership::_IsAliased(const Node& node) const - { - return m_aliasedNodes.count(&node) > 0; - } -} diff --git a/contrib/yaml-cpp-pm/src/nodeownership.h b/contrib/yaml-cpp-pm/src/nodeownership.h deleted file mode 100644 index fc5b29243..000000000 --- a/contrib/yaml-cpp-pm/src/nodeownership.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp-pm/noncopyable.h" -#include "ptr_vector.h" -#include - -namespace YAML_PM -{ - class Node; - - class NodeOwnership: private noncopyable - { - public: - explicit NodeOwnership(NodeOwnership *pOwner = 0); - ~NodeOwnership(); - - Node& Create() { return m_pOwner->_Create(); } - void MarkAsAliased(const Node& node) { m_pOwner->_MarkAsAliased(node); } - bool IsAliased(const Node& node) const { return m_pOwner->_IsAliased(node); } - - private: - Node& _Create(); - void _MarkAsAliased(const Node& node); - bool _IsAliased(const Node& node) const; - - private: - ptr_vector m_nodes; - std::set m_aliasedNodes; - NodeOwnership *m_pOwner; - }; -} - -#endif // NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/null.cpp b/contrib/yaml-cpp-pm/src/null.cpp deleted file mode 100644 index a0ea21e8c..000000000 --- a/contrib/yaml-cpp-pm/src/null.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "yaml-cpp-pm/null.h" -#include "yaml-cpp-pm/node.h" - -namespace YAML_PM -{ - _Null Null; - - bool IsNull(const Node& node) - { - return node.Read(Null); - } -} diff --git a/contrib/yaml-cpp-pm/src/ostream.cpp b/contrib/yaml-cpp-pm/src/ostream.cpp deleted file mode 100644 index 07cbde0a3..000000000 --- a/contrib/yaml-cpp-pm/src/ostream.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "yaml-cpp-pm/ostream.h" -#include - -namespace YAML_PM -{ - ostream::ostream(): m_buffer(0), m_pos(0), m_size(0), m_row(0), m_col(0) - { - reserve(1024); - } - - ostream::~ostream() - { - delete [] m_buffer; - } - - void ostream::reserve(unsigned size) - { - if(size <= m_size) - return; - - char *newBuffer = new char[size]; - std::memset(newBuffer, 0, size * sizeof(char)); - std::memcpy(newBuffer, m_buffer, m_size * sizeof(char)); - delete [] m_buffer; - m_buffer = newBuffer; - m_size = size; - } - - void ostream::put(char ch) - { - if(m_pos >= m_size - 1) // an extra space for the NULL terminator - reserve(m_size * 2); - - m_buffer[m_pos] = ch; - m_pos++; - - if(ch == '\n') { - m_row++; - m_col = 0; - } else - m_col++; - } - - ostream& operator << (ostream& out, const char *str) - { - std::size_t length = std::strlen(str); - for(std::size_t i=0;i -#include - -namespace YAML_PM -{ - Parser::Parser() - { - } - - Parser::Parser(std::istream& in) - { - Load(in); - } - - Parser::~Parser() - { - } - - Parser::operator bool() const - { - return m_pScanner.get() && !m_pScanner->empty(); - } - - void Parser::Load(std::istream& in) - { - m_pScanner.reset(new Scanner(in)); - m_pDirectives.reset(new Directives); - } - - // HandleNextDocument - // . Handles the next document - // . Throws a ParserException on error. - // . Returns false if there are no more documents - bool Parser::HandleNextDocument(EventHandler& eventHandler) - { - if(!m_pScanner.get()) - return false; - - ParseDirectives(); - if(m_pScanner->empty()) - return false; - - SingleDocParser sdp(*m_pScanner, *m_pDirectives); - sdp.HandleDocument(eventHandler); - return true; - } - - // GetNextDocument - // . Reads the next document in the queue (of tokens). - // . Throws a ParserException on error. - bool Parser::GetNextDocument(Node& document) - { - NodeBuilder builder(document); - return HandleNextDocument(builder); - } - - // ParseDirectives - // . Reads any directives that are next in the queue. - void Parser::ParseDirectives() - { - bool readDirective = false; - - while(1) { - if(m_pScanner->empty()) - break; - - Token& token = m_pScanner->peek(); - if(token.type != Token::DIRECTIVE) - break; - - // we keep the directives from the last document if none are specified; - // but if any directives are specific, then we reset them - if(!readDirective) - m_pDirectives.reset(new Directives); - - readDirective = true; - HandleDirective(token); - m_pScanner->pop(); - } - } - - void Parser::HandleDirective(const Token& token) - { - if(token.value == "YAML") - HandleYamlDirective(token); - else if(token.value == "TAG") - HandleTagDirective(token); - } - - // HandleYamlDirective - // . Should be of the form 'major.minor' (like a version number) - void Parser::HandleYamlDirective(const Token& token) - { - if(token.params.size() != 1) - throw ParserException(token.mark, ErrorMsg::YAML_DIRECTIVE_ARGS); - - if(!m_pDirectives->version.isDefault) - throw ParserException(token.mark, ErrorMsg::REPEATED_YAML_DIRECTIVE); - - std::stringstream str(token.params[0]); - str >> m_pDirectives->version.major; - str.get(); - str >> m_pDirectives->version.minor; - if(!str || str.peek() != EOF) - throw ParserException(token.mark, std::string(ErrorMsg::YAML_VERSION) + token.params[0]); - - if(m_pDirectives->version.major > 1) - throw ParserException(token.mark, ErrorMsg::YAML_MAJOR_VERSION); - - m_pDirectives->version.isDefault = false; - // TODO: warning on major == 1, minor > 2? - } - - // HandleTagDirective - // . Should be of the form 'handle prefix', where 'handle' is converted to 'prefix' in the file. - void Parser::HandleTagDirective(const Token& token) - { - if(token.params.size() != 2) - throw ParserException(token.mark, ErrorMsg::TAG_DIRECTIVE_ARGS); - - const std::string& handle = token.params[0]; - const std::string& prefix = token.params[1]; - if(m_pDirectives->tags.find(handle) != m_pDirectives->tags.end()) - throw ParserException(token.mark, ErrorMsg::REPEATED_TAG_DIRECTIVE); - - m_pDirectives->tags[handle] = prefix; - } - - void Parser::PrintTokens(std::ostream& out) - { - if(!m_pScanner.get()) - return; - - while(1) { - if(m_pScanner->empty()) - break; - - out << m_pScanner->peek() << "\n"; - m_pScanner->pop(); - } - } -} diff --git a/contrib/yaml-cpp-pm/src/ptr_stack.h b/contrib/yaml-cpp-pm/src/ptr_stack.h deleted file mode 100644 index a45b77fc5..000000000 --- a/contrib/yaml-cpp-pm/src/ptr_stack.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp-pm/noncopyable.h" -#include -#include -#include -#include - -template -class ptr_stack: private YAML_PM::noncopyable -{ -public: - ptr_stack() {} - ~ptr_stack() { clear(); } - - void clear() { - for(unsigned i=0;i t) { - m_data.push_back(NULL); - m_data.back() = t.release(); - } - std::auto_ptr pop() { - std::auto_ptr t(m_data.back()); - m_data.pop_back(); - return t; - } - T& top() { return *m_data.back(); } - const T& top() const { return *m_data.back(); } - -private: - std::vector m_data; -}; - -#endif // PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/ptr_vector.h b/contrib/yaml-cpp-pm/src/ptr_vector.h deleted file mode 100644 index 37f13f596..000000000 --- a/contrib/yaml-cpp-pm/src/ptr_vector.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp-pm/noncopyable.h" -#include -#include -#include -#include - -namespace YAML_PM { - - template - class ptr_vector: private YAML_PM::noncopyable - { - public: - ptr_vector() {} - ~ptr_vector() { clear(); } - - void clear() { - for(unsigned i=0;i t) { - m_data.push_back(NULL); - m_data.back() = t.release(); - } - T& operator[](std::size_t i) { return *m_data[i]; } - const T& operator[](std::size_t i) const { return *m_data[i]; } - - T& back() { return *m_data.back(); } - const T& back() const { return *m_data.back(); } - - private: - std::vector m_data; - }; -} - -#endif // PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/regex.cpp b/contrib/yaml-cpp-pm/src/regex.cpp deleted file mode 100644 index 28b1dbeca..000000000 --- a/contrib/yaml-cpp-pm/src/regex.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "regex.h" - -namespace YAML_PM -{ - // constructors - RegEx::RegEx(): m_op(REGEX_EMPTY) - { - } - - RegEx::RegEx(REGEX_OP op): m_op(op) - { - } - - RegEx::RegEx(char ch): m_op(REGEX_MATCH), m_a(ch) - { - } - - RegEx::RegEx(char a, char z): m_op(REGEX_RANGE), m_a(a), m_z(z) - { - } - - RegEx::RegEx(const std::string& str, REGEX_OP op): m_op(op) - { - for(std::size_t i=0;i= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include -#include - -namespace YAML_PM -{ - class Stream; - - enum REGEX_OP { REGEX_EMPTY, REGEX_MATCH, REGEX_RANGE, REGEX_OR, REGEX_AND, REGEX_NOT, REGEX_SEQ }; - - // simplified regular expressions - // . Only straightforward matches (no repeated characters) - // . Only matches from start of string - class RegEx - { - public: - RegEx(); - RegEx(char ch); - RegEx(char a, char z); - RegEx(const std::string& str, REGEX_OP op = REGEX_SEQ); - ~RegEx() {} - - friend RegEx operator ! (const RegEx& ex); - friend RegEx operator || (const RegEx& ex1, const RegEx& ex2); - friend RegEx operator && (const RegEx& ex1, const RegEx& ex2); - friend RegEx operator + (const RegEx& ex1, const RegEx& ex2); - - bool Matches(char ch) const; - bool Matches(const std::string& str) const; - bool Matches(const Stream& in) const; - template bool Matches(const Source& source) const; - - int Match(const std::string& str) const; - int Match(const Stream& in) const; - template int Match(const Source& source) const; - - private: - RegEx(REGEX_OP op); - - template bool IsValidSource(const Source& source) const; - template int MatchUnchecked(const Source& source) const; - - template int MatchOpEmpty(const Source& source) const; - template int MatchOpMatch(const Source& source) const; - template int MatchOpRange(const Source& source) const; - template int MatchOpOr(const Source& source) const; - template int MatchOpAnd(const Source& source) const; - template int MatchOpNot(const Source& source) const; - template int MatchOpSeq(const Source& source) const; - - private: - REGEX_OP m_op; - char m_a, m_z; - std::vector m_params; - }; -} - -#include "regeximpl.h" - -#endif // REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/regeximpl.h b/contrib/yaml-cpp-pm/src/regeximpl.h deleted file mode 100644 index b19308bd8..000000000 --- a/contrib/yaml-cpp-pm/src/regeximpl.h +++ /dev/null @@ -1,186 +0,0 @@ -#ifndef REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "stream.h" -#include "stringsource.h" -#include "streamcharsource.h" - -namespace YAML_PM -{ - // query matches - inline bool RegEx::Matches(char ch) const { - std::string str; - str += ch; - return Matches(str); - } - - inline bool RegEx::Matches(const std::string& str) const { - return Match(str) >= 0; - } - - inline bool RegEx::Matches(const Stream& in) const { - return Match(in) >= 0; - } - - template - inline bool RegEx::Matches(const Source& source) const { - return Match(source) >= 0; - } - - // Match - // . Matches the given string against this regular expression. - // . Returns the number of characters matched. - // . Returns -1 if no characters were matched (the reason for - // not returning zero is that we may have an empty regex - // which is ALWAYS successful at matching zero characters). - // . REMEMBER that we only match from the start of the buffer! - inline int RegEx::Match(const std::string& str) const - { - StringCharSource source(str.c_str(), str.size()); - return Match(source); - } - - inline int RegEx::Match(const Stream& in) const - { - StreamCharSource source(in); - return Match(source); - } - - template - inline bool RegEx::IsValidSource(const Source& source) const - { - return source; - } - - template<> - inline bool RegEx::IsValidSource(const StringCharSource&source) const - { - switch(m_op) { - case REGEX_MATCH: - case REGEX_RANGE: - return source; - default: - return true; - } - } - - template - inline int RegEx::Match(const Source& source) const - { - return IsValidSource(source) ? MatchUnchecked(source) : -1; - } - - template - inline int RegEx::MatchUnchecked(const Source& source) const - { - switch(m_op) { - case REGEX_EMPTY: - return MatchOpEmpty(source); - case REGEX_MATCH: - return MatchOpMatch(source); - case REGEX_RANGE: - return MatchOpRange(source); - case REGEX_OR: - return MatchOpOr(source); - case REGEX_AND: - return MatchOpAnd(source); - case REGEX_NOT: - return MatchOpNot(source); - case REGEX_SEQ: - return MatchOpSeq(source); - } - - return -1; - } - - ////////////////////////////////////////////////////////////////////////////// - // Operators - // Note: the convention MatchOp* is that we can assume IsSourceValid(source). - // So we do all our checks *before* we call these functions - - // EmptyOperator - template - inline int RegEx::MatchOpEmpty(const Source& source) const { - return source[0] == Stream::eof() ? 0 : -1; - } - - template <> - inline int RegEx::MatchOpEmpty(const StringCharSource& source) const { - return !source ? 0 : -1; // the empty regex only is successful on the empty string - } - - // MatchOperator - template - inline int RegEx::MatchOpMatch(const Source& source) const { - if(source[0] != m_a) - return -1; - return 1; - } - - // RangeOperator - template - inline int RegEx::MatchOpRange(const Source& source) const { - if(m_a > source[0] || m_z < source[0]) - return -1; - return 1; - } - - // OrOperator - template - inline int RegEx::MatchOpOr(const Source& source) const { - for(std::size_t i=0;i= 0) - return n; - } - return -1; - } - - // AndOperator - // Note: 'AND' is a little funny, since we may be required to match things - // of different lengths. If we find a match, we return the length of - // the FIRST entry on the list. - template - inline int RegEx::MatchOpAnd(const Source& source) const { - int first = -1; - for(std::size_t i=0;i - inline int RegEx::MatchOpNot(const Source& source) const { - if(m_params.empty()) - return -1; - if(m_params[0].MatchUnchecked(source) >= 0) - return -1; - return 1; - } - - // SeqOperator - template - inline int RegEx::MatchOpSeq(const Source& source) const { - int offset = 0; - for(std::size_t i=0;i -#include - -namespace YAML_PM -{ - Scanner::Scanner(std::istream& in) - : INPUT(in), m_startedStream(false), m_endedStream(false), m_simpleKeyAllowed(false), m_canBeJSONFlow(false) - { - } - - Scanner::~Scanner() - { - } - - // empty - // . Returns true if there are no more tokens to be read - bool Scanner::empty() - { - EnsureTokensInQueue(); - return m_tokens.empty(); - } - - // pop - // . Simply removes the next token on the queue. - void Scanner::pop() - { - EnsureTokensInQueue(); - if(!m_tokens.empty()) - m_tokens.pop(); - } - - // peek - // . Returns (but does not remove) the next token on the queue. - Token& Scanner::peek() - { - EnsureTokensInQueue(); - assert(!m_tokens.empty()); // should we be asserting here? I mean, we really just be checking - // if it's empty before peeking. - -#if 0 - static Token *pLast = 0; - if(pLast != &m_tokens.front()) - std::cerr << "peek: " << m_tokens.front() << "\n"; - pLast = &m_tokens.front(); -#endif - - return m_tokens.front(); - } - - // EnsureTokensInQueue - // . Scan until there's a valid token at the front of the queue, - // or we're sure the queue is empty. - void Scanner::EnsureTokensInQueue() - { - while(1) { - if(!m_tokens.empty()) { - Token& token = m_tokens.front(); - - // if this guy's valid, then we're done - if(token.status == Token::VALID) - return; - - // here's where we clean up the impossible tokens - if(token.status == Token::INVALID) { - m_tokens.pop(); - continue; - } - - // note: what's left are the unverified tokens - } - - // no token? maybe we've actually finished - if(m_endedStream) - return; - - // no? then scan... - ScanNextToken(); - } - } - - // ScanNextToken - // . The main scanning function; here we branch out and - // scan whatever the next token should be. - void Scanner::ScanNextToken() - { - if(m_endedStream) - return; - - if(!m_startedStream) - return StartStream(); - - // get rid of whitespace, etc. (in between tokens it should be irrelevent) - ScanToNextToken(); - - // maybe need to end some blocks - PopIndentToHere(); - - // ***** - // And now branch based on the next few characters! - // ***** - - // end of stream - if(!INPUT) - return EndStream(); - - if(INPUT.column() == 0 && INPUT.peek() == Keys::Directive) - return ScanDirective(); - - // document token - if(INPUT.column() == 0 && Exp::DocStart().Matches(INPUT)) - return ScanDocStart(); - - if(INPUT.column() == 0 && Exp::DocEnd().Matches(INPUT)) - return ScanDocEnd(); - - // flow start/end/entry - if(INPUT.peek() == Keys::FlowSeqStart || INPUT.peek() == Keys::FlowMapStart) - return ScanFlowStart(); - - if(INPUT.peek() == Keys::FlowSeqEnd || INPUT.peek() == Keys::FlowMapEnd) - return ScanFlowEnd(); - - if(INPUT.peek() == Keys::FlowEntry) - return ScanFlowEntry(); - - // block/map stuff - if(Exp::BlockEntry().Matches(INPUT)) - return ScanBlockEntry(); - - if((InBlockContext() ? Exp::Key() : Exp::KeyInFlow()).Matches(INPUT)) - return ScanKey(); - - if(GetValueRegex().Matches(INPUT)) - return ScanValue(); - - // alias/anchor - if(INPUT.peek() == Keys::Alias || INPUT.peek() == Keys::Anchor) - return ScanAnchorOrAlias(); - - // tag - if(INPUT.peek() == Keys::Tag) - return ScanTag(); - - // special scalars - if(InBlockContext() && (INPUT.peek() == Keys::LiteralScalar || INPUT.peek() == Keys::FoldedScalar)) - return ScanBlockScalar(); - - if(INPUT.peek() == '\'' || INPUT.peek() == '\"') - return ScanQuotedScalar(); - - // plain scalars - if((InBlockContext() ? Exp::PlainScalar() : Exp::PlainScalarInFlow()).Matches(INPUT)) - return ScanPlainScalar(); - - // don't know what it is! - throw ParserException(INPUT.mark(), ErrorMsg::UNKNOWN_TOKEN); - } - - // ScanToNextToken - // . Eats input until we reach the next token-like thing. - void Scanner::ScanToNextToken() - { - while(1) { - // first eat whitespace - while(INPUT && IsWhitespaceToBeEaten(INPUT.peek())) { - if(InBlockContext() && Exp::Tab().Matches(INPUT)) - m_simpleKeyAllowed = false; - INPUT.eat(1); - } - - // then eat a comment - if(Exp::Comment().Matches(INPUT)) { - // eat until line break - while(INPUT && !Exp::Break().Matches(INPUT)) - INPUT.eat(1); - } - - // if it's NOT a line break, then we're done! - if(!Exp::Break().Matches(INPUT)) - break; - - // otherwise, let's eat the line break and keep going - int n = Exp::Break().Match(INPUT); - INPUT.eat(n); - - // oh yeah, and let's get rid of that simple key - InvalidateSimpleKey(); - - // new line - we may be able to accept a simple key now - if(InBlockContext()) - m_simpleKeyAllowed = true; - } - } - - /////////////////////////////////////////////////////////////////////// - // Misc. helpers - - // IsWhitespaceToBeEaten - // . We can eat whitespace if it's a space or tab - // . Note: originally tabs in block context couldn't be eaten - // "where a simple key could be allowed - // (i.e., not at the beginning of a line, or following '-', '?', or ':')" - // I think this is wrong, since tabs can be non-content whitespace; it's just - // that they can't contribute to indentation, so once you've seen a tab in a - // line, you can't start a simple key - bool Scanner::IsWhitespaceToBeEaten(char ch) - { - if(ch == ' ') - return true; - - if(ch == '\t') - return true; - - return false; - } - - // GetValueRegex - // . Get the appropriate regex to check if it's a value token - const RegEx& Scanner::GetValueRegex() const - { - if(InBlockContext()) - return Exp::Value(); - - return m_canBeJSONFlow ? Exp::ValueInJSONFlow() : Exp::ValueInFlow(); - } - - // StartStream - // . Set the initial conditions for starting a stream. - void Scanner::StartStream() - { - m_startedStream = true; - m_simpleKeyAllowed = true; - std::auto_ptr pIndent(new IndentMarker(-1, IndentMarker::NONE)); - m_indentRefs.push_back(pIndent); - m_indents.push(&m_indentRefs.back()); - } - - // EndStream - // . Close out the stream, finish up, etc. - void Scanner::EndStream() - { - // force newline - if(INPUT.column() > 0) - INPUT.ResetColumn(); - - PopAllIndents(); - PopAllSimpleKeys(); - - m_simpleKeyAllowed = false; - m_endedStream = true; - } - - Token *Scanner::PushToken(Token::TYPE type) - { - m_tokens.push(Token(type, INPUT.mark())); - return &m_tokens.back(); - } - - Token::TYPE Scanner::GetStartTokenFor(IndentMarker::INDENT_TYPE type) const - { - switch(type) { - case IndentMarker::SEQ: return Token::BLOCK_SEQ_START; - case IndentMarker::MAP: return Token::BLOCK_MAP_START; - case IndentMarker::NONE: assert(false); break; - } - assert(false); - throw std::runtime_error("yaml-cpp: internal error, invalid indent type"); - } - - // PushIndentTo - // . Pushes an indentation onto the stack, and enqueues the - // proper token (sequence start or mapping start). - // . Returns the indent marker it generates (if any). - Scanner::IndentMarker *Scanner::PushIndentTo(int column, IndentMarker::INDENT_TYPE type) - { - // are we in flow? - if(InFlowContext()) - return 0; - - std::auto_ptr pIndent(new IndentMarker(column, type)); - IndentMarker& indent = *pIndent; - const IndentMarker& lastIndent = *m_indents.top(); - - // is this actually an indentation? - if(indent.column < lastIndent.column) - return 0; - if(indent.column == lastIndent.column && !(indent.type == IndentMarker::SEQ && lastIndent.type == IndentMarker::MAP)) - return 0; - - // push a start token - indent.pStartToken = PushToken(GetStartTokenFor(type)); - - // and then the indent - m_indents.push(&indent); - m_indentRefs.push_back(pIndent); - return &m_indentRefs.back(); - } - - // PopIndentToHere - // . Pops indentations off the stack until we reach the current indentation level, - // and enqueues the proper token each time. - // . Then pops all invalid indentations off. - void Scanner::PopIndentToHere() - { - // are we in flow? - if(InFlowContext()) - return; - - // now pop away - while(!m_indents.empty()) { - const IndentMarker& indent = *m_indents.top(); - if(indent.column < INPUT.column()) - break; - if(indent.column == INPUT.column() && !(indent.type == IndentMarker::SEQ && !Exp::BlockEntry().Matches(INPUT))) - break; - - PopIndent(); - } - - while(!m_indents.empty() && m_indents.top()->status == IndentMarker::INVALID) - PopIndent(); - } - - // PopAllIndents - // . Pops all indentations (except for the base empty one) off the stack, - // and enqueues the proper token each time. - void Scanner::PopAllIndents() - { - // are we in flow? - if(InFlowContext()) - return; - - // now pop away - while(!m_indents.empty()) { - const IndentMarker& indent = *m_indents.top(); - if(indent.type == IndentMarker::NONE) - break; - - PopIndent(); - } - } - - // PopIndent - // . Pops a single indent, pushing the proper token - void Scanner::PopIndent() - { - const IndentMarker& indent = *m_indents.top(); - m_indents.pop(); - - if(indent.status != IndentMarker::VALID) { - InvalidateSimpleKey(); - return; - } - - if(indent.type == IndentMarker::SEQ) - m_tokens.push(Token(Token::BLOCK_SEQ_END, INPUT.mark())); - else if(indent.type == IndentMarker::MAP) - m_tokens.push(Token(Token::BLOCK_MAP_END, INPUT.mark())); - } - - // GetTopIndent - int Scanner::GetTopIndent() const - { - if(m_indents.empty()) - return 0; - return m_indents.top()->column; - } - - // ThrowParserException - // . Throws a ParserException with the current token location - // (if available). - // . Does not parse any more tokens. - void Scanner::ThrowParserException(const std::string& msg) const - { - Mark mark = Mark::null(); - if(!m_tokens.empty()) { - const Token& token = m_tokens.front(); - mark = token.mark; - } - throw ParserException(mark, msg); - } -} - diff --git a/contrib/yaml-cpp-pm/src/scanner.h b/contrib/yaml-cpp-pm/src/scanner.h deleted file mode 100644 index 48a1b375b..000000000 --- a/contrib/yaml-cpp-pm/src/scanner.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include -#include -#include -#include -#include -#include -#include "ptr_vector.h" -#include "stream.h" -#include "token.h" - -namespace YAML_PM -{ - class Node; - class RegEx; - - class Scanner - { - public: - Scanner(std::istream& in); - ~Scanner(); - - // token queue management (hopefully this looks kinda stl-ish) - bool empty(); - void pop(); - Token& peek(); - - private: - struct IndentMarker { - enum INDENT_TYPE { MAP, SEQ, NONE }; - enum STATUS { VALID, INVALID, UNKNOWN }; - IndentMarker(int column_, INDENT_TYPE type_): column(column_), type(type_), status(VALID), pStartToken(0) {} - - int column; - INDENT_TYPE type; - STATUS status; - Token *pStartToken; - }; - - enum FLOW_MARKER { FLOW_MAP, FLOW_SEQ }; - - private: - // scanning - void EnsureTokensInQueue(); - void ScanNextToken(); - void ScanToNextToken(); - void StartStream(); - void EndStream(); - Token *PushToken(Token::TYPE type); - - bool InFlowContext() const { return !m_flows.empty(); } - bool InBlockContext() const { return m_flows.empty(); } - int GetFlowLevel() const { return m_flows.size(); } - - Token::TYPE GetStartTokenFor(IndentMarker::INDENT_TYPE type) const; - IndentMarker *PushIndentTo(int column, IndentMarker::INDENT_TYPE type); - void PopIndentToHere(); - void PopAllIndents(); - void PopIndent(); - int GetTopIndent() const; - - // checking input - bool CanInsertPotentialSimpleKey() const; - bool ExistsActiveSimpleKey() const; - void InsertPotentialSimpleKey(); - void InvalidateSimpleKey(); - bool VerifySimpleKey(); - void PopAllSimpleKeys(); - - void ThrowParserException(const std::string& msg) const; - - bool IsWhitespaceToBeEaten(char ch); - const RegEx& GetValueRegex() const; - - struct SimpleKey { - SimpleKey(const Mark& mark_, int flowLevel_); - - void Validate(); - void Invalidate(); - - Mark mark; - int flowLevel; - IndentMarker *pIndent; - Token *pMapStart, *pKey; - }; - - // and the tokens - void ScanDirective(); - void ScanDocStart(); - void ScanDocEnd(); - void ScanBlockSeqStart(); - void ScanBlockMapSTart(); - void ScanBlockEnd(); - void ScanBlockEntry(); - void ScanFlowStart(); - void ScanFlowEnd(); - void ScanFlowEntry(); - void ScanKey(); - void ScanValue(); - void ScanAnchorOrAlias(); - void ScanTag(); - void ScanPlainScalar(); - void ScanQuotedScalar(); - void ScanBlockScalar(); - - private: - // the stream - Stream INPUT; - - // the output (tokens) - std::queue m_tokens; - - // state info - bool m_startedStream, m_endedStream; - bool m_simpleKeyAllowed; - bool m_canBeJSONFlow; - std::stack m_simpleKeys; - std::stack m_indents; - ptr_vector m_indentRefs; // for "garbage collection" - std::stack m_flows; - }; -} - -#endif // SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - diff --git a/contrib/yaml-cpp-pm/src/scanscalar.cpp b/contrib/yaml-cpp-pm/src/scanscalar.cpp deleted file mode 100644 index e15269d6c..000000000 --- a/contrib/yaml-cpp-pm/src/scanscalar.cpp +++ /dev/null @@ -1,214 +0,0 @@ -#include "scanscalar.h" -#include "scanner.h" -#include "exp.h" -#include "yaml-cpp-pm/exceptions.h" -#include "token.h" - -namespace YAML_PM -{ - // ScanScalar - // . This is where the scalar magic happens. - // - // . We do the scanning in three phases: - // 1. Scan until newline - // 2. Eat newline - // 3. Scan leading blanks. - // - // . Depending on the parameters given, we store or stop - // and different places in the above flow. - std::string ScanScalar(Stream& INPUT, ScanScalarParams& params) - { - bool foundNonEmptyLine = false; - bool pastOpeningBreak = (params.fold == FOLD_FLOW); - bool emptyLine = false, moreIndented = false; - int foldedNewlineCount = 0; - bool foldedNewlineStartedMoreIndented = false; - std::size_t lastEscapedChar = std::string::npos; - std::string scalar; - params.leadingSpaces = false; - - while(INPUT) { - // ******************************** - // Phase #1: scan until line ending - - std::size_t lastNonWhitespaceChar = scalar.size(); - bool escapedNewline = false; - while(!params.end.Matches(INPUT) && !Exp::Break().Matches(INPUT)) { - if(!INPUT) - break; - - // document indicator? - if(INPUT.column() == 0 && Exp::DocIndicator().Matches(INPUT)) { - if(params.onDocIndicator == BREAK) - break; - else if(params.onDocIndicator == THROW) - throw ParserException(INPUT.mark(), ErrorMsg::DOC_IN_SCALAR); - } - - foundNonEmptyLine = true; - pastOpeningBreak = true; - - // escaped newline? (only if we're escaping on slash) - if(params.escape == '\\' && Exp::EscBreak().Matches(INPUT)) { - // eat escape character and get out (but preserve trailing whitespace!) - INPUT.get(); - lastNonWhitespaceChar = scalar.size(); - lastEscapedChar = scalar.size(); - escapedNewline = true; - break; - } - - // escape this? - if(INPUT.peek() == params.escape) { - scalar += Exp::Escape(INPUT); - lastNonWhitespaceChar = scalar.size(); - lastEscapedChar = scalar.size(); - continue; - } - - // otherwise, just add the damn character - char ch = INPUT.get(); - scalar += ch; - if(ch != ' ' && ch != '\t') - lastNonWhitespaceChar = scalar.size(); - } - - // eof? if we're looking to eat something, then we throw - if(!INPUT) { - if(params.eatEnd) - throw ParserException(INPUT.mark(), ErrorMsg::EOF_IN_SCALAR); - break; - } - - // doc indicator? - if(params.onDocIndicator == BREAK && INPUT.column() == 0 && Exp::DocIndicator().Matches(INPUT)) - break; - - // are we done via character match? - int n = params.end.Match(INPUT); - if(n >= 0) { - if(params.eatEnd) - INPUT.eat(n); - break; - } - - // do we remove trailing whitespace? - if(params.fold == FOLD_FLOW) - scalar.erase(lastNonWhitespaceChar); - - // ******************************** - // Phase #2: eat line ending - n = Exp::Break().Match(INPUT); - INPUT.eat(n); - - // ******************************** - // Phase #3: scan initial spaces - - // first the required indentation - while(INPUT.peek() == ' ' && (INPUT.column() < params.indent || (params.detectIndent && !foundNonEmptyLine))) - INPUT.eat(1); - - // update indent if we're auto-detecting - if(params.detectIndent && !foundNonEmptyLine) - params.indent = std::max(params.indent, INPUT.column()); - - // and then the rest of the whitespace - while(Exp::Blank().Matches(INPUT)) { - // we check for tabs that masquerade as indentation - if(INPUT.peek() == '\t'&& INPUT.column() < params.indent && params.onTabInIndentation == THROW) - throw ParserException(INPUT.mark(), ErrorMsg::TAB_IN_INDENTATION); - - if(!params.eatLeadingWhitespace) - break; - - INPUT.eat(1); - } - - // was this an empty line? - bool nextEmptyLine = Exp::Break().Matches(INPUT); - bool nextMoreIndented = Exp::Blank().Matches(INPUT); - if(params.fold == FOLD_BLOCK && foldedNewlineCount == 0 && nextEmptyLine) - foldedNewlineStartedMoreIndented = moreIndented; - - // for block scalars, we always start with a newline, so we should ignore it (not fold or keep) - if(pastOpeningBreak) { - switch(params.fold) { - case DONT_FOLD: - scalar += "\n"; - break; - case FOLD_BLOCK: - if(!emptyLine && !nextEmptyLine && !moreIndented && !nextMoreIndented && INPUT.column() >= params.indent) - scalar += " "; - else if(nextEmptyLine) - foldedNewlineCount++; - else - scalar += "\n"; - - if(!nextEmptyLine && foldedNewlineCount > 0) { - scalar += std::string(foldedNewlineCount - 1, '\n'); - if(foldedNewlineStartedMoreIndented || nextMoreIndented | !foundNonEmptyLine) - scalar += "\n"; - foldedNewlineCount = 0; - } - break; - case FOLD_FLOW: - if(nextEmptyLine) - scalar += "\n"; - else if(!emptyLine && !nextEmptyLine && !escapedNewline) - scalar += " "; - break; - } - } - - emptyLine = nextEmptyLine; - moreIndented = nextMoreIndented; - pastOpeningBreak = true; - - // are we done via indentation? - if(!emptyLine && INPUT.column() < params.indent) { - params.leadingSpaces = true; - break; - } - } - - // post-processing - if(params.trimTrailingSpaces) { - std::size_t pos = scalar.find_last_not_of(' '); - if(lastEscapedChar != std::string::npos) { - if(pos < lastEscapedChar || pos == std::string::npos) - pos = lastEscapedChar; - } - if(pos < scalar.size()) - scalar.erase(pos + 1); - } - - switch(params.chomp) { - case CLIP: { - std::size_t pos = scalar.find_last_not_of('\n'); - if(lastEscapedChar != std::string::npos) { - if(pos < lastEscapedChar || pos == std::string::npos) - pos = lastEscapedChar; - } - if(pos == std::string::npos) - scalar.erase(); - else if(pos + 1 < scalar.size()) - scalar.erase(pos + 2); - } break; - case STRIP: { - std::size_t pos = scalar.find_last_not_of('\n'); - if(lastEscapedChar != std::string::npos) { - if(pos < lastEscapedChar || pos == std::string::npos) - pos = lastEscapedChar; - } - if(pos == std::string::npos) - scalar.erase(); - else if(pos < scalar.size()) - scalar.erase(pos + 1); - } break; - default: - break; - } - - return scalar; - } -} diff --git a/contrib/yaml-cpp-pm/src/scanscalar.h b/contrib/yaml-cpp-pm/src/scanscalar.h deleted file mode 100644 index 4c1f3338b..000000000 --- a/contrib/yaml-cpp-pm/src/scanscalar.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include -#include "regex.h" -#include "stream.h" - -namespace YAML_PM -{ - enum CHOMP { STRIP = -1, CLIP, KEEP }; - enum ACTION { NONE, BREAK, THROW }; - enum FOLD { DONT_FOLD, FOLD_BLOCK, FOLD_FLOW }; - - struct ScanScalarParams { - ScanScalarParams(): eatEnd(false), indent(0), detectIndent(false), eatLeadingWhitespace(0), escape(0), fold(DONT_FOLD), - trimTrailingSpaces(0), chomp(CLIP), onDocIndicator(NONE), onTabInIndentation(NONE), leadingSpaces(false) {} - - // input: - RegEx end; // what condition ends this scalar? - bool eatEnd; // should we eat that condition when we see it? - int indent; // what level of indentation should be eaten and ignored? - bool detectIndent; // should we try to autodetect the indent? - bool eatLeadingWhitespace; // should we continue eating this delicious indentation after 'indent' spaces? - char escape; // what character do we escape on (i.e., slash or single quote) (0 for none) - FOLD fold; // how do we fold line ends? - bool trimTrailingSpaces; // do we remove all trailing spaces (at the very end) - CHOMP chomp; // do we strip, clip, or keep trailing newlines (at the very end) - // Note: strip means kill all, clip means keep at most one, keep means keep all - ACTION onDocIndicator; // what do we do if we see a document indicator? - ACTION onTabInIndentation; // what do we do if we see a tab where we should be seeing indentation spaces - - // output: - bool leadingSpaces; - }; - - std::string ScanScalar(Stream& INPUT, ScanScalarParams& info); -} - -#endif // SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - diff --git a/contrib/yaml-cpp-pm/src/scantag.cpp b/contrib/yaml-cpp-pm/src/scantag.cpp deleted file mode 100644 index 297ffa6e2..000000000 --- a/contrib/yaml-cpp-pm/src/scantag.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "scanner.h" -#include "regex.h" -#include "exp.h" -#include "yaml-cpp-pm/exceptions.h" - -namespace YAML_PM -{ - const std::string ScanVerbatimTag(Stream& INPUT) - { - std::string tag; - - // eat the start character - INPUT.get(); - - while(INPUT) { - if(INPUT.peek() == Keys::VerbatimTagEnd) { - // eat the end character - INPUT.get(); - return tag; - } - - int n = Exp::URI().Match(INPUT); - if(n <= 0) - break; - - tag += INPUT.get(n); - } - - throw ParserException(INPUT.mark(), ErrorMsg::END_OF_VERBATIM_TAG); - } - - const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle) - { - std::string tag; - canBeHandle = true; - Mark firstNonWordChar; - - while(INPUT) { - if(INPUT.peek() == Keys::Tag) { - if(!canBeHandle) - throw ParserException(firstNonWordChar, ErrorMsg::CHAR_IN_TAG_HANDLE); - break; - } - - int n = 0; - if(canBeHandle) { - n = Exp::Word().Match(INPUT); - if(n <= 0) { - canBeHandle = false; - firstNonWordChar = INPUT.mark(); - } - } - - if(!canBeHandle) - n = Exp::Tag().Match(INPUT); - - if(n <= 0) - break; - - tag += INPUT.get(n); - } - - return tag; - } - - const std::string ScanTagSuffix(Stream& INPUT) - { - std::string tag; - - while(INPUT) { - int n = Exp::Tag().Match(INPUT); - if(n <= 0) - break; - - tag += INPUT.get(n); - } - - if(tag.empty()) - throw ParserException(INPUT.mark(), ErrorMsg::TAG_WITH_NO_SUFFIX); - - return tag; - } -} - diff --git a/contrib/yaml-cpp-pm/src/scantag.h b/contrib/yaml-cpp-pm/src/scantag.h deleted file mode 100644 index 402a9c13f..000000000 --- a/contrib/yaml-cpp-pm/src/scantag.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include -#include "stream.h" - -namespace YAML_PM -{ - const std::string ScanVerbatimTag(Stream& INPUT); - const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle); - const std::string ScanTagSuffix(Stream& INPUT); -} - -#endif // SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - diff --git a/contrib/yaml-cpp-pm/src/scantoken.cpp b/contrib/yaml-cpp-pm/src/scantoken.cpp deleted file mode 100644 index d9d7104a6..000000000 --- a/contrib/yaml-cpp-pm/src/scantoken.cpp +++ /dev/null @@ -1,439 +0,0 @@ -#include "scanner.h" -#include "token.h" -#include "yaml-cpp-pm/exceptions.h" -#include "exp.h" -#include "scanscalar.h" -#include "scantag.h" -#include "tag.h" -#include - -namespace YAML_PM -{ - /////////////////////////////////////////////////////////////////////// - // Specialization for scanning specific tokens - - // Directive - // . Note: no semantic checking is done here (that's for the parser to do) - void Scanner::ScanDirective() - { - std::string name; - std::vector params; - - // pop indents and simple keys - PopAllIndents(); - PopAllSimpleKeys(); - - m_simpleKeyAllowed = false; - m_canBeJSONFlow = false; - - // store pos and eat indicator - Token token(Token::DIRECTIVE, INPUT.mark()); - INPUT.eat(1); - - // read name - while(INPUT && !Exp::BlankOrBreak().Matches(INPUT)) - token.value += INPUT.get(); - - // read parameters - while(1) { - // first get rid of whitespace - while(Exp::Blank().Matches(INPUT)) - INPUT.eat(1); - - // break on newline or comment - if(!INPUT || Exp::Break().Matches(INPUT) || Exp::Comment().Matches(INPUT)) - break; - - // now read parameter - std::string param; - while(INPUT && !Exp::BlankOrBreak().Matches(INPUT)) - param += INPUT.get(); - - token.params.push_back(param); - } - - m_tokens.push(token); - } - - // DocStart - void Scanner::ScanDocStart() - { - PopAllIndents(); - PopAllSimpleKeys(); - m_simpleKeyAllowed = false; - m_canBeJSONFlow = false; - - // eat - Mark mark = INPUT.mark(); - INPUT.eat(3); - m_tokens.push(Token(Token::DOC_START, mark)); - } - - // DocEnd - void Scanner::ScanDocEnd() - { - PopAllIndents(); - PopAllSimpleKeys(); - m_simpleKeyAllowed = false; - m_canBeJSONFlow = false; - - // eat - Mark mark = INPUT.mark(); - INPUT.eat(3); - m_tokens.push(Token(Token::DOC_END, mark)); - } - - // FlowStart - void Scanner::ScanFlowStart() - { - // flows can be simple keys - InsertPotentialSimpleKey(); - m_simpleKeyAllowed = true; - m_canBeJSONFlow = false; - - // eat - Mark mark = INPUT.mark(); - char ch = INPUT.get(); - FLOW_MARKER flowType = (ch == Keys::FlowSeqStart ? FLOW_SEQ : FLOW_MAP); - m_flows.push(flowType); - Token::TYPE type = (flowType == FLOW_SEQ ? Token::FLOW_SEQ_START : Token::FLOW_MAP_START); - m_tokens.push(Token(type, mark)); - } - - // FlowEnd - void Scanner::ScanFlowEnd() - { - if(InBlockContext()) - throw ParserException(INPUT.mark(), ErrorMsg::FLOW_END); - - // we might have a solo entry in the flow context - if(InFlowContext()) { - if(m_flows.top() == FLOW_MAP && VerifySimpleKey()) - m_tokens.push(Token(Token::VALUE, INPUT.mark())); - else if(m_flows.top() == FLOW_SEQ) - InvalidateSimpleKey(); - } - - m_simpleKeyAllowed = false; - m_canBeJSONFlow = true; - - // eat - Mark mark = INPUT.mark(); - char ch = INPUT.get(); - - // check that it matches the start - FLOW_MARKER flowType = (ch == Keys::FlowSeqEnd ? FLOW_SEQ : FLOW_MAP); - if(m_flows.top() != flowType) - throw ParserException(mark, ErrorMsg::FLOW_END); - m_flows.pop(); - - Token::TYPE type = (flowType ? Token::FLOW_SEQ_END : Token::FLOW_MAP_END); - m_tokens.push(Token(type, mark)); - } - - // FlowEntry - void Scanner::ScanFlowEntry() - { - // we might have a solo entry in the flow context - if(InFlowContext()) { - if(m_flows.top() == FLOW_MAP && VerifySimpleKey()) - m_tokens.push(Token(Token::VALUE, INPUT.mark())); - else if(m_flows.top() == FLOW_SEQ) - InvalidateSimpleKey(); - } - - m_simpleKeyAllowed = true; - m_canBeJSONFlow = false; - - // eat - Mark mark = INPUT.mark(); - INPUT.eat(1); - m_tokens.push(Token(Token::FLOW_ENTRY, mark)); - } - - // BlockEntry - void Scanner::ScanBlockEntry() - { - // we better be in the block context! - if(InFlowContext()) - throw ParserException(INPUT.mark(), ErrorMsg::BLOCK_ENTRY); - - // can we put it here? - if(!m_simpleKeyAllowed) - throw ParserException(INPUT.mark(), ErrorMsg::BLOCK_ENTRY); - - PushIndentTo(INPUT.column(), IndentMarker::SEQ); - m_simpleKeyAllowed = true; - m_canBeJSONFlow = false; - - // eat - Mark mark = INPUT.mark(); - INPUT.eat(1); - m_tokens.push(Token(Token::BLOCK_ENTRY, mark)); - } - - // Key - void Scanner::ScanKey() - { - // handle keys diffently in the block context (and manage indents) - if(InBlockContext()) { - if(!m_simpleKeyAllowed) - throw ParserException(INPUT.mark(), ErrorMsg::MAP_KEY); - - PushIndentTo(INPUT.column(), IndentMarker::MAP); - } - - // can only put a simple key here if we're in block context - m_simpleKeyAllowed = InBlockContext(); - - // eat - Mark mark = INPUT.mark(); - INPUT.eat(1); - m_tokens.push(Token(Token::KEY, mark)); - } - - // Value - void Scanner::ScanValue() - { - // and check that simple key - bool isSimpleKey = VerifySimpleKey(); - m_canBeJSONFlow = false; - - if(isSimpleKey) { - // can't follow a simple key with another simple key (dunno why, though - it seems fine) - m_simpleKeyAllowed = false; - } else { - // handle values diffently in the block context (and manage indents) - if(InBlockContext()) { - if(!m_simpleKeyAllowed) - throw ParserException(INPUT.mark(), ErrorMsg::MAP_VALUE); - - PushIndentTo(INPUT.column(), IndentMarker::MAP); - } - - // can only put a simple key here if we're in block context - m_simpleKeyAllowed = InBlockContext(); - } - - // eat - Mark mark = INPUT.mark(); - INPUT.eat(1); - m_tokens.push(Token(Token::VALUE, mark)); - } - - // AnchorOrAlias - void Scanner::ScanAnchorOrAlias() - { - bool alias; - std::string name; - - // insert a potential simple key - InsertPotentialSimpleKey(); - m_simpleKeyAllowed = false; - m_canBeJSONFlow = false; - - // eat the indicator - Mark mark = INPUT.mark(); - char indicator = INPUT.get(); - alias = (indicator == Keys::Alias); - - // now eat the content - while(INPUT && Exp::Anchor().Matches(INPUT)) - name += INPUT.get(); - - // we need to have read SOMETHING! - if(name.empty()) - throw ParserException(INPUT.mark(), alias ? ErrorMsg::ALIAS_NOT_FOUND : ErrorMsg::ANCHOR_NOT_FOUND); - - // and needs to end correctly - if(INPUT && !Exp::AnchorEnd().Matches(INPUT)) - throw ParserException(INPUT.mark(), alias ? ErrorMsg::CHAR_IN_ALIAS : ErrorMsg::CHAR_IN_ANCHOR); - - // and we're done - Token token(alias ? Token::ALIAS : Token::ANCHOR, mark); - token.value = name; - m_tokens.push(token); - } - - // Tag - void Scanner::ScanTag() - { - // insert a potential simple key - InsertPotentialSimpleKey(); - m_simpleKeyAllowed = false; - m_canBeJSONFlow = false; - - Token token(Token::TAG, INPUT.mark()); - - // eat the indicator - INPUT.get(); - - if(INPUT && INPUT.peek() == Keys::VerbatimTagStart){ - std::string tag = ScanVerbatimTag(INPUT); - - token.value = tag; - token.data = Tag::VERBATIM; - } else { - bool canBeHandle; - token.value = ScanTagHandle(INPUT, canBeHandle); - if(!canBeHandle && token.value.empty()) - token.data = Tag::NON_SPECIFIC; - else if(token.value.empty()) - token.data = Tag::SECONDARY_HANDLE; - else - token.data = Tag::PRIMARY_HANDLE; - - // is there a suffix? - if(canBeHandle && INPUT.peek() == Keys::Tag) { - // eat the indicator - INPUT.get(); - token.params.push_back(ScanTagSuffix(INPUT)); - token.data = Tag::NAMED_HANDLE; - } - } - - m_tokens.push(token); - } - - // PlainScalar - void Scanner::ScanPlainScalar() - { - std::string scalar; - - // set up the scanning parameters - ScanScalarParams params; - params.end = (InFlowContext() ? Exp::EndScalarInFlow() : Exp::EndScalar()) || (Exp::BlankOrBreak() + Exp::Comment()); - params.eatEnd = false; - params.indent = (InFlowContext() ? 0 : GetTopIndent() + 1); - params.fold = FOLD_FLOW; - params.eatLeadingWhitespace = true; - params.trimTrailingSpaces = true; - params.chomp = STRIP; - params.onDocIndicator = BREAK; - params.onTabInIndentation = THROW; - - // insert a potential simple key - InsertPotentialSimpleKey(); - - Mark mark = INPUT.mark(); - scalar = ScanScalar(INPUT, params); - - // can have a simple key only if we ended the scalar by starting a new line - m_simpleKeyAllowed = params.leadingSpaces; - m_canBeJSONFlow = false; - - // finally, check and see if we ended on an illegal character - //if(Exp::IllegalCharInScalar.Matches(INPUT)) - // throw ParserException(INPUT.mark(), ErrorMsg::CHAR_IN_SCALAR); - - Token token(Token::PLAIN_SCALAR, mark); - token.value = scalar; - m_tokens.push(token); - } - - // QuotedScalar - void Scanner::ScanQuotedScalar() - { - std::string scalar; - - // peek at single or double quote (don't eat because we need to preserve (for the time being) the input position) - char quote = INPUT.peek(); - bool single = (quote == '\''); - - // setup the scanning parameters - ScanScalarParams params; - params.end = (single ? RegEx(quote) && !Exp::EscSingleQuote() : RegEx(quote)); - params.eatEnd = true; - params.escape = (single ? '\'' : '\\'); - params.indent = 0; - params.fold = FOLD_FLOW; - params.eatLeadingWhitespace = true; - params.trimTrailingSpaces = false; - params.chomp = CLIP; - params.onDocIndicator = THROW; - - // insert a potential simple key - InsertPotentialSimpleKey(); - - Mark mark = INPUT.mark(); - - // now eat that opening quote - INPUT.get(); - - // and scan - scalar = ScanScalar(INPUT, params); - m_simpleKeyAllowed = false; - m_canBeJSONFlow = true; - - Token token(Token::NON_PLAIN_SCALAR, mark); - token.value = scalar; - m_tokens.push(token); - } - - // BlockScalarToken - // . These need a little extra processing beforehand. - // . We need to scan the line where the indicator is (this doesn't count as part of the scalar), - // and then we need to figure out what level of indentation we'll be using. - void Scanner::ScanBlockScalar() - { - std::string scalar; - - ScanScalarParams params; - params.indent = 1; - params.detectIndent = true; - - // eat block indicator ('|' or '>') - Mark mark = INPUT.mark(); - char indicator = INPUT.get(); - params.fold = (indicator == Keys::FoldedScalar ? FOLD_BLOCK : DONT_FOLD); - - // eat chomping/indentation indicators - params.chomp = CLIP; - int n = Exp::Chomp().Match(INPUT); - for(int i=0;i= 0) - params.indent += GetTopIndent(); - - params.eatLeadingWhitespace = false; - params.trimTrailingSpaces = false; - params.onTabInIndentation = THROW; - - scalar = ScanScalar(INPUT, params); - - // simple keys always ok after block scalars (since we're gonna start a new line anyways) - m_simpleKeyAllowed = true; - m_canBeJSONFlow = false; - - Token token(Token::NON_PLAIN_SCALAR, mark); - token.value = scalar; - m_tokens.push(token); - } -} diff --git a/contrib/yaml-cpp-pm/src/setting.h b/contrib/yaml-cpp-pm/src/setting.h deleted file mode 100644 index 6c9732de5..000000000 --- a/contrib/yaml-cpp-pm/src/setting.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include -#include -#include "yaml-cpp-pm/noncopyable.h" - -namespace YAML_PM -{ - class SettingChangeBase; - - template - class Setting - { - public: - Setting(): m_value() {} - - const T get() const { return m_value; } - std::auto_ptr set(const T& value); - void restore(const Setting& oldSetting) { - m_value = oldSetting.get(); - } - - private: - T m_value; - }; - - class SettingChangeBase - { - public: - virtual ~SettingChangeBase() {} - virtual void pop() = 0; - }; - - template - class SettingChange: public SettingChangeBase - { - public: - SettingChange(Setting *pSetting): m_pCurSetting(pSetting) { - // copy old setting to save its state - m_oldSetting = *pSetting; - } - - virtual void pop() { - m_pCurSetting->restore(m_oldSetting); - } - - private: - Setting *m_pCurSetting; - Setting m_oldSetting; - }; - - template - inline std::auto_ptr Setting::set(const T& value) { - std::auto_ptr pChange(new SettingChange (this)); - m_value = value; - return pChange; - } - - class SettingChanges: private noncopyable - { - public: - SettingChanges() {} - ~SettingChanges() { clear(); } - - void clear() { - restore(); - - for(setting_changes::const_iterator it=m_settingChanges.begin();it!=m_settingChanges.end();++it) - delete *it; - m_settingChanges.clear(); - } - - void restore() { - for(setting_changes::const_iterator it=m_settingChanges.begin();it!=m_settingChanges.end();++it) - (*it)->pop(); - } - - void push(std::auto_ptr pSettingChange) { - m_settingChanges.push_back(pSettingChange.release()); - } - - // like std::auto_ptr - assignment is transfer of ownership - SettingChanges& operator = (SettingChanges& rhs) { - if(this == &rhs) - return *this; - - clear(); - m_settingChanges = rhs.m_settingChanges; - rhs.m_settingChanges.clear(); - return *this; - } - - private: - typedef std::vector setting_changes; - setting_changes m_settingChanges; - }; -} - -#endif // SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/simplekey.cpp b/contrib/yaml-cpp-pm/src/simplekey.cpp deleted file mode 100644 index f43618c65..000000000 --- a/contrib/yaml-cpp-pm/src/simplekey.cpp +++ /dev/null @@ -1,139 +0,0 @@ -#include "scanner.h" -#include "token.h" -#include "yaml-cpp-pm/exceptions.h" -#include "exp.h" - -namespace YAML_PM -{ - Scanner::SimpleKey::SimpleKey(const Mark& mark_, int flowLevel_) - : mark(mark_), flowLevel(flowLevel_), pIndent(0), pMapStart(0), pKey(0) - { - } - - void Scanner::SimpleKey::Validate() - { - // Note: pIndent will *not* be garbage here; - // we "garbage collect" them so we can - // always refer to them - if(pIndent) - pIndent->status = IndentMarker::VALID; - if(pMapStart) - pMapStart->status = Token::VALID; - if(pKey) - pKey->status = Token::VALID; - } - - void Scanner::SimpleKey::Invalidate() - { - if(pIndent) - pIndent->status = IndentMarker::INVALID; - if(pMapStart) - pMapStart->status = Token::INVALID; - if(pKey) - pKey->status = Token::INVALID; - } - - // CanInsertPotentialSimpleKey - bool Scanner::CanInsertPotentialSimpleKey() const - { - if(!m_simpleKeyAllowed) - return false; - - return !ExistsActiveSimpleKey(); - } - - // ExistsActiveSimpleKey - // . Returns true if there's a potential simple key at our flow level - // (there's allowed at most one per flow level, i.e., at the start of the flow start token) - bool Scanner::ExistsActiveSimpleKey() const - { - if(m_simpleKeys.empty()) - return false; - - const SimpleKey& key = m_simpleKeys.top(); - return key.flowLevel == GetFlowLevel(); - } - - // InsertPotentialSimpleKey - // . If we can, add a potential simple key to the queue, - // and save it on a stack. - void Scanner::InsertPotentialSimpleKey() - { - if(!CanInsertPotentialSimpleKey()) - return; - - SimpleKey key(INPUT.mark(), GetFlowLevel()); - - // first add a map start, if necessary - if(InBlockContext()) { - key.pIndent = PushIndentTo(INPUT.column(), IndentMarker::MAP); - if(key.pIndent) { - key.pIndent->status = IndentMarker::UNKNOWN; - key.pMapStart = key.pIndent->pStartToken; - key.pMapStart->status = Token::UNVERIFIED; - } - } - - // then add the (now unverified) key - m_tokens.push(Token(Token::KEY, INPUT.mark())); - key.pKey = &m_tokens.back(); - key.pKey->status = Token::UNVERIFIED; - - m_simpleKeys.push(key); - } - - // InvalidateSimpleKey - // . Automatically invalidate the simple key in our flow level - void Scanner::InvalidateSimpleKey() - { - if(m_simpleKeys.empty()) - return; - - // grab top key - SimpleKey& key = m_simpleKeys.top(); - if(key.flowLevel != GetFlowLevel()) - return; - - key.Invalidate(); - m_simpleKeys.pop(); - } - - // VerifySimpleKey - // . Determines whether the latest simple key to be added is valid, - // and if so, makes it valid. - bool Scanner::VerifySimpleKey() - { - if(m_simpleKeys.empty()) - return false; - - // grab top key - SimpleKey key = m_simpleKeys.top(); - - // only validate if we're in the correct flow level - if(key.flowLevel != GetFlowLevel()) - return false; - - m_simpleKeys.pop(); - - bool isValid = true; - - // needs to be less than 1024 characters and inline - if(INPUT.line() != key.mark.line || INPUT.pos() - key.mark.pos > 1024) - isValid = false; - - // invalidate key - if(isValid) - key.Validate(); - else - key.Invalidate(); - - return isValid; - } - - void Scanner::PopAllSimpleKeys() - { - while(!m_simpleKeys.empty()) - m_simpleKeys.pop(); - } -} - diff --git a/contrib/yaml-cpp-pm/src/singledocparser.cpp b/contrib/yaml-cpp-pm/src/singledocparser.cpp deleted file mode 100644 index 54555fd08..000000000 --- a/contrib/yaml-cpp-pm/src/singledocparser.cpp +++ /dev/null @@ -1,381 +0,0 @@ -#include "singledocparser.h" -#include "collectionstack.h" -#include "directives.h" -#include "yaml-cpp-pm/eventhandler.h" -#include "yaml-cpp-pm/exceptions.h" -#include "scanner.h" -#include "tag.h" -#include "token.h" -#include -#include -#include - -namespace YAML_PM -{ - SingleDocParser::SingleDocParser(Scanner& scanner, const Directives& directives): m_scanner(scanner), m_directives(directives), m_pCollectionStack(new CollectionStack), m_curAnchor(0) - { - } - - SingleDocParser::~SingleDocParser() - { - } - - // HandleDocument - // . Handles the next document - // . Throws a ParserException on error. - void SingleDocParser::HandleDocument(EventHandler& eventHandler) - { - assert(!m_scanner.empty()); // guaranteed that there are tokens - assert(!m_curAnchor); - - eventHandler.OnDocumentStart(m_scanner.peek().mark); - - // eat doc start - if(m_scanner.peek().type == Token::DOC_START) - m_scanner.pop(); - - // recurse! - HandleNode(eventHandler); - - eventHandler.OnDocumentEnd(); - - // and finally eat any doc ends we see - while(!m_scanner.empty() && m_scanner.peek().type == Token::DOC_END) - m_scanner.pop(); - } - - void SingleDocParser::HandleNode(EventHandler& eventHandler) - { - // an empty node *is* a possibility - if(m_scanner.empty()) { - eventHandler.OnNull(Mark::null(), NullAnchor); - return; - } - - // save location - Mark mark = m_scanner.peek().mark; - - // special case: a value node by itself must be a map, with no header - if(m_scanner.peek().type == Token::VALUE) { - eventHandler.OnMapStart(mark, "", NullAnchor); - HandleMap(eventHandler); - eventHandler.OnMapEnd(); - return; - } - - // special case: an alias node - if(m_scanner.peek().type == Token::ALIAS) { - eventHandler.OnAlias(mark, LookupAnchor(mark, m_scanner.peek().value)); - m_scanner.pop(); - return; - } - - std::string tag; - anchor_t anchor; - ParseProperties(tag, anchor); - - const Token& token = m_scanner.peek(); - - // add non-specific tags - if(tag.empty()) - tag = (token.type == Token::NON_PLAIN_SCALAR ? "!" : "?"); - - // now split based on what kind of node we should be - switch(token.type) { - case Token::PLAIN_SCALAR: - case Token::NON_PLAIN_SCALAR: - eventHandler.OnScalar(mark, tag, anchor, token.value); - m_scanner.pop(); - return; - case Token::FLOW_SEQ_START: - case Token::BLOCK_SEQ_START: - eventHandler.OnSequenceStart(mark, tag, anchor); - HandleSequence(eventHandler); - eventHandler.OnSequenceEnd(); - return; - case Token::FLOW_MAP_START: - case Token::BLOCK_MAP_START: - eventHandler.OnMapStart(mark, tag, anchor); - HandleMap(eventHandler); - eventHandler.OnMapEnd(); - return; - case Token::KEY: - // compact maps can only go in a flow sequence - if(m_pCollectionStack->GetCurCollectionType() == CollectionType::FlowSeq) { - eventHandler.OnMapStart(mark, tag, anchor); - HandleMap(eventHandler); - eventHandler.OnMapEnd(); - return; - } - break; - default: - break; - } - - if(tag == "?") - eventHandler.OnNull(mark, anchor); - else - eventHandler.OnScalar(mark, tag, anchor, ""); - } - - void SingleDocParser::HandleSequence(EventHandler& eventHandler) - { - // split based on start token - switch(m_scanner.peek().type) { - case Token::BLOCK_SEQ_START: HandleBlockSequence(eventHandler); break; - case Token::FLOW_SEQ_START: HandleFlowSequence(eventHandler); break; - default: break; - } - } - - void SingleDocParser::HandleBlockSequence(EventHandler& eventHandler) - { - // eat start token - m_scanner.pop(); - m_pCollectionStack->PushCollectionType(CollectionType::BlockSeq); - - while(1) { - if(m_scanner.empty()) - throw ParserException(Mark::null(), ErrorMsg::END_OF_SEQ); - - Token token = m_scanner.peek(); - if(token.type != Token::BLOCK_ENTRY && token.type != Token::BLOCK_SEQ_END) - throw ParserException(token.mark, ErrorMsg::END_OF_SEQ); - - m_scanner.pop(); - if(token.type == Token::BLOCK_SEQ_END) - break; - - // check for null - if(!m_scanner.empty()) { - const Token& token = m_scanner.peek(); - if(token.type == Token::BLOCK_ENTRY || token.type == Token::BLOCK_SEQ_END) { - eventHandler.OnNull(token.mark, NullAnchor); - continue; - } - } - - HandleNode(eventHandler); - } - - m_pCollectionStack->PopCollectionType(CollectionType::BlockSeq); - } - - void SingleDocParser::HandleFlowSequence(EventHandler& eventHandler) - { - // eat start token - m_scanner.pop(); - m_pCollectionStack->PushCollectionType(CollectionType::FlowSeq); - - while(1) { - if(m_scanner.empty()) - throw ParserException(Mark::null(), ErrorMsg::END_OF_SEQ_FLOW); - - // first check for end - if(m_scanner.peek().type == Token::FLOW_SEQ_END) { - m_scanner.pop(); - break; - } - - // then read the node - HandleNode(eventHandler); - - // now eat the separator (or could be a sequence end, which we ignore - but if it's neither, then it's a bad node) - Token& token = m_scanner.peek(); - if(token.type == Token::FLOW_ENTRY) - m_scanner.pop(); - else if(token.type != Token::FLOW_SEQ_END) - throw ParserException(token.mark, ErrorMsg::END_OF_SEQ_FLOW); - } - - m_pCollectionStack->PopCollectionType(CollectionType::FlowSeq); - } - - void SingleDocParser::HandleMap(EventHandler& eventHandler) - { - // split based on start token - switch(m_scanner.peek().type) { - case Token::BLOCK_MAP_START: HandleBlockMap(eventHandler); break; - case Token::FLOW_MAP_START: HandleFlowMap(eventHandler); break; - case Token::KEY: HandleCompactMap(eventHandler); break; - case Token::VALUE: HandleCompactMapWithNoKey(eventHandler); break; - default: break; - } - } - - void SingleDocParser::HandleBlockMap(EventHandler& eventHandler) - { - // eat start token - m_scanner.pop(); - m_pCollectionStack->PushCollectionType(CollectionType::BlockMap); - - while(1) { - if(m_scanner.empty()) - throw ParserException(Mark::null(), ErrorMsg::END_OF_MAP); - - Token token = m_scanner.peek(); - if(token.type != Token::KEY && token.type != Token::VALUE && token.type != Token::BLOCK_MAP_END) - throw ParserException(token.mark, ErrorMsg::END_OF_MAP); - - if(token.type == Token::BLOCK_MAP_END) { - m_scanner.pop(); - break; - } - - // grab key (if non-null) - if(token.type == Token::KEY) { - m_scanner.pop(); - HandleNode(eventHandler); - } else { - eventHandler.OnNull(token.mark, NullAnchor); - } - - // now grab value (optional) - if(!m_scanner.empty() && m_scanner.peek().type == Token::VALUE) { - m_scanner.pop(); - HandleNode(eventHandler); - } else { - eventHandler.OnNull(token.mark, NullAnchor); - } - } - - m_pCollectionStack->PopCollectionType(CollectionType::BlockMap); - } - - void SingleDocParser::HandleFlowMap(EventHandler& eventHandler) - { - // eat start token - m_scanner.pop(); - m_pCollectionStack->PushCollectionType(CollectionType::FlowMap); - - while(1) { - if(m_scanner.empty()) - throw ParserException(Mark::null(), ErrorMsg::END_OF_MAP_FLOW); - - Token& token = m_scanner.peek(); - // first check for end - if(token.type == Token::FLOW_MAP_END) { - m_scanner.pop(); - break; - } - - // grab key (if non-null) - if(token.type == Token::KEY) { - m_scanner.pop(); - HandleNode(eventHandler); - } else { - eventHandler.OnNull(token.mark, NullAnchor); - } - - // now grab value (optional) - if(!m_scanner.empty() && m_scanner.peek().type == Token::VALUE) { - m_scanner.pop(); - HandleNode(eventHandler); - } else { - eventHandler.OnNull(token.mark, NullAnchor); - } - - // now eat the separator (or could be a map end, which we ignore - but if it's neither, then it's a bad node) - Token& nextToken = m_scanner.peek(); - if(nextToken.type == Token::FLOW_ENTRY) - m_scanner.pop(); - else if(nextToken.type != Token::FLOW_MAP_END) - throw ParserException(nextToken.mark, ErrorMsg::END_OF_MAP_FLOW); - } - - m_pCollectionStack->PopCollectionType(CollectionType::FlowMap); - } - - // . Single "key: value" pair in a flow sequence - void SingleDocParser::HandleCompactMap(EventHandler& eventHandler) - { - m_pCollectionStack->PushCollectionType(CollectionType::CompactMap); - - // grab key - Mark mark = m_scanner.peek().mark; - m_scanner.pop(); - HandleNode(eventHandler); - - // now grab value (optional) - if(!m_scanner.empty() && m_scanner.peek().type == Token::VALUE) { - m_scanner.pop(); - HandleNode(eventHandler); - } else { - eventHandler.OnNull(mark, NullAnchor); - } - - m_pCollectionStack->PopCollectionType(CollectionType::CompactMap); - } - - // . Single ": value" pair in a flow sequence - void SingleDocParser::HandleCompactMapWithNoKey(EventHandler& eventHandler) - { - m_pCollectionStack->PushCollectionType(CollectionType::CompactMap); - - // null key - eventHandler.OnNull(m_scanner.peek().mark, NullAnchor); - - // grab value - m_scanner.pop(); - HandleNode(eventHandler); - - m_pCollectionStack->PopCollectionType(CollectionType::CompactMap); - } - - // ParseProperties - // . Grabs any tag or anchor tokens and deals with them. - void SingleDocParser::ParseProperties(std::string& tag, anchor_t& anchor) - { - tag.clear(); - anchor = NullAnchor; - - while(1) { - if(m_scanner.empty()) - return; - - switch(m_scanner.peek().type) { - case Token::TAG: ParseTag(tag); break; - case Token::ANCHOR: ParseAnchor(anchor); break; - default: return; - } - } - } - - void SingleDocParser::ParseTag(std::string& tag) - { - Token& token = m_scanner.peek(); - if(!tag.empty()) - throw ParserException(token.mark, ErrorMsg::MULTIPLE_TAGS); - - Tag tagInfo(token); - tag = tagInfo.Translate(m_directives); - m_scanner.pop(); - } - - void SingleDocParser::ParseAnchor(anchor_t& anchor) - { - Token& token = m_scanner.peek(); - if(anchor) - throw ParserException(token.mark, ErrorMsg::MULTIPLE_ANCHORS); - - anchor = RegisterAnchor(token.value); - m_scanner.pop(); - } - - anchor_t SingleDocParser::RegisterAnchor(const std::string& name) - { - if(name.empty()) - return NullAnchor; - - return m_anchors[name] = ++m_curAnchor; - } - - anchor_t SingleDocParser::LookupAnchor(const Mark& mark, const std::string& name) const - { - Anchors::const_iterator it = m_anchors.find(name); - if(it == m_anchors.end()) - throw ParserException(mark, ErrorMsg::UNKNOWN_ANCHOR); - - return it->second; - } -} diff --git a/contrib/yaml-cpp-pm/src/singledocparser.h b/contrib/yaml-cpp-pm/src/singledocparser.h deleted file mode 100644 index 33766c823..000000000 --- a/contrib/yaml-cpp-pm/src/singledocparser.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp-pm/anchor.h" -#include "yaml-cpp-pm/noncopyable.h" -#include -#include -#include - -namespace YAML_PM -{ - struct Directives; - struct Mark; - struct Token; - class CollectionStack; - class EventHandler; - class Node; - class Scanner; - - class SingleDocParser: private noncopyable - { - public: - SingleDocParser(Scanner& scanner, const Directives& directives); - ~SingleDocParser(); - - void HandleDocument(EventHandler& eventHandler); - - private: - void HandleNode(EventHandler& eventHandler); - - void HandleSequence(EventHandler& eventHandler); - void HandleBlockSequence(EventHandler& eventHandler); - void HandleFlowSequence(EventHandler& eventHandler); - - void HandleMap(EventHandler& eventHandler); - void HandleBlockMap(EventHandler& eventHandler); - void HandleFlowMap(EventHandler& eventHandler); - void HandleCompactMap(EventHandler& eventHandler); - void HandleCompactMapWithNoKey(EventHandler& eventHandler); - - void ParseProperties(std::string& tag, anchor_t& anchor); - void ParseTag(std::string& tag); - void ParseAnchor(anchor_t& anchor); - - anchor_t RegisterAnchor(const std::string& name); - anchor_t LookupAnchor(const Mark& mark, const std::string& name) const; - - private: - Scanner& m_scanner; - const Directives& m_directives; - std::auto_ptr m_pCollectionStack; - - typedef std::map Anchors; - Anchors m_anchors; - - anchor_t m_curAnchor; - }; -} - -#endif // SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/stream.cpp b/contrib/yaml-cpp-pm/src/stream.cpp deleted file mode 100644 index 927c1c3f7..000000000 --- a/contrib/yaml-cpp-pm/src/stream.cpp +++ /dev/null @@ -1,448 +0,0 @@ -#include "stream.h" -#include -#include "exp.h" - -#ifndef YAML_PREFETCH_SIZE -#define YAML_PREFETCH_SIZE 2048 -#endif - -#define S_ARRAY_SIZE( A ) (sizeof(A)/sizeof(*(A))) -#define S_ARRAY_END( A ) ((A) + S_ARRAY_SIZE(A)) - -#define CP_REPLACEMENT_CHARACTER (0xFFFD) - -namespace YAML_PM -{ - enum UtfIntroState { - uis_start, - uis_utfbe_b1, - uis_utf32be_b2, - uis_utf32be_bom3, - uis_utf32be, - uis_utf16be, - uis_utf16be_bom1, - uis_utfle_bom1, - uis_utf16le_bom2, - uis_utf32le_bom3, - uis_utf16le, - uis_utf32le, - uis_utf8_imp, - uis_utf16le_imp, - uis_utf32le_imp3, - uis_utf8_bom1, - uis_utf8_bom2, - uis_utf8, - uis_error - }; - - enum UtfIntroCharType { - uict00, - uictBB, - uictBF, - uictEF, - uictFE, - uictFF, - uictAscii, - uictOther, - uictMax - }; - - static bool s_introFinalState[] = { - false, //uis_start - false, //uis_utfbe_b1 - false, //uis_utf32be_b2 - false, //uis_utf32be_bom3 - true, //uis_utf32be - true, //uis_utf16be - false, //uis_utf16be_bom1 - false, //uis_utfle_bom1 - false, //uis_utf16le_bom2 - false, //uis_utf32le_bom3 - true, //uis_utf16le - true, //uis_utf32le - false, //uis_utf8_imp - false, //uis_utf16le_imp - false, //uis_utf32le_imp3 - false, //uis_utf8_bom1 - false, //uis_utf8_bom2 - true, //uis_utf8 - true, //uis_error - }; - - static UtfIntroState s_introTransitions[][uictMax] = { - // uict00, uictBB, uictBF, uictEF, uictFE, uictFF, uictAscii, uictOther - {uis_utfbe_b1, uis_utf8, uis_utf8, uis_utf8_bom1, uis_utf16be_bom1, uis_utfle_bom1, uis_utf8_imp, uis_utf8}, - {uis_utf32be_b2, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf16be, uis_utf8}, - {uis_utf32be, uis_utf8, uis_utf8, uis_utf8, uis_utf32be_bom3, uis_utf8, uis_utf8, uis_utf8}, - {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf32be, uis_utf8, uis_utf8}, - {uis_utf32be, uis_utf32be, uis_utf32be, uis_utf32be, uis_utf32be, uis_utf32be, uis_utf32be, uis_utf32be}, - {uis_utf16be, uis_utf16be, uis_utf16be, uis_utf16be, uis_utf16be, uis_utf16be, uis_utf16be, uis_utf16be}, - {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf16be, uis_utf8, uis_utf8}, - {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf16le_bom2, uis_utf8, uis_utf8, uis_utf8}, - {uis_utf32le_bom3, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le}, - {uis_utf32le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le}, - {uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le}, - {uis_utf32le, uis_utf32le, uis_utf32le, uis_utf32le, uis_utf32le, uis_utf32le, uis_utf32le, uis_utf32le}, - {uis_utf16le_imp, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8}, - {uis_utf32le_imp3, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le}, - {uis_utf32le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le}, - {uis_utf8, uis_utf8_bom2, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8}, - {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8}, - {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8}, - }; - - static char s_introUngetCount[][uictMax] = { - // uict00, uictBB, uictBF, uictEF, uictFE, uictFF, uictAscii, uictOther - {0, 1, 1, 0, 0, 0, 0, 1}, - {0, 2, 2, 2, 2, 2, 2, 2}, - {3, 3, 3, 3, 0, 3, 3, 3}, - {4, 4, 4, 4, 4, 0, 4, 4}, - {1, 1, 1, 1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1, 1, 1, 1}, - {2, 2, 2, 2, 2, 0, 2, 2}, - {2, 2, 2, 2, 0, 2, 2, 2}, - {0, 1, 1, 1, 1, 1, 1, 1}, - {0, 2, 2, 2, 2, 2, 2, 2}, - {1, 1, 1, 1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1, 1, 1, 1}, - {0, 2, 2, 2, 2, 2, 2, 2}, - {0, 3, 3, 3, 3, 3, 3, 3}, - {4, 4, 4, 4, 4, 4, 4, 4}, - {2, 0, 2, 2, 2, 2, 2, 2}, - {3, 3, 0, 3, 3, 3, 3, 3}, - {1, 1, 1, 1, 1, 1, 1, 1}, - }; - - inline UtfIntroCharType IntroCharTypeOf(std::istream::int_type ch) - { - if (std::istream::traits_type::eof() == ch) { - return uictOther; - } - - switch (ch) { - case 0: return uict00; - case 0xBB: return uictBB; - case 0xBF: return uictBF; - case 0xEF: return uictEF; - case 0xFE: return uictFE; - case 0xFF: return uictFF; - } - - if ((ch > 0) && (ch < 0xFF)) { - return uictAscii; - } - - return uictOther; - } - - inline char Utf8Adjust(unsigned long ch, unsigned char lead_bits, unsigned char rshift) - { - const unsigned char header = ((1 << lead_bits) - 1) << (8 - lead_bits); - const unsigned char mask = (0xFF >> (lead_bits + 1)); - return static_cast(static_cast( - header | ((ch >> rshift) & mask) - )); - } - - inline void QueueUnicodeCodepoint(std::deque& q, unsigned long ch) - { - // We are not allowed to queue the Stream::eof() codepoint, so - // replace it with CP_REPLACEMENT_CHARACTER - if (static_cast(Stream::eof()) == ch) - { - ch = CP_REPLACEMENT_CHARACTER; - } - - if (ch < 0x80) - { - q.push_back(Utf8Adjust(ch, 0, 0)); - } - else if (ch < 0x800) - { - q.push_back(Utf8Adjust(ch, 2, 6)); - q.push_back(Utf8Adjust(ch, 1, 0)); - } - else if (ch < 0x10000) - { - q.push_back(Utf8Adjust(ch, 3, 12)); - q.push_back(Utf8Adjust(ch, 1, 6)); - q.push_back(Utf8Adjust(ch, 1, 0)); - } - else - { - q.push_back(Utf8Adjust(ch, 4, 18)); - q.push_back(Utf8Adjust(ch, 1, 12)); - q.push_back(Utf8Adjust(ch, 1, 6)); - q.push_back(Utf8Adjust(ch, 1, 0)); - } - } - - Stream::Stream(std::istream& input) - : m_input(input), - m_pPrefetched(new unsigned char[YAML_PREFETCH_SIZE]), - m_nPrefetchedAvailable(0), m_nPrefetchedUsed(0) - { - typedef std::istream::traits_type char_traits; - - if(!input) - return; - - // Determine (or guess) the character-set by reading the BOM, if any. See - // the YAML specification for the determination algorithm. - char_traits::int_type intro[4]; - int nIntroUsed = 0; - UtfIntroState state = uis_start; - for(; !s_introFinalState[state]; ) { - std::istream::int_type ch = input.get(); - intro[nIntroUsed++] = ch; - UtfIntroCharType charType = IntroCharTypeOf(ch); - UtfIntroState newState = s_introTransitions[state][charType]; - int nUngets = s_introUngetCount[state][charType]; - if(nUngets > 0) { - input.clear(); - for(; nUngets > 0; --nUngets) { - if(char_traits::eof() != intro[--nIntroUsed]) - input.putback(char_traits::to_char_type(intro[nIntroUsed])); - } - } - state = newState; - } - - switch (state) { - case uis_utf8: m_charSet = utf8; break; - case uis_utf16le: m_charSet = utf16le; break; - case uis_utf16be: m_charSet = utf16be; break; - case uis_utf32le: m_charSet = utf32le; break; - case uis_utf32be: m_charSet = utf32be; break; - default: m_charSet = utf8; break; - } - - ReadAheadTo(0); - } - - Stream::~Stream() - { - delete[] m_pPrefetched; - } - - char Stream::peek() const - { - if (m_readahead.empty()) - { - return Stream::eof(); - } - - return m_readahead[0]; - } - - Stream::operator bool() const - { - return m_input.good() || (!m_readahead.empty() && m_readahead[0] != Stream::eof()); - } - - // get - // . Extracts a character from the stream and updates our position - char Stream::get() - { - char ch = peek(); - AdvanceCurrent(); - m_mark.column++; - - if(ch == '\n') { - m_mark.column = 0; - m_mark.line++; - } - - return ch; - } - - // get - // . Extracts 'n' characters from the stream and updates our position - std::string Stream::get(int n) - { - std::string ret; - ret.reserve(n); - for(int i=0;i i; - } - - void Stream::StreamInUtf8() const - { - unsigned char b = GetNextByte(); - if (m_input.good()) - { - m_readahead.push_back(b); - } - } - - void Stream::StreamInUtf16() const - { - unsigned long ch = 0; - unsigned char bytes[2]; - int nBigEnd = (m_charSet == utf16be) ? 0 : 1; - - bytes[0] = GetNextByte(); - bytes[1] = GetNextByte(); - if (!m_input.good()) - { - return; - } - ch = (static_cast(bytes[nBigEnd]) << 8) | - static_cast(bytes[1 ^ nBigEnd]); - - if (ch >= 0xDC00 && ch < 0xE000) - { - // Trailing (low) surrogate...ugh, wrong order - QueueUnicodeCodepoint(m_readahead, CP_REPLACEMENT_CHARACTER); - return; - } - else if (ch >= 0xD800 && ch < 0xDC00) - { - // ch is a leading (high) surrogate - - // Four byte UTF-8 code point - - // Read the trailing (low) surrogate - for (;;) - { - bytes[0] = GetNextByte(); - bytes[1] = GetNextByte(); - if (!m_input.good()) - { - QueueUnicodeCodepoint(m_readahead, CP_REPLACEMENT_CHARACTER); - return; - } - unsigned long chLow = (static_cast(bytes[nBigEnd]) << 8) | - static_cast(bytes[1 ^ nBigEnd]); - if (chLow < 0xDC00 || ch >= 0xE000) - { - // Trouble...not a low surrogate. Dump a REPLACEMENT CHARACTER into the stream. - QueueUnicodeCodepoint(m_readahead, CP_REPLACEMENT_CHARACTER); - - // Deal with the next UTF-16 unit - if (chLow < 0xD800 || ch >= 0xE000) - { - // Easiest case: queue the codepoint and return - QueueUnicodeCodepoint(m_readahead, ch); - return; - } - else - { - // Start the loop over with the new high surrogate - ch = chLow; - continue; - } - } - - // Select the payload bits from the high surrogate - ch &= 0x3FF; - ch <<= 10; - - // Include bits from low surrogate - ch |= (chLow & 0x3FF); - - // Add the surrogacy offset - ch += 0x10000; - } - } - - QueueUnicodeCodepoint(m_readahead, ch); - } - - inline char* ReadBuffer(unsigned char* pBuffer) - { - return reinterpret_cast(pBuffer); - } - - unsigned char Stream::GetNextByte() const - { - if (m_nPrefetchedUsed >= m_nPrefetchedAvailable) - { - std::streambuf *pBuf = m_input.rdbuf(); - m_nPrefetchedAvailable = pBuf->sgetn(ReadBuffer(m_pPrefetched), - YAML_PREFETCH_SIZE); - m_nPrefetchedUsed = 0; - if (!m_nPrefetchedAvailable) - { - m_input.setstate(std::ios_base::eofbit); - } - - if (0 == m_nPrefetchedAvailable) - { - return 0; - } - } - - return m_pPrefetched[m_nPrefetchedUsed++]; - } - - void Stream::StreamInUtf32() const - { - static int indexes[2][4] = { - {3, 2, 1, 0}, - {0, 1, 2, 3} - }; - - unsigned long ch = 0; - unsigned char bytes[4]; - int* pIndexes = (m_charSet == utf32be) ? indexes[1] : indexes[0]; - - bytes[0] = GetNextByte(); - bytes[1] = GetNextByte(); - bytes[2] = GetNextByte(); - bytes[3] = GetNextByte(); - if (!m_input.good()) - { - return; - } - - for (int i = 0; i < 4; ++i) - { - ch <<= 8; - ch |= bytes[pIndexes[i]]; - } - - QueueUnicodeCodepoint(m_readahead, ch); - } -} diff --git a/contrib/yaml-cpp-pm/src/stream.h b/contrib/yaml-cpp-pm/src/stream.h deleted file mode 100644 index 2b88ee861..000000000 --- a/contrib/yaml-cpp-pm/src/stream.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp-pm/noncopyable.h" -#include "yaml-cpp-pm/mark.h" -#include -#include -#include -#include -#include -#include - -namespace YAML_PM -{ - class Stream: private noncopyable - { - public: - friend class StreamCharSource; - - Stream(std::istream& input); - ~Stream(); - - operator bool() const; - bool operator !() const { return !static_cast (*this); } - - char peek() const; - char get(); - std::string get(int n); - void eat(int n = 1); - - static char eof() { return 0x04; } - - const Mark mark() const { return m_mark; } - int pos() const { return m_mark.pos; } - int line() const { return m_mark.line; } - int column() const { return m_mark.column; } - void ResetColumn() { m_mark.column = 0; } - - private: - enum CharacterSet {utf8, utf16le, utf16be, utf32le, utf32be}; - - std::istream& m_input; - Mark m_mark; - - CharacterSet m_charSet; - mutable std::deque m_readahead; - unsigned char* const m_pPrefetched; - mutable size_t m_nPrefetchedAvailable; - mutable size_t m_nPrefetchedUsed; - - void AdvanceCurrent(); - char CharAt(size_t i) const; - bool ReadAheadTo(size_t i) const; - bool _ReadAheadTo(size_t i) const; - void StreamInUtf8() const; - void StreamInUtf16() const; - void StreamInUtf32() const; - unsigned char GetNextByte() const; - }; - - // CharAt - // . Unchecked access - inline char Stream::CharAt(size_t i) const { - return m_readahead[i]; - } - - inline bool Stream::ReadAheadTo(size_t i) const { - if(m_readahead.size() > i) - return true; - return _ReadAheadTo(i); - } -} - -#endif // STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/streamcharsource.h b/contrib/yaml-cpp-pm/src/streamcharsource.h deleted file mode 100644 index b22a99d5d..000000000 --- a/contrib/yaml-cpp-pm/src/streamcharsource.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp-pm/noncopyable.h" -#include - -namespace YAML_PM -{ - class StreamCharSource - { - public: - StreamCharSource(const Stream& stream): m_offset(0), m_stream(stream) {} - StreamCharSource(const StreamCharSource& source): m_offset(source.m_offset), m_stream(source.m_stream) {} - ~StreamCharSource() {} - - operator bool() const; - char operator [] (std::size_t i) const { return m_stream.CharAt(m_offset + i); } - bool operator !() const { return !static_cast(*this); } - - const StreamCharSource operator + (int i) const; - - private: - std::size_t m_offset; - const Stream& m_stream; - - StreamCharSource& operator = (const StreamCharSource&); // non-assignable - }; - - inline StreamCharSource::operator bool() const { - return m_stream.ReadAheadTo(m_offset); - } - - inline const StreamCharSource StreamCharSource::operator + (int i) const { - StreamCharSource source(*this); - if(static_cast (source.m_offset) + i >= 0) - source.m_offset += i; - else - source.m_offset = 0; - return source; - } -} - -#endif // STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/stringsource.h b/contrib/yaml-cpp-pm/src/stringsource.h deleted file mode 100644 index b41e269e8..000000000 --- a/contrib/yaml-cpp-pm/src/stringsource.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include - -namespace YAML_PM -{ - class StringCharSource - { - public: - StringCharSource(const char *str, std::size_t size): m_str(str), m_size(size), m_offset(0) {} - - operator bool() const { return m_offset < m_size; } - char operator [] (std::size_t i) const { return m_str[m_offset + i]; } - bool operator !() const { return !static_cast(*this); } - - const StringCharSource operator + (int i) const { - StringCharSource source(*this); - if(static_cast (source.m_offset) + i >= 0) - source.m_offset += i; - else - source.m_offset = 0; - return source; - } - - StringCharSource& operator ++ () { - ++m_offset; - return *this; - } - - StringCharSource& operator += (std::size_t offset) { - m_offset += offset; - return *this; - } - private: - const char *m_str; - std::size_t m_size; - std::size_t m_offset; - }; -} - -#endif // STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/tag.cpp b/contrib/yaml-cpp-pm/src/tag.cpp deleted file mode 100644 index 8b72a20f1..000000000 --- a/contrib/yaml-cpp-pm/src/tag.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "tag.h" -#include "directives.h" -#include "token.h" -#include -#include - -namespace YAML_PM -{ - Tag::Tag(const Token& token): type(static_cast(token.data)) - { - switch(type) { - case VERBATIM: - value = token.value; - break; - case PRIMARY_HANDLE: - value = token.value; - break; - case SECONDARY_HANDLE: - value = token.value; - break; - case NAMED_HANDLE: - handle = token.value; - value = token.params[0]; - break; - case NON_SPECIFIC: - break; - default: - assert(false); - } - } - - const std::string Tag::Translate(const Directives& directives) - { - switch(type) { - case VERBATIM: - return value; - case PRIMARY_HANDLE: - return directives.TranslateTagHandle("!") + value; - case SECONDARY_HANDLE: - return directives.TranslateTagHandle("!!") + value; - case NAMED_HANDLE: - return directives.TranslateTagHandle("!" + handle + "!") + value; - case NON_SPECIFIC: - // TODO: - return "!"; - default: - assert(false); - } - throw std::runtime_error("yaml-cpp: internal error, bad tag type"); - } -} - diff --git a/contrib/yaml-cpp-pm/src/tag.h b/contrib/yaml-cpp-pm/src/tag.h deleted file mode 100644 index 27614ff58..000000000 --- a/contrib/yaml-cpp-pm/src/tag.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include - -namespace YAML_PM -{ - struct Token; - struct Directives; - - struct Tag { - enum TYPE { - VERBATIM, PRIMARY_HANDLE, SECONDARY_HANDLE, NAMED_HANDLE, NON_SPECIFIC - }; - - Tag(const Token& token); - const std::string Translate(const Directives& directives); - - TYPE type; - std::string handle, value; - }; -} - -#endif // TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/src/token.h b/contrib/yaml-cpp-pm/src/token.h deleted file mode 100644 index 1a0ff7a2b..000000000 --- a/contrib/yaml-cpp-pm/src/token.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM -#define TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp-pm/mark.h" -#include -#include -#include - -namespace YAML_PM -{ - const std::string TokenNames[] = { - "DIRECTIVE", - "DOC_START", - "DOC_END", - "BLOCK_SEQ_START", - "BLOCK_MAP_START", - "BLOCK_SEQ_END", - "BLOCK_MAP_END", - "BLOCK_ENTRY", - "FLOW_SEQ_START", - "FLOW_MAP_START", - "FLOW_SEQ_END", - "FLOW_MAP_END", - "FLOW_MAP_COMPACT", - "FLOW_ENTRY", - "KEY", - "VALUE", - "ANCHOR", - "ALIAS", - "TAG", - "SCALAR" - }; - - struct Token { - // enums - enum STATUS { VALID, INVALID, UNVERIFIED }; - enum TYPE { - DIRECTIVE, - DOC_START, - DOC_END, - BLOCK_SEQ_START, - BLOCK_MAP_START, - BLOCK_SEQ_END, - BLOCK_MAP_END, - BLOCK_ENTRY, - FLOW_SEQ_START, - FLOW_MAP_START, - FLOW_SEQ_END, - FLOW_MAP_END, - FLOW_MAP_COMPACT, - FLOW_ENTRY, - KEY, - VALUE, - ANCHOR, - ALIAS, - TAG, - PLAIN_SCALAR, - NON_PLAIN_SCALAR - }; - - // data - Token(TYPE type_, const Mark& mark_): status(VALID), type(type_), mark(mark_), data(0) {} - - friend std::ostream& operator << (std::ostream& out, const Token& token) { - out << TokenNames[token.type] << std::string(": ") << token.value; - for(std::size_t i=0;i params; - int data; - }; -} - -#endif // TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM diff --git a/contrib/yaml-cpp-pm/util/CMakeLists.txt b/contrib/yaml-cpp-pm/util/CMakeLists.txt deleted file mode 100644 index 22339f025..000000000 --- a/contrib/yaml-cpp-pm/util/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_executable(parse parse.cpp) -target_link_libraries(parse yaml-cpp) diff --git a/contrib/yaml-cpp-pm/util/api.cpp b/contrib/yaml-cpp-pm/util/api.cpp deleted file mode 100644 index 769091260..000000000 --- a/contrib/yaml-cpp-pm/util/api.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// a sketch of what the new API might look like - -#include "yaml-cpp-pm/yaml.h" -#include - -int main() -{ - { - // test.yaml - // - foo - // - primes: [2, 3, 5, 7, 11] - // odds: [1, 3, 5, 7, 9, 11] - // - [x, y] - - // move-like semantics - YAML::Value root = YAML::Parse("test.yaml"); - - std::cout << root[0].as(); // "foo" - std::cout << str(root[0]); // "foo", shorthand? - std::cout << root[1]["primes"][3].as(); // "7" - std::cout << root[1]["odds"][6].as(); // throws? - - root[2].push_back(5); - root[3] = "Hello, World"; - root[0].reset(); - root[0]["key"] = "value"; - - std::cout << root; - // # not sure about formatting - // - {key: value} - // - primes: [2, 3, 5, 7, 11] - // odds: [1, 3, 5, 7, 9, 11] - // - [x, y, 5] - // - Hello, World - } - - { - // for all copy-like commands, think of python's "name/value" semantics - YAML::Value root = "Hello"; // Hello - root = YAML::Sequence(); // [] - root[0] = 0; // [0] - root[2] = "two"; // [0, ~, two] # forces root[1] to be initialized to null - - YAML::Value other = root; // both point to the same thing - other[0] = 5; // now root[0] is 0 also - other.push_back(root); // &1 [5, ~, two, *1] - other[3][0] = 0; // &1 [0, ~, two, *1] # since it's a true alias - other.push_back(Copy(root)); // &1 [0, ~, two, *1, &2 [0, ~, two, *2]] - other[4][0] = 5; // &1 [0, ~, two, *1, &2 [5, ~, two, *2]] # they're really different - } - - { - YAML::Value node; // ~ - node[0] = 1; // [1] # auto-construct a sequence - node["key"] = 5; // {0: 1, key: 5} # auto-turn it into a map - node.push_back(10); // error, can't turn a map into a sequence - node.erase("key"); // {0: 1} # still a map, even if we remove the key that caused the problem - node = "Hello"; // Hello # assignment overwrites everything, so it's now just a plain scalar - } - - { - YAML::Value map; // ~ - map[3] = 1; // {3: 1} # auto-constructs a map, *not* a sequence - - YAML::Value seq; // ~ - seq = YAML::Sequence(); // [] - seq[3] = 1; // [~, ~, ~, 1] - } - - { - YAML::Value node; // ~ - node[0] = node; // &1 [*1] # fun stuff - } - - { - YAML::Value node; - YAML::Value subnode = node["key"]; // 'subnode' is not instantiated ('node' is still null) - subnode = "value"; // {key: value} # now it is - YAML::Value subnode2 = node["key2"]; - node["key3"] = subnode2; // subnode2 is still not instantiated, but node["key3"] is "pseudo" aliased to it - subnode2 = "monkey"; // {key: value, key2: &1 monkey, key3: *1} # bam! it instantiates both - } - - { - YAML::Value seq = YAML::Sequence(); - seq[0] = "zero"; // [zero] - seq[1] = seq[0]; // [&1 zero, *1] - seq[0] = seq[1]; // [&1 zero, *1] # no-op (they both alias the same thing, so setting them equal is nothing) - Is(seq[0], seq[1]); // true - seq[1] = "one"; // [&1 one, *1] - UnAlias(seq[1]); // [one, one] - Is(seq[0], seq[1]); // false - } - - { - YAML::Value root; - root.push_back("zero"); - root.push_back("one"); - root.push_back("two"); - YAML::Value two = root[2]; - root = "scalar"; // 'two' is still "two", even though 'root' is "scalar" (the sequence effectively no longer exists) - - // Note: in all likelihood, the memory for nodes "zero" and "one" is still allocated. How can it go away? Weak pointers? - } - - { - YAML::Value root; // ~ - root[0] = root; // &1 [*1] - root[0] = 5; // [5] - } - - { - YAML::Value root; - YAML::Value key; - key["key"] = "value"; - root[key] = key; // &1 {key: value}: *1 - } - - { - YAML::Value root; - root[0] = "hi"; - root[1][0] = "bye"; - root[1][1] = root; // &1 [hi, [bye, *1]] # root - YAML::Value sub = root[1]; // &1 [bye, [hi, *1]] # sub - root = "gone"; // [bye, gone] # sub - } - - return 0; -} diff --git a/contrib/yaml-cpp-pm/util/parse.cpp b/contrib/yaml-cpp-pm/util/parse.cpp deleted file mode 100644 index d369649d4..000000000 --- a/contrib/yaml-cpp-pm/util/parse.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "yaml-cpp-pm/yaml.h" -#include "yaml-cpp-pm/eventhandler.h" -#include -#include -#include - -struct Params { - bool hasFile; - std::string fileName; -}; - -Params ParseArgs(int argc, char **argv) { - Params p; - - std::vector args(argv + 1, argv + argc); - - return p; -} - -class NullEventHandler: public YAML_PM::EventHandler -{ -public: - virtual void OnDocumentStart(const YAML_PM::Mark&) {} - virtual void OnDocumentEnd() {} - - virtual void OnNull(const YAML_PM::Mark&, YAML_PM::anchor_t) {} - virtual void OnAlias(const YAML_PM::Mark&, YAML_PM::anchor_t) {} - virtual void OnScalar(const YAML_PM::Mark&, const std::string&, YAML_PM::anchor_t, const std::string&) {} - - virtual void OnSequenceStart(const YAML_PM::Mark&, const std::string&, YAML_PM::anchor_t) {} - virtual void OnSequenceEnd() {} - - virtual void OnMapStart(const YAML_PM::Mark&, const std::string&, YAML_PM::anchor_t) {} - virtual void OnMapEnd() {} -}; - -void parse(std::istream& input) -{ - try { - YAML_PM::Parser parser(input); - YAML_PM::Node doc; - while(parser.GetNextDocument(doc)) { - YAML_PM::Emitter emitter; - emitter << doc; - std::cout << emitter.c_str() << "\n"; - } - } catch(const YAML_PM::Exception& e) { - std::cerr << e.what() << "\n"; - } -} - -int main(int argc, char **argv) -{ - Params p = ParseArgs(argc, argv); - - if(argc > 1) { - std::ifstream fin; - fin.open(argv[1]); - parse(fin); - } else { - parse(std::cin); - } - - return 0; -} diff --git a/examples/demo_cmake/CMakeLists.txt b/examples/demo_cmake/CMakeLists.txt index 923cbbf38..83ebd2a71 100644 --- a/examples/demo_cmake/CMakeLists.txt +++ b/examples/demo_cmake/CMakeLists.txt @@ -1,16 +1,16 @@ # This is demo on how to link libpointmatcher to an # external project. -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 3.10) project(convert) -set (CMAKE_CXX_STANDARD 11) -add_compile_options(-std=c++11) +set(CMAKE_CXX_STANDARD 11) find_package(libpointmatcher REQUIRED) +find_package(Boost REQUIRED COMPONENTS filesystem) -include_directories(${CMAKE_CURRENT_BINARY_DIR} ${libpointmatcher_INCLUDE_DIRS}) +include_directories(${CMAKE_CURRENT_BINARY_DIR} ${libpointmatcher_INCLUDE_DIRS} ${Boost_INCLUDE_DIR}) add_executable(${PROJECT_NAME} convert.cpp) -target_link_libraries(${PROJECT_NAME} ${libpointmatcher_LIBRARIES}) +target_link_libraries(${PROJECT_NAME} ${libpointmatcher_LIBRARIES} ${Boost_LIBRARIES}) diff --git a/libpointmatcherConfig.cmake.in b/libpointmatcherConfig.cmake.in index 3d7eb1478..f3b03aa50 100644 --- a/libpointmatcherConfig.cmake.in +++ b/libpointmatcherConfig.cmake.in @@ -10,7 +10,7 @@ if (Boost_MINOR_VERSION GREATER 47) find_package(Boost COMPONENTS thread filesystem system program_options date_time chrono REQUIRED) endif () include(${CMAKE_CURRENT_LIST_DIR}/libpointmatcher-config.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/yaml-cpp-pm-targets.cmake) +#include(${CMAKE_CURRENT_LIST_DIR}/yaml-cpp-pm-targets.cmake) # Compute paths get_filename_component(POINTMATCHER_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/pointmatcher/DataPointsFilter.cpp b/pointmatcher/DataPointsFilter.cpp index b01631c41..baec06c06 100644 --- a/pointmatcher/DataPointsFilter.cpp +++ b/pointmatcher/DataPointsFilter.cpp @@ -36,17 +36,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "PointMatcher.h" #include "PointMatcherPrivate.h" -#ifdef SYSTEM_YAML_CPP - #include "yaml-cpp/yaml.h" -#else - #include "yaml-cpp-pm/yaml.h" - namespace YAML = YAML_PM; -#endif // HAVE_YAML_CPP +#include //! Construct without parameter template PointMatcher::DataPointsFilter::DataPointsFilter() -{} +{} //! Construct with parameters template @@ -77,15 +72,13 @@ PointMatcher::DataPointsFilters::DataPointsFilters() template PointMatcher::DataPointsFilters::DataPointsFilters(std::istream& in) { - YAML::Parser parser(in); - YAML::Node doc; - parser.GetNextDocument(doc); + YAML::Node doc = YAML::Load(in); // Fix for issue #6: compilation on gcc 4.4.4 //PointMatcher pm; const PointMatcher & pm = PointMatcher::get(); - for(YAML::Iterator moduleIt = doc.begin(); moduleIt != doc.end(); ++moduleIt) + for(YAML::const_iterator moduleIt = doc.begin(); moduleIt != doc.end(); ++moduleIt) { const YAML::Node& module(*moduleIt); this->push_back(pm.REG(DataPointsFilter).createFromYAML(module)); diff --git a/pointmatcher/ICP.cpp b/pointmatcher/ICP.cpp index adc119cfe..e7cb625bd 100644 --- a/pointmatcher/ICP.cpp +++ b/pointmatcher/ICP.cpp @@ -46,11 +46,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "TransformationCheckersImpl.h" #include "InspectorsImpl.h" -#ifdef SYSTEM_YAML_CPP - #include "yaml-cpp/yaml.h" -#else - #include "yaml-cpp-pm/yaml.h" -#endif // HAVE_YAML_CPP +#include using namespace std; using namespace PointMatcherSupport; @@ -117,10 +113,8 @@ template void PointMatcher::ICPChainBase::loadFromYaml(std::istream& in) { this->cleanup(); - - YAML::Parser parser(in); - YAML::Node doc; - parser.GetNextDocument(doc); + + YAML::Node doc = YAML::Load(in); typedef set StringSet; StringSet usedModuleTypes; @@ -155,10 +149,10 @@ void PointMatcher::ICPChainBase::loadFromYaml(std::istream& in) //loadAdditionalYAMLContent(doc); // check YAML entries that do not correspend to any module - for(YAML::Iterator moduleTypeIt = doc.begin(); moduleTypeIt != doc.end(); ++moduleTypeIt) + for(YAML::const_iterator moduleTypeIt = doc.begin(); moduleTypeIt != doc.end(); ++moduleTypeIt) { - string moduleType; - moduleTypeIt.first() >> moduleType; + std::string moduleType = moduleTypeIt->first.as(); + if (usedModuleTypes.find(moduleType) == usedModuleTypes.end()) throw InvalidModuleType( (boost::format("Module type %1% does not exist") % moduleType).str() @@ -192,16 +186,18 @@ template template const std::string& PointMatcher::ICPChainBase::createModulesFromRegistrar(const std::string& regName, const YAML::Node& doc, const R& registrar, std::vector >& modules) { - const YAML::Node *reg = doc.FindValue(regName); + const YAML::Node reg = doc[regName]; + if (reg) { //cout << regName << endl; - for(YAML::Iterator moduleIt = reg->begin(); moduleIt != reg->end(); ++moduleIt) + for(YAML::const_iterator moduleIt = reg.begin(); moduleIt != reg.end(); ++moduleIt) { const YAML::Node& module(*moduleIt); modules.push_back(registrar.createFromYAML(module)); } } + return regName; } @@ -210,28 +206,33 @@ template template const std::string& PointMatcher::ICPChainBase::createModuleFromRegistrar(const std::string& regName, const YAML::Node& doc, const R& registrar, std::shared_ptr& module) { - const YAML::Node *reg = doc.FindValue(regName); + const YAML::Node reg = doc[regName]; + if (reg) { //cout << regName << endl; - module = registrar.createFromYAML(*reg); + module = registrar.createFromYAML(reg); } else module.reset(); + return regName; } template -std::string PointMatcher::ICPChainBase::nodeVal(const std::string& regName, const PointMatcherSupport::YAML::Node& doc) +std::string PointMatcher::ICPChainBase::nodeVal(const std::string& regName, const YAML::Node& doc) { - const YAML::Node *reg = doc.FindValue(regName); + const YAML::Node reg = doc[regName]; + if (reg) { std::string name; Parametrizable::Parameters params; - PointMatcherSupport::getNameParamsFromYAML(*reg, name, params); + PointMatcherSupport::getNameParamsFromYAML(reg, name, params); + return name; } + return ""; } diff --git a/pointmatcher/PointMatcher.h b/pointmatcher/PointMatcher.h index f26aa2ce0..0529e39ce 100644 --- a/pointmatcher/PointMatcher.h +++ b/pointmatcher/PointMatcher.h @@ -684,18 +684,18 @@ struct PointMatcher void cleanup(); - virtual void loadAdditionalYAMLContent(PointMatcherSupport::YAML::Node& doc); + virtual void loadAdditionalYAMLContent(YAML::Node& doc); //! Instantiate modules if their names are in the YAML file template - const std::string& createModulesFromRegistrar(const std::string& regName, const PointMatcherSupport::YAML::Node& doc, const R& registrar, std::vector >& modules); + const std::string& createModulesFromRegistrar(const std::string& regName, const YAML::Node& doc, const R& registrar, std::vector >& modules); //! Instantiate a module if its name is in the YAML file template - const std::string& createModuleFromRegistrar(const std::string& regName, const PointMatcherSupport::YAML::Node& doc, const R& registrar, std::shared_ptr& module); + const std::string& createModuleFromRegistrar(const std::string& regName, const YAML::Node& doc, const R& registrar, std::shared_ptr& module); //! Get the value of a field in a node - std::string nodeVal(const std::string& regName, const PointMatcherSupport::YAML::Node& doc); + std::string nodeVal(const std::string& regName, const YAML::Node& doc); }; //! ICP algorithm @@ -778,4 +778,3 @@ struct PointMatcher }; // PointMatcher #endif // __POINTMATCHER_CORE_H - diff --git a/pointmatcher/Registrar.cpp b/pointmatcher/Registrar.cpp index e5c2e5e94..f8cb080d8 100644 --- a/pointmatcher/Registrar.cpp +++ b/pointmatcher/Registrar.cpp @@ -1,11 +1,6 @@ #include "PointMatcher.h" -#ifdef SYSTEM_YAML_CPP - #include "yaml-cpp/yaml.h" -#else - #include "yaml-cpp-pm/yaml.h" - namespace YAML = YAML_PM; -#endif // HAVE_YAML_CPP +#include namespace PointMatcherSupport { @@ -14,18 +9,17 @@ namespace PointMatcherSupport if (module.size() != 1) { // parameter-less entry - name = module.to(); + name = module.as(); } else { // get parameters - YAML::Iterator mapIt(module.begin()); - mapIt.first() >> name; - for(YAML::Iterator paramIt = mapIt.second().begin(); paramIt != mapIt.second().end(); ++paramIt) + YAML::const_iterator mapIt(module.begin()); + name = mapIt->first.as(); + for(YAML::const_iterator paramIt = mapIt->second.begin(); paramIt != mapIt->second.end(); ++paramIt) { - std::string key, value; - paramIt.first() >> key; - paramIt.second() >> value; + std::string key = paramIt->first.as(); + std::string value = paramIt->second.as(); params[key] = value; } } diff --git a/pointmatcher/Registrar.h b/pointmatcher/Registrar.h index 706211f07..686a4cf1b 100644 --- a/pointmatcher/Registrar.h +++ b/pointmatcher/Registrar.h @@ -38,30 +38,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "Parametrizable.h" #include "PointMatcher.h" + +#include #include #include - -#ifdef SYSTEM_YAML_CPP - namespace YAML - { - class Node; - } -#else - namespace YAML_PM - { - class Node; - } -#endif // HAVE_YAML_CPP - namespace PointMatcherSupport { -#ifdef SYSTEM_YAML_CPP - namespace YAML = ::YAML; -#else - namespace YAML = ::YAML_PM; -#endif - //! Retrieve name and parameters from a yaml node void getNameParamsFromYAML(const YAML::Node& module, std::string& name, Parametrizable::Parameters& params); From 0a574268425ffeb93c93d4393843688c6e97fa95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pomerleau?= Date: Sat, 14 Oct 2023 09:08:43 -0400 Subject: [PATCH 002/124] Update README.md --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 737fbd0a3..481f9c204 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ Those tutorials are written using Markdown syntax and stored in the project's `/ Libpointmatcher's source code is fully documented based on doxygen to provide an easy API to developers. An example of this API can be found [here](https://norlab.ulaval.ca/libpointmatcher-doc/), but it is suggested to use the one build for your version in `doc/html`. -libpointmatcher is being developed by [François Pomerleau](mailto:f.pomerleau@gmail.com) and [Stéphane Magnenat](http://stephane.magnenat.net) as part of our work at [ASL-ETH](http://www.asl.ethz.ch). +libpointmatcher was orginaly developed by [François Pomerleau](mailto:f.pomerleau@gmail.com) and [Stéphane Magnenat](http://stephane.magnenat.net) as part of our work at [ASL-ETH](http://www.asl.ethz.ch). +It is now maintained by the Northern Robotics Laboratory ([Norlab](https://norlab.ulaval.ca/)), led by François Pomerleau. You can read the latest changes in the [release notes](doc/ReleaseNotes.md). @@ -37,7 +38,8 @@ and was compiled on: ### Compilation & Installation -For beginner users who are not familiar with compiling and installing a library in Linux, go [here](doc/CompilationUbuntu.md) for detailed instructions on how to compile libpointmatcher from the source code. If you are comfortable with Linux and CMake and have already installed the prerequisites above, the following commands should install libpointmatcher on your system. +For beginner users unfamiliar with compiling and installing a library in Linux, go [here](doc/CompilationUbuntu.md) for detailed instructions on compiling libpointmatcher from the source code. +If you are comfortable with Linux and CMake and have already installed the prerequisites above, the following commands should install libpointmatcher on your system. ```bash mkdir build && cd build @@ -57,7 +59,7 @@ utest/utest --path ../examples/data/ ### Linking to external projects. -We mainly develop for __cmake projects__ and we provide example files under [`examples/demo_cmake/`](https://github.com/ethz-asl/libpointmatcher/tree/master/examples/demo_cmake) to help you in your own project. We also provide a __QT Creator__ example in [`examples/demo_QT/`](https://github.com/ethz-asl/libpointmatcher/tree/master/examples/demo_Qt), which manually list all the dependencies in the file [`demo.pro`](https://github.com/ethz-asl/libpointmatcher/blob/master/examples/demo_Qt/demo.pro). You would need to ajust those paths to point at the appropriate locations on your system. For a more detailled procedure, check the [Linking Projects to libpointmatcher](doc/LinkingProjects.md) section. +We mainly develop for __cmake projects__ and we provide example files under [`examples/demo_cmake/`](https://github.com/ethz-asl/libpointmatcher/tree/master/examples/demo_cmake) to help you in your own project. We also provide a __QT Creator__ example in [`examples/demo_QT/`](https://github.com/ethz-asl/libpointmatcher/tree/master/examples/demo_Qt), which manually lists all the dependencies in the file [`demo.pro`](https://github.com/ethz-asl/libpointmatcher/blob/master/examples/demo_Qt/demo.pro). You would need to ajust those paths to point at the appropriate locations on your system. For a more detailed procedure, check the [Linking Projects to libpointmatcher](doc/LinkingProjects.md) section. ### Bug reporting @@ -71,7 +73,7 @@ The library support different file formats for importing or exporting data: * ply (Polygon File Format) * pcd (Point Cloud Library Format) -Those functionnalities are available without increasing the list of dependencies at the expense of a limited functionality support. For more details, see the tutorial [Importing and Exporting Point Clouds](doc/ImportExport.md). Example executables using those file formats from the command line can be found in the `/examples` directory and are described [here](doc/ICPIntro.md) in more details. +Those functionnalities are available without increasing the list of dependencies at the expense of limited functionality support. For more details, see the tutorial [Importing and Exporting Point Clouds](doc/ImportExport.md). Example executables using those file formats from the command line can be found in the `/examples` directory and are described [here](doc/ICPIntro.md) in more detail. # Citing @@ -123,11 +125,11 @@ You can download the files in CSV or VTK formats, which are directly supported b If you are using libpointmatcher in your project and you would like to have it listed here, please contact [François Pomerleau](mailto:f.pomerleau@gmail.com). * European Project [NIFTi](http://www.nifti.eu/) (FP7 ICT-247870): Search and rescue project in dynamic environments. Results: [video of multi-floor reconstruction](http://www.youtube.com/watch?v=lP5Mj-TGaiw) and [video of railyard reconstruction](http://www.youtube.com/watch?v=ygIvzWVfPYk). All results with real-time computation. - * NASA Ames [Stereo Pipeline](https://ti.arc.nasa.gov/tech/asr/groups/intelligent-robotics/ngt/stereo/): Planetary reconstruction from satellite observations. Results: used for Mars, Moon and Earth point clouds. + * NASA Ames [Stereo Pipeline](https://ti.arc.nasa.gov/tech/asr/groups/intelligent-robotics/ngt/stereo/): Planetary reconstruction from satellite observations. Results: used for Mars, Moon, and Earth point clouds. * Armasuisse S+T UGV research program [ARTOR](http://www.artor.ethz.ch/): Development of techniques for reliable autonomous navigation of a wheeled robot in rough, outdoor terrain. Results: [video of urban and dynamic 3D reconstruction](http://www.youtube.com/watch?v=UCCAUf64tD0) and [video of open space 3D reconstruction](http://www.youtube.com/watch?v=M5Y99o7um88) with real-time computation. * Swiss National Science Foundation - [Limnobotics](http://www.limnobotics.ch/): Robotic solution for toxic algae monitoring in lacs. Result: [video of 3D shore reconstruction](http://www.youtube.com/watch?v=g8l-Xq4qYeE) with real-time computation. * [CGAL](https://www.cgal.org/) includes our library for their registration pipeline. - * [Norlab](https://norlab.ulaval.ca/) is maintaining and using the library for their research on autonomous navigation in harsh environments. + * [Norlab](https://norlab.ulaval.ca/) is maintaining and using the library for its research on autonomous navigation in harsh environments. * [ANYbotics AG](https://www.anybotics.com) is investigating autonomous navigation algorithms using this library. * [Point Laz Mining LiDAR Expert](https://www.pointlaz.com/) is scanning mine shafts to ensure infrastructure safety. From aa6f690515a87944091d0ca273d5d99aa6286b44 Mon Sep 17 00:00:00 2001 From: boxanm <47394922+boxanm@users.noreply.github.com> Date: Thu, 26 Oct 2023 03:39:59 -0400 Subject: [PATCH 003/124] Update CompilationPython.md --- doc/CompilationPython.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/CompilationPython.md b/doc/CompilationPython.md index 85aa4ab86..5f2101a79 100644 --- a/doc/CompilationPython.md +++ b/doc/CompilationPython.md @@ -42,6 +42,12 @@ sudo apt install catch python3-dev brew install catch2 ``` +#### Case-sensitivity +Note that to build pypointmatcher, your filesystem must be case-sensitive. +This applies especially to MacOS, where the APFS is case-insensitive for legacy reasons. +To overcome this, open `Disk Utility` and add a new case-sensitive APFS volume to your container. +Then, move libpointmatcher to the new volume. + The rest of this tutorial will guide you through the necessary steps to compile pypointmatcher. ## pybind11 From f46ee5d80a938a9ec936db54760d648d0a719577 Mon Sep 17 00:00:00 2001 From: KernelA <17554646+KernelA@users.noreply.github.com> Date: Mon, 30 Oct 2023 14:40:04 +0300 Subject: [PATCH 004/124] Set boost static link to OFF by default --- .github/workflows/build-python.yaml | 2 ++ CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-python.yaml b/.github/workflows/build-python.yaml index 75c18b788..490122edb 100644 --- a/.github/workflows/build-python.yaml +++ b/.github/workflows/build-python.yaml @@ -266,6 +266,7 @@ jobs: -Dpybind11_DIR=${{ env.PYBIND11_INSTALL_PATH }}/share/cmake/pybind11 \ -DBUILD_PYTHON_MODULE:BOOL=ON \ -DUSE_OPEN_MP:BOOL=ON \ + -DBoost_USE_STATIC_LIBS=ON \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -S . -B ${{ env.BUILD_DIR }} sudo cmake --build ${{ env.BUILD_DIR }} --target install @@ -280,6 +281,7 @@ jobs: -DLIBNABO_INSTALL_DIR:PATH="${{ env.LIBNABO_INSTALL_PATH }}" ` -Dpybind11_DIR:PATH="${{ env.PYBIND11_INSTALL_PATH }}/share/cmake/pybind11" ` -DBUILD_PYTHON_MODULE:BOOL=ON ` + -DBoost_USE_STATIC_LIBS=ON ` -DPYTHON_INSTALL_TARGET:PATH="./python/${{ env.PYTHON_PACKAGE_NAME }}" ` -DVCPKG_TARGET_TRIPLET="x64-windows-static" ` -DUSE_OPEN_MP:BOOL=ON ` diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c6d14117..4386f4b0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,7 +127,7 @@ endif() #-------------------- # DEPENDENCY: boost #-------------------- -set(Boost_USE_STATIC_LIBS ON) +set(Boost_USE_STATIC_LIBS OFF) find_package(Boost REQUIRED COMPONENTS thread filesystem system program_options date_time) if (Boost_MINOR_VERSION GREATER 47) From d92dcd0879037887cd091ffd6a374cd51ec3f661 Mon Sep 17 00:00:00 2001 From: KernelA <17554646+KernelA@users.noreply.github.com> Date: Mon, 30 Oct 2023 14:40:30 +0300 Subject: [PATCH 005/124] Migrate to pyproject.toml --- python/pyproject.toml | 10 +++++++++- python/setup.cfg | 5 ----- 2 files changed, 9 insertions(+), 6 deletions(-) delete mode 100644 python/setup.cfg diff --git a/python/pyproject.toml b/python/pyproject.toml index 115f8d0af..a57528f77 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -2,5 +2,13 @@ requires = [ "setuptools>=61.0", "wheel>=0.36", + "build>=0.10" +] +build-backend = "setuptools.build_meta" + +[project] +name = "pypointmatcher" +classifiers = [ + "Intended Audience :: Developers", + "Programming Language :: Python :: 3" ] -build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/python/setup.cfg b/python/setup.cfg deleted file mode 100644 index 563822d8c..000000000 --- a/python/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[metadata] -name = pypointmatcher -classifiers = - Intended Audience :: Developers - Programming Language :: Python :: 3 \ No newline at end of file From 1f1d6d91951ace900ab2e21dbfb26d8e1480495f Mon Sep 17 00:00:00 2001 From: KernelA <17554646+KernelA@users.noreply.github.com> Date: Mon, 30 Oct 2023 14:47:34 +0300 Subject: [PATCH 006/124] Note about static linkage --- doc/CompilationPython.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/CompilationPython.md b/doc/CompilationPython.md index 85aa4ab86..a162996cf 100644 --- a/doc/CompilationPython.md +++ b/doc/CompilationPython.md @@ -129,6 +129,8 @@ cmake -DBUILD_PYTHON_MODULE=ON .. Everything is now set up to proceed to the compilation and the installation. +> **Note** *If you want to compile boost with static linkage, then make sure that it was compiled with position independent code. pybind compiles dynamic library. Static linking in dynamic library can be done if the static library was compiled with position independent code.* + ## Compilation Now, to compile pypointmatcher into the `build/` directory, run the following command: From 65cb5ec2932c458789d650c7ab8ec48004e8afcc Mon Sep 17 00:00:00 2001 From: KernelA <17554646+KernelA@users.noreply.github.com> Date: Mon, 30 Oct 2023 14:57:19 +0300 Subject: [PATCH 007/124] Run action for develop branch --- .github/workflows/build-python.yaml | 8 ++++---- CMakeLists.txt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-python.yaml b/.github/workflows/build-python.yaml index 490122edb..ceb1c387a 100644 --- a/.github/workflows/build-python.yaml +++ b/.github/workflows/build-python.yaml @@ -6,7 +6,7 @@ on: tags: - '[0-9]+.[0-9]+.[0-9]+' pull_request: - branches: [master] + branches: [master, develop] workflow_dispatch: env: @@ -184,7 +184,7 @@ jobs: if: ${{ steps.cache-boost.outputs.cache-hit != 'true' && runner.os == 'Linux' }} working-directory: ${{ env.BOOST_SRC_DIR }}/${{ env.BOOST_DIR }} run: | - ./bootstrap.sh --with-libraries=thread,filesystem,system,program_options,date_time,chrono --with-icu --with-python=python --prefix=${{ env.BOOST_INSTALL_PATH }} + ./bootstrap.sh --with-libraries=thread,filesystem,system,program_options,date_time,chrono --with-icu --prefix=${{ env.BOOST_INSTALL_PATH }} ./b2 cxxflags=-fPIC cflags=-fPIC link=static install - name: Download source code libnabo ${{ env.LIBNABO_VERSION }} @@ -266,7 +266,7 @@ jobs: -Dpybind11_DIR=${{ env.PYBIND11_INSTALL_PATH }}/share/cmake/pybind11 \ -DBUILD_PYTHON_MODULE:BOOL=ON \ -DUSE_OPEN_MP:BOOL=ON \ - -DBoost_USE_STATIC_LIBS=ON \ + -DBoost_USE_STATIC_LIBS:BOOL=ON \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -S . -B ${{ env.BUILD_DIR }} sudo cmake --build ${{ env.BUILD_DIR }} --target install @@ -281,7 +281,7 @@ jobs: -DLIBNABO_INSTALL_DIR:PATH="${{ env.LIBNABO_INSTALL_PATH }}" ` -Dpybind11_DIR:PATH="${{ env.PYBIND11_INSTALL_PATH }}/share/cmake/pybind11" ` -DBUILD_PYTHON_MODULE:BOOL=ON ` - -DBoost_USE_STATIC_LIBS=ON ` + -DBoost_USE_STATIC_LIBS:BOOL=ON ` -DPYTHON_INSTALL_TARGET:PATH="./python/${{ env.PYTHON_PACKAGE_NAME }}" ` -DVCPKG_TARGET_TRIPLET="x64-windows-static" ` -DUSE_OPEN_MP:BOOL=ON ` diff --git a/CMakeLists.txt b/CMakeLists.txt index 4386f4b0d..7380be5d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,7 +127,7 @@ endif() #-------------------- # DEPENDENCY: boost #-------------------- -set(Boost_USE_STATIC_LIBS OFF) +set(Boost_USE_STATIC_LIBS OFF CACHE BOOL "Set to TRUE to use static boost") find_package(Boost REQUIRED COMPONENTS thread filesystem system program_options date_time) if (Boost_MINOR_VERSION GREATER 47) From ed50d89cab2db35cd763670d2abd3ddf359bceb6 Mon Sep 17 00:00:00 2001 From: KernelA <17554646+KernelA@users.noreply.github.com> Date: Mon, 30 Oct 2023 16:31:02 +0300 Subject: [PATCH 008/124] Remove boost static linkage value (by default it is OFF) --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7380be5d3..714cc14c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,8 +127,6 @@ endif() #-------------------- # DEPENDENCY: boost #-------------------- -set(Boost_USE_STATIC_LIBS OFF CACHE BOOL "Set to TRUE to use static boost") - find_package(Boost REQUIRED COMPONENTS thread filesystem system program_options date_time) if (Boost_MINOR_VERSION GREATER 47) find_package(Boost REQUIRED COMPONENTS thread filesystem system program_options date_time chrono) From f35579aaef8c6eec4d2682ab727408aa9fcabe98 Mon Sep 17 00:00:00 2001 From: KernelA <17554646+KernelA@users.noreply.github.com> Date: Mon, 30 Oct 2023 16:55:50 +0300 Subject: [PATCH 009/124] Fix issue with dynamic properties --- .github/workflows/build-python.yaml | 7 +++++-- python/pyproject.toml | 2 ++ python/setup.py | 1 - 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-python.yaml b/.github/workflows/build-python.yaml index ceb1c387a..ab2442bcd 100644 --- a/.github/workflows/build-python.yaml +++ b/.github/workflows/build-python.yaml @@ -294,11 +294,14 @@ jobs: run: | python -m build --wheel --no-isolation --outdir ${{ env.PYTHON_WHEEL_DIR }} - - name: Test package + - name: Install package working-directory: ./python run: | pip install ${{ env.PYTHON_WHEEL_DIR }}/*.whl - python -c "from pypointmatcher import *" + + - name: Test import + working-directory: ${{ runner.temp }} + run: python -c "from pypointmatcher import *" - name: Upload python wheel uses: actions/upload-artifact@v3 diff --git a/python/pyproject.toml b/python/pyproject.toml index a57528f77..f205cf1ed 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -7,7 +7,9 @@ requires = [ build-backend = "setuptools.build_meta" [project] +dynamic = ["version"] name = "pypointmatcher" +dependencies = ["numpy>=1.20"] classifiers = [ "Intended Audience :: Developers", "Programming Language :: Python :: 3" diff --git a/python/setup.py b/python/setup.py index 367f2efa5..3d421c628 100644 --- a/python/setup.py +++ b/python/setup.py @@ -33,7 +33,6 @@ def has_ext_modules(self): setup(packages=find_packages(include=["pypointmatcher*"]), - install_requires=["numpy>=1.20"], package_data={"": ["*.so"]}, version=version, distclass=BinaryDistribution From c3ce0678f8f28d113992f328aa71807cbb9d0310 Mon Sep 17 00:00:00 2001 From: KernelA <17554646+KernelA@users.noreply.github.com> Date: Mon, 30 Oct 2023 17:12:23 +0300 Subject: [PATCH 010/124] Ignore build artifacts --- python/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 python/.gitignore diff --git a/python/.gitignore b/python/.gitignore new file mode 100644 index 000000000..a66c47ad1 --- /dev/null +++ b/python/.gitignore @@ -0,0 +1 @@ +*.egg-info \ No newline at end of file From d07e09662ccf7df2b91363734013b7ee39ada241 Mon Sep 17 00:00:00 2001 From: boxanm Date: Tue, 31 Oct 2023 12:25:45 +0100 Subject: [PATCH 011/124] Clear Python binding compilation guide --- doc/CompilationPython.md | 63 ++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 38 deletions(-) diff --git a/doc/CompilationPython.md b/doc/CompilationPython.md index a162996cf..cb1a9ed3f 100644 --- a/doc/CompilationPython.md +++ b/doc/CompilationPython.md @@ -9,26 +9,25 @@ This tutorial presents the different steps of compiling *pypointmatcher*, the li To get started, you will need the same prerequisites as libpointmatcher, but also some additional dependencies as listed here: -| Name | Version
(Tested August 2020 on Ubuntu 18.04) | -| :--------------- | :-----------------------------------------------: | -| pybind11 | 2.5.0 | -| Python3 | 3.6.9 | -| | | -| **Dependencies** | | -| python3-dev | 3.6.7 | -| catch | 1.10.0 | -| pytest | 5.4.3 | - -`pytest` needs to be installed with `pip`: +| Name | Version
(Tested October 2023 on Ubuntu 22.04) | +| :--------------- |:--------------------------------------------------:| +| pybind11 | 2.5.0 | +| Python3 | 3.10.12 | +| | | +| **Dependencies** | | +| python3-dev | 3.10.6 | +| catch | 1.12.1 | +| pytest | 7.4.2 | -```bash -pip3 install pytest wheel +> ***Note:*** *This guide assumes you're using a virtual python environment. For this, you can use the [virtualenv tool](https://virtualenv.pypa.io/en/stable/). If you are not familiar with Python virtual environments, you can [read this tutorial](https://realpython.com/python-virtual-environments-a-primer/), which explains very well the reasons for using a virtual environment, or [watch this video tutorial](https://youtu.be/nnhjvHYRsmM)* + +Install `pytest` with `pip`: -# If you have multiple installed versions of python3 : -# python3.6 -m pip install pytest +```bash +pip3 install pytest wheel build ``` -But `catch` and `python3-dev` need to be installed with a package manager: +And `catch` and `python3-dev` with your package manager: *Ubuntu users:* @@ -52,7 +51,7 @@ pybind11 is a library used to create Python bindings of existing C++ code and vi The very first step is to clone [pybind11](https://github.com/pybind/pybind11) into a directory of your choice. -At the moment, pypointmatcher can only be compiled with **version 2.5.0** of pybind11. To install the right version, run the following commands: +At the moment, pypointmatcher is only tested for compilation with **version 2.5.0** of pybind11. To install the right version, run the following commands: ```bash cd pybind11 @@ -115,9 +114,7 @@ Once this is done, return to libpointmatcher's `build/` directory. You're now ready to proceed to the [configuration step](#configuration). -## Configuring the variables - -> ***Note:*** *It is recommended to create a virtual environment before proceeding with the next steps. For this, you can use the [virtualenv tool](https://virtualenv.pypa.io/en/stable/). If you are not familiar with Python virtual environments, you can [read this tutorial](https://realpython.com/python-virtual-environments-a-primer/), which explains very well the reasons for using a virtual environment, or [watch this video tutorial](https://youtu.be/nnhjvHYRsmM)* +### Configuring the variables #### Enabling the compilation @@ -136,32 +133,22 @@ Everything is now set up to proceed to the compilation and the installation. Now, to compile pypointmatcher into the `build/` directory, run the following command: ```bash -cmake --build . -j N --target install +make -j 4 +sudo make install ``` -where `N` is the number of jobs (or threads) you allow at once on your computer for the compilation. If `-j` is omitted the native build tool's default number is used. - -> ***Note:*** *Depending on your system, the compilation can take quite some time, so consider leaving the `-j` command with no argument in order to speed up this step.* - ## Installation -And finally, to install the module on your system, run the following command: - +To install the module on your system, first open the `python` directory: ```console -pip install build +cd /libpointmatcher/python ``` - -Return to the `python` directory: +and install the bindings through pip: ```console -cd /libpointmatcher/python -python -m build --wheel --no-isolation --outdir ./dist - -pip install ./dist/pypointmatcher-*.whl +python3 -m build --wheel --no-isolation --outdir /tmp/libpointmatcher +pip3 install /tmp/libpointmatcher/pypointmatcher-*.whl ``` - -**`python -m build` will lead to error** - -Check that all working: +Finally, verify that `pypointmatcher` can be imported as a regular Python package: ``` python -c "from pypointmatcher import *" ``` From 2d7b88c06a2275fe2ffd7d37c4b28b89f4b2ec38 Mon Sep 17 00:00:00 2001 From: boxanm Date: Tue, 31 Oct 2023 12:26:17 +0100 Subject: [PATCH 012/124] Remove deprecated Python install target variable --- python/CMakeLists.txt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index d5d4445a9..636e0e87e 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,9 +1,3 @@ -if("${PYTHON_INSTALL_TARGET}" STREQUAL "") - set(PYTHON_INSTALL_TARGET ${CMAKE_CURRENT_SOURCE_DIR}/pypointmatcher) -endif() - -message(STATUS "The Python module will be install at this location : ${PYTHON_INSTALL_TARGET}") - set(PYBIND11_SOURCES #pointmatcher module pointmatcher/data_points.cpp @@ -110,8 +104,9 @@ if(pybind11_FOUND) pointmatcher) add_dependencies(pypointmatcher_native pointmatcher) + message(STATUS "The Python module will be install at this location : ${CMAKE_CURRENT_SOURCE_DIR}/pypointmatcher") - install(TARGETS pypointmatcher_native LIBRARY DESTINATION ${PYTHON_INSTALL_TARGET}) + install(TARGETS pypointmatcher_native LIBRARY DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/pypointmatcher) else() message(FATAL_ERROR "pybind11 is required! Please follow the \"Compiling \ libpointmatcher's with Python\" instructions from the official libpointmatcher's documentation.") From 2a68c3efe2cf6d038d21411f28535e33e2c335a2 Mon Sep 17 00:00:00 2001 From: boxanm Date: Wed, 15 Nov 2023 15:32:58 -0500 Subject: [PATCH 013/124] Add yaml-cpp dependency --- .github/workflows/build-python.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-python.yaml b/.github/workflows/build-python.yaml index ab2442bcd..74883f691 100644 --- a/.github/workflows/build-python.yaml +++ b/.github/workflows/build-python.yaml @@ -131,6 +131,7 @@ jobs: gcc \ make \ libeigen3-dev \ + libyaml-cpp-dev \ ninja-build \ catch \ libomp-dev \ From 4e9f2326175eb68d62dd26b581af1660bd770964 Mon Sep 17 00:00:00 2001 From: boxanm Date: Wed, 15 Nov 2023 17:08:03 -0500 Subject: [PATCH 014/124] Change yaml-cpp scope to PUBLIC to fix build on macOS X --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c37f7de31..36b69685b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -369,8 +369,8 @@ else() endif() if(yaml-cpp_FOUND) - target_link_libraries(pointmatcher PRIVATE ${YAML_CPP_LIBRARIES}) - target_include_directories(pointmatcher PRIVATE ${YAML_CPP_INCLUDE_DIR}) + target_link_libraries(pointmatcher PUBLIC ${YAML_CPP_LIBRARIES}) + target_include_directories(pointmatcher PUBLIC ${YAML_CPP_INCLUDE_DIR}) endif() target_link_libraries(pointmatcher PUBLIC ${Boost_LIBRARIES}) From 9a1443c3e6b357e703942ac27a50191ebc3a18f1 Mon Sep 17 00:00:00 2001 From: boxanm Date: Wed, 15 Nov 2023 17:22:46 -0500 Subject: [PATCH 015/124] Add yaml-cpp dependency to the compilation guides --- doc/CompilationMac.md | 30 +++++++++++++++++++++++++++--- doc/CompilationUbuntu.md | 37 +++++++++++++++++++++++-------------- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/doc/CompilationMac.md b/doc/CompilationMac.md index 71a89451b..3a8f843ac 100644 --- a/doc/CompilationMac.md +++ b/doc/CompilationMac.md @@ -20,6 +20,7 @@ If you are used to development project, here is what you need: |_Dependency:_ || |boost | 1.57.0 | |eigen | 3.2.4 | +|yaml-cpp | 0.5+ | |libnabo | [from source](https://github.com/ethz-asl/libnabo) | @@ -111,12 +112,35 @@ The Eigen linear algebra is required before installing libpointmatcher and can b brew install eigen ``` -### 2. Installing libnabo +### 2. Installing yaml-cpp + +The straightforward way to install yaml-cpp library through brew was, as for hte end 2023, not functional +```bash +brew install yaml-cpp +``` +Instead, you can install the library from sources. Follow https://github.com/jbeder/yaml-cpp/tree/master +```bash +mkdir ~/Libraries/ +cd ~/Libraries +git clone git@github.com:jbeder/yaml-cpp.git +cd yaml-cpp +``` +Now you can compile and install yaml-cpp by entering the following commands + +```bash +SRC_DIR=$PWD +BUILD_DIR=${SRC_DIR}/build +mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} +cmake .. +make +sudo make install +``` + +### 3. Installing libnabo libnabo is a library for performing fast nearest-neighbor searches in low-dimensional spaces. It can be found [here](https://github.com/ethz-asl/libnabo). Clone the source repository into a local directory of your choice. ```bash -mkdir ~/Libraries/ cd ~/Libraries git clone git://github.com/ethz-asl/libnabo.git cd libnabo @@ -150,7 +174,7 @@ sudo make install *Note:* If Eigen or Boost are not in their regular system locations you will have to indicate their location by setting the corresponding CMake flags. You can use the following command to default flags: Go [here](#possible-caveats) to see how it can be achieve. -### 3. Installing libpointmatcher +### 4. Installing libpointmatcher First, you need to clone the source repository into a local directory. As an example we reuse the Libraries directory that was created to contain the libnabo sources. diff --git a/doc/CompilationUbuntu.md b/doc/CompilationUbuntu.md index f42a4e63f..c9dcf9ca3 100644 --- a/doc/CompilationUbuntu.md +++ b/doc/CompilationUbuntu.md @@ -7,18 +7,19 @@ If you are used to development projects, here is what you need: -|Name |Version
(Tested Feb. 20, 2015) |Version
(Tested Sept. 6, 2016) | Version
(Tested Jan. 8, 2019) | -|---------------|-----------------------|-----------------------|-----------------------| -|Ubuntu | 12.04.5 LTS (64 bit) | 14.04.5 LTS (64 bit) | 18.04.1 LTS (64 bit) | -|gcc | 4.6.3 | 4.8.4 | 7.3.0 | -|git | 1.7.9.5 | 1.9.1 | 2.17.1 | -|cmake | 2.8.11.2 | 2.8.12.2 | 3.10.2 | -|doxygen (opt.) | 1.7.6.1 | 1.8.6-2 | 1.8.13-10 | -||||| -| _Dependency:_| | | -|boost | 1.48.0.2 | 1.54.0 | 1.65.1 | -|eigen | 3.0.5 | 3.2.0-8 | 3.3.4-4 | -|libnabo | [from source](https://github.com/ethz-asl/libnabo) | [from source](https://github.com/ethz-asl/libnabo) | [from source](https://github.com/ethz-asl/libnabo) | +| Name | Version
(Tested Feb. 20, 2015) |Version
(Tested Sept. 6, 2016) | Version
(Tested Jan. 8, 2019) | +|----------------|-----------------------------------------|-----------------------|-----------------------| +| Ubuntu | 12.04.5 LTS (64 bit) | 14.04.5 LTS (64 bit) | 18.04.1 LTS (64 bit) | +| gcc | 4.6.3 | 4.8.4 | 7.3.0 | +| git | 1.7.9.5 | 1.9.1 | 2.17.1 | +| cmake | 2.8.11.2 | 2.8.12.2 | 3.10.2 | +| doxygen (opt.) | 1.7.6.1 | 1.8.6-2 | 1.8.13-10 | +| | ||| +| _Dependency:_ | | | +| boost | 1.48.0.2 | 1.54.0 | 1.65.1 | +| eigen | 3.0.5 | 3.2.0-8 | 3.3.4-4 | +| yaml-cpp | 0.5+ | 0.5+ | 0.5+ | +| libnabo | [from source](https://github.com/ethz-asl/libnabo) | [from source](https://github.com/ethz-asl/libnabo) | [from source](https://github.com/ethz-asl/libnabo) | __Note:__ we only support 64-bit systems because of some issues with Eigen. Other versions will most probably work but you'll have to try yourself to know for sure. @@ -86,7 +87,15 @@ The Eigen linear algebra library is required before installing libpointmatcher a sudo apt-get install libeigen3-dev ``` -### 2. Installing libnabo +### 2. Installing yaml-cpp + +The yaml-cpp library can be installed via apt by running: + +```bash +sudo apt-get install libyaml-cpp-dev +``` + +### 3. Installing libnabo libnabo is a library for performing fast nearest-neighbor searches in low-dimensional spaces. It can be found [here](https://github.com/ethz-asl/libnabo). Clone the source repository into a local directory of your choice. @@ -137,7 +146,7 @@ sudo apt-get install libyaml-cpp0.3-dev The yaml-cpp package for Trusty Tahr provides yaml-cpp0.5. Libpointmatcher is so far only compatible with yaml-cpp0.3 and thus an older version of yaml-cpp should be installed manually. --> -### 3. Installing libpointmatcher +### 4. Installing libpointmatcher First, you need to clone the source repository into a local directory. As an example, we reuse the Libraries directory that was created to contain the libnabo sources. From 0358dd06d615bc8593d794df94eeca582c047776 Mon Sep 17 00:00:00 2001 From: boxanm Date: Thu, 16 Nov 2023 08:16:41 -0500 Subject: [PATCH 016/124] Fix Transformations test build when using Eigen3.4 --- utest/ui/Transformations.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utest/ui/Transformations.cpp b/utest/ui/Transformations.cpp index ab1c51d46..e65138a39 100644 --- a/utest/ui/Transformations.cpp +++ b/utest/ui/Transformations.cpp @@ -59,7 +59,7 @@ static inline void assertOnDataPointsTransformation(const PM::DataPoints& cloud, EXPECT_EQ(cloud.featureLabels, transformedCloud.featureLabels); EXPECT_EQ(cloud.descriptorLabels, transformedCloud.descriptorLabels); EXPECT_EQ(cloud.timeLabels, transformedCloud.timeLabels); - EXPECT_EQ(cloud.times, transformedCloud.times); + EXPECT_TRUE(cloud.times.isApprox(transformedCloud.times, 0)); } //--------------------------- From 93dd753c3fbffb91f193512f1679986b46876395 Mon Sep 17 00:00:00 2001 From: boxanm Date: Thu, 16 Nov 2023 13:28:22 -0500 Subject: [PATCH 017/124] New commit to trigger build server --- utest/ui/Transformations.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/utest/ui/Transformations.cpp b/utest/ui/Transformations.cpp index e65138a39..d2fb43d4c 100644 --- a/utest/ui/Transformations.cpp +++ b/utest/ui/Transformations.cpp @@ -3,7 +3,6 @@ using namespace std; using namespace PointMatcherSupport; - static inline Eigen::Transform buildUpTransformation2D(const Eigen::Matrix& translation, const Eigen::Rotation2D& rotation, const NumericType scale = 1.0) From 238d2fb5d8b719d8c98c65d61e2ea23e5d697697 Mon Sep 17 00:00:00 2001 From: boxanm Date: Mon, 20 Nov 2023 16:19:42 -0500 Subject: [PATCH 018/124] Replace 3D point cloud by 2D data inside 2D transformation tests --- utest/ui/Transformations.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/utest/ui/Transformations.cpp b/utest/ui/Transformations.cpp index d2fb43d4c..6e4f97c47 100644 --- a/utest/ui/Transformations.cpp +++ b/utest/ui/Transformations.cpp @@ -185,7 +185,7 @@ TEST(Transformation, ComputePureTranslationDataPoints2D) const Eigen::Rotation2D rotation{ 0 }; const Eigen::Transform transformation = buildUpTransformation2D(translation, rotation); // Transform and assert on the result. - assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + assertOnDataPointsTransformation(data2D, transformation.matrix(), transformator); } // Pure translation. { @@ -193,7 +193,7 @@ TEST(Transformation, ComputePureTranslationDataPoints2D) const Eigen::Rotation2D rotation{ 0 }; const Eigen::Transform transformation = buildUpTransformation2D(translation, rotation); // Transform and assert on the result. - assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + assertOnDataPointsTransformation(data2D, transformation.matrix(), transformator); } } @@ -230,7 +230,7 @@ TEST(Transformation, ComputeRigidTransformDataPoints2D) const Eigen::Rotation2D rotation{ 0 }; const Eigen::Transform transformation = buildUpTransformation2D(translation, rotation); // Transform and assert on the result. - assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + assertOnDataPointsTransformation(data2D, transformation.matrix(), transformator); } // Pure translation. { @@ -238,7 +238,7 @@ TEST(Transformation, ComputeRigidTransformDataPoints2D) const Eigen::Rotation2D rotation{ 0 }; const Eigen::Transform transformation = buildUpTransformation2D(translation, rotation); // Transform and assert on the result. - assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + assertOnDataPointsTransformation(data2D, transformation.matrix(), transformator); } // Pure rotation. { @@ -246,7 +246,7 @@ TEST(Transformation, ComputeRigidTransformDataPoints2D) const Eigen::Rotation2D rotation{ 3.53453 }; const Eigen::Transform transformation = buildUpTransformation2D(translation, rotation); // Transform and assert on the result. - assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + assertOnDataPointsTransformation(data2D, transformation.matrix(), transformator); } // Translation + rotation. { @@ -254,7 +254,7 @@ TEST(Transformation, ComputeRigidTransformDataPoints2D) const Eigen::Rotation2D rotation{ -123.3 }; const Eigen::Transform transformation = buildUpTransformation2D(translation, rotation); // Transform and assert on the result. - assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + assertOnDataPointsTransformation(data2D, transformation.matrix(), transformator); } } @@ -310,7 +310,7 @@ TEST(Transformation, ComputeSimilarityTransformDataPoints2D) const NumericType scale{ 1.0 }; const Eigen::Transform transformation = buildUpTransformation2D(translation, rotation, scale); // Transform and assert on the result. - assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + assertOnDataPointsTransformation(data2D, transformation.matrix(), transformator); } // Pure Upscaling. { @@ -319,7 +319,7 @@ TEST(Transformation, ComputeSimilarityTransformDataPoints2D) const NumericType scale{ 5.0 }; const Eigen::Transform transformation = buildUpTransformation2D(translation, rotation, scale); // Transform and assert on the result. - assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + assertOnDataPointsTransformation(data2D, transformation.matrix(), transformator); } // Pure Downscaling. { @@ -328,7 +328,7 @@ TEST(Transformation, ComputeSimilarityTransformDataPoints2D) const NumericType scale{ 0.1 }; const Eigen::Transform transformation = buildUpTransformation2D(translation, rotation, scale); // Transform and assert on the result. - assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + assertOnDataPointsTransformation(data2D, transformation.matrix(), transformator); } // Pure translation + Downscaling. { @@ -337,7 +337,7 @@ TEST(Transformation, ComputeSimilarityTransformDataPoints2D) const NumericType scale{ 0.5 }; const Eigen::Transform transformation = buildUpTransformation2D(translation, rotation, scale); // Transform and assert on the result. - assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + assertOnDataPointsTransformation(data2D, transformation.matrix(), transformator); } // Pure rotation + Upscaling. { @@ -346,7 +346,7 @@ TEST(Transformation, ComputeSimilarityTransformDataPoints2D) const NumericType scale{ 1.9 }; const Eigen::Transform transformation = buildUpTransformation2D(translation, rotation, scale); // Transform and assert on the result. - assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + assertOnDataPointsTransformation(data2D, transformation.matrix(), transformator); } // Translation + rotation + Upscaling. { @@ -355,7 +355,7 @@ TEST(Transformation, ComputeSimilarityTransformDataPoints2D) const NumericType scale{ 1.9 }; const Eigen::Transform transformation = buildUpTransformation2D(translation, rotation, scale); // Transform and assert on the result. - assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + assertOnDataPointsTransformation(data2D, transformation.matrix(), transformator); } } From bf10bb8f873f30625408ad569825902f442e3fe1 Mon Sep 17 00:00:00 2001 From: boxanm Date: Tue, 21 Nov 2023 09:54:45 -0500 Subject: [PATCH 019/124] Added AddDescriptorDataPointsFilter --- CMakeLists.txt | 1 + .../DataPointsFilters/AddDescriptor.cpp | 42 ++++++++++++++ .../DataPointsFilters/AddDescriptor.h | 57 +++++++++++++++++++ pointmatcher/DataPointsFiltersImpl.h | 2 + pointmatcher/Parametrizable.h | 55 ++++++++++++++++-- pointmatcher/Registrar.h | 2 +- pointmatcher/Registry.cpp | 1 + 7 files changed, 155 insertions(+), 5 deletions(-) create mode 100644 pointmatcher/DataPointsFilters/AddDescriptor.cpp create mode 100644 pointmatcher/DataPointsFilters/AddDescriptor.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 36b69685b..95d4af29f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -314,6 +314,7 @@ set(POINTMATCHER_SRC pointmatcher/ErrorMinimizers/PointToPointSimilarity.cpp pointmatcher/ErrorMinimizers/Identity.cpp #DataPointsFilters + pointmatcher/DataPointsFilters/AddDescriptor.cpp pointmatcher/DataPointsFilters/Identity.cpp pointmatcher/DataPointsFilters/RemoveNaN.cpp pointmatcher/DataPointsFilters/MaxDist.cpp diff --git a/pointmatcher/DataPointsFilters/AddDescriptor.cpp b/pointmatcher/DataPointsFilters/AddDescriptor.cpp new file mode 100644 index 000000000..7c0500ecf --- /dev/null +++ b/pointmatcher/DataPointsFilters/AddDescriptor.cpp @@ -0,0 +1,42 @@ +// kate: replace-tabs off; indent-width 4; indent-mode normal +// vim: ts=4:sw=4:noexpandtab + +#include "AddDescriptor.h" + +template +AddDescriptorDataPointsFilter::AddDescriptorDataPointsFilter(const Parameters& params) : + PointMatcher::DataPointsFilter("AddDescriptorDataPointsFilter", + AddDescriptorDataPointsFilter::availableParameters(), params), + descriptorName(Parametrizable::get("descriptorName")), + descriptorDimension(Parametrizable::get("descriptorDimension")), + descriptorValues(Parametrizable::getVector("descriptorValues")) +{ + assert(descriptorDimension == descriptorValues.size()); +} + +// AddDescriptorDataPointsFilter +template +typename PointMatcher::DataPoints AddDescriptorDataPointsFilter::filter( + const DataPoints& input) +{ + DataPoints output(input); + inPlaceFilter(output); + return output; +} + +// In-place filter +template +void AddDescriptorDataPointsFilter::inPlaceFilter( + DataPoints& cloud) +{ + Matrix matrix = PM::Matrix::Ones(descriptorDimension, cloud.getNbPoints()); + for(std::size_t i = 0; i < descriptorDimension; ++i) + { + matrix.row(i) *= descriptorValues[i]; + } + cloud.addDescriptor(descriptorName, matrix); + +} + +template struct AddDescriptorDataPointsFilter; +template struct AddDescriptorDataPointsFilter; diff --git a/pointmatcher/DataPointsFilters/AddDescriptor.h b/pointmatcher/DataPointsFilters/AddDescriptor.h new file mode 100644 index 000000000..27d1bfb01 --- /dev/null +++ b/pointmatcher/DataPointsFilters/AddDescriptor.h @@ -0,0 +1,57 @@ +// kate: replace-tabs off; indent-width 4; indent-mode normal +// vim: ts=4:sw=4:noexpandtab + +#pragma once + +#include "PointMatcher.h" + +//! Add new descriptor to an existing point cloud +template +struct AddDescriptorDataPointsFilter : public PointMatcher::DataPointsFilter +{ + // Type definitions + typedef PointMatcher PM; + typedef typename PM::DataPoints DataPoints; + typedef typename PM::DataPointsFilter DataPointsFilter; + + typedef PointMatcherSupport::Parametrizable Parametrizable; + typedef PointMatcherSupport::Parametrizable P; + typedef Parametrizable::Parameters Parameters; + typedef Parametrizable::ParameterDoc ParameterDoc; + typedef Parametrizable::ParametersDoc ParametersDoc; + typedef Parametrizable::InvalidParameter InvalidParameter; + + typedef typename PointMatcher::Matrix Matrix; + typedef typename PointMatcher::Vector Vector; + typedef typename PointMatcher::DataPoints::InvalidField InvalidField; + + const std::string descriptorName; + const std::size_t descriptorDimension; + const std::vector descriptorValues; + + inline static const std::string description() + { + return "Adds a new descriptor to an existing point cloud.\n\n" + "Required descriptors: none.\n" + "Produced descriptors: User defined.\n" + "Altered descriptors: none.\n" + "Altered features: none."; + } + + inline static const ParametersDoc availableParameters() + { + return { + {"descriptorName", "Name of the descriptor to be added.", "testDescriptor" }, + {"descriptorDimension", "Length of the descriptor to be added.", "1", "1", "4294967295", &P::Comp < std::size_t > }, + {"descriptorValues", "Values of the descriptor to be added.\n" + "List of 'descriptorDimension' numbers of type T, separated by commas, closed in brackets,\n" + "e.g. [2.2, 3.0, 6.1]", ""} + }; + } + + //Constructor, uses parameter interface + explicit AddDescriptorDataPointsFilter(const Parameters& params = Parameters()); + + virtual DataPoints filter(const DataPoints& input); + virtual void inPlaceFilter(DataPoints& cloud); +}; diff --git a/pointmatcher/DataPointsFiltersImpl.h b/pointmatcher/DataPointsFiltersImpl.h index 8f6612938..a24d71d07 100644 --- a/pointmatcher/DataPointsFiltersImpl.h +++ b/pointmatcher/DataPointsFiltersImpl.h @@ -36,6 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef __POINTMATCHER_DATAPOINTSFILTERS_H #define __POINTMATCHER_DATAPOINTSFILTERS_H +#include "DataPointsFilters/AddDescriptor.h" #include "DataPointsFilters/Identity.h" #include "DataPointsFilters/RemoveNaN.h" #include "DataPointsFilters/MaxDist.h" @@ -70,6 +71,7 @@ template struct DataPointsFiltersImpl { typedef ::IdentityDataPointsFilter IdentityDataPointsFilter; + typedef ::AddDescriptorDataPointsFilter AddDescriptorDataPointsFilter; typedef ::RemoveNaNDataPointsFilter RemoveNaNDataPointsFilter; typedef ::MaxDistDataPointsFilter MaxDistDataPointsFilter; typedef ::MinDistDataPointsFilter MinDistDataPointsFilter; diff --git a/pointmatcher/Parametrizable.h b/pointmatcher/Parametrizable.h index 318e7f12c..d2c407637 100644 --- a/pointmatcher/Parametrizable.h +++ b/pointmatcher/Parametrizable.h @@ -45,6 +45,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #define BOOST_ASSIGN_MAX_PARAMS 6 #include +#include namespace PointMatcherSupport @@ -77,7 +78,37 @@ namespace PointMatcherSupport { return boost::lexical_cast(arg); } - + + //! Special case of lexical cast to std::vector + template + inline std::vector lexical_cast_vector(const std::string& arg) + { + std::string cleanedInput = arg; + if (cleanedInput.find('[') != 0) + { + throw std::runtime_error("Vector parameter '" + arg + "' must start with '['"); + } + if (cleanedInput.find(']') != cleanedInput.size()-1) + { + throw std::runtime_error("Vector parameter '" + arg + "' must end with ']'"); + } + cleanedInput.erase(std::remove(cleanedInput.begin(), cleanedInput.end(), '['), cleanedInput.end()); + cleanedInput.erase(std::remove(cleanedInput.begin(), cleanedInput.end(), ' '), cleanedInput.end()); + cleanedInput.erase(std::remove(cleanedInput.begin(), cleanedInput.end(), ']'), cleanedInput.end()); + + // Split the string into a vector of strings using commas as the delimiter + std::vector tokens; + boost::algorithm::split(tokens, cleanedInput, boost::algorithm::is_any_of(",")); + + std::vector result; + result.reserve(tokens.size()); + for(const auto& token: tokens) + { + auto value = lexical_cast_scalar_to_string(token); + result.push_back(value); + } + return result; + } //! Special case of lexical cast to float, use lexical_cast_scalar_to_string template<> inline float lexical_cast(const std::string& arg) { return lexical_cast_scalar_to_string(arg); } @@ -87,12 +118,24 @@ namespace PointMatcherSupport // - //! Return the a string value using lexical_cast + //! Return the string value using lexical_cast template - std::string toParam(const S& value) + inline std::string toParam(const S& value) { return lexical_cast(value); } + + //! Return the string value of a std::vector + template + inline std::string toParam(const std::vector& input) + { + std::ostringstream oss; + oss << "["; + std::copy(input.begin(), input.end() - 1, + std::ostream_iterator(oss, ", ")); + oss << input.back() << "]"; + return oss.str(); + } //! The superclass of classes that are constructed using generic parameters. This class provides the parameter storage and fetching mechanism struct Parametrizable @@ -170,7 +213,11 @@ namespace PointMatcherSupport //! Return the value of paramName, lexically-casted to S template S get(const std::string& paramName) { return lexical_cast(getParamValueString(paramName)); } - + + //! Return the value of paramName, lexically-casted std::vector + template + inline std::vector getVector(const std::string& paramName) {return lexical_cast_vector(getParamValueString(paramName)); } + friend std::ostream& operator<< (std::ostream& o, const Parametrizable& p); }; std::ostream& operator<< (std::ostream& o, const Parametrizable::ParametersDoc& p); diff --git a/pointmatcher/Registrar.h b/pointmatcher/Registrar.h index 686a4cf1b..5bfa8654e 100644 --- a/pointmatcher/Registrar.h +++ b/pointmatcher/Registrar.h @@ -113,7 +113,7 @@ namespace PointMatcherSupport { for (const auto& param : params) throw Parametrizable::InvalidParameter( - (boost::format("Parameter %1% was set but module %2% dos not use any parameter") % param.first % className).str() + (boost::format("Parameter %1% was set but module %2% does not use any parameter") % param.first % className).str() ); return std::make_shared(); diff --git a/pointmatcher/Registry.cpp b/pointmatcher/Registry.cpp index 512b2aef3..584e56c41 100644 --- a/pointmatcher/Registry.cpp +++ b/pointmatcher/Registry.cpp @@ -64,6 +64,7 @@ PointMatcher::PointMatcher() ADD_TO_REGISTRAR_NO_PARAM(Transformation, PureTranslation, typename TransformationsImpl::PureTranslation) ADD_TO_REGISTRAR_NO_PARAM(Transformation, SimilarityTransformation, typename TransformationsImpl::SimilarityTransformation) + ADD_TO_REGISTRAR(DataPointsFilter, AddDescriptorDataPointsFilter, typename DataPointsFiltersImpl::AddDescriptorDataPointsFilter) ADD_TO_REGISTRAR_NO_PARAM(DataPointsFilter, IdentityDataPointsFilter, typename DataPointsFiltersImpl::IdentityDataPointsFilter) ADD_TO_REGISTRAR_NO_PARAM(DataPointsFilter, RemoveNaNDataPointsFilter, typename DataPointsFiltersImpl::RemoveNaNDataPointsFilter) ADD_TO_REGISTRAR(DataPointsFilter, MaxDistDataPointsFilter, typename DataPointsFiltersImpl::MaxDistDataPointsFilter) From 6d8b8896b461437289d9285af3eb531c7ffabf6a Mon Sep 17 00:00:00 2001 From: boxanm Date: Tue, 21 Nov 2023 09:54:53 -0500 Subject: [PATCH 020/124] Added unit tests for the AddDescriptorDataPointsFilter --- utest/ui/DataFilters.cpp | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/utest/ui/DataFilters.cpp b/utest/ui/DataFilters.cpp index 1bff003da..f688a3fba 100644 --- a/utest/ui/DataFilters.cpp +++ b/utest/ui/DataFilters.cpp @@ -950,3 +950,47 @@ TEST_F(DataFilterTest, SpectralDecompositionDataPointsFilter) addFilter("SpectralDecompositionDataPointsFilter", params); validate3dTransformation(); } + +TEST_F(DataFilterTest, AddDescriptorDataPointsFilter) +{ + using DPFiltersPtr = std::shared_ptr; + + // Test with point cloud + DP cloud = generateRandomDataPoints(100); + + std::string descriptorName = "test_descriptor"; + std::size_t descriptorDimension = 3; + std::vector descriptorValues{2, 3, 4}; + + // This filter adds a new descriptor + params = PM::Parameters(); + params["descriptorName"] = descriptorName; + params["descriptorDimension"] = toParam(descriptorDimension); + params["descriptorValues"] = toParam(descriptorValues); + + DPFiltersPtr addDescriptorFilter = PM::get().DataPointsFilterRegistrar.create( + "AddDescriptorDataPointsFilter", params + ); + + DP filteredCloud = addDescriptorFilter->filter(cloud); + + EXPECT_EQ(cloud.getNbPoints(), filteredCloud.getNbPoints()); + EXPECT_EQ(cloud.getDescriptorDim()+descriptorDimension, filteredCloud.getDescriptorDim()); + EXPECT_EQ(cloud.getTimeDim(), filteredCloud.getTimeDim()); + + Eigen::RowVectorX row = Eigen::RowVectorX::Ones(cloud.getNbPoints()); + EXPECT_EQ(filteredCloud.descriptorLabels.back().text, descriptorName); + EXPECT_EQ(filteredCloud.descriptorLabels.back().span, descriptorDimension); + for(unsigned i = 0; i < descriptorDimension; ++i) + { + EXPECT_EQ(filteredCloud.descriptors.row(filteredCloud.descriptors.rows()-3+i), row*descriptorValues[i]); + } + + params = PM::Parameters(); + params["descriptorName"] = "my_descriptor"; + params["descriptorDimension"] = toParam(descriptorDimension); + params["descriptorValues"] = "[2, 3, 4]"; + + addFilter("AddDescriptorDataPointsFilter", params); + validate3dTransformation(); +} \ No newline at end of file From 4c2a42b2d7aa534ae7e0282b6dbb262488dc2139 Mon Sep 17 00:00:00 2001 From: boxanm Date: Tue, 21 Nov 2023 10:16:32 -0500 Subject: [PATCH 021/124] Deal with overwriting existing descriptors --- examples/CMakeLists.txt | 3 +++ .../DataPointsFilters/AddDescriptor.cpp | 22 +++++++++++++++-- .../DataPointsFilters/AddDescriptor.h | 2 +- utest/ui/DataFilters.cpp | 24 +++++++++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b79b78636..e7fbf9084 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,3 +22,6 @@ target_link_libraries(icp_advance_api pointmatcher) add_executable(icp_customized icp_customized.cpp) target_link_libraries(icp_customized pointmatcher) + +add_executable(add_descriptor_debug addDescriptorDebug.cpp) +target_link_libraries(add_descriptor_debug pointmatcher) \ No newline at end of file diff --git a/pointmatcher/DataPointsFilters/AddDescriptor.cpp b/pointmatcher/DataPointsFilters/AddDescriptor.cpp index 7c0500ecf..dc629e5b3 100644 --- a/pointmatcher/DataPointsFilters/AddDescriptor.cpp +++ b/pointmatcher/DataPointsFilters/AddDescriptor.cpp @@ -27,14 +27,32 @@ typename PointMatcher::DataPoints AddDescriptorDataPointsFilter::filter( // In-place filter template void AddDescriptorDataPointsFilter::inPlaceFilter( - DataPoints& cloud) + DataPoints& cloud) { Matrix matrix = PM::Matrix::Ones(descriptorDimension, cloud.getNbPoints()); for(std::size_t i = 0; i < descriptorDimension; ++i) { matrix.row(i) *= descriptorValues[i]; } - cloud.addDescriptor(descriptorName, matrix); + if(!cloud.descriptorExists(descriptorName)) + { + cloud.addDescriptor(descriptorName, matrix); + } + else + { + if(descriptorDimension == cloud.getDescriptorDimension(descriptorName)) + { + cloud.getDescriptorViewByName(descriptorName) = matrix; + } + else + { + // FIXME deal with overwriting descriptors that have different dimensions + throw std::runtime_error("Can't overwrite existing descriptor " + descriptorName + " with dimension " + + std::to_string(cloud.getDescriptorDimension(descriptorName)) + + " by a new descriptor with dimension " + + std::to_string(descriptorDimension) + "."); + } + } } diff --git a/pointmatcher/DataPointsFilters/AddDescriptor.h b/pointmatcher/DataPointsFilters/AddDescriptor.h index 27d1bfb01..855390a30 100644 --- a/pointmatcher/DataPointsFilters/AddDescriptor.h +++ b/pointmatcher/DataPointsFilters/AddDescriptor.h @@ -31,7 +31,7 @@ struct AddDescriptorDataPointsFilter : public PointMatcher::DataPointsFilter inline static const std::string description() { - return "Adds a new descriptor to an existing point cloud.\n\n" + return "Adds a new descriptor to an existing point cloud or overwrites existing descriptor with the same name.\n\n" "Required descriptors: none.\n" "Produced descriptors: User defined.\n" "Altered descriptors: none.\n" diff --git a/utest/ui/DataFilters.cpp b/utest/ui/DataFilters.cpp index f688a3fba..08782adc8 100644 --- a/utest/ui/DataFilters.cpp +++ b/utest/ui/DataFilters.cpp @@ -986,6 +986,30 @@ TEST_F(DataFilterTest, AddDescriptorDataPointsFilter) EXPECT_EQ(filteredCloud.descriptors.row(filteredCloud.descriptors.rows()-3+i), row*descriptorValues[i]); } + + descriptorValues = std::vector{-2, -3, -4}; + params["descriptorValues"] = toParam(descriptorValues); + + addDescriptorFilter = PM::get().DataPointsFilterRegistrar.create( + "AddDescriptorDataPointsFilter", params + ); + DP filteredCloudOvewriteParams = addDescriptorFilter->filter(filteredCloud); + EXPECT_EQ(filteredCloudOvewriteParams.descriptorLabels.back().text, descriptorName); + EXPECT_EQ(filteredCloudOvewriteParams.descriptorLabels.back().span, descriptorDimension); + for(unsigned i = 0; i < descriptorDimension; ++i) + { + EXPECT_EQ(filteredCloudOvewriteParams.descriptors.row(filteredCloud.descriptors.rows()-3+i), row*descriptorValues[i]); + } + + + descriptorValues = std::vector{-2, -3, -4, -5}; + params["descriptorDimension"] = toParam(4); + params["descriptorValues"] = toParam(descriptorValues); + addDescriptorFilter = PM::get().DataPointsFilterRegistrar.create( + "AddDescriptorDataPointsFilter", params + ); + EXPECT_THROW(addDescriptorFilter->filter(filteredCloud), std::runtime_error); + params = PM::Parameters(); params["descriptorName"] = "my_descriptor"; params["descriptorDimension"] = toParam(descriptorDimension); From c4fa9ffe91219db711f8b073f9f701a1b2638276 Mon Sep 17 00:00:00 2001 From: boxanm <47394922+boxanm@users.noreply.github.com> Date: Tue, 21 Nov 2023 10:21:07 -0500 Subject: [PATCH 022/124] Remove debug example file from examples/CMakeLists.txt --- examples/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e7fbf9084..b79b78636 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,6 +22,3 @@ target_link_libraries(icp_advance_api pointmatcher) add_executable(icp_customized icp_customized.cpp) target_link_libraries(icp_customized pointmatcher) - -add_executable(add_descriptor_debug addDescriptorDebug.cpp) -target_link_libraries(add_descriptor_debug pointmatcher) \ No newline at end of file From feb7c2b4609e2c5aa34fcc97a9325cd6e349e9b0 Mon Sep 17 00:00:00 2001 From: boxanm Date: Tue, 21 Nov 2023 11:27:35 -0500 Subject: [PATCH 023/124] Fix descriptor values loading from a .yaml file --- examples/data/add_descriptor_config.yaml | 4 ++++ pointmatcher/Registrar.cpp | 17 +++++++++++++++-- utest/ui/IO.cpp | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 examples/data/add_descriptor_config.yaml diff --git a/examples/data/add_descriptor_config.yaml b/examples/data/add_descriptor_config.yaml new file mode 100644 index 000000000..b873a62c8 --- /dev/null +++ b/examples/data/add_descriptor_config.yaml @@ -0,0 +1,4 @@ +- AddDescriptorDataPointsFilter: + descriptorName: deviation + descriptorDimension: 9 + descriptorValues: [0.0009, 0, 0, 0, 0.0009, 0, 0, 0, 0.0009] \ No newline at end of file diff --git a/pointmatcher/Registrar.cpp b/pointmatcher/Registrar.cpp index f8cb080d8..de9ffd798 100644 --- a/pointmatcher/Registrar.cpp +++ b/pointmatcher/Registrar.cpp @@ -19,8 +19,21 @@ namespace PointMatcherSupport for(YAML::const_iterator paramIt = mapIt->second.begin(); paramIt != mapIt->second.end(); ++paramIt) { std::string key = paramIt->first.as(); - std::string value = paramIt->second.as(); - params[key] = value; + if (paramIt->second.IsSequence()) + { + std::ostringstream oss; + oss << "["; + for(int i = 0; i < paramIt->second.size()-1; ++i) + { + oss << paramIt->second[i] << ", "; + } + oss << paramIt->second[paramIt->second.size()-1] << "]"; + params[key] = oss.str(); + } + else + { + params[key] = paramIt->second.as(); + } } } } diff --git a/utest/ui/IO.cpp b/utest/ui/IO.cpp index 5b3aa6eda..41a2380a8 100644 --- a/utest/ui/IO.cpp +++ b/utest/ui/IO.cpp @@ -25,6 +25,9 @@ TEST(IOTest, loadYaml) std::ifstream ifs3((dataPath + "unit_tests/badIcpConfig_InvalidModuleType.yaml").c_str()); EXPECT_THROW(icp.loadFromYaml(ifs3), PointMatcherSupport::InvalidModuleType); + + std::ifstream ifs4((dataPath + "add_descriptor_config.yaml").c_str()); + EXPECT_NO_THROW(PM::DataPointsFilters filters(ifs4)); } TEST(IOTest, loadCSV) From 58d30f9a354960b5547dc205efcf2c0e89b4ec98 Mon Sep 17 00:00:00 2001 From: boxanm Date: Tue, 21 Nov 2023 17:09:31 -0500 Subject: [PATCH 024/124] Fix build on Ubuntu 18 with Eigen 3.3.4 --- utest/ui/DataFilters.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utest/ui/DataFilters.cpp b/utest/ui/DataFilters.cpp index 08782adc8..371f8f34e 100644 --- a/utest/ui/DataFilters.cpp +++ b/utest/ui/DataFilters.cpp @@ -978,7 +978,7 @@ TEST_F(DataFilterTest, AddDescriptorDataPointsFilter) EXPECT_EQ(cloud.getDescriptorDim()+descriptorDimension, filteredCloud.getDescriptorDim()); EXPECT_EQ(cloud.getTimeDim(), filteredCloud.getTimeDim()); - Eigen::RowVectorX row = Eigen::RowVectorX::Ones(cloud.getNbPoints()); + Eigen::Matrix row = Eigen::Matrix::Ones(cloud.getNbPoints()); EXPECT_EQ(filteredCloud.descriptorLabels.back().text, descriptorName); EXPECT_EQ(filteredCloud.descriptorLabels.back().span, descriptorDimension); for(unsigned i = 0; i < descriptorDimension; ++i) From bdd3e22daaebdbeef8f56623fc54454e34770105 Mon Sep 17 00:00:00 2001 From: boxanm Date: Tue, 21 Nov 2023 22:39:59 -0500 Subject: [PATCH 025/124] Modify CMakeLists and remove random_shuffle to support C++17 --- CMakeLists.txt | 24 +++++++++---------- .../DataPointsFilters/NormalSpace.cpp | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 36b69685b..1adc22df1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.8) include(GNUInstallDirs) # populate CMAKE_INSTALL_{LIB,BIN}DIR include(CheckSymbolExists) @@ -239,21 +239,21 @@ check_symbol_exists(_POSIX_TIMERS "unistd.h;time.h" POSIX_TIMERS) #========================== libpointmatcher itself ============================== -# Check the compiler version as we need full C++11 support. +# Check the compiler version as we need full C++17 support. if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # using Clang - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.3") - message(WARNING, "Your clang compiler has version ${CMAKE_CXX_COMPILER_VERSION}, while only version 3.3 or later is supported") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5") + message(WARNING, "Your clang compiler has version ${CMAKE_CXX_COMPILER_VERSION}, while only version 5 or later is supported") endif () elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") # using AppleClang - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.1") - message(WARNING "Your XCode environment has version ${CMAKE_CXX_COMPILER_VERSION}, while only version 5.1 or later is supported") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "7.0") + message(WARNING "Your XCode environment has version ${CMAKE_CXX_COMPILER_VERSION}, while only version 7.0 or later is supported") endif() elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # using GCC - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.2") - message(WARNING, "Your g++ compiler has version ${CMAKE_CXX_COMPILER_VERSION}, while only version 4.8.2 or later is supported") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9") + message(WARNING, "Your g++ compiler has version ${CMAKE_CXX_COMPILER_VERSION}, while only version 9 or later is supported") endif () elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # using MSVC @@ -262,18 +262,18 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") endif() endif () -# enable C++11 support. -if (CMAKE_VERSION VERSION_LESS "3.1") +# enable C++17 support. +if (CMAKE_VERSION VERSION_LESS "3.8") if (MSVC) message(FATAL_ERROR, "CMake version 3.1 or later is required to compiler ${PROJECT_NAME} with Microsoft Visual C++") endif () if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set (CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}") else () - set (CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}") + set (CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}") endif () else () - set (CMAKE_CXX_STANDARD 11) + set (CMAKE_CXX_STANDARD 17) endif () # SOURCE diff --git a/pointmatcher/DataPointsFilters/NormalSpace.cpp b/pointmatcher/DataPointsFilters/NormalSpace.cpp index c62fd7574..a228adbfc 100644 --- a/pointmatcher/DataPointsFilters/NormalSpace.cpp +++ b/pointmatcher/DataPointsFilters/NormalSpace.cpp @@ -99,7 +99,7 @@ void NormalSpaceDataPointsFilter::inPlaceFilter(DataPoints& cloud) // Generate a random sequence of indices so that elements are placed in buckets in random order std::vector randIdcs(nbPoints); std::iota(randIdcs.begin(), randIdcs.end(), 0); - std::random_shuffle(randIdcs.begin(), randIdcs.end()); + std::shuffle(randIdcs.begin(), randIdcs.end(), gen); ///(1) put all points of the data into buckets based on their normal direction for (auto randIdx : randIdcs) From 5eb2d4a7601f7fe029a7fd238fbddb987cbfb2e9 Mon Sep 17 00:00:00 2001 From: boxanm Date: Tue, 21 Nov 2023 23:01:04 -0500 Subject: [PATCH 026/124] Add Documentation for the AddDescriptorFilter --- doc/DataFilters.md | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/doc/DataFilters.md b/doc/DataFilters.md index b2dfed344..da24f5951 100644 --- a/doc/DataFilters.md +++ b/doc/DataFilters.md @@ -51,19 +51,21 @@ Note that *datapoint filters* differ from *outlier filters* which appear further ### Descriptor Augmenting -1. [Observation Direction Filter](#obsdirectionhead) +1. [Add Descriptor Filter](#adddescriptorhead) -2. [Surface Normal Filter](#surfacenormalhead) +2. [Observation Direction Filter](#obsdirectionhead) -3. [Orient Normals Filter](#orientnormalshead) +3. [Surface Normal Filter](#surfacenormalhead) -4. [Sampling Surface Normal Filter](#samplingnormhead) +4. [Orient Normals Filter](#orientnormalshead) -5. [Simple Sensor Noise Filter](#sensornoisehead) +5. [Sampling Surface Normal Filter](#samplingnormhead) -6. [Saliency Filter](#saliencyhead) +6. [Simple Sensor Noise Filter](#sensornoisehead) -7. [Fixed Step Sampling Filter](#fixedstepsamplinghead) +7. [Saliency Filter](#saliencyhead) + +8. [Fixed Step Sampling Filter](#fixedstepsamplinghead) ## An Example Point Cloud View of an Appartment @@ -74,6 +76,25 @@ The following examples are drawn from the apartment dataset available for [downl ![alt text](images/appt_top.png "Top down view of point cloud from appartment dataset") +## Add Descriptor Filter + +### Description + +Adds a new descriptor to an existing point cloud or overwrites existing descriptor with the same name. + +__Required descriptors:__ none +__Output descriptor:__ User defined. +__Sensor assumed to be at the origin:__ no +__Impact on the number of points:__ none +__Altered descriptors:__ Existing descriptor with name equal to `descriptorName`. +__Altered features:__ none.; + +| Parameter | Description | Default value | Allowable range | +|---------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------|:--------------|:----------------| +| descriptorName | Name of the descriptor to be added. | | | +| descriptorDimension | Length of the descriptor to be added. | 1 | 1 to 4294967295 | +| descriptorValues | Values of the descriptor to be added. List of 'descriptorDimension' numbers of type T, separated by commas, closed in brackets, e.g. [2.2, 3.0, 6.1] | | | + ## Bounding Box Filter ### Description From c15f4f5a7d583aae296da3c1e7d486509c1ceb0a Mon Sep 17 00:00:00 2001 From: boxanm Date: Tue, 21 Nov 2023 23:15:19 -0500 Subject: [PATCH 027/124] Add Python bindings for AddDescriptorFilter --- python/CMakeLists.txt | 1 + python/datapointsfilters/add_descriptor.cpp | 26 +++++++++++++++++++++ python/datapointsfilters/add_descriptor.h | 14 +++++++++++ 3 files changed, 41 insertions(+) create mode 100644 python/datapointsfilters/add_descriptor.cpp create mode 100644 python/datapointsfilters/add_descriptor.h diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 636e0e87e..d4ab984b2 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -49,6 +49,7 @@ set(PYBIND11_SOURCES errorminimizers/point_to_point_with_cov.cpp #datapointfilters module + datapointsfilters/add_descriptor.cpp datapointsfilters/bounding_box.cpp datapointsfilters/covariance_sampling.cpp datapointsfilters/cut_at_descriptor_threshold.cpp diff --git a/python/datapointsfilters/add_descriptor.cpp b/python/datapointsfilters/add_descriptor.cpp new file mode 100644 index 000000000..639a97496 --- /dev/null +++ b/python/datapointsfilters/add_descriptor.cpp @@ -0,0 +1,26 @@ +#include "bounding_box.h" + +#include "DataPointsFilters/AddDescriptor.h" + +namespace python +{ + namespace datapointsfilters + { + void pybindAddDescriptor(py::module& p_module) + { + using AddDescriptorDataPointsFilter = AddDescriptorDataPointsFilter; + py::class_, DataPointsFilter>(p_module, "AddDescriptorDataPointsFilter") + .def_static("description", &AddDescriptorDataPointsFilter::description) + .def_static("availableParameters", &AddDescriptorDataPointsFilter::availableParameters) + + .def_readonly("descriptorName", &AddDescriptorDataPointsFilter::descriptorName) + .def_readonly("descriptorDimension", &AddDescriptorDataPointsFilter::descriptorDimension) + .def_readonly("descriptorValues", &AddDescriptorDataPointsFilter::descriptorValues) + + .def(py::init(), py::arg("params") = Parameters(), "Constructor, uses parameter interface") + + .def("filter", &AddDescriptorDataPointsFilter::filter, py::arg("input")) + .def("inPlaceFilter", &AddDescriptorDataPointsFilter::inPlaceFilter, py::arg("cloud")); + } + } +} diff --git a/python/datapointsfilters/add_descriptor.h b/python/datapointsfilters/add_descriptor.h new file mode 100644 index 000000000..033229be8 --- /dev/null +++ b/python/datapointsfilters/add_descriptor.h @@ -0,0 +1,14 @@ +#ifndef PYTHON_DATAPOINTSFILTERS_ADD_DESCRIPTOR_H +#define PYTHON_DATAPOINTSFILTERS_ADD_DESCRIPTOR_H + +#include "pypoint_matcher_helper.h" + +namespace python +{ + namespace datapointsfilters + { + void pybindAddDescriptor(py::module& p_module); + } +} + +#endif //PYTHON_DATAPOINTSFILTERS_ADD_DESCRIPTOR_H From cf9ee11f01bccc953ec8a1c1d520d1c62fdd035d Mon Sep 17 00:00:00 2001 From: boxanm Date: Sat, 25 Nov 2023 09:54:02 -0500 Subject: [PATCH 028/124] Fix Cmake libnabo Libraries variable --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95d4af29f..fb7c99cc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,7 +161,8 @@ if (NOT TARGET nabo) # Find libnabo: find_package(libnabo REQUIRED PATHS ${LIBNABO_INSTALL_DIR}) if (TARGET libnabo::nabo) - message(STATUS "libnabo found, version ${libnabo_VERSION} (Config mode)") + set(libnabo_LIBRARIES libnabo::nabo) + message(STATUS "libnabo found, version ${libnabo_VERSION} (Config mode, libs=${libnabo_LIBRARIES})") else() message(STATUS "libnabo found, version ${libnabo_VERSION} (include=${libnabo_INCLUDE_DIRS} libs=${libnabo_LIBRARIES})") endif() @@ -173,7 +174,6 @@ endif() # This cmake target alias will be defined by either: # a) libnabo sources if built as a git submodule in the same project than this library, or # b) by libnabo-targets.cmake, included by find_package(libnabo) above. -# set(libnabo_LIBRARIES libnabo::nabo) #-------------------- # DEPENDENCY: OpenMP (optional) From 4f8de80450cbbd480dc85d950a0d1087970cc1bf Mon Sep 17 00:00:00 2001 From: boxanm Date: Sat, 25 Nov 2023 09:54:35 -0500 Subject: [PATCH 029/124] Fix yaml-cpp version 0.8 linking --- CMakeLists.txt | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb7c99cc3..38a7f539b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -220,12 +220,9 @@ endif() message(STATUS "Looking for yaml-cpp on system...") -find_package(yaml-cpp QUIET) - -if(yaml-cpp_FOUND) - message(STATUS "yaml-cpp version ${yaml-cpp_VERSION} found, text-based configuration enabled") -else() - message(STATUS "yaml-cpp not found, text-based configuration and related applications disabled") +find_package(yaml-cpp CONFIG REQUIRED) +if(TARGET yaml-cpp::yaml-cpp) + set(YAML_CPP_LIBRARIES "yaml-cpp::yaml-cpp") endif() #-------------------- @@ -360,7 +357,7 @@ target_include_directories(pointmatcher PUBLIC $ $ $ - $ + $ ) if (NOT MSVC) @@ -369,10 +366,8 @@ else() target_compile_options(pointmatcher PRIVATE /bigobj) endif() -if(yaml-cpp_FOUND) - target_link_libraries(pointmatcher PUBLIC ${YAML_CPP_LIBRARIES}) - target_include_directories(pointmatcher PUBLIC ${YAML_CPP_INCLUDE_DIR}) -endif() +target_link_libraries(pointmatcher PUBLIC ${YAML_CPP_LIBRARIES}) +target_include_directories(pointmatcher PUBLIC ${YAML_CPP_INCLUDE_DIR}) target_link_libraries(pointmatcher PUBLIC ${Boost_LIBRARIES}) From 53617d26a48f69171ef8db0e131bc6b2d75cd519 Mon Sep 17 00:00:00 2001 From: boxanm Date: Sat, 25 Nov 2023 10:00:11 -0500 Subject: [PATCH 030/124] Update repo's website --- package.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.xml b/package.xml index 6e3d7539e..2e4ae2f3f 100644 --- a/package.xml +++ b/package.xml @@ -6,7 +6,7 @@ Francois Pomerleau BSD - https://github.com/ethz-asl/libpointmatcher + https://github.com/norlab-ulaval/libpointmatcher cmake From 900c9326d1066d4324fb88f469b510024edba484 Mon Sep 17 00:00:00 2001 From: boxanm Date: Sat, 25 Nov 2023 10:00:28 -0500 Subject: [PATCH 031/124] Add yaml-cpp as a dependency do package.xml --- package.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.xml b/package.xml index 2e4ae2f3f..2503ee4f7 100644 --- a/package.xml +++ b/package.xml @@ -13,10 +13,12 @@ boost libnabo eigen + yaml-cpp boost libnabo eigen + yaml-cpp catkin From 6aaa9a7ff45476c0f709c1aa0c815341368031ab Mon Sep 17 00:00:00 2001 From: boxanm Date: Sat, 25 Nov 2023 10:00:47 -0500 Subject: [PATCH 032/124] Use CMakePackageConfigHelpers to generate CMake config file --- CMakeLists.txt | 43 +++++++++++++++++----------------- libpointmatcherConfig.cmake.in | 18 +++----------- 2 files changed, 24 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 38a7f539b..ab695cfb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.8) include(GNUInstallDirs) # populate CMAKE_INSTALL_{LIB,BIN}DIR include(CheckSymbolExists) +include(CMakePackageConfigHelpers) #======================== @@ -26,12 +27,8 @@ endif () string(REGEX REPLACE ".*\"(.*)\".*" "\\1" POINTMATCHER_PROJECT_VERSION "${POINTMATCHER_PROJECT_VERSION}") # In 3.0+, project(...) should specify VERSION to satisfy CMP0048 -if (CMAKE_VERSION VERSION_LESS 3.0.0) - project(libpointmatcher) -else () - cmake_policy(SET CMP0048 NEW) - project(libpointmatcher VERSION ${POINTMATCHER_PROJECT_VERSION}) -endif () +cmake_policy(SET CMP0048 NEW) +project(libpointmatcher VERSION ${POINTMATCHER_PROJECT_VERSION}) set(CMAKE_DEBUG_POSTFIX "d") @@ -425,7 +422,7 @@ set(GENERATE_API_DOC false CACHE BOOL "Set to true to build the documentation us if(GENERATE_API_DOC) - message("-- API Documentation (doxygen): enabled") + message(STATUS "API Documentation (doxygen): enabled") # Note: there seems to be equations in the documentation leading to the # use of Latex anyway. This cause problems for user without latex... @@ -444,13 +441,13 @@ endif() #=============== trigger other makefile ====================== -# Example programs +# Example programs TODO option(POINTMATCHER_BUILD_EXAMPLES "Build libpointmatcher examples" ON) if (POINTMATCHER_BUILD_EXAMPLES) add_subdirectory(examples) endif() -# Evaluation programs +# Evaluation programs TODO option(POINTMATCHER_BUILD_EVALUATIONS "Build libpointmatcher evaluations" ON) if (POINTMATCHER_BUILD_EVALUATIONS) add_subdirectory(evaluations) @@ -483,6 +480,8 @@ endif() # target_link_libraries(executableName ${libpointmatcher_LIBRARIES}) # ... +# 1- local build # + # Install cmake config module install(EXPORT ${PROJECT_NAME}-config DESTINATION share/${PROJECT_NAME}/cmake) @@ -500,27 +499,27 @@ get_property(CONF_INCLUDE_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY IN set(POINTMATCHER_LIB $) # Configure config file for local build tree -configure_file(libpointmatcherConfig.cmake.in - "${PROJECT_BINARY_DIR}/libpointmatcherConfig.cmake" @ONLY) +configure_package_config_file(libpointmatcherConfig.cmake.in + "${PROJECT_BINARY_DIR}/libpointmatcherConfig.cmake" + INSTALL_DESTINATION share/libnabo/cmake + PATH_VARS PROJECT_NAME + ) # 2- installation build # # Change the include location for the case of an install location set(CONF_INCLUDE_DIRS ${INSTALL_INCLUDE_DIR} ${CONF_INCLUDE_DIRS} ) -#FIXME: this will only be applied to installed files. Confirm that we want that. -# gather all the includes but remove ones in the source tree -# because we added an include for the local yaml-cpp-pm we should also remove it -list(REMOVE_ITEM CONF_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}) - # We put the generated file for installation in a different repository (i.e., ./CMakeFiles/) -configure_file(libpointmatcherConfig.cmake.in - "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/libpointmatcherConfig.cmake" @ONLY) +configure_package_config_file(libpointmatcherConfig.cmake.in + "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/libpointmatcherConfig.cmake" + INSTALL_DESTINATION share/libnabo/cmake + PATH_VARS PROJECT_NAME + ) # The same versioning file can be used for both cases -configure_file(libpointmatcherConfigVersion.cmake.in - "${PROJECT_BINARY_DIR}/libpointmatcherConfigVersion.cmake" @ONLY) - +write_basic_package_version_file(libpointmatcherConfigVersion.cmake + COMPATIBILITY AnyNewerVersion) # Install the libpointmatcherConfig.cmake and libpointmatcherConfigVersion.cmake install( diff --git a/libpointmatcherConfig.cmake.in b/libpointmatcherConfig.cmake.in index f3b03aa50..1feb40084 100644 --- a/libpointmatcherConfig.cmake.in +++ b/libpointmatcherConfig.cmake.in @@ -2,6 +2,7 @@ # It defines the following variables # libpointmatcher_INCLUDE_DIRS - include directories for pointmatcher # libpointmatcher_LIBRARIES - libraries to link against +@PACKAGE_INIT@ include(CMakeFindDependencyMacro) find_dependency(libnabo REQUIRED) @@ -10,23 +11,10 @@ if (Boost_MINOR_VERSION GREATER 47) find_package(Boost COMPONENTS thread filesystem system program_options date_time chrono REQUIRED) endif () include(${CMAKE_CURRENT_LIST_DIR}/libpointmatcher-config.cmake) -#include(${CMAKE_CURRENT_LIST_DIR}/yaml-cpp-pm-targets.cmake) # Compute paths get_filename_component(POINTMATCHER_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) set(libpointmatcher_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@") -set(LIBPOINTMATCHER_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@") -set(pointmatcher_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@") -set(POINTMATCHER_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@") -set(libpointmatcher_INCLUDE_DIR "@CONF_INCLUDE_DIRS@") +set(libpointmatcher_LIBRARIES "@POINTMATCHER_LIB@;@YAML_CPP_LIBRARIES@;@libnabo_LIBRARIES@;@EXTERNAL_LIBS@;@Boost_LIBRARIES@") -set(libpointmatcher_LIBRARIES "@POINTMATCHER_LIB@;@libnabo_LIBRARIES@;@EXTERNAL_LIBS@;@Boost_LIBRARIES@") -set(LIBPOINTMATCHER_LIBRARIES "@POINTMATCHER_LIB@;@libnabo_LIBRARIES@;@EXTERNAL_LIBS@;@Boost_LIBRARIES@") -set(pointmatcher_LIBRARIES "@POINTMATCHER_LIB@;@libnabo_LIBRARIES@;@EXTERNAL_LIBS@;@Boost_LIBRARIES@") -set(POINTMATCHER_LIBRARIES "@POINTMATCHER_LIB@;@libnabo_LIBRARIES@;@EXTERNAL_LIBS@;@Boost_LIBRARIES@") - -# This causes catkin simple to link against these libraries -set(libpointmatcher_FOUND_CATKIN_PROJECT true) -set(LIBPOINTMATCHER_FOUND_CATKIN_PROJECT true) -set(pointmatcher_FOUND_CATKIN_PROJECT true) -set(POINTMATCHER_FOUND_CATKIN_PROJECT true) +check_required_components("@PROJECT_NAME@") From ff2ffb6376df6f2a9264f980e0d6b10d47b1a2ab Mon Sep 17 00:00:00 2001 From: boxanm Date: Sat, 25 Nov 2023 10:02:56 -0500 Subject: [PATCH 033/124] Update Cmake evaluations and examples variable names --- CMakeLists.txt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab695cfb7..7d5813dc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -441,22 +441,20 @@ endif() #=============== trigger other makefile ====================== -# Example programs TODO -option(POINTMATCHER_BUILD_EXAMPLES "Build libpointmatcher examples" ON) -if (POINTMATCHER_BUILD_EXAMPLES) +# Example programs +option(BUILD_EXAMPLES "Build libpointmatcher examples" ON) +if (BUILD_EXAMPLES) add_subdirectory(examples) endif() -# Evaluation programs TODO -option(POINTMATCHER_BUILD_EVALUATIONS "Build libpointmatcher evaluations" ON) -if (POINTMATCHER_BUILD_EVALUATIONS) +# Evaluation programs +option(BUILD_EVALUATIONS "Build libpointmatcher evaluations" ON) +if (BUILD_EVALUATIONS) add_subdirectory(evaluations) endif() # Unit testing - option(BUILD_TESTS "Build all tests." OFF) - if (BUILD_TESTS) enable_testing() add_subdirectory(utest) From 965df316a3128dea0b87549aaffa2a7cebd55eb0 Mon Sep 17 00:00:00 2001 From: boxanm Date: Sat, 25 Nov 2023 11:25:02 -0500 Subject: [PATCH 034/124] Update yaml-cpp installation on MacOS --- CMakeLists.txt | 4 +++- doc/CompilationMac.md | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d5813dc3..52d2ec064 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,11 +216,13 @@ endif() #-------------------- message(STATUS "Looking for yaml-cpp on system...") - find_package(yaml-cpp CONFIG REQUIRED) if(TARGET yaml-cpp::yaml-cpp) set(YAML_CPP_LIBRARIES "yaml-cpp::yaml-cpp") endif() +if(YAML_CPP_LIBRARIES STREQUAL "") + set(YAML_CPP_LIBRARIES "yaml-cpp") # Fix linking issue on MacOS with yaml-cpp 0.7.0 +endif () #-------------------- # DEPENDENCY: rt (optional) diff --git a/doc/CompilationMac.md b/doc/CompilationMac.md index 3a8f843ac..7f3a631fe 100644 --- a/doc/CompilationMac.md +++ b/doc/CompilationMac.md @@ -114,7 +114,7 @@ brew install eigen ### 2. Installing yaml-cpp -The straightforward way to install yaml-cpp library through brew was, as for hte end 2023, not functional +The straightforward way to install yaml-cpp library through brew was, as for the end of 2023, not functional ```bash brew install yaml-cpp ``` @@ -122,7 +122,7 @@ Instead, you can install the library from sources. Follow https://github.com/jbe ```bash mkdir ~/Libraries/ cd ~/Libraries -git clone git@github.com:jbeder/yaml-cpp.git +git clone -b yaml-cpp-0.7.0 git@github.com:jbeder/yaml-cpp.git cd yaml-cpp ``` Now you can compile and install yaml-cpp by entering the following commands @@ -131,7 +131,7 @@ Now you can compile and install yaml-cpp by entering the following commands SRC_DIR=$PWD BUILD_DIR=${SRC_DIR}/build mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} -cmake .. +cmake -DBUILD_TESTING=FALSE .. make sudo make install ``` From ddf4faada3c5cb3b0566a719beff6732af018c48 Mon Sep 17 00:00:00 2001 From: RedLeaderOne Date: Mon, 27 Nov 2023 15:23:26 -0500 Subject: [PATCH 035/124] feat: prepare libpointmatcher-build-system beta release [NMO-425] --- build_system/.env | 4 +--- build_system/.env.prompt | 4 +++- .../docker-compose.libpointmatcher.yaml | 8 +++---- .../function_library/general_utilities.bash | 2 ++ .../function_library/prompt_utilities.bash | 3 ++- .../function_library/terminal_splash.bash | 4 +++- build_system/lpm_execute_compose.bash | 18 +++++++-------- ...lpm_execute_compose_over_build_matrix.bash | 22 +++++++++---------- .../lpm_utility_script/lpm_bashrc_config.bash | 5 ++++- build_system/ubuntu/Dockerfile.dependencies | 12 +++++----- .../ubuntu/Dockerfile.dependencies_doc | 4 ++-- .../ubuntu/Dockerfile.libpointmatcher | 10 ++++----- .../ubuntu/Dockerfile.libpointmatcher_ci_PR | 12 +++++----- ...ockerfile.libpointmatcher_ci_SITREP_matrix | 12 +++++----- 14 files changed, 64 insertions(+), 56 deletions(-) diff --git a/build_system/.env b/build_system/.env index d30c0d3a4..921cd9645 100644 --- a/build_system/.env +++ b/build_system/.env @@ -11,9 +11,7 @@ LPM_PROJECT_DOCKERHUB=norlabulaval # - Original repo: https://github.com/ethz-asl/libpointmatcher # - DEV repo: https://github.com/norlab-ulaval/libpointmatcher-build-system -# ToDo: on repository ownership transfer >> modify next bloc ↓↓ -LPM_LIBPOINTMATCHER_SRC_DOMAIN=ethz-asl -#LPM_LIBPOINTMATCHER_SRC_DOMAIN=norlab-ulaval +LPM_LIBPOINTMATCHER_SRC_DOMAIN=norlab-ulaval #LPM_LIBPOINTMATCHER_SRC_REPO_NAME=libpointmatcher-build-system # Temporary dev fork LPM_LIBPOINTMATCHER_SRC_REPO_NAME=libpointmatcher diff --git a/build_system/.env.prompt b/build_system/.env.prompt index b4a01d917..bfdcf9cf4 100644 --- a/build_system/.env.prompt +++ b/build_system/.env.prompt @@ -1,9 +1,11 @@ -# (NICE TO HAVE) ToDo: refactor (ref task NMO-304 ♻︎ → Refactor .env.prompt variables prefixed by LPM_ to MSG_) +# (NICE TO HAVE) ToDo: refactor out libpointmatcher-build-system specific env var (move them to the top .env) +# (NICE TO HAVE) ToDo: rename `.env.prompt` to `.env.prompt_style` and move it to the `function_library` LPM_PROMPT_NAME="LPM" LPM_SPLASH_NAME="Libpoinmatcher" LPM_BUILD_SYSTEM_SPLASH_NAME="Libpoinmatcher Build System" +# (NICE TO HAVE) ToDo: refactor (ref task NMO-304 ♻︎ → Refactor .env.prompt variables prefixed by LPM_ to MSG_) LPM_LINE_CHAR_BUILDER_LVL1='▉' LPM_LINE_CHAR_BUILDER_LVL2='⣿' LPM_LINE_CHAR_INSTALLER=':' diff --git a/build_system/docker-compose.libpointmatcher.yaml b/build_system/docker-compose.libpointmatcher.yaml index befe24879..179deac2c 100644 --- a/build_system/docker-compose.libpointmatcher.yaml +++ b/build_system/docker-compose.libpointmatcher.yaml @@ -1,6 +1,6 @@ services: - # ====Dependency related services=================================================================================== + # ====Dependency related services================================================================ dependencies: image: ${LPM_PROJECT_DOCKERHUB:?err}/libpointmatcher-dependencies:${LPM_IMAGE_TAG:?err} build: @@ -34,7 +34,7 @@ services: tty: true stdin_open: true - # ====Pull-request related services================================================================================ + # ====Pull-request related services============================================================== ci_PR: image: ${LPM_PROJECT_DOCKERHUB:?err}/libpointmatcher-ci-pr:${LPM_IMAGE_TAG:?err} pull_policy: build @@ -60,7 +60,7 @@ services: extends: ci_PR platform: "linux/arm64/v8" - # ====Build system assessment services============================================================================== + # ====Build system assessment services=========================================================== ci_SITREP_matrix: image: ${LPM_PROJECT_DOCKERHUB:?err}/libpointmatcher-ci-sitrep-matrix:${LPM_IMAGE_TAG:?err} pull_policy: build @@ -86,7 +86,7 @@ services: extends: ci_SITREP_matrix platform: "linux/arm64/v8" - # ====Dockerhub release image====================================================================================== + # ====Dockerhub release image==================================================================== release: image: ${LPM_PROJECT_DOCKERHUB:?err}/libpointmatcher:${LPM_IMAGE_TAG:?err} container_name: libpointmatcher diff --git a/build_system/function_library/general_utilities.bash b/build_system/function_library/general_utilities.bash index aabc0d4d9..434c7c2a5 100644 --- a/build_system/function_library/general_utilities.bash +++ b/build_system/function_library/general_utilities.bash @@ -39,6 +39,8 @@ source ./function_library/prompt_utilities.bash # Returns: # Return docker command exit code # ================================================================================================================= +# ToDo: redaction >> add read global IS_TEAMCITY_RUN to the doc +# ToDo: assessment >> consider adding the logic determine if run in teamcity in the script instead of relying on the IS_TEAMCITY_RUN env variable function show_and_execute_docker() { local FULL_DOCKER_COMMAND=$1 unset DOCKER_EXIT_CODE diff --git a/build_system/function_library/prompt_utilities.bash b/build_system/function_library/prompt_utilities.bash index be296574a..d3b7dacb6 100644 --- a/build_system/function_library/prompt_utilities.bash +++ b/build_system/function_library/prompt_utilities.bash @@ -133,7 +133,7 @@ function draw_horizontal_line_across_the_terminal_window() { local pad # Ref https://bash.cyberciti.biz/guide/$TERM_variable - TPUT_FLAG='' + TPUT_FLAG="-T $TERM" if [[ -z ${TERM} ]]; then TPUT_FLAG='-T xterm-256color' elif [[ ${TERM} == dumb ]]; then @@ -149,6 +149,7 @@ function draw_horizontal_line_across_the_terminal_window() { #printf '%*s\n' "${COLUMNS:-$(tput ${TPUT_FLAG} cols)}" '' | tr ' ' "${SYMBOL}" # Alt version + # shellcheck disable=SC2086 terminal_width="${COLUMNS:-$(tput ${TPUT_FLAG} cols)}" pad=$(printf -- "${SYMBOL}%.0s" $(seq $terminal_width)) printf -- "${pad}\n" diff --git a/build_system/function_library/terminal_splash.bash b/build_system/function_library/terminal_splash.bash index eee570839..b9d74062c 100644 --- a/build_system/function_library/terminal_splash.bash +++ b/build_system/function_library/terminal_splash.bash @@ -9,6 +9,7 @@ #set -v # ....Pre-condition................................................................................................ +# ToDo: assessment >> next precondition ↓↓ not required if [[ "$(basename $(pwd))" != "build_system" ]]; then echo -e "\nERROR: This script must be sourced from directory 'build_system'!\n cwd: $(pwd)" exit 1 @@ -56,7 +57,7 @@ function echo_centering_str() { #echo "\$COLUMNS=${COLUMNS}" # Ref https://bash.cyberciti.biz/guide/$TERM_variable - TPUT_FLAG='' + TPUT_FLAG="-T $TERM" if [[ -z ${TERM} ]]; then TPUT_FLAG='-T xterm-256color' elif [[ ${TERM} == dumb ]]; then @@ -70,6 +71,7 @@ function echo_centering_str() { local terminal_width # terminal_width=$(tput ${TPUT_FLAG} cols) + # shellcheck disable=SC2086 terminal_width="${COLUMNS:-$(tput ${TPUT_FLAG} cols)}" local total_padding_len=$(( $terminal_width - $str_len )) local single_side_padding_len=$(( $total_padding_len / 2 )) diff --git a/build_system/lpm_execute_compose.bash b/build_system/lpm_execute_compose.bash index 7d33a27a8..47490dc9f 100644 --- a/build_system/lpm_execute_compose.bash +++ b/build_system/lpm_execute_compose.bash @@ -28,7 +28,7 @@ # Dont use "set -e" in this script as it will affect the build system policy, use the --fail-fast flag instead # -# ....Default...................................................................................................... +# ....Default...................................................................................... LIBPOINTMATCHER_VERSION='head' LIBPOINTMATCHER_CMAKE_BUILD_TYPE='RelWithDebInfo' OS_NAME='ubuntu' @@ -36,17 +36,17 @@ OS_VERSION='focal' #LPM_JOB_ID='0' DOCKER_COMPOSE_CMD_ARGS='up --build --force-recreate' # alt: build --no-cache --push -# ....Project root logic........................................................................................... +# ....Project root logic........................................................................... TMP_CWD=$(pwd) -# ....Load environment variables from file......................................................................... +# ....Load environment variables from file......................................................... set -o allexport source .env source .env.build_matrix source .env.prompt set +o allexport -# ....Helper function.............................................................................................. +# ....Helper function.............................................................................. ## import shell functions from Libpointmatcher-build-system utilities library source ./function_library/prompt_utilities.bash source ./function_library/general_utilities.bash @@ -75,7 +75,7 @@ function print_help_in_terminal() { " } -# ....TeamCity service message logic................................................................................ +# ....TeamCity service message logic............................................................... if [[ ${TEAMCITY_VERSION} ]]; then export IS_TEAMCITY_RUN=true TC_VERSION="TEAMCITY_VERSION=${TEAMCITY_VERSION}" @@ -84,7 +84,7 @@ else fi print_msg "IS_TEAMCITY_RUN=${IS_TEAMCITY_RUN} ${TC_VERSION}" -# ====Begin======================================================================================================== +# ====Begin======================================================================================== SHOW_SPLASH_EC="${SHOW_SPLASH_EC:-true}" if [[ "${SHOW_SPLASH_EC}" == 'true' ]]; then @@ -93,7 +93,7 @@ fi print_formated_script_header 'lpm_execute_compose.bash' "${LPM_LINE_CHAR_BUILDER_LVL2}" -# ....Script command line flags.................................................................................... +# ....Script command line flags.................................................................... while [ $# -gt 0 ]; do case $1 in @@ -148,7 +148,7 @@ while [ $# -gt 0 ]; do done -# .................................................................................................................. +# ................................................................................................. # Note: LIBPOINTMATCHER_VERSION will be used to fetch the repo at release tag (ref task NMO-252) export LIBPOINTMATCHER_VERSION="${LIBPOINTMATCHER_VERSION}" export LIBPOINTMATCHER_CMAKE_BUILD_TYPE="${LIBPOINTMATCHER_CMAKE_BUILD_TYPE}" @@ -182,5 +182,5 @@ ${MSG_DIMMED_FORMAT} DEPENDENCIES_BASE_IMAGE=${DEPENDENCIES_BASE_IMAGE} ${MSG ${MSG_DIMMED_FORMAT} DEPENDENCIES_BASE_IMAGE_TAG=${DEPENDENCIES_BASE_IMAGE_TAG} ${MSG_END_FORMAT}" print_formated_script_footer 'lpm_execute_compose.bash' "${LPM_LINE_CHAR_BUILDER_LVL2}" -# ====Teardown===================================================================================================== +# ====Teardown===================================================================================== cd "${TMP_CWD}" diff --git a/build_system/lpm_execute_compose_over_build_matrix.bash b/build_system/lpm_execute_compose_over_build_matrix.bash index 3e42a1478..56269849a 100644 --- a/build_system/lpm_execute_compose_over_build_matrix.bash +++ b/build_system/lpm_execute_compose_over_build_matrix.bash @@ -41,21 +41,21 @@ #set -v #set -x -# ....Default...................................................................................................... +# ....Default...................................................................................... DOCKER_COMPOSE_CMD_ARGS='up --build --force-recreate' BUILD_STATUS_PASS=0 -# ....Project root logic........................................................................................... +# ....Project root logic........................................................................... TMP_CWD=$(pwd) -# ....Load environment variables from file......................................................................... +# ....Load environment variables from file......................................................... set -o allexport source .env source .env.build_matrix source .env.prompt set +o allexport -# ....Helper function.............................................................................................. +# ....Helper function.............................................................................. ## import shell functions from Libpointmatcher-build-system utilities library source ./function_library/prompt_utilities.bash source ./function_library/general_utilities.bash @@ -93,12 +93,12 @@ function print_help_in_terminal() { " } -# ====Begin======================================================================================================== +# ====Begin======================================================================================== norlab_splash "${LPM_BUILD_SYSTEM_SPLASH_NAME}" "https://github.com/${LPM_LIBPOINTMATCHER_SRC_DOMAIN}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" print_formated_script_header 'lpm_execute_compose_over_build_matrix.bash' "${LPM_LINE_CHAR_BUILDER_LVL1}" -# ....Script command line flags.................................................................................... +# ....Script command line flags.................................................................... while [ $# -gt 0 ]; do case $1 in @@ -169,7 +169,7 @@ while [ $# -gt 0 ]; do done -# .................................................................................................................. +# ................................................................................................. print_msg "Build images specified in ${MSG_DIMMED_FORMAT}'docker-compose.libpointmatcher.yaml'${MSG_END_FORMAT} following ${MSG_DIMMED_FORMAT}.env.build_matrix${MSG_END_FORMAT}" ## Freeze build matrix env variable to prevent override by lpm_execute_compose.bash when reloading .env/build_matrix @@ -236,7 +236,7 @@ for EACH_LPM_VERSION in "${FREEZED_LPM_MATRIX_LIBPOINTMATCHER_VERSIONS[@]}"; do --os-version "${EACH_OS_VERSION}" \ -- "${DOCKER_COMPOSE_CMD_ARGS}" - # ....Collect image tags exported by lpm_execute_compose.bash.............................................. + # ....Collect image tags exported by lpm_execute_compose.bash.............................. # Global: Read 'DOCKER_EXIT_CODE' env variable exported by function show_and_execute_docker if [[ ${DOCKER_EXIT_CODE} == 0 ]]; then MSG_STATUS="${MSG_DONE_FORMAT}Pass ${MSG_DIMMED_FORMAT}›" @@ -261,7 +261,7 @@ for EACH_LPM_VERSION in "${FREEZED_LPM_MATRIX_LIBPOINTMATCHER_VERSIONS[@]}"; do IMAGE_TAG_CRAWLED=("${IMAGE_TAG_CRAWLED[@]}" "${MSG_STATUS} ${LPM_IMAGE_TAG} Compile mode: ${EACH_CMAKE_BUILD_TYPE}") IMAGE_TAG_CRAWLED_TC=("${IMAGE_TAG_CRAWLED_TC[@]}" "${MSG_STATUS_TC_TAG} ${LPM_IMAGE_TAG} Compile mode: ${EACH_CMAKE_BUILD_TYPE}") fi - # ......................................................................................................... + # ......................................................................................... if [[ ${TEAMCITY_VERSION} ]]; then echo -e "##teamcity[blockClosed name='${MSG_BASE_TEAMCITY} execute lpm_execute_compose.bash']" @@ -306,13 +306,13 @@ done print_formated_script_footer 'lpm_execute_compose_over_build_matrix.bash' "${LPM_LINE_CHAR_BUILDER_LVL1}" -# ====TeamCity service message===================================================================================== +# ====TeamCity service message===================================================================== if [[ ${TEAMCITY_VERSION} ]]; then # Tag added to the TeamCity build via a service message for tc_build_tag in "${IMAGE_TAG_CRAWLED_TC[@]}" ; do echo -e "##teamcity[addBuildTag '${tc_build_tag}']" done fi -# ====Teardown===================================================================================================== +# ====Teardown===================================================================================== cd "${TMP_CWD}" exit $BUILD_STATUS_PASS diff --git a/build_system/lpm_utility_script/lpm_bashrc_config.bash b/build_system/lpm_utility_script/lpm_bashrc_config.bash index fd3c4a04c..96765b919 100644 --- a/build_system/lpm_utility_script/lpm_bashrc_config.bash +++ b/build_system/lpm_utility_script/lpm_bashrc_config.bash @@ -18,7 +18,10 @@ TMP_CWD=$(pwd) if [[ "$(basename $(pwd))" != "${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" ]]; then cd .. -elif [[ "$(basename $(pwd))" == "${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" ]]; then +fi + +# ToDo: validate >> next bloc ↓↓ +if [[ "$(basename $(pwd))" == "${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" ]]; then LPM_PATH=$(pwd) else print_msg_error_and_exit "Can't find directory ${MSG_DIMMED_FORMAT}${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}${MSG_END_FORMAT}" diff --git a/build_system/ubuntu/Dockerfile.dependencies b/build_system/ubuntu/Dockerfile.dependencies index c1f59a6e3..26a09eeff 100644 --- a/build_system/ubuntu/Dockerfile.dependencies +++ b/build_system/ubuntu/Dockerfile.dependencies @@ -19,7 +19,7 @@ ENV TZ=Etc/UTC ENV TERM=${TERM:-"xterm-256color"} -# ....Setup timezone and localization.............................................................................. +# ....Setup timezone and localization.............................................................. # change the locale from POSIX to UTF-8 RUN apt-get update && \ apt-get install --assume-yes --no-install-recommends \ @@ -32,9 +32,9 @@ ENV LANG=en_US.UTF-8 ENV PYTHONIOENCODING=utf-8 -# ====Begin install================================================================================================= +# ====Begin install================================================================================ -# ....Install development utilities................................................................................ +# ....Install development utilities................................................................ RUN apt-get update && \ apt-get install --assume-yes --no-install-recommends \ sudo \ @@ -51,7 +51,7 @@ RUN apt-get update && \ apt-utils && \ rm -rf /var/lib/apt/lists/* -# ====Begin======================================================================================================== +# ====Begin======================================================================================== WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}/build_system" COPY ./build_system/.env.prompt . @@ -65,7 +65,7 @@ RUN chmod +x ./ubuntu/lpm_install_python_dev_tools.bash RUN source ./ubuntu/lpm_install_python_dev_tools.bash -# ====Install Libpointmatcher dependencies========================================================================== +# ====Install Libpointmatcher dependencies========================================================= FROM base-image AS libpointmatcher-dependencies WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}/build_system" @@ -80,7 +80,7 @@ WORKDIR ./ubuntu RUN chmod +x ./lpm_install_dependencies_ubuntu.bash RUN source ./lpm_install_dependencies_ubuntu.bash -# ====End========================================================================================================== +# ====End========================================================================================== WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/" RUN rm -r -f "./${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" diff --git a/build_system/ubuntu/Dockerfile.dependencies_doc b/build_system/ubuntu/Dockerfile.dependencies_doc index d717b0779..7b46d0477 100644 --- a/build_system/ubuntu/Dockerfile.dependencies_doc +++ b/build_system/ubuntu/Dockerfile.dependencies_doc @@ -21,14 +21,14 @@ COPY ./build_system/ubuntu/lpm_install_doc_dependencies_ubuntu.bash ./ubuntu/ COPY ./build_system/function_library/ ./function_library/ COPY ./build_system/lpm_utility_script/lpm_export_which_architecture.bash ./lpm_utility_script/ -# ====Install Libpointmatcher documentation related dependencies==================================================== +# ====Install Libpointmatcher documentation related dependencies=================================== WORKDIR ./ubuntu RUN chmod +x lpm_install_doc_dependencies_ubuntu.bash RUN source lpm_install_doc_dependencies_ubuntu.bash -# ====End========================================================================================================== +# ====End========================================================================================== WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/" RUN rm -r -f "./${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" diff --git a/build_system/ubuntu/Dockerfile.libpointmatcher b/build_system/ubuntu/Dockerfile.libpointmatcher index 263d74fe3..f01b63ad1 100644 --- a/build_system/ubuntu/Dockerfile.libpointmatcher +++ b/build_system/ubuntu/Dockerfile.libpointmatcher @@ -27,14 +27,14 @@ ENV IS_TEAMCITY_RUN=${IS_TEAMCITY_RUN:-false} SHELL ["/bin/bash", "-c"] ARG DEBIAN_FRONTEND=noninteractive -# ====Build system related setup==================================================================================== +# ====Build system related setup=================================================================== WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}-CICD/" # Copy only the build system file for running the install and test scripts # Note: Logic to copy files from the checkout branch is handle by 'lpm_install_libpointmatcher_ubuntu.bash' script COPY ./build_system/ ./build_system/ -# ==== Build libpointmatcher checkout branch ====================================================================== +# ==== Build libpointmatcher checkout branch ====================================================== WORKDIR ./build_system/ubuntu RUN chmod +x lpm_install_libpointmatcher_ubuntu.bash @@ -45,7 +45,7 @@ RUN chmod +x entrypoint.bash #RUN chmod +x lpm_install_doc_dependencies_ubuntu.bash #RUN bash lpm_install_doc_dependencies_ubuntu.bash -# ====Install Libpointmatcher======================================================================================= +# ====Install Libpointmatcher====================================================================== # (CRITICAL) ToDo: validate effect on teamcity build log (source vs bash) RUN source lpm_install_libpointmatcher_ubuntu.bash \ @@ -53,12 +53,12 @@ RUN source lpm_install_libpointmatcher_ubuntu.bash \ --cmake-build-type ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} \ ${LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG} -# ==== Execute libpointmatcher unit-test=========================================================================== +# ==== Execute libpointmatcher unit-test=========================================================== # Conditional execution if build/utest/ directory is present RUN source entrypoint_execute_lpm_unittest.bash -# ====End========================================================================================================== +# ====End========================================================================================== FROM libpointmatcher-dependencies AS libpointmatcher-release WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}-CICD/build_system/ubuntu" diff --git a/build_system/ubuntu/Dockerfile.libpointmatcher_ci_PR b/build_system/ubuntu/Dockerfile.libpointmatcher_ci_PR index 72f159687..2fcc0d238 100644 --- a/build_system/ubuntu/Dockerfile.libpointmatcher_ci_PR +++ b/build_system/ubuntu/Dockerfile.libpointmatcher_ci_PR @@ -29,18 +29,18 @@ ARG DEBIAN_FRONTEND=noninteractive # ToDo: validate ENV TERM=${TERM:-"xterm-256color"} -# ====Checkout libpointmatcher repository=========================================================================== +# ====Checkout libpointmatcher repository========================================================== WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" # Copy all files from the checkout branch in the repository (except those in the .dockerignore) COPY . . -# ====Check Libpointmatcher dependencies installed versions======================================================== +# ====Check Libpointmatcher dependencies installed versions======================================== WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" RUN chmod +x ./utest/listVersionsUbuntu.sh RUN utest/listVersionsUbuntu.sh -# ==== Build libpointmatcher checkout branch ====================================================================== +# ==== Build libpointmatcher checkout branch ====================================================== WORKDIR ./build_system/ubuntu RUN chmod +x lpm_install_libpointmatcher_ubuntu.bash @@ -53,16 +53,16 @@ RUN source lpm_install_libpointmatcher_ubuntu.bash \ --cmake-build-type ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} \ ${LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG} -# ==== Execute libpointmatcher unit-test=========================================================================== +# ==== Execute libpointmatcher unit-test=========================================================== RUN source lpm_execute_libpointmatcher_unittest.bash -# ................................................................................................................ +# ................................................................................................. ## Alternate version #RUN chmod +x entrypoint_build_and_test_libpointmatcher_checkout_branch.bash #RUN chmod +x entrypoint_build_libpointmatcher_checkout_branch.bash #RUN source entrypoint_build_and_test_libpointmatcher_checkout_branch.bash #RUN source entrypoint_build_libpointmatcher_checkout_branch.bash -# ====End========================================================================================================== +# ====End========================================================================================== ENTRYPOINT [ "./entrypoint.bash" ] CMD [ "bash" ] diff --git a/build_system/ubuntu/Dockerfile.libpointmatcher_ci_SITREP_matrix b/build_system/ubuntu/Dockerfile.libpointmatcher_ci_SITREP_matrix index 7df986c56..bdfb65678 100644 --- a/build_system/ubuntu/Dockerfile.libpointmatcher_ci_SITREP_matrix +++ b/build_system/ubuntu/Dockerfile.libpointmatcher_ci_SITREP_matrix @@ -28,14 +28,14 @@ ARG DEBIAN_FRONTEND=noninteractive ENV TERM=${TERM:-"xterm-256color"} -# ====Checkout libpointmatcher repository=========================================================================== +# ====Checkout libpointmatcher repository========================================================== WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}-CICD/" # Copy only the build system file for running the install and test scripts # Note: Logic to copy files from the checkout branch is handle by 'lpm_install_libpointmatcher_ubuntu.bash' script COPY ./build_system/ ./build_system/ -# ==== Build libpointmatcher checkout branch ====================================================================== +# ==== Build libpointmatcher checkout branch ====================================================== WORKDIR ./build_system/ubuntu RUN chmod +x lpm_install_libpointmatcher_ubuntu.bash @@ -49,21 +49,21 @@ RUN source lpm_install_libpointmatcher_ubuntu.bash \ --cmake-build-type ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} \ ${LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG} -# ==== Execute libpointmatcher unit-test=========================================================================== +# ==== Execute libpointmatcher unit-test=========================================================== RUN source lpm_execute_libpointmatcher_unittest.bash -# ====Check Libpointmatcher dependencies installed versions======================================================== +# ====Check Libpointmatcher dependencies installed versions======================================== WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" RUN chmod +x ./utest/listVersionsUbuntu.sh RUN utest/listVersionsUbuntu.sh -# ................................................................................................................ +# ................................................................................................. ## Alternate version #RUN chmod +x entrypoint_build_and_test_libpointmatcher_checkout_branch.bash #RUN chmod +x entrypoint_build_libpointmatcher_checkout_branch.bash #RUN source entrypoint_build_and_test_libpointmatcher_checkout_branch.bash #RUN source entrypoint_build_libpointmatcher_checkout_branch.bash -# ====End========================================================================================================== +# ====End========================================================================================== ENTRYPOINT [ "./entrypoint.bash" ] CMD [ "bash" ] From ffc87d996c683bc101d2b3ffa1ee9bbe9200b16b Mon Sep 17 00:00:00 2001 From: RedLeaderOne Date: Mon, 27 Nov 2023 20:31:55 -0500 Subject: [PATCH 036/124] fix: build-system side unstable compilation issue fix [NMO-402] --- .github/CODEOWNERS | 13 ++++++++++ .../docker-compose.libpointmatcher.yaml | 18 ++++++++----- .../lpm_install_dependencies_ubuntu.bash | 25 +++++++++++-------- .../lpm_install_libpointmatcher_ubuntu.bash | 23 ++++++++++------- 4 files changed, 53 insertions(+), 26 deletions(-) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..07f6752e2 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,13 @@ +# Files or directories with designated code owner. +# Branch with "Require review from Code Owners" will automaticaly trigger a request to a designated code owner + +# DevOps related +/build_system/ @RedLeader962 +/.github/ @RedLeader962 +/.dockerignore @RedLeader962 +/.gitignore @RedLeader962 + +# Core +/pointmatcher @boxanm @simonpierredeschenes @aguenette +/python @boxanm @simonpierredeschenes @aguenette +/utest @boxanm @simonpierredeschenes @aguenette diff --git a/build_system/docker-compose.libpointmatcher.yaml b/build_system/docker-compose.libpointmatcher.yaml index befe24879..5b748ece0 100644 --- a/build_system/docker-compose.libpointmatcher.yaml +++ b/build_system/docker-compose.libpointmatcher.yaml @@ -1,6 +1,6 @@ services: - # ====Dependency related services=================================================================================== + # ====Dependency related services================================================================ dependencies: image: ${LPM_PROJECT_DOCKERHUB:?err}/libpointmatcher-dependencies:${LPM_IMAGE_TAG:?err} build: @@ -34,7 +34,7 @@ services: tty: true stdin_open: true - # ====Pull-request related services================================================================================ + # ====Pull-request related services============================================================== ci_PR: image: ${LPM_PROJECT_DOCKERHUB:?err}/libpointmatcher-ci-pr:${LPM_IMAGE_TAG:?err} pull_policy: build @@ -53,14 +53,20 @@ services: tty: true stdin_open: true init: true # Propagate exit code (See remark in task NMO-266) + depends_on: + - dependencies ci_PR_amd64: extends: ci_PR - platform: "linux/amd64" + build: + platforms: + - "linux/amd64" ci_PR_arm64v8: extends: ci_PR - platform: "linux/arm64/v8" + build: + platforms: + - "linux/arm64/v8" - # ====Build system assessment services============================================================================== + # ====Build system assessment services=========================================================== ci_SITREP_matrix: image: ${LPM_PROJECT_DOCKERHUB:?err}/libpointmatcher-ci-sitrep-matrix:${LPM_IMAGE_TAG:?err} pull_policy: build @@ -86,7 +92,7 @@ services: extends: ci_SITREP_matrix platform: "linux/arm64/v8" - # ====Dockerhub release image====================================================================================== + # ====Dockerhub release image==================================================================== release: image: ${LPM_PROJECT_DOCKERHUB:?err}/libpointmatcher:${LPM_IMAGE_TAG:?err} container_name: libpointmatcher diff --git a/build_system/ubuntu/lpm_install_dependencies_ubuntu.bash b/build_system/ubuntu/lpm_install_dependencies_ubuntu.bash index b2f62d661..5264a91be 100644 --- a/build_system/ubuntu/lpm_install_dependencies_ubuntu.bash +++ b/build_system/ubuntu/lpm_install_dependencies_ubuntu.bash @@ -7,14 +7,14 @@ # set -e # Note: we want the installer to always fail-fast (it wont affect the build system policy) -# ....Project root logic........................................................................................... +# ....Project root logic........................................................................... TMP_CWD=$(pwd) if [[ "$(basename $(pwd))" != "build_system" ]]; then cd ../ fi -# ....Load environment variables from file......................................................................... +# ....Load environment variables from file......................................................... set -o allexport source ./.env source ./.env.prompt @@ -23,7 +23,7 @@ set +o allexport # skip GUI dialog by setting everything to default export DEBIAN_FRONTEND=noninteractive -# ....Helper function.............................................................................................. +# ....Helper function.............................................................................. ## import shell functions from Libpointmatcher-build-system utilities library source ./function_library/prompt_utilities.bash source ./function_library/terminal_splash.bash @@ -32,7 +32,7 @@ source ./function_library/general_utilities.bash # Set environment variable LPM_IMAGE_ARCHITECTURE source ./lpm_utility_script/lpm_export_which_architecture.bash -# ====Begin======================================================================================================== +# ====Begin======================================================================================== SHOW_SPLASH_IDU="${SHOW_SPLASH_IDU:-true}" if [[ "${SHOW_SPLASH_IDU}" == 'true' ]]; then @@ -41,7 +41,7 @@ fi print_formated_script_header "lpm_install_dependencies_ubuntu.bash (${LPM_IMAGE_ARCHITECTURE})" "${LPM_LINE_CHAR_INSTALLER}" -# ................................................................................................................ +# ................................................................................................. teamcity_service_msg_blockOpened "Install development utilities" sudo apt-get update && @@ -63,7 +63,7 @@ sudo apt-get update && cmake --version teamcity_service_msg_blockClosed -# ................................................................................................................ +# ................................................................................................. if [[ ${IS_TEAMCITY_RUN} == true ]]; then print_msg "The install script is run in teamCity >> the python install step was executed earlier in the Dockerfile.dependencies" @@ -72,7 +72,7 @@ else source ./ubuntu/lpm_install_python_dev_tools.bash fi -# ................................................................................................................ +# ................................................................................................. teamcity_service_msg_blockOpened "Install Libpointmatcher dependencies › Boost" # https://www.boost.org/doc/libs/1_79_0/more/getting_started/unix-variants.html @@ -82,7 +82,7 @@ sudo apt-get update && sudo rm -rf /var/lib/apt/lists/* teamcity_service_msg_blockClosed -# ................................................................................................................ +# ................................................................................................. teamcity_service_msg_blockOpened "Install Libpointmatcher dependencies › Eigen" # https://eigen.tuxfamily.org/index.php @@ -92,7 +92,7 @@ sudo apt-get update && sudo rm -rf /var/lib/apt/lists/* teamcity_service_msg_blockClosed -# ................................................................................................................ +# ................................................................................................. teamcity_service_msg_blockOpened "Install Libpointmatcher dependencies › Libnabo" # https://github.com/ethz-asl/libnabo @@ -136,6 +136,8 @@ git clone https://github.com/ethz-asl/libnabo.git && teamcity_service_msg_compilationStarted "cmake" +# (Priority) inprogress: investigate?? (ref task NMO-402 fix: unstable compilation issue) +# ToDo: Add mention about 'CMAKE_INSTALL_PREFIX' in the doc install step as a fix cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo \ -D CMAKE_INSTALL_PREFIX=${LPM_INSTALLED_LIBRARIES_PATH} \ "${LPM_INSTALLED_LIBRARIES_PATH}/libnabo" && @@ -143,10 +145,11 @@ cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo \ make test && sudo make install + teamcity_service_msg_compilationFinished teamcity_service_msg_blockClosed -# ................................................................................................................ +# ................................................................................................. teamcity_service_msg_blockOpened "Install Libpointmatcher dev tools" sudo apt-get update && @@ -158,5 +161,5 @@ teamcity_service_msg_blockClosed echo " " && print_msg_done "Libpointmatcher dependencies installed" print_formated_script_footer "lpm_install_dependencies_ubuntu.bash (${LPM_IMAGE_ARCHITECTURE})" "${LPM_LINE_CHAR_INSTALLER}" -# ====Teardown===================================================================================================== +# ====Teardown===================================================================================== cd "${TMP_CWD}" diff --git a/build_system/ubuntu/lpm_install_libpointmatcher_ubuntu.bash b/build_system/ubuntu/lpm_install_libpointmatcher_ubuntu.bash index cba0cf489..52ab162d4 100644 --- a/build_system/ubuntu/lpm_install_libpointmatcher_ubuntu.bash +++ b/build_system/ubuntu/lpm_install_libpointmatcher_ubuntu.bash @@ -25,21 +25,21 @@ # set -e # Note: we want the installer to always fail-fast (it wont affect the build system policy) -# ....Default...................................................................................................... +# ....Default...................................................................................... LIBPOINTMATCHER_VERSION='head' BUILD_TESTS_FLAG=FALSE GENERATE_API_DOC_FLAG=FALSE BUILD_SYSTEM_CI_INSTALL=FALSE CMAKE_BUILD_TYPE=RelWithDebInfo -# ....Project root logic........................................................................................... +# ....Project root logic........................................................................... TMP_CWD=$(pwd) if [[ "$(basename $(pwd))" != "build_system" ]]; then cd ../ fi -# ....Load environment variables from file......................................................................... +# ....Load environment variables from file......................................................... set -o allexport source ./.env source ./.env.prompt @@ -48,7 +48,7 @@ set +o allexport ## skip GUI dialog by setting everything to default export DEBIAN_FRONTEND=noninteractive -# ....Helper function.............................................................................................. +# ....Helper function.............................................................................. ## import shell functions from Libpointmatcher-build-system utilities library source ./function_library/prompt_utilities.bash source ./function_library/terminal_splash.bash @@ -77,7 +77,7 @@ function print_help_in_terminal() { " } -# ====Begin======================================================================================================== +# ====Begin======================================================================================== SHOW_SPLASH_ILU="${SHOW_SPLASH_ILU:-true}" if [[ "${SHOW_SPLASH_ILU}" == 'true' ]]; then @@ -87,7 +87,7 @@ fi print_formated_script_header "lpm_install_libpointmatcher_ubuntu.bash (${LPM_IMAGE_ARCHITECTURE})" "${LPM_LINE_CHAR_INSTALLER}" -# ....Script command line flags.................................................................................... +# ....Script command line flags.................................................................... while [ $# -gt 0 ]; do @@ -139,7 +139,7 @@ while [ $# -gt 0 ]; do done -# ................................................................................................................ +# ................................................................................................. teamcity_service_msg_blockOpened "Install Libpointmatcher" # https://github.com/ethz-asl/libpointmatcher/tree/master @@ -178,13 +178,18 @@ teamcity_service_msg_compilationStarted "cmake" # (CRITICAL) ToDo: validate >> GENERATE_API_DOC install dir +# (Priority) inprogress: investigate?? (ref task NMO-402 fix: unstable compilation issue) cmake -D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \ -D BUILD_TESTS=${BUILD_TESTS_FLAG} \ -D GENERATE_API_DOC=${GENERATE_API_DOC_FLAG} \ - -D LIBNABO_INSTALL_DIR="${LPM_INSTALLED_LIBRARIES_PATH}/libnabo" \ -D CMAKE_INSTALL_PREFIX="${LPM_INSTALLED_LIBRARIES_PATH}" \ "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" +# Note: +# - Previously use intall flag quick-hack to work around the install issue. +# - Keep it here as futur reference +# -D LIBNABO_INSTALL_DIR="${LPM_INSTALLED_LIBRARIES_PATH}/libnabo" \ + BUILD_EXIT_CODE=$? make -j $(nproc) @@ -234,5 +239,5 @@ else fi print_formated_script_footer "lpm_install_libpointmatcher_ubuntu.bash (${LPM_IMAGE_ARCHITECTURE})" "${LPM_LINE_CHAR_INSTALLER}" -# ====Teardown===================================================================================================== +# ====Teardown===================================================================================== cd "${TMP_CWD}" From 12c225eda6ef2e4353e33def4e9a297058739603 Mon Sep 17 00:00:00 2001 From: RedLeaderOne Date: Wed, 29 Nov 2023 08:43:14 -0500 Subject: [PATCH 037/124] fix: build-system side unstable compilation issue fix [NMO-402] - added test logic for LPM compilation cases: - automatic path resolution, - prefixed path, - use lpm directly, - use lpm as a library - file formating --- .../docker-compose.libpointmatcher.yaml | 49 ++++++- build_system/ubuntu/Dockerfile.dependencies | 27 ++-- .../ubuntu/Dockerfile.libpointmatcher | 10 +- .../ubuntu/Dockerfile.libpointmatcher_ci_PR | 12 +- ...ockerfile.libpointmatcher_ci_SITREP_matrix | 12 +- ...ockerfile.libpointmatcher_test_compilation | 120 +++++++++++++++++ ..._install_dependencies_general_ubuntu.bash} | 65 +-------- ...m_install_dependencies_libnabo_ubuntu.bash | 124 ++++++++++++++++++ .../lpm_install_doc_dependencies_ubuntu.bash | 12 +- .../lpm_install_libpointmatcher_ubuntu.bash | 22 +++- 10 files changed, 352 insertions(+), 101 deletions(-) create mode 100644 build_system/ubuntu/Dockerfile.libpointmatcher_test_compilation rename build_system/ubuntu/{lpm_install_dependencies_ubuntu.bash => lpm_install_dependencies_general_ubuntu.bash} (58%) create mode 100644 build_system/ubuntu/lpm_install_dependencies_libnabo_ubuntu.bash diff --git a/build_system/docker-compose.libpointmatcher.yaml b/build_system/docker-compose.libpointmatcher.yaml index 5b748ece0..02c3f1efe 100644 --- a/build_system/docker-compose.libpointmatcher.yaml +++ b/build_system/docker-compose.libpointmatcher.yaml @@ -1,9 +1,10 @@ services: # ====Dependency related services================================================================ - dependencies: - image: ${LPM_PROJECT_DOCKERHUB:?err}/libpointmatcher-dependencies:${LPM_IMAGE_TAG:?err} + dependencies-general: + image: ${LPM_PROJECT_DOCKERHUB:?err}/libpointmatcher-dependencies-general:${LPM_IMAGE_TAG:?err} build: + target: libpointmatcher-dependencies-general context: .. dockerfile: ./build_system/ubuntu/Dockerfile.dependencies platforms: @@ -18,6 +19,13 @@ services: tty: true stdin_open: true init: true # Propagate exit code (See remark in task NMO-266) + + dependencies: + extends: dependencies-general + image: ${LPM_PROJECT_DOCKERHUB:?err}/libpointmatcher-dependencies:${LPM_IMAGE_TAG:?err} + build: + target: libpointmatcher-dependencies-libnabo + dependencies-doc: image: ${LPM_PROJECT_DOCKERHUB:?err}/libpointmatcher-dependencies-doc:${LPM_IMAGE_TAG:?err} build: @@ -35,6 +43,43 @@ services: stdin_open: true # ====Pull-request related services============================================================== + _test_compilation: + image: ${LPM_PROJECT_DOCKERHUB:?err}/libpointmatcher-compilation-test:${LPM_IMAGE_TAG:?err} + pull_policy: build + build: + context: .. + dockerfile: './build_system/ubuntu/Dockerfile.libpointmatcher_test_compilation' + target: test-compilation-auto-path-resolution + ## Mute 'platforms' while using arch virtualization with C++ build to prevent segmentation fault during lpm cmake install +# platforms: +# - "linux/amd64" +# - "linux/arm64/v8" + args: + PROJECT_HUB: ${LPM_PROJECT_DOCKERHUB} + BASE_IMAGE: libpointmatcher-dependencies-general + BASE_IMAGE_TAG: ${LPM_IMAGE_TAG} + IS_TEAMCITY_RUN: ${IS_TEAMCITY_RUN} + LIBPOINTMATCHER_VERSION: 'head' + LIBPOINTMATCHER_CMAKE_BUILD_TYPE: ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE:?err} + LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG: '--build-system-CI-install' + tty: true + stdin_open: true + init: true # Propagate exit code (See remark in task NMO-266) + depends_on: + - dependencies-general + test_compilation_prefixed_path: + extends: _test_compilation + build: + target: test-compilation-prefixed-path + depends_on: + - _test_compilation + test_compilation_auto_path_resolution: + extends: _test_compilation + build: + target: test-compilation-auto-path-resolution + depends_on: + - _test_compilation + ci_PR: image: ${LPM_PROJECT_DOCKERHUB:?err}/libpointmatcher-ci-pr:${LPM_IMAGE_TAG:?err} pull_policy: build diff --git a/build_system/ubuntu/Dockerfile.dependencies b/build_system/ubuntu/Dockerfile.dependencies index c1f59a6e3..9a14b2716 100644 --- a/build_system/ubuntu/Dockerfile.dependencies +++ b/build_system/ubuntu/Dockerfile.dependencies @@ -19,7 +19,7 @@ ENV TZ=Etc/UTC ENV TERM=${TERM:-"xterm-256color"} -# ....Setup timezone and localization.............................................................................. +# ....Setup timezone and localization.............................................................. # change the locale from POSIX to UTF-8 RUN apt-get update && \ apt-get install --assume-yes --no-install-recommends \ @@ -32,9 +32,9 @@ ENV LANG=en_US.UTF-8 ENV PYTHONIOENCODING=utf-8 -# ====Begin install================================================================================================= +# ====Begin install================================================================================= -# ....Install development utilities................................................................................ +# ....Install development utilities................................................................ RUN apt-get update && \ apt-get install --assume-yes --no-install-recommends \ sudo \ @@ -51,7 +51,7 @@ RUN apt-get update && \ apt-utils && \ rm -rf /var/lib/apt/lists/* -# ====Begin======================================================================================================== +# ====Begin======================================================================================== WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}/build_system" COPY ./build_system/.env.prompt . @@ -65,24 +65,29 @@ RUN chmod +x ./ubuntu/lpm_install_python_dev_tools.bash RUN source ./ubuntu/lpm_install_python_dev_tools.bash -# ====Install Libpointmatcher dependencies========================================================================== -FROM base-image AS libpointmatcher-dependencies +# ====Install Libpointmatcher dependencies========================================================= +FROM base-image AS libpointmatcher-dependencies-general WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}/build_system" -COPY ./build_system/ubuntu/lpm_install_dependencies_ubuntu.bash ./ubuntu/ +COPY ./build_system/ubuntu/lpm_install_dependencies_general_ubuntu.bash ./ubuntu/ +COPY ./build_system/ubuntu/lpm_install_dependencies_libnabo_ubuntu.bash ./ubuntu/ COPY ./build_system/ubuntu/lpm_install_python_dev_tools.bash ./ubuntu/ COPY ./build_system/function_library/ ./function_library/ COPY ./build_system/lpm_utility_script/lpm_export_which_architecture.bash ./lpm_utility_script/ WORKDIR ./ubuntu +RUN chmod +x ./lpm_install_dependencies_general_ubuntu.bash +RUN source ./lpm_install_dependencies_general_ubuntu.bash -RUN chmod +x ./lpm_install_dependencies_ubuntu.bash -RUN source ./lpm_install_dependencies_ubuntu.bash +FROM libpointmatcher-dependencies-general AS libpointmatcher-dependencies-libnabo -# ====End========================================================================================================== +RUN chmod +x ./lpm_install_dependencies_libnabo_ubuntu.bash +RUN source ./lpm_install_dependencies_libnabo_ubuntu.bash + +# ====End========================================================================================== +#FROM libpointmatcher-dependencies-libnabo AS final WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/" RUN rm -r -f "./${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" -FROM libpointmatcher-dependencies AS final CMD [ "bash" ] diff --git a/build_system/ubuntu/Dockerfile.libpointmatcher b/build_system/ubuntu/Dockerfile.libpointmatcher index 263d74fe3..f01b63ad1 100644 --- a/build_system/ubuntu/Dockerfile.libpointmatcher +++ b/build_system/ubuntu/Dockerfile.libpointmatcher @@ -27,14 +27,14 @@ ENV IS_TEAMCITY_RUN=${IS_TEAMCITY_RUN:-false} SHELL ["/bin/bash", "-c"] ARG DEBIAN_FRONTEND=noninteractive -# ====Build system related setup==================================================================================== +# ====Build system related setup=================================================================== WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}-CICD/" # Copy only the build system file for running the install and test scripts # Note: Logic to copy files from the checkout branch is handle by 'lpm_install_libpointmatcher_ubuntu.bash' script COPY ./build_system/ ./build_system/ -# ==== Build libpointmatcher checkout branch ====================================================================== +# ==== Build libpointmatcher checkout branch ====================================================== WORKDIR ./build_system/ubuntu RUN chmod +x lpm_install_libpointmatcher_ubuntu.bash @@ -45,7 +45,7 @@ RUN chmod +x entrypoint.bash #RUN chmod +x lpm_install_doc_dependencies_ubuntu.bash #RUN bash lpm_install_doc_dependencies_ubuntu.bash -# ====Install Libpointmatcher======================================================================================= +# ====Install Libpointmatcher====================================================================== # (CRITICAL) ToDo: validate effect on teamcity build log (source vs bash) RUN source lpm_install_libpointmatcher_ubuntu.bash \ @@ -53,12 +53,12 @@ RUN source lpm_install_libpointmatcher_ubuntu.bash \ --cmake-build-type ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} \ ${LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG} -# ==== Execute libpointmatcher unit-test=========================================================================== +# ==== Execute libpointmatcher unit-test=========================================================== # Conditional execution if build/utest/ directory is present RUN source entrypoint_execute_lpm_unittest.bash -# ====End========================================================================================================== +# ====End========================================================================================== FROM libpointmatcher-dependencies AS libpointmatcher-release WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}-CICD/build_system/ubuntu" diff --git a/build_system/ubuntu/Dockerfile.libpointmatcher_ci_PR b/build_system/ubuntu/Dockerfile.libpointmatcher_ci_PR index 72f159687..2fcc0d238 100644 --- a/build_system/ubuntu/Dockerfile.libpointmatcher_ci_PR +++ b/build_system/ubuntu/Dockerfile.libpointmatcher_ci_PR @@ -29,18 +29,18 @@ ARG DEBIAN_FRONTEND=noninteractive # ToDo: validate ENV TERM=${TERM:-"xterm-256color"} -# ====Checkout libpointmatcher repository=========================================================================== +# ====Checkout libpointmatcher repository========================================================== WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" # Copy all files from the checkout branch in the repository (except those in the .dockerignore) COPY . . -# ====Check Libpointmatcher dependencies installed versions======================================================== +# ====Check Libpointmatcher dependencies installed versions======================================== WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" RUN chmod +x ./utest/listVersionsUbuntu.sh RUN utest/listVersionsUbuntu.sh -# ==== Build libpointmatcher checkout branch ====================================================================== +# ==== Build libpointmatcher checkout branch ====================================================== WORKDIR ./build_system/ubuntu RUN chmod +x lpm_install_libpointmatcher_ubuntu.bash @@ -53,16 +53,16 @@ RUN source lpm_install_libpointmatcher_ubuntu.bash \ --cmake-build-type ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} \ ${LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG} -# ==== Execute libpointmatcher unit-test=========================================================================== +# ==== Execute libpointmatcher unit-test=========================================================== RUN source lpm_execute_libpointmatcher_unittest.bash -# ................................................................................................................ +# ................................................................................................. ## Alternate version #RUN chmod +x entrypoint_build_and_test_libpointmatcher_checkout_branch.bash #RUN chmod +x entrypoint_build_libpointmatcher_checkout_branch.bash #RUN source entrypoint_build_and_test_libpointmatcher_checkout_branch.bash #RUN source entrypoint_build_libpointmatcher_checkout_branch.bash -# ====End========================================================================================================== +# ====End========================================================================================== ENTRYPOINT [ "./entrypoint.bash" ] CMD [ "bash" ] diff --git a/build_system/ubuntu/Dockerfile.libpointmatcher_ci_SITREP_matrix b/build_system/ubuntu/Dockerfile.libpointmatcher_ci_SITREP_matrix index 7df986c56..bdfb65678 100644 --- a/build_system/ubuntu/Dockerfile.libpointmatcher_ci_SITREP_matrix +++ b/build_system/ubuntu/Dockerfile.libpointmatcher_ci_SITREP_matrix @@ -28,14 +28,14 @@ ARG DEBIAN_FRONTEND=noninteractive ENV TERM=${TERM:-"xterm-256color"} -# ====Checkout libpointmatcher repository=========================================================================== +# ====Checkout libpointmatcher repository========================================================== WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}-CICD/" # Copy only the build system file for running the install and test scripts # Note: Logic to copy files from the checkout branch is handle by 'lpm_install_libpointmatcher_ubuntu.bash' script COPY ./build_system/ ./build_system/ -# ==== Build libpointmatcher checkout branch ====================================================================== +# ==== Build libpointmatcher checkout branch ====================================================== WORKDIR ./build_system/ubuntu RUN chmod +x lpm_install_libpointmatcher_ubuntu.bash @@ -49,21 +49,21 @@ RUN source lpm_install_libpointmatcher_ubuntu.bash \ --cmake-build-type ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} \ ${LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG} -# ==== Execute libpointmatcher unit-test=========================================================================== +# ==== Execute libpointmatcher unit-test=========================================================== RUN source lpm_execute_libpointmatcher_unittest.bash -# ====Check Libpointmatcher dependencies installed versions======================================================== +# ====Check Libpointmatcher dependencies installed versions======================================== WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" RUN chmod +x ./utest/listVersionsUbuntu.sh RUN utest/listVersionsUbuntu.sh -# ................................................................................................................ +# ................................................................................................. ## Alternate version #RUN chmod +x entrypoint_build_and_test_libpointmatcher_checkout_branch.bash #RUN chmod +x entrypoint_build_libpointmatcher_checkout_branch.bash #RUN source entrypoint_build_and_test_libpointmatcher_checkout_branch.bash #RUN source entrypoint_build_libpointmatcher_checkout_branch.bash -# ====End========================================================================================================== +# ====End========================================================================================== ENTRYPOINT [ "./entrypoint.bash" ] CMD [ "bash" ] diff --git a/build_system/ubuntu/Dockerfile.libpointmatcher_test_compilation b/build_system/ubuntu/Dockerfile.libpointmatcher_test_compilation new file mode 100644 index 000000000..4f2b5afd0 --- /dev/null +++ b/build_system/ubuntu/Dockerfile.libpointmatcher_test_compilation @@ -0,0 +1,120 @@ +ARG PROJECT_HUB=norlabulaval +ARG BASE_IMAGE=libpointmatcher-dependencies-general +ARG BASE_IMAGE_TAG +FROM ${PROJECT_HUB}/${BASE_IMAGE}:${BASE_IMAGE_TAG:?err} AS libpointmatcher-dependencies-general + +LABEL org.opencontainers.image.authors="luc.coupal.1@ulaval.ca" + +ARG LIBPOINTMATCHER_VERSION='head' +ENV LIBPOINTMATCHER_VERSION=${LIBPOINTMATCHER_VERSION} +LABEL libpointmatcher.version="${LIBPOINTMATCHER_VERSION}" + +ARG LPM_INSTALLED_LIBRARIES_PATH +ARG LPM_LIBPOINTMATCHER_SRC_REPO_NAME +ENV LPM_INSTALLED_LIBRARIES_PATH=${LPM_INSTALLED_LIBRARIES_PATH:?'Build argument needs to be set and non-empty.'} +ENV LPM_LIBPOINTMATCHER_SRC_REPO_NAME=${LPM_LIBPOINTMATCHER_SRC_REPO_NAME:?'Build argument needs to be set and non-empty.'} + +ARG LIBPOINTMATCHER_CMAKE_BUILD_TYPE=RelWithDebInfo +ARG LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG='--build-system-CI-install' +# Note: Those env variable are used in the entrypoint build version +ENV LIBPOINTMATCHER_CMAKE_BUILD_TYPE=${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} +ENV LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG=${LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG} + +ARG IS_TEAMCITY_RUN +ENV IS_TEAMCITY_RUN=${IS_TEAMCITY_RUN:-false} + +SHELL ["/bin/bash", "-c"] +ARG DEBIAN_FRONTEND=noninteractive + +# ToDo: validate +ENV TERM=${TERM:-"xterm-256color"} + +# ====Checkout libpointmatcher repository========================================================== +WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" + +# Copy all files from the checkout branch in the repository (except those in the .dockerignore) +COPY . . + +#WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}/build_system/ubuntu" + +WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" +RUN chmod +x ./utest/listVersionsUbuntu.sh + +WORKDIR ./build_system/ubuntu +RUN chmod +x lpm_install_dependencies_libnabo_ubuntu.bash +RUN chmod +x lpm_install_libpointmatcher_ubuntu.bash +RUN chmod +x lpm_execute_libpointmatcher_unittest.bash +RUN chmod +x entrypoint.bash + +# ====Test compilation with automatic path resolution============================================== +FROM libpointmatcher-dependencies-general AS test-compilation-auto-path-resolution +ENV OVERRIDE_LIBNABO_CMAKE_INSTALL_PREFIX=() +ENV OVERRIDE_LPM_CMAKE_INSTALL_PREFIX=() + +RUN echo && echo ">> nproc=$(nproc)" && echo # ToDo: on task end >> delete this line + +# ....Install libnabo.............................................................................. +WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}/build_system/ubuntu" +RUN source ./lpm_install_dependencies_libnabo_ubuntu.bash + +# ....Check Libpointmatcher dependencies installed versions........................................ +WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" +RUN utest/listVersionsUbuntu.sh + +# .... Build libpointmatcher checkout branch ...................................................... +WORKDIR ./build_system/ubuntu +RUN source lpm_install_libpointmatcher_ubuntu.bash \ + --libpointmatcher-version ${LIBPOINTMATCHER_VERSION} \ + --cmake-build-type ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} \ + ${LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG} + +# .... Compile package dependent on libpointmatcher ............................................... +WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}" +RUN git clone https://github.com/norlab-ulaval/norlab_icp_mapper.git \ + && mkdir -p norlab_icp_mapper/build && cd norlab_icp_mapper/build \ + && cmake -DCMAKE_BUILD_TYPE=Release .. \ + && make -j $(nproc) \ + && make install + +ENTRYPOINT [ "./entrypoint.bash" ] +CMD [ "bash" ] + +# ====Test compilation with explicit path resolution=============================================== +FROM libpointmatcher-dependencies-general AS test-compilation-prefixed-path +ENV OVERRIDE_LIBNABO_CMAKE_INSTALL_PREFIX=("-D CMAKE_INSTALL_PREFIX=${LPM_INSTALLED_LIBRARIES_PATH:?err}") +ENV OVERRIDE_LPM_CMAKE_INSTALL_PREFIX=("-D CMAKE_INSTALL_PREFIX=${LPM_INSTALLED_LIBRARIES_PATH:?err}") + +RUN echo && echo ">> nproc=$(nproc)" && echo # ToDo: on task end >> delete this line + +# ....Install libnabo.............................................................................. +WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}/build_system/ubuntu" +RUN source ./lpm_install_dependencies_libnabo_ubuntu.bash + +# ....Check Libpointmatcher dependencies installed versions........................................ +WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" +RUN utest/listVersionsUbuntu.sh + +# .... Build libpointmatcher checkout branch ...................................................... +WORKDIR ./build_system/ubuntu +RUN source lpm_install_libpointmatcher_ubuntu.bash \ + --libpointmatcher-version ${LIBPOINTMATCHER_VERSION} \ + --cmake-build-type ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} \ + ${LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG} + +# .... Compile package dependent on libpointmatcher ............................................... +WORKDIR "${LPM_INSTALLED_LIBRARIES_PATH}" +RUN git clone https://github.com/norlab-ulaval/norlab_icp_mapper.git \ + && mkdir -p norlab_icp_mapper/build && cd norlab_icp_mapper/build \ + && cmake -DCMAKE_BUILD_TYPE=Release .. \ + && make -j $(nproc) \ + && make install + +ENTRYPOINT [ "./entrypoint.bash" ] +CMD [ "bash" ] + +# ................................................................................................. +## Alternate version +#RUN chmod +x entrypoint_build_and_test_libpointmatcher_checkout_branch.bash +#RUN chmod +x entrypoint_build_libpointmatcher_checkout_branch.bash +#RUN source entrypoint_build_and_test_libpointmatcher_checkout_branch.bash +#RUN source entrypoint_build_libpointmatcher_checkout_branch.bash diff --git a/build_system/ubuntu/lpm_install_dependencies_ubuntu.bash b/build_system/ubuntu/lpm_install_dependencies_general_ubuntu.bash similarity index 58% rename from build_system/ubuntu/lpm_install_dependencies_ubuntu.bash rename to build_system/ubuntu/lpm_install_dependencies_general_ubuntu.bash index 5264a91be..a66a6bdb6 100644 --- a/build_system/ubuntu/lpm_install_dependencies_ubuntu.bash +++ b/build_system/ubuntu/lpm_install_dependencies_general_ubuntu.bash @@ -3,7 +3,7 @@ # Libpointmatcher dependencies installer # # Usage: -# $ bash lpm_install_dependencies_ubuntu.bash +# $ source lpm_install_dependencies_general_ubuntu.bash # set -e # Note: we want the installer to always fail-fast (it wont affect the build system policy) @@ -39,7 +39,7 @@ if [[ "${SHOW_SPLASH_IDU}" == 'true' ]]; then norlab_splash "${LPM_SPLASH_NAME}" "https://github.com/${LPM_LIBPOINTMATCHER_SRC_DOMAIN}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" fi -print_formated_script_header "lpm_install_dependencies_ubuntu.bash (${LPM_IMAGE_ARCHITECTURE})" "${LPM_LINE_CHAR_INSTALLER}" +print_formated_script_header "lpm_install_dependencies_general_ubuntu.bash (${LPM_IMAGE_ARCHITECTURE})" "${LPM_LINE_CHAR_INSTALLER}" # ................................................................................................. teamcity_service_msg_blockOpened "Install development utilities" @@ -91,63 +91,6 @@ sudo apt-get update && libeigen3-dev && sudo rm -rf /var/lib/apt/lists/* -teamcity_service_msg_blockClosed -# ................................................................................................. -teamcity_service_msg_blockOpened "Install Libpointmatcher dependencies › Libnabo" -# https://github.com/ethz-asl/libnabo - -print_msg "Create required dir structure" -mkdir -p "${LPM_INSTALLED_LIBRARIES_PATH}" - -## Note: -# - ANN is not mentioned in doc because it's only required for `make test` benchmarks -# - Leave it commented in code for future references -## ANN is a library written in C++, which supports data structures and algorithms for both exact and approximate nearest neighbor searching in arbitrarily high dimensions. -## https://www.cs.umd.edu/~mount/ANN/ -#cd "${LPM_INSTALLED_LIBRARIES_PATH}" -#wget https://www.cs.umd.edu/~mount/ANN/Files/1.1.2/ann_1.1.2.tar.gz -#tar xzf ann_1.1.2.tar.gz -#cd ann_1.1.2/ -#make linux-g++ -#sudo cp lib/libANN.a /usr/local/lib/ -#sudo cp include/ANN/ANN.h /usr/local/include/ -## shellcheck disable=SC2103 -#cd .. -# -# -## Note: -# - FLANN is not mentioned in doc because it's only required for `make test` benchmarks -# - Leave it commented in code for future references -## Fast Library for Approximate Nearest Neighbors - development -## FLANN is a library for performing fast approximate nearest neighbor searches in high dimensional spaces. -## https://github.com/flann-lib/flann -#sudo apt-get update \ -# && sudo apt-get install --assume-yes \ -# libflann-dev \ -# && sudo rm -rf /var/lib/apt/lists/* - -cd "${LPM_INSTALLED_LIBRARIES_PATH}" -git clone https://github.com/ethz-asl/libnabo.git && - cd libnabo && - mkdir build && cd build - -# git checkout 1.0.7 - - -teamcity_service_msg_compilationStarted "cmake" - -# (Priority) inprogress: investigate?? (ref task NMO-402 fix: unstable compilation issue) -# ToDo: Add mention about 'CMAKE_INSTALL_PREFIX' in the doc install step as a fix -cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo \ - -D CMAKE_INSTALL_PREFIX=${LPM_INSTALLED_LIBRARIES_PATH} \ - "${LPM_INSTALLED_LIBRARIES_PATH}/libnabo" && - make -j $(nproc) && - make test && - sudo make install - - -teamcity_service_msg_compilationFinished - teamcity_service_msg_blockClosed # ................................................................................................. teamcity_service_msg_blockOpened "Install Libpointmatcher dev tools" @@ -159,7 +102,7 @@ sudo apt-get update && teamcity_service_msg_blockClosed -echo " " && print_msg_done "Libpointmatcher dependencies installed" -print_formated_script_footer "lpm_install_dependencies_ubuntu.bash (${LPM_IMAGE_ARCHITECTURE})" "${LPM_LINE_CHAR_INSTALLER}" +#echo " " && print_msg_done "Libpointmatcher general dependencies installed" +print_formated_script_footer "lpm_install_dependencies_general_ubuntu.bash (${LPM_IMAGE_ARCHITECTURE})" "${LPM_LINE_CHAR_INSTALLER}" # ====Teardown===================================================================================== cd "${TMP_CWD}" diff --git a/build_system/ubuntu/lpm_install_dependencies_libnabo_ubuntu.bash b/build_system/ubuntu/lpm_install_dependencies_libnabo_ubuntu.bash new file mode 100644 index 000000000..06eafd769 --- /dev/null +++ b/build_system/ubuntu/lpm_install_dependencies_libnabo_ubuntu.bash @@ -0,0 +1,124 @@ +#!/bin/bash -i +# +# Libpointmatcher dependencies installer +# +# Usage: +# $ source lpm_install_dependencies_libnabo_ubuntu.bash +# +# $ export OVERRIDE_LIBNABO_CMAKE_INSTALL_PREFIX=( "-D CMAKE_INSTALL_PREFIX=/opt" ) && source lpm_install_dependencies_libnabo_ubuntu.bash +# +# Global: +# - Read "OVERRIDE_LIBNABO_CMAKE_INSTALL_PREFIX" +# +set -e # Note: we want the installer to always fail-fast (it wont affect the build system policy) + +# ....Project root logic........................................................................... +TMP_CWD=$(pwd) + +if [[ "$(basename $(pwd))" != "build_system" ]]; then + cd ../ +fi + +# ....Load environment variables from file......................................................... +set -o allexport +source ./.env +source ./.env.prompt +set +o allexport + +# skip GUI dialog by setting everything to default +export DEBIAN_FRONTEND=noninteractive + +# ....Helper function.............................................................................. +## import shell functions from Libpointmatcher-build-system utilities library +source ./function_library/prompt_utilities.bash +source ./function_library/terminal_splash.bash +source ./function_library/general_utilities.bash + +# Set environment variable LPM_IMAGE_ARCHITECTURE +source ./lpm_utility_script/lpm_export_which_architecture.bash + +# ....Override..................................................................................... +declare -ar DEFAULT_LIBNABO_CMAKE_INSTALL_PREFIX=( "-D CMAKE_INSTALL_PREFIX=${LPM_INSTALLED_LIBRARIES_PATH:?err}" ) +declare -a OVERRIDE_LIBNABO_CMAKE_INSTALL_PREFIX +declare -ar LIBNABO_CMAKE_INSTALL_PREFIX=( "${OVERRIDE_LIBNABO_CMAKE_INSTALL_PREFIX[@]:-${DEFAULT_LIBNABO_CMAKE_INSTALL_PREFIX[@]}}" ) + + +# ====Begin======================================================================================== +SHOW_SPLASH_IDU="${SHOW_SPLASH_IDU:-true}" + +if [[ "${SHOW_SPLASH_IDU}" == 'true' ]]; then + norlab_splash "${LPM_SPLASH_NAME}" "https://github.com/${LPM_LIBPOINTMATCHER_SRC_DOMAIN}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" +fi + +print_formated_script_header "lpm_install_dependencies_libnabo_ubuntu.bash (${LPM_IMAGE_ARCHITECTURE})" "${LPM_LINE_CHAR_INSTALLER}" + +# ................................................................................................. +teamcity_service_msg_blockOpened "Install Libpointmatcher dependencies › Libnabo" +# https://github.com/ethz-asl/libnabo + +print_msg "Create required dir structure" +mkdir -p "${LPM_INSTALLED_LIBRARIES_PATH}" + +## Note: +# - ANN is not mentioned in doc because it's only required for `make test` benchmarks +# - Leave it commented in code for future references +## ANN is a library written in C++, which supports data structures and algorithms for both exact and approximate nearest neighbor searching in arbitrarily high dimensions. +## https://www.cs.umd.edu/~mount/ANN/ +#cd "${LPM_INSTALLED_LIBRARIES_PATH}" +#wget https://www.cs.umd.edu/~mount/ANN/Files/1.1.2/ann_1.1.2.tar.gz +#tar xzf ann_1.1.2.tar.gz +#cd ann_1.1.2/ +#make linux-g++ +#sudo cp lib/libANN.a /usr/local/lib/ +#sudo cp include/ANN/ANN.h /usr/local/include/ +## shellcheck disable=SC2103 +#cd .. +# +# +## Note: +# - FLANN is not mentioned in doc because it's only required for `make test` benchmarks +# - Leave it commented in code for future references +## Fast Library for Approximate Nearest Neighbors - development +## FLANN is a library for performing fast approximate nearest neighbor searches in high dimensional spaces. +## https://github.com/flann-lib/flann +#sudo apt-get update \ +# && sudo apt-get install --assume-yes \ +# libflann-dev \ +# && sudo rm -rf /var/lib/apt/lists/* + +cd "${LPM_INSTALLED_LIBRARIES_PATH}" +git clone https://github.com/ethz-asl/libnabo.git && + cd libnabo && + mkdir build && cd build + +# git checkout 1.0.7 + + +teamcity_service_msg_compilationStarted "cmake" + +## (Priority) inprogress: investigate?? (ref task NMO-402 fix: unstable compilation issue) +## ToDo: Add mention about 'CMAKE_INSTALL_PREFIX' in the doc install step as a fix +#cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo \ +# -D CMAKE_INSTALL_PREFIX=${LPM_INSTALLED_LIBRARIES_PATH} \ +# "${LPM_INSTALLED_LIBRARIES_PATH}/libnabo" && +# make -j $(nproc) && +# make test && +# sudo make install + + +cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo ${LIBNABO_CMAKE_INSTALL_PREFIX[@]} \ + "${LPM_INSTALLED_LIBRARIES_PATH}/libnabo" && + make -j $(nproc) && + sudo make install + +# (NICE TO HAVE) ToDo: refactor (ref task NMO-428 refactor: drop libnabo `make test` step after libnabo-build-system deployment) +# make test && + +teamcity_service_msg_compilationFinished + +teamcity_service_msg_blockClosed + +echo " " && print_msg_done "Libpointmatcher dependencies installed" +print_formated_script_footer "lpm_install_dependencies_libnabo_ubuntu.bash (${LPM_IMAGE_ARCHITECTURE})" "${LPM_LINE_CHAR_INSTALLER}" +# ====Teardown===================================================================================== +cd "${TMP_CWD}" diff --git a/build_system/ubuntu/lpm_install_doc_dependencies_ubuntu.bash b/build_system/ubuntu/lpm_install_doc_dependencies_ubuntu.bash index 663dbede1..fd4dc3a00 100644 --- a/build_system/ubuntu/lpm_install_doc_dependencies_ubuntu.bash +++ b/build_system/ubuntu/lpm_install_doc_dependencies_ubuntu.bash @@ -7,7 +7,7 @@ # set -e # Note: we want the installer to always fail-fast (it wont affect the build system policy) -# ....Project root logic........................................................................................... +# ....Project root logic........................................................................... TMP_CWD=$(pwd) if [[ "$(basename $(pwd))" != "build_system" ]]; then @@ -15,7 +15,7 @@ if [[ "$(basename $(pwd))" != "build_system" ]]; then fi -# ....Load environment variables from file......................................................................... +# ....Load environment variables from file......................................................... set -o allexport source ./.env source ./.env.prompt @@ -24,7 +24,7 @@ set +o allexport ## skip GUI dialog by setting everything to default export DEBIAN_FRONTEND=noninteractive -# ....Helper function.............................................................................................. +# ....Helper function.............................................................................. ## import shell functions from Libpointmatcher-build-system utilities library source ./function_library/prompt_utilities.bash source ./function_library/terminal_splash.bash @@ -33,7 +33,7 @@ source ./function_library/general_utilities.bash ## Set environment variable 'LPM_IMAGE_ARCHITECTURE' source ./lpm_utility_script/lpm_export_which_architecture.bash -# ====Begin======================================================================================================== +# ====Begin======================================================================================== SHOW_SPLASH_IDDU="${SHOW_SPLASH_IDDU:-true}" if [[ "${SHOW_SPLASH_IDDU}" == 'true' ]]; then @@ -43,7 +43,7 @@ fi print_formated_script_header "lpm_install_doc_dependencies_ubuntu.bash (${LPM_IMAGE_ARCHITECTURE})" "${LPM_LINE_CHAR_INSTALLER}" -# ................................................................................................................ +# ................................................................................................. teamcity_service_msg_blockOpened "Install libpointmatcher documentation related dependencies" ## Package required when GENERATE_API_DOC flag is set to true @@ -58,6 +58,6 @@ teamcity_service_msg_blockClosed echo " " && print_msg_done "Libpointmatcher documentation related dependencies installed" print_formated_script_footer "lpm_install_doc_dependencies_ubuntu.bash (${LPM_IMAGE_ARCHITECTURE})" "${LPM_LINE_CHAR_INSTALLER}" -# ====Teardown===================================================================================================== +# ====Teardown===================================================================================== cd "${TMP_CWD}" diff --git a/build_system/ubuntu/lpm_install_libpointmatcher_ubuntu.bash b/build_system/ubuntu/lpm_install_libpointmatcher_ubuntu.bash index 52ab162d4..9ad031b99 100644 --- a/build_system/ubuntu/lpm_install_libpointmatcher_ubuntu.bash +++ b/build_system/ubuntu/lpm_install_libpointmatcher_ubuntu.bash @@ -19,9 +19,15 @@ # (default to RelWithDebInfo) # [-h, --help] Get help # +# Global +# - Read OVERRIDE_LPM_CMAKE_INSTALL_PREFIX +# Usage: +# export OVERRIDE_LPM_CMAKE_INSTALL_PREFIX=( "-D CMAKE_INSTALL_PREFIX=/opt" ) \ +# && source lpm_install_libpointmatcher_ubuntu.bash +# # Note: # - this script required package: g++, make, cmake, build-essential, git and all libpointmatcher dependencies -# - execute `lpm_install_dependencies_ubuntu.bash` first +# - execute `lpm_install_dependencies_general_ubuntu.bash` first # set -e # Note: we want the installer to always fail-fast (it wont affect the build system policy) @@ -32,6 +38,7 @@ GENERATE_API_DOC_FLAG=FALSE BUILD_SYSTEM_CI_INSTALL=FALSE CMAKE_BUILD_TYPE=RelWithDebInfo + # ....Project root logic........................................................................... TMP_CWD=$(pwd) @@ -139,6 +146,13 @@ while [ $# -gt 0 ]; do done + +# ....Override..................................................................................... +declare -ar DEFAULT_CMAKE_INSTALL_PREFIX=( "-D CMAKE_INSTALL_PREFIX=${LPM_INSTALLED_LIBRARIES_PATH:?err}" ) +declare -a OVERRIDE_LPM_CMAKE_INSTALL_PREFIX +declare -a LPM_CMAKE_INSTALL_PREFIX=( "${OVERRIDE_LPM_CMAKE_INSTALL_PREFIX[@]:-${DEFAULT_CMAKE_INSTALL_PREFIX[@]}}" ) + + # ................................................................................................. teamcity_service_msg_blockOpened "Install Libpointmatcher" # https://github.com/ethz-asl/libpointmatcher/tree/master @@ -176,15 +190,15 @@ mkdir -p build && cd build teamcity_service_msg_compilationStarted "cmake" # (CRITICAL) ToDo: validate >> GENERATE_API_DOC install dir - - # (Priority) inprogress: investigate?? (ref task NMO-402 fix: unstable compilation issue) cmake -D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \ -D BUILD_TESTS=${BUILD_TESTS_FLAG} \ -D GENERATE_API_DOC=${GENERATE_API_DOC_FLAG} \ - -D CMAKE_INSTALL_PREFIX="${LPM_INSTALLED_LIBRARIES_PATH}" \ + "${LPM_CMAKE_INSTALL_PREFIX[@]}" \ "${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}" +# -D CMAKE_INSTALL_PREFIX="${LPM_INSTALLED_LIBRARIES_PATH}" \ + # Note: # - Previously use intall flag quick-hack to work around the install issue. # - Keep it here as futur reference From e427c07c81e05774798a20c19115e657d52b9abf Mon Sep 17 00:00:00 2001 From: RedLeaderOne Date: Wed, 29 Nov 2023 12:45:59 -0500 Subject: [PATCH 038/124] fix: build-system side unstable compilation issue fix [NMO-402] - refactor environment variable prefix to match norlab-build-system lib - change the name for the call to repository version master branch current version from "head" to "latest" --- build_system/.env | 5 +- build_system/.env.build_matrix | 22 ++-- .../docker-compose.libpointmatcher.yaml | 8 +- build_system/lpm_execute_compose.bash | 30 +++--- ...lpm_execute_compose_over_build_matrix.bash | 102 +++++++++--------- .../ubuntu/Dockerfile.libpointmatcher | 8 +- .../ubuntu/Dockerfile.libpointmatcher_ci_PR | 8 +- ...ockerfile.libpointmatcher_ci_SITREP_matrix | 8 +- ...ockerfile.libpointmatcher_test_compilation | 10 +- ..._test_libpointmatcher_checkout_branch.bash | 2 +- ...build_libpointmatcher_checkout_branch.bash | 2 +- .../lpm_install_libpointmatcher_ubuntu.bash | 16 +-- 12 files changed, 109 insertions(+), 112 deletions(-) diff --git a/build_system/.env b/build_system/.env index d30c0d3a4..30a73b0f3 100644 --- a/build_system/.env +++ b/build_system/.env @@ -11,11 +11,8 @@ LPM_PROJECT_DOCKERHUB=norlabulaval # - Original repo: https://github.com/ethz-asl/libpointmatcher # - DEV repo: https://github.com/norlab-ulaval/libpointmatcher-build-system -# ToDo: on repository ownership transfer >> modify next bloc ↓↓ -LPM_LIBPOINTMATCHER_SRC_DOMAIN=ethz-asl -#LPM_LIBPOINTMATCHER_SRC_DOMAIN=norlab-ulaval +LPM_LIBPOINTMATCHER_SRC_DOMAIN=norlab-ulaval -#LPM_LIBPOINTMATCHER_SRC_REPO_NAME=libpointmatcher-build-system # Temporary dev fork LPM_LIBPOINTMATCHER_SRC_REPO_NAME=libpointmatcher # diff --git a/build_system/.env.build_matrix b/build_system/.env.build_matrix index b75eba850..3dedd5f43 100644 --- a/build_system/.env.build_matrix +++ b/build_system/.env.build_matrix @@ -5,25 +5,25 @@ # # Libpointmatcher version # -# 'head' is the latest push to the libpointmatcher master branch -#LPM_MATRIX_LIBPOINTMATCHER_VERSIONS=( 'v1.3.1' 'head' 'v2.0.test' ) -LPM_MATRIX_LIBPOINTMATCHER_VERSIONS=( 'head' ) +# 'latest' is the latest push to the libpointmatcher master branch +#NBS_MATRIX_REPOSITORY_VERSIONS=( 'v1.3.1' 'latest' 'v2.0.test' ) +NBS_MATRIX_REPOSITORY_VERSIONS=( 'latest' ) # # Libpointmatcher CMAKE_BUILD_TYPE # # Part of the build matrix used for assessing the state of the codebase # Note: 'None' for building dependencies images -LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE_SITREP=( 'Debug' 'Release' 'RelWithDebInfo' 'MinSizeRel' ) +NBS_MATRIX_CMAKE_BUILD_TYPE_SITREP=( 'Debug' 'Release' 'RelWithDebInfo' 'MinSizeRel' ) # Part of the build matrix used for PR -LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE=( 'Release' 'RelWithDebInfo' 'MinSizeRel' ) +NBS_MATRIX_CMAKE_BUILD_TYPE=( 'Release' 'RelWithDebInfo' 'MinSizeRel' ) # # LIBPOINTMATCHER supported OS # # (Priority) ToDo: implement OsX support for arm64-Darwin (ref task NMO-213) -#LPM_MATRIX_SUPPORTED_OS=( 'ubuntu' 'osx' ) -LPM_MATRIX_SUPPORTED_OS=( 'ubuntu' ) +#NBS_MATRIX_SUPPORTED_OS=( 'ubuntu' 'osx' ) +NBS_MATRIX_SUPPORTED_OS=( 'ubuntu' ) # # ubuntu supported versions @@ -31,13 +31,13 @@ LPM_MATRIX_SUPPORTED_OS=( 'ubuntu' ) # Ubuntu release: https://ubuntu.com/about/release-cycle # bionic=18.04 focal=20.04 jammy=22.04 # Part of the build matrix used for PR -LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS_SITREP=( 'bionic' 'focal' 'jammy' ) +NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS_SITREP=( 'bionic' 'focal' 'jammy' ) # Part of the build matrix used for assessing the state of the codebase # ToDo: fixme!! (ref task NMO-305 ﹅→ Build fail: ubuntu jammy with utest compilation). # Mute 'jammy' from the build matrix until then. -LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS=( 'bionic' 'focal' ) +NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS=( 'bionic' 'focal' ) # # iceboxed: implement other OS support (ref task NMO-213 OsX arm64-Darwin and NMO-210 OsX x86 CD components) -#LPM_MATRIX_OSX_SUPPORTED_VERSIONS=( 'monterey' 'ventura' ) -LPM_MATRIX_OSX_SUPPORTED_VERSIONS=( ) +#NBS_MATRIX_OSX_SUPPORTED_VERSIONS=( 'monterey' 'ventura' ) +NBS_MATRIX_OSX_SUPPORTED_VERSIONS=( ) diff --git a/build_system/docker-compose.libpointmatcher.yaml b/build_system/docker-compose.libpointmatcher.yaml index 02c3f1efe..05b0fcb70 100644 --- a/build_system/docker-compose.libpointmatcher.yaml +++ b/build_system/docker-compose.libpointmatcher.yaml @@ -59,7 +59,7 @@ services: BASE_IMAGE: libpointmatcher-dependencies-general BASE_IMAGE_TAG: ${LPM_IMAGE_TAG} IS_TEAMCITY_RUN: ${IS_TEAMCITY_RUN} - LIBPOINTMATCHER_VERSION: 'head' + REPOSITORY_VERSION: 'latest' LIBPOINTMATCHER_CMAKE_BUILD_TYPE: ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE:?err} LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG: '--build-system-CI-install' tty: true @@ -92,7 +92,7 @@ services: BASE_IMAGE: libpointmatcher-dependencies BASE_IMAGE_TAG: ${LPM_IMAGE_TAG} IS_TEAMCITY_RUN: ${IS_TEAMCITY_RUN} - LIBPOINTMATCHER_VERSION: 'head' + REPOSITORY_VERSION: 'latest' LIBPOINTMATCHER_CMAKE_BUILD_TYPE: ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE:?err} LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG: '--build-system-CI-install --compile-test' tty: true @@ -124,7 +124,7 @@ services: BASE_IMAGE: libpointmatcher-dependencies BASE_IMAGE_TAG: ${LPM_IMAGE_TAG} IS_TEAMCITY_RUN: ${IS_TEAMCITY_RUN} - LIBPOINTMATCHER_VERSION: ${LIBPOINTMATCHER_VERSION:?err} + REPOSITORY_VERSION: ${REPOSITORY_VERSION:?err} LIBPOINTMATCHER_CMAKE_BUILD_TYPE: ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE:?err} LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG: '--compile-test' tty: true @@ -153,7 +153,7 @@ services: BASE_IMAGE: libpointmatcher-dependencies-doc BASE_IMAGE_TAG: ${LPM_IMAGE_TAG} IS_TEAMCITY_RUN: ${IS_TEAMCITY_RUN} - LIBPOINTMATCHER_VERSION: ${LIBPOINTMATCHER_VERSION:?err} + REPOSITORY_VERSION: ${REPOSITORY_VERSION:?err} LIBPOINTMATCHER_CMAKE_BUILD_TYPE: 'Release' LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG: '--compile-test --generate-doc' tty: true diff --git a/build_system/lpm_execute_compose.bash b/build_system/lpm_execute_compose.bash index 7d33a27a8..59c03ac96 100644 --- a/build_system/lpm_execute_compose.bash +++ b/build_system/lpm_execute_compose.bash @@ -8,8 +8,8 @@ # $ bash lpm_execute_compose.bash -- run --rm ci # # Arguments: -# [--libpointmatcher-version v1.3.1] The libpointmatcher release tag (default: see LIBPOINTMATCHER_VERSION) -# [--libpointmatcher-cmake-build-type RelWithDebInfo] +# [--repository-version v1.3.1] The libpointmatcher release tag (default: see REPOSITORY_VERSION) +# [--cmake-build-type RelWithDebInfo] # Change the libpointmatcher compilation mode. # Either 'None' 'Debug' 'Release' 'RelWithDebInfo' or 'MinSizeRel' # [--os-name ubuntu] The operating system name. Either 'ubuntu' or 'osx' (default: see OS_NAME) @@ -29,7 +29,7 @@ # # ....Default...................................................................................................... -LIBPOINTMATCHER_VERSION='head' +REPOSITORY_VERSION='latest' LIBPOINTMATCHER_CMAKE_BUILD_TYPE='RelWithDebInfo' OS_NAME='ubuntu' OS_VERSION='focal' @@ -58,8 +58,8 @@ function print_help_in_terminal() { \033[1m :\033[0m -h, --help Get help - --libpointmatcher-version v1.3.1 The libpointmatcher release tag (default to master branch head) - --libpointmatcher-cmake-build-type RelWithDebInfo + --repository-version v1.3.1 The libpointmatcher release tag (default to master branch latest) + --cmake-build-type RelWithDebInfo Change the libpointmatcher compilation mode. Either 'None' 'Debug' 'Release' 'RelWithDebInfo' or 'MinSizeRel' --os-name ubuntu The operating system name. Either 'ubuntu' or 'osx' (default to 'ubuntu') @@ -97,14 +97,14 @@ print_formated_script_header 'lpm_execute_compose.bash' "${LPM_LINE_CHAR_BUILDER while [ $# -gt 0 ]; do case $1 in - --libpointmatcher-version) - LIBPOINTMATCHER_VERSION="${2}" - shift # Remove argument (--libpointmatcher-version) + --repository-version) + REPOSITORY_VERSION="${2}" + shift # Remove argument (--repository-version) shift # Remove argument value ;; - --libpointmatcher-cmake-build-type) + --cmake-build-type) LIBPOINTMATCHER_CMAKE_BUILD_TYPE="${2}" - shift # Remove argument (--libpointmatcher-cmake-build-type) + shift # Remove argument (--cmake-build-type) shift # Remove argument value ;; --os-name) @@ -149,16 +149,16 @@ while [ $# -gt 0 ]; do done # .................................................................................................................. -# Note: LIBPOINTMATCHER_VERSION will be used to fetch the repo at release tag (ref task NMO-252) -export LIBPOINTMATCHER_VERSION="${LIBPOINTMATCHER_VERSION}" +# Note: REPOSITORY_VERSION will be used to fetch the repo at release tag (ref task NMO-252) +export REPOSITORY_VERSION="${REPOSITORY_VERSION}" export LIBPOINTMATCHER_CMAKE_BUILD_TYPE="${LIBPOINTMATCHER_CMAKE_BUILD_TYPE}" export DEPENDENCIES_BASE_IMAGE="${OS_NAME}" export DEPENDENCIES_BASE_IMAGE_TAG="${OS_VERSION}" -export LPM_IMAGE_TAG="${LIBPOINTMATCHER_VERSION}-${DEPENDENCIES_BASE_IMAGE}-${DEPENDENCIES_BASE_IMAGE_TAG}" +export LPM_IMAGE_TAG="${REPOSITORY_VERSION}-${DEPENDENCIES_BASE_IMAGE}-${DEPENDENCIES_BASE_IMAGE_TAG}" print_msg "Environment variables set for compose:\n -${MSG_DIMMED_FORMAT} LIBPOINTMATCHER_VERSION=${LIBPOINTMATCHER_VERSION} ${MSG_END_FORMAT} +${MSG_DIMMED_FORMAT} REPOSITORY_VERSION=${REPOSITORY_VERSION} ${MSG_END_FORMAT} ${MSG_DIMMED_FORMAT} LIBPOINTMATCHER_CMAKE_BUILD_TYPE=${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} ${MSG_END_FORMAT} ${MSG_DIMMED_FORMAT} DEPENDENCIES_BASE_IMAGE=${DEPENDENCIES_BASE_IMAGE} ${MSG_END_FORMAT} ${MSG_DIMMED_FORMAT} DEPENDENCIES_BASE_IMAGE_TAG=${DEPENDENCIES_BASE_IMAGE_TAG} ${MSG_END_FORMAT} @@ -176,7 +176,7 @@ show_and_execute_docker "compose -f docker-compose.libpointmatcher.yaml ${DOCKER print_msg "Environment variables used by compose:\n -${MSG_DIMMED_FORMAT} LIBPOINTMATCHER_VERSION=${LIBPOINTMATCHER_VERSION} ${MSG_END_FORMAT} +${MSG_DIMMED_FORMAT} REPOSITORY_VERSION=${REPOSITORY_VERSION} ${MSG_END_FORMAT} ${MSG_DIMMED_FORMAT} LIBPOINTMATCHER_CMAKE_BUILD_TYPE=${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} ${MSG_END_FORMAT} ${MSG_DIMMED_FORMAT} DEPENDENCIES_BASE_IMAGE=${DEPENDENCIES_BASE_IMAGE} ${MSG_END_FORMAT} ${MSG_DIMMED_FORMAT} DEPENDENCIES_BASE_IMAGE_TAG=${DEPENDENCIES_BASE_IMAGE_TAG} ${MSG_END_FORMAT}" diff --git a/build_system/lpm_execute_compose_over_build_matrix.bash b/build_system/lpm_execute_compose_over_build_matrix.bash index 3e42a1478..ee61aca24 100644 --- a/build_system/lpm_execute_compose_over_build_matrix.bash +++ b/build_system/lpm_execute_compose_over_build_matrix.bash @@ -8,10 +8,10 @@ # $ bash lpm_execute_compose_over_build_matrix.bash -- up --build --force-recreate # # Arguments: -# [--libpointmatcher-version-build-matrix-override head] +# [--repository-version-build-matrix-override latest] # The libpointmatcher release tag. Override must be a single value # (default to array sequence specified in .env.build_matrix) -# [--libpointmatcher-cmake-build-type-build-matrix-override RelWithDebInfo] +# [--cmake-build-type-build-matrix-override RelWithDebInfo] # Change the libpointmatcher compilation mode. # Either 'None' 'Debug' 'Release' 'RelWithDebInfo' or 'MinSizeRel' # (default to array sequence specified in .env.build_matrix) @@ -29,8 +29,8 @@ # pass them in the docker-compose.yaml if you experience problem. # [--docker-debug-logs] Set Docker builder log output for debug (i.e.BUILDKIT_PROGRESS=plain) # [--fail-fast] Exit script at first encountered error -# [--ci-sitrep-run] Override LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE and -# LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS with there respective _SITREP version +# [--ci-sitrep-run] Override NBS_MATRIX_CMAKE_BUILD_TYPE and +# NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS with there respective _SITREP version # [-h, --help] Get help # # Note: @@ -67,10 +67,10 @@ function print_help_in_terminal() { \033[1m :\033[0m -h, --help Get help - --libpointmatcher-version-build-matrix-override head + --repository-version-build-matrix-override latest The libpointmatcher release tag. Override must be a single value (default to array sequence specified in .env.build_matrix) - --libpointmatcher-cmake-build-type-build-matrix-override RelWithDebInfo + --cmake-build-type-build-matrix-override RelWithDebInfo Change the libpointmatcher compilation mode. Either 'None' 'Debug' 'Release' 'RelWithDebInfo' or 'MinSizeRel' (default to array sequence specified in .env.build_matrix) @@ -84,8 +84,8 @@ function print_help_in_terminal() { --docker-debug-logs Set Docker builder log output for debug (i.e.BUILDKIT_PROGRESS=plain) --fail-fast Exit script at first encountered error - --ci-sitrep-run Override LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE and - LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS with there respective _SITREP version + --ci-sitrep-run Override NBS_MATRIX_CMAKE_BUILD_TYPE and + NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS with there respective _SITREP version \033[1m [-- ]\033[0m Any argument passed after '--' will be passed to docker compose as docker @@ -102,33 +102,33 @@ print_formated_script_header 'lpm_execute_compose_over_build_matrix.bash' "${LPM while [ $# -gt 0 ]; do case $1 in - --libpointmatcher-version-build-matrix-override) - unset LPM_MATRIX_LIBPOINTMATCHER_VERSIONS - LPM_MATRIX_LIBPOINTMATCHER_VERSIONS=("$2") - shift # Remove argument (--libpointmatcher-version-build-matrix-override) + --repository-version-build-matrix-override) + unset NBS_MATRIX_REPOSITORY_VERSIONS + NBS_MATRIX_REPOSITORY_VERSIONS=("$2") + shift # Remove argument (--repository-version-build-matrix-override) shift # Remove argument value ;; - --libpointmatcher-cmake-build-type-build-matrix-override) - unset LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE - LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE=("$2") - shift # Remove argument (--libpointmatcher-cmake-build-type-build-matrix-override) + --cmake-build-type-build-matrix-override) + unset NBS_MATRIX_CMAKE_BUILD_TYPE + NBS_MATRIX_CMAKE_BUILD_TYPE=("$2") + shift # Remove argument (--cmake-build-type-build-matrix-override) shift # Remove argument value ;; --os-name-build-matrix-override) - unset LPM_MATRIX_SUPPORTED_OS - LPM_MATRIX_SUPPORTED_OS=("$2") + unset NBS_MATRIX_SUPPORTED_OS + NBS_MATRIX_SUPPORTED_OS=("$2") shift # Remove argument (--os-name-build-matrix-override) shift # Remove argument value ;; --ubuntu-version-build-matrix-override) - unset LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS - LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS=("$2") + unset NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS + NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS=("$2") shift # Remove argument (--ubuntu-version-build-matrix-override) shift # Remove argument value ;; --osx-version-build-matrix-override) - unset LPM_MATRIX_OSX_SUPPORTED_VERSIONS - LPM_MATRIX_OSX_SUPPORTED_VERSIONS=("$2") + unset NBS_MATRIX_OSX_SUPPORTED_VERSIONS + NBS_MATRIX_OSX_SUPPORTED_VERSIONS=("$2") shift # Remove argument (--osx-version-build-matrix-override) shift # Remove argument value ;; @@ -144,13 +144,13 @@ while [ $# -gt 0 ]; do ;; --ci-sitrep-run) shift # Remove argument (--ci-sitrep-run) - unset LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE - unset LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS - LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE=("${LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE_SITREP[@]}") - LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS=("${LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS_SITREP[@]}") + unset NBS_MATRIX_CMAKE_BUILD_TYPE + unset NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS + NBS_MATRIX_CMAKE_BUILD_TYPE=("${NBS_MATRIX_CMAKE_BUILD_TYPE_SITREP[@]}") + NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS=("${NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS_SITREP[@]}") print_msg "${MSG_DIMMED_FORMAT}ci-sitrep${MSG_END_FORMAT} run environment variable override: - - ${MSG_DIMMED_FORMAT}LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE=(${LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE_SITREP[*]})${MSG_END_FORMAT} - - ${MSG_DIMMED_FORMAT}LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS=(${LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS_SITREP[*]})${MSG_END_FORMAT}" + - ${MSG_DIMMED_FORMAT}NBS_MATRIX_CMAKE_BUILD_TYPE=(${NBS_MATRIX_CMAKE_BUILD_TYPE_SITREP[*]})${MSG_END_FORMAT} + - ${MSG_DIMMED_FORMAT}NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS=(${NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS_SITREP[*]})${MSG_END_FORMAT}" ;; -h | --help) print_help_in_terminal @@ -173,34 +173,34 @@ done print_msg "Build images specified in ${MSG_DIMMED_FORMAT}'docker-compose.libpointmatcher.yaml'${MSG_END_FORMAT} following ${MSG_DIMMED_FORMAT}.env.build_matrix${MSG_END_FORMAT}" ## Freeze build matrix env variable to prevent override by lpm_execute_compose.bash when reloading .env/build_matrix -FREEZED_LPM_MATRIX_LIBPOINTMATCHER_VERSIONS=("${LPM_MATRIX_LIBPOINTMATCHER_VERSIONS[@]}") -FREEZED_LPM_MATRIX_SUPPORTED_OS=("${LPM_MATRIX_SUPPORTED_OS[@]}") -FREEZED_LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS=("${LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS[@]}") -FREEZED_LPM_MATRIX_OSX_SUPPORTED_VERSIONS=("${LPM_MATRIX_OSX_SUPPORTED_VERSIONS[@]}") -FREEZED_LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE=("${LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE[@]}") +FREEZED_NBS_MATRIX_REPOSITORY_VERSIONS=("${NBS_MATRIX_REPOSITORY_VERSIONS[@]}") +FREEZED_NBS_MATRIX_SUPPORTED_OS=("${NBS_MATRIX_SUPPORTED_OS[@]}") +FREEZED_NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS=("${NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS[@]}") +FREEZED_NBS_MATRIX_OSX_SUPPORTED_VERSIONS=("${NBS_MATRIX_OSX_SUPPORTED_VERSIONS[@]}") +FREEZED_NBS_MATRIX_CMAKE_BUILD_TYPE=("${NBS_MATRIX_CMAKE_BUILD_TYPE[@]}") print_msg "Environment variables ${MSG_EMPH_FORMAT}(build matrix)${MSG_END_FORMAT} set for compose:\n -${MSG_DIMMED_FORMAT} LPM_MATRIX_LIBPOINTMATCHER_VERSIONS=(${FREEZED_LPM_MATRIX_LIBPOINTMATCHER_VERSIONS[*]}) ${MSG_END_FORMAT} -${MSG_DIMMED_FORMAT} LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE=(${FREEZED_LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE[*]}) ${MSG_END_FORMAT} -${MSG_DIMMED_FORMAT} LPM_MATRIX_SUPPORTED_OS=(${FREEZED_LPM_MATRIX_SUPPORTED_OS[*]}) ${MSG_END_FORMAT} -${MSG_DIMMED_FORMAT} LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS=(${FREEZED_LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS[*]}) ${MSG_END_FORMAT} -${MSG_DIMMED_FORMAT} LPM_MATRIX_OSX_SUPPORTED_VERSIONS=(${FREEZED_LPM_MATRIX_OSX_SUPPORTED_VERSIONS[*]}) ${MSG_END_FORMAT} +${MSG_DIMMED_FORMAT} NBS_MATRIX_REPOSITORY_VERSIONS=(${FREEZED_NBS_MATRIX_REPOSITORY_VERSIONS[*]}) ${MSG_END_FORMAT} +${MSG_DIMMED_FORMAT} NBS_MATRIX_CMAKE_BUILD_TYPE=(${FREEZED_NBS_MATRIX_CMAKE_BUILD_TYPE[*]}) ${MSG_END_FORMAT} +${MSG_DIMMED_FORMAT} NBS_MATRIX_SUPPORTED_OS=(${FREEZED_NBS_MATRIX_SUPPORTED_OS[*]}) ${MSG_END_FORMAT} +${MSG_DIMMED_FORMAT} NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS=(${FREEZED_NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS[*]}) ${MSG_END_FORMAT} +${MSG_DIMMED_FORMAT} NBS_MATRIX_OSX_SUPPORTED_VERSIONS=(${FREEZED_NBS_MATRIX_OSX_SUPPORTED_VERSIONS[*]}) ${MSG_END_FORMAT} " # Note: EACH_LPM_VERSION is used for container labeling and to fetch the repo at release tag -for EACH_LPM_VERSION in "${FREEZED_LPM_MATRIX_LIBPOINTMATCHER_VERSIONS[@]}"; do +for EACH_LPM_VERSION in "${FREEZED_NBS_MATRIX_REPOSITORY_VERSIONS[@]}"; do if [[ ${TEAMCITY_VERSION} ]]; then echo -e "##teamcity[blockOpened name='${MSG_BASE_TEAMCITY} ${EACH_LPM_VERSION}']" fi - for EACH_OS_NAME in "${FREEZED_LPM_MATRIX_SUPPORTED_OS[@]}"; do + for EACH_OS_NAME in "${FREEZED_NBS_MATRIX_SUPPORTED_OS[@]}"; do unset CRAWL_OS_VERSIONS if [[ ${EACH_OS_NAME} == 'ubuntu' ]]; then - CRAWL_OS_VERSIONS=("${FREEZED_LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS[@]}") + CRAWL_OS_VERSIONS=("${FREEZED_NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS[@]}") elif [[ ${EACH_OS_NAME} == 'osx' ]]; then - CRAWL_OS_VERSIONS=("${FREEZED_LPM_MATRIX_OSX_SUPPORTED_VERSIONS[@]}") + CRAWL_OS_VERSIONS=("${FREEZED_NBS_MATRIX_OSX_SUPPORTED_VERSIONS[@]}") else print_msg_error_and_exit "${EACH_OS_NAME} not supported!" fi @@ -220,18 +220,18 @@ for EACH_LPM_VERSION in "${FREEZED_LPM_MATRIX_LIBPOINTMATCHER_VERSIONS[@]}"; do echo -e "##teamcity[blockOpened name='${MSG_BASE_TEAMCITY} ${EACH_OS_VERSION}']" fi - for EACH_CMAKE_BUILD_TYPE in "${FREEZED_LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE[@]}"; do + for EACH_CMAKE_BUILD_TYPE in "${FREEZED_NBS_MATRIX_CMAKE_BUILD_TYPE[@]}"; do # shellcheck disable=SC2034 SHOW_SPLASH_EC='false' if [[ ${TEAMCITY_VERSION} ]]; then - echo -e "##teamcity[blockOpened name='${MSG_BASE_TEAMCITY} execute lpm_execute_compose.bash' description='${MSG_DIMMED_FORMAT_TEAMCITY} --libpointmatcher-version ${EACH_LPM_VERSION} --libpointmatcher-cmake-build-type ${EACH_CMAKE_BUILD_TYPE} --os-name ${EACH_OS_NAME} --os-version ${EACH_OS_VERSION} -- ${DOCKER_COMPOSE_CMD_ARGS}${MSG_END_FORMAT_TEAMCITY}|n']" + echo -e "##teamcity[blockOpened name='${MSG_BASE_TEAMCITY} execute lpm_execute_compose.bash' description='${MSG_DIMMED_FORMAT_TEAMCITY} --repository-version ${EACH_LPM_VERSION} --cmake-build-type ${EACH_CMAKE_BUILD_TYPE} --os-name ${EACH_OS_NAME} --os-version ${EACH_OS_VERSION} -- ${DOCKER_COMPOSE_CMD_ARGS}${MSG_END_FORMAT_TEAMCITY}|n']" echo " " fi - source ./lpm_execute_compose.bash --libpointmatcher-version "${EACH_LPM_VERSION}" \ - --libpointmatcher-cmake-build-type "${EACH_CMAKE_BUILD_TYPE}" \ + source ./lpm_execute_compose.bash --repository-version "${EACH_LPM_VERSION}" \ + --cmake-build-type "${EACH_CMAKE_BUILD_TYPE}" \ --os-name "${EACH_OS_NAME}" \ --os-version "${EACH_OS_VERSION}" \ -- "${DOCKER_COMPOSE_CMD_ARGS}" @@ -287,11 +287,11 @@ done echo " " print_msg "Environment variables ${MSG_EMPH_FORMAT}(build matrix)${MSG_END_FORMAT} used by compose:\n -${MSG_DIMMED_FORMAT} LPM_MATRIX_LIBPOINTMATCHER_VERSIONS=(${FREEZED_LPM_MATRIX_LIBPOINTMATCHER_VERSIONS[*]}) ${MSG_END_FORMAT} -${MSG_DIMMED_FORMAT} LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE=(${FREEZED_LPM_MATRIX_LIBPOINTMATCHER_CMAKE_BUILD_TYPE[*]}) ${MSG_END_FORMAT} -${MSG_DIMMED_FORMAT} LPM_MATRIX_SUPPORTED_OS=(${FREEZED_LPM_MATRIX_SUPPORTED_OS[*]}) ${MSG_END_FORMAT} -${MSG_DIMMED_FORMAT} LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS=(${FREEZED_LPM_MATRIX_UBUNTU_SUPPORTED_VERSIONS[*]}) ${MSG_END_FORMAT} -${MSG_DIMMED_FORMAT} LPM_MATRIX_OSX_SUPPORTED_VERSIONS=(${FREEZED_LPM_MATRIX_OSX_SUPPORTED_VERSIONS[*]}) ${MSG_END_FORMAT} +${MSG_DIMMED_FORMAT} NBS_MATRIX_REPOSITORY_VERSIONS=(${FREEZED_NBS_MATRIX_REPOSITORY_VERSIONS[*]}) ${MSG_END_FORMAT} +${MSG_DIMMED_FORMAT} NBS_MATRIX_CMAKE_BUILD_TYPE=(${FREEZED_NBS_MATRIX_CMAKE_BUILD_TYPE[*]}) ${MSG_END_FORMAT} +${MSG_DIMMED_FORMAT} NBS_MATRIX_SUPPORTED_OS=(${FREEZED_NBS_MATRIX_SUPPORTED_OS[*]}) ${MSG_END_FORMAT} +${MSG_DIMMED_FORMAT} NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS=(${FREEZED_NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS[*]}) ${MSG_END_FORMAT} +${MSG_DIMMED_FORMAT} NBS_MATRIX_OSX_SUPPORTED_VERSIONS=(${FREEZED_NBS_MATRIX_OSX_SUPPORTED_VERSIONS[*]}) ${MSG_END_FORMAT} " print_msg_done "FINAL › Build matrix completed with command diff --git a/build_system/ubuntu/Dockerfile.libpointmatcher b/build_system/ubuntu/Dockerfile.libpointmatcher index f01b63ad1..739707439 100644 --- a/build_system/ubuntu/Dockerfile.libpointmatcher +++ b/build_system/ubuntu/Dockerfile.libpointmatcher @@ -5,9 +5,9 @@ FROM ${PROJECT_HUB}/${BASE_IMAGE}:${BASE_IMAGE_TAG:?err} AS libpointmatcher-depe LABEL org.opencontainers.image.authors="luc.coupal.1@ulaval.ca" -ARG LIBPOINTMATCHER_VERSION -ENV LIBPOINTMATCHER_VERSION=${LIBPOINTMATCHER_VERSION:?'Build argument needs to be set and non-empty.'} -LABEL libpointmatcher.version="${LIBPOINTMATCHER_VERSION}" +ARG REPOSITORY_VERSION +ENV REPOSITORY_VERSION=${REPOSITORY_VERSION:?'Build argument needs to be set and non-empty.'} +LABEL libpointmatcher.version="${REPOSITORY_VERSION}" ARG LPM_INSTALLED_LIBRARIES_PATH @@ -49,7 +49,7 @@ RUN chmod +x entrypoint.bash # (CRITICAL) ToDo: validate effect on teamcity build log (source vs bash) RUN source lpm_install_libpointmatcher_ubuntu.bash \ - --libpointmatcher-version ${LIBPOINTMATCHER_VERSION} \ + --repository-version ${REPOSITORY_VERSION} \ --cmake-build-type ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} \ ${LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG} diff --git a/build_system/ubuntu/Dockerfile.libpointmatcher_ci_PR b/build_system/ubuntu/Dockerfile.libpointmatcher_ci_PR index 2fcc0d238..711337f8c 100644 --- a/build_system/ubuntu/Dockerfile.libpointmatcher_ci_PR +++ b/build_system/ubuntu/Dockerfile.libpointmatcher_ci_PR @@ -5,9 +5,9 @@ FROM ${PROJECT_HUB}/${BASE_IMAGE}:${BASE_IMAGE_TAG:?err} AS libpointmatcher-depe LABEL org.opencontainers.image.authors="luc.coupal.1@ulaval.ca" -ARG LIBPOINTMATCHER_VERSION='head' -ENV LIBPOINTMATCHER_VERSION=${LIBPOINTMATCHER_VERSION} -LABEL libpointmatcher.version="${LIBPOINTMATCHER_VERSION}" +ARG REPOSITORY_VERSION='latest' +ENV REPOSITORY_VERSION=${REPOSITORY_VERSION} +LABEL libpointmatcher.version="${REPOSITORY_VERSION}" ARG LPM_INSTALLED_LIBRARIES_PATH ARG LPM_LIBPOINTMATCHER_SRC_REPO_NAME @@ -49,7 +49,7 @@ RUN chmod +x entrypoint.bash RUN source lpm_install_libpointmatcher_ubuntu.bash \ - --libpointmatcher-version ${LIBPOINTMATCHER_VERSION} \ + --repository-version ${REPOSITORY_VERSION} \ --cmake-build-type ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} \ ${LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG} diff --git a/build_system/ubuntu/Dockerfile.libpointmatcher_ci_SITREP_matrix b/build_system/ubuntu/Dockerfile.libpointmatcher_ci_SITREP_matrix index bdfb65678..fe3641035 100644 --- a/build_system/ubuntu/Dockerfile.libpointmatcher_ci_SITREP_matrix +++ b/build_system/ubuntu/Dockerfile.libpointmatcher_ci_SITREP_matrix @@ -5,9 +5,9 @@ FROM ${PROJECT_HUB}/${BASE_IMAGE}:${BASE_IMAGE_TAG:?err} AS libpointmatcher-depe LABEL org.opencontainers.image.authors="luc.coupal.1@ulaval.ca" -ARG LIBPOINTMATCHER_VERSION='head' -ENV LIBPOINTMATCHER_VERSION=${LIBPOINTMATCHER_VERSION} -LABEL libpointmatcher.version="${LIBPOINTMATCHER_VERSION}" +ARG REPOSITORY_VERSION='latest' +ENV REPOSITORY_VERSION=${REPOSITORY_VERSION} +LABEL libpointmatcher.version="${REPOSITORY_VERSION}" ARG LPM_INSTALLED_LIBRARIES_PATH ARG LPM_LIBPOINTMATCHER_SRC_REPO_NAME @@ -45,7 +45,7 @@ RUN chmod +x entrypoint.bash # Note: Logic for cd into ${LPM_INSTALLED_LIBRARIES_PATH}/${LPM_LIBPOINTMATCHER_SRC_REPO_NAME} is the responsablitiy of lpm_install_libpointmatcher_ubuntu.bash RUN source lpm_install_libpointmatcher_ubuntu.bash \ - --libpointmatcher-version ${LIBPOINTMATCHER_VERSION} \ + --repository-version ${REPOSITORY_VERSION} \ --cmake-build-type ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} \ ${LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG} diff --git a/build_system/ubuntu/Dockerfile.libpointmatcher_test_compilation b/build_system/ubuntu/Dockerfile.libpointmatcher_test_compilation index 4f2b5afd0..451173f0a 100644 --- a/build_system/ubuntu/Dockerfile.libpointmatcher_test_compilation +++ b/build_system/ubuntu/Dockerfile.libpointmatcher_test_compilation @@ -5,9 +5,9 @@ FROM ${PROJECT_HUB}/${BASE_IMAGE}:${BASE_IMAGE_TAG:?err} AS libpointmatcher-depe LABEL org.opencontainers.image.authors="luc.coupal.1@ulaval.ca" -ARG LIBPOINTMATCHER_VERSION='head' -ENV LIBPOINTMATCHER_VERSION=${LIBPOINTMATCHER_VERSION} -LABEL libpointmatcher.version="${LIBPOINTMATCHER_VERSION}" +ARG REPOSITORY_VERSION='latest' +ENV REPOSITORY_VERSION=${REPOSITORY_VERSION} +LABEL libpointmatcher.version="${REPOSITORY_VERSION}" ARG LPM_INSTALLED_LIBRARIES_PATH ARG LPM_LIBPOINTMATCHER_SRC_REPO_NAME @@ -64,7 +64,7 @@ RUN utest/listVersionsUbuntu.sh # .... Build libpointmatcher checkout branch ...................................................... WORKDIR ./build_system/ubuntu RUN source lpm_install_libpointmatcher_ubuntu.bash \ - --libpointmatcher-version ${LIBPOINTMATCHER_VERSION} \ + --repository-version ${REPOSITORY_VERSION} \ --cmake-build-type ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} \ ${LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG} @@ -97,7 +97,7 @@ RUN utest/listVersionsUbuntu.sh # .... Build libpointmatcher checkout branch ...................................................... WORKDIR ./build_system/ubuntu RUN source lpm_install_libpointmatcher_ubuntu.bash \ - --libpointmatcher-version ${LIBPOINTMATCHER_VERSION} \ + --repository-version ${REPOSITORY_VERSION} \ --cmake-build-type ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} \ ${LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG} diff --git a/build_system/ubuntu/entrypoint_build_and_test_libpointmatcher_checkout_branch.bash b/build_system/ubuntu/entrypoint_build_and_test_libpointmatcher_checkout_branch.bash index 7636b1c77..7fcd3d939 100644 --- a/build_system/ubuntu/entrypoint_build_and_test_libpointmatcher_checkout_branch.bash +++ b/build_system/ubuntu/entrypoint_build_and_test_libpointmatcher_checkout_branch.bash @@ -16,7 +16,7 @@ set +o allexport # ==== Build libpointmatcher checkout branch ====================================================================== source lpm_install_libpointmatcher_ubuntu.bash \ - --libpointmatcher-version ${LIBPOINTMATCHER_VERSION:?'err variable not set'} \ + --repository-version ${REPOSITORY_VERSION:?'err variable not set'} \ --cmake-build-type ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} \ ${LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG} diff --git a/build_system/ubuntu/entrypoint_build_libpointmatcher_checkout_branch.bash b/build_system/ubuntu/entrypoint_build_libpointmatcher_checkout_branch.bash index c10a49cee..087397ac2 100644 --- a/build_system/ubuntu/entrypoint_build_libpointmatcher_checkout_branch.bash +++ b/build_system/ubuntu/entrypoint_build_libpointmatcher_checkout_branch.bash @@ -16,7 +16,7 @@ set +o allexport # ==== Build libpointmatcher checkout branch ====================================================================== source lpm_install_libpointmatcher_ubuntu.bash \ - --libpointmatcher-version ${LIBPOINTMATCHER_VERSION:?'err variable not set'} \ + --repository-version ${REPOSITORY_VERSION:?'err variable not set'} \ --cmake-build-type ${LIBPOINTMATCHER_CMAKE_BUILD_TYPE} \ ${LIBPOINTMATCHER_INSTALL_SCRIPT_FLAG} diff --git a/build_system/ubuntu/lpm_install_libpointmatcher_ubuntu.bash b/build_system/ubuntu/lpm_install_libpointmatcher_ubuntu.bash index 9ad031b99..d2d14b1da 100644 --- a/build_system/ubuntu/lpm_install_libpointmatcher_ubuntu.bash +++ b/build_system/ubuntu/lpm_install_libpointmatcher_ubuntu.bash @@ -8,7 +8,7 @@ # Arguments: # [--install-path ] The directory where to install libpointmatcher (absolute path) # (default location defined in the .env) -# [--libpointmatcher-version v1.3.1] Install libpointmatcher release tag version (default to master branch head) +# [--repository-version v1.3.1] Install libpointmatcher release tag version (default to master branch latest) # [--compile-test] Compile the libpointmatcher unit-test # [--generate-doc] Generate the libpointmatcher doxygen documentation # in /usr/local/share/doc/libpointmatcher/api/html/index.html @@ -32,7 +32,7 @@ set -e # Note: we want the installer to always fail-fast (it wont affect the build system policy) # ....Default...................................................................................... -LIBPOINTMATCHER_VERSION='head' +REPOSITORY_VERSION='latest' BUILD_TESTS_FLAG=FALSE GENERATE_API_DOC_FLAG=FALSE BUILD_SYSTEM_CI_INSTALL=FALSE @@ -70,7 +70,7 @@ function print_help_in_terminal() { \033[1m:\033[0m --install-path The directory where to install libpointmatcher (absolute path) (default location ${MSG_DIMMED_FORMAT}${LPM_INSTALLED_LIBRARIES_PATH:?'err LPM_INSTALLED_LIBRARIES_PATH env variable was not fetched from the .env'}${MSG_END_FORMAT}) - --libpointmatcher-version v1.3.1 Install libpointmatcher release tag version (default to master branch head) + --repository-version v1.3.1 Install libpointmatcher release tag version (default to master branch latest) --compile-test Compile the libpointmatcher unit-test in ${MSG_DIMMED_FORMAT}${LPM_INSTALLED_LIBRARIES_PATH}/libpointmatcher/build${MSG_END_FORMAT} --generate-doc Generate the libpointmatcher doxygen documentation @@ -105,9 +105,9 @@ while [ $# -gt 0 ]; do shift # Remove argument (--install-path) shift # Remove argument value ;; - --libpointmatcher-version) - LIBPOINTMATCHER_VERSION="${2}" - shift # Remove argument (--libpointmatcher-version) + --repository-version) + REPOSITORY_VERSION="${2}" + shift # Remove argument (--repository-version) shift # Remove argument value ;; --cmake-build-type) @@ -170,14 +170,14 @@ if [[ ${BUILD_SYSTEM_CI_INSTALL} == FALSE ]]; then git clone https://github.com/"${LPM_LIBPOINTMATCHER_SRC_DOMAIN}"/"${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}".git - if [[ "${LIBPOINTMATCHER_VERSION}" != 'head' ]]; then + if [[ "${REPOSITORY_VERSION}" != 'latest' ]]; then cd "${LPM_LIBPOINTMATCHER_SRC_REPO_NAME}"/ git fetch --tags git tag --list # Remove prefix 'v' from version tag - GITHUB_TAG="${LIBPOINTMATCHER_VERSION/v/}" + GITHUB_TAG="${REPOSITORY_VERSION/v/}" print_msg "GITHUB_TAG=${GITHUB_TAG}" git checkout tags/"${GITHUB_TAG}" From be05d5d7f13a243fba0bb2fe8351fba89e8fe07a Mon Sep 17 00:00:00 2001 From: RedLeaderOne Date: Wed, 29 Nov 2023 15:46:19 -0500 Subject: [PATCH 039/124] fix: build-system side unstable compilation issue fix [NMO-402] - added development idea run configuration --- ...ompose._ \342\200\272 --help menu.run.xml" | 19 +++++++++++++++++++ ...r build & run IamBuildSystemTester.run.xml | 17 +++++++++++++++++ ...d_matrix.bash \342\200\272 config.run.xml" | 19 +++++++++++++++++++ ....bash \342\200\272 config --quiet.run.xml" | 19 +++++++++++++++++++ ...bash \342\200\272 build --dry-run.run.xml" | 19 +++++++++++++++++++ ...\200\272 build _service_ _popup_.run.xml" | 19 +++++++++++++++++++ ...ies_arm64v8 ci_PR_arm64v8 _popup_.run.xml" | 19 +++++++++++++++++++ ...ependencies (BUILD MATRIX SUBSET).run.xml" | 19 +++++++++++++++++++ ...uild test_compilation__ (Release).run.xml" | 19 +++++++++++++++++++ ...efixed_path (BUILD MATRIX SUBSET).run.xml" | 19 +++++++++++++++++++ ...s-general dependencies (AS IN TC).run.xml" | 19 +++++++++++++++++++ ...wd tree + docker system disk usage.run.xml | 17 +++++++++++++++++ .../.jetbrains_run_config/interactive.run.xml | 17 +++++++++++++++++ .../list docker images + container.run.xml | 17 +++++++++++++++++ ...lpm_execute_compose.bash -- build.run.xml" | 17 +++++++++++++++++ ...sh \342\200\272 test flag (popup).run.xml" | 17 +++++++++++++++++ ...sh \342\200\272 test flag (popup).run.xml" | 17 +++++++++++++++++ ...00\272 test flag override (popup).run.xml" | 17 +++++++++++++++++ ...rminal in a Ubuntu 20.04 container.run.xml | 17 +++++++++++++++++ 19 files changed, 343 insertions(+) create mode 100644 "build_system/.jetbrains_run_config/(HELP) bash lpm_execute_compose._ \342\200\272 --help menu.run.xml" create mode 100644 build_system/.jetbrains_run_config/(command version) docker build & run IamBuildSystemTester.run.xml create mode 100644 "build_system/.jetbrains_run_config/(investigate compose var substitution) lpm_execute_compose_over_build_matrix.bash \342\200\272 config.run.xml" create mode 100644 "build_system/.jetbrains_run_config/(test compose file) lpm_execute_compose_over_build_matrix.bash \342\200\272 config --quiet.run.xml" create mode 100644 "build_system/.jetbrains_run_config/(test) lpm_execute_compose_over_build_matrix.bash \342\200\272 build --dry-run.run.xml" create mode 100644 "build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build _service_ _popup_.run.xml" create mode 100644 "build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build dependencies_arm64v8 ci_PR_arm64v8 _popup_.run.xml" create mode 100644 "build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build dependencies-general dependencies (BUILD MATRIX SUBSET).run.xml" create mode 100644 "build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build test_compilation__ (Release).run.xml" create mode 100644 "build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build test_compilation_prefixed_path (BUILD MATRIX SUBSET).run.xml" create mode 100644 "build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build&push dependencies-general dependencies (AS IN TC).run.xml" create mode 100644 build_system/.jetbrains_run_config/cwd tree + docker system disk usage.run.xml create mode 100644 build_system/.jetbrains_run_config/interactive.run.xml create mode 100644 build_system/.jetbrains_run_config/list docker images + container.run.xml create mode 100644 "build_system/.jetbrains_run_config/lpm_execute_compose.bash \342\200\272 lpm_execute_compose.bash -- build.run.xml" create mode 100644 "build_system/.jetbrains_run_config/lpm_execute_compose.bash \342\200\272 lpm_execute_compose.bash \342\200\272 test flag (popup).run.xml" create mode 100644 "build_system/.jetbrains_run_config/lpm_execute_compose_over_build_matrix.bash \342\200\272 test flag (popup).run.xml" create mode 100644 "build_system/.jetbrains_run_config/lpm_execute_compose_over_build_matrix.bash \342\200\272 test flag override (popup).run.xml" create mode 100644 build_system/.jetbrains_run_config/run and open a terminal in a Ubuntu 20.04 container.run.xml diff --git "a/build_system/.jetbrains_run_config/(HELP) bash lpm_execute_compose._ \342\200\272 --help menu.run.xml" "b/build_system/.jetbrains_run_config/(HELP) bash lpm_execute_compose._ \342\200\272 --help menu.run.xml" new file mode 100644 index 000000000..1c701be1f --- /dev/null +++ "b/build_system/.jetbrains_run_config/(HELP) bash lpm_execute_compose._ \342\200\272 --help menu.run.xml" @@ -0,0 +1,19 @@ + + + + \ No newline at end of file diff --git a/build_system/.jetbrains_run_config/(command version) docker build & run IamBuildSystemTester.run.xml b/build_system/.jetbrains_run_config/(command version) docker build & run IamBuildSystemTester.run.xml new file mode 100644 index 000000000..af7f549ae --- /dev/null +++ b/build_system/.jetbrains_run_config/(command version) docker build & run IamBuildSystemTester.run.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git "a/build_system/.jetbrains_run_config/(investigate compose var substitution) lpm_execute_compose_over_build_matrix.bash \342\200\272 config.run.xml" "b/build_system/.jetbrains_run_config/(investigate compose var substitution) lpm_execute_compose_over_build_matrix.bash \342\200\272 config.run.xml" new file mode 100644 index 000000000..089d69820 --- /dev/null +++ "b/build_system/.jetbrains_run_config/(investigate compose var substitution) lpm_execute_compose_over_build_matrix.bash \342\200\272 config.run.xml" @@ -0,0 +1,19 @@ + + + + \ No newline at end of file diff --git "a/build_system/.jetbrains_run_config/(test compose file) lpm_execute_compose_over_build_matrix.bash \342\200\272 config --quiet.run.xml" "b/build_system/.jetbrains_run_config/(test compose file) lpm_execute_compose_over_build_matrix.bash \342\200\272 config --quiet.run.xml" new file mode 100644 index 000000000..0b696d1e9 --- /dev/null +++ "b/build_system/.jetbrains_run_config/(test compose file) lpm_execute_compose_over_build_matrix.bash \342\200\272 config --quiet.run.xml" @@ -0,0 +1,19 @@ + + + + \ No newline at end of file diff --git "a/build_system/.jetbrains_run_config/(test) lpm_execute_compose_over_build_matrix.bash \342\200\272 build --dry-run.run.xml" "b/build_system/.jetbrains_run_config/(test) lpm_execute_compose_over_build_matrix.bash \342\200\272 build --dry-run.run.xml" new file mode 100644 index 000000000..523970b98 --- /dev/null +++ "b/build_system/.jetbrains_run_config/(test) lpm_execute_compose_over_build_matrix.bash \342\200\272 build --dry-run.run.xml" @@ -0,0 +1,19 @@ + + + + \ No newline at end of file diff --git "a/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build _service_ _popup_.run.xml" "b/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build _service_ _popup_.run.xml" new file mode 100644 index 000000000..54a9e30be --- /dev/null +++ "b/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build _service_ _popup_.run.xml" @@ -0,0 +1,19 @@ + + + + \ No newline at end of file diff --git "a/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build dependencies_arm64v8 ci_PR_arm64v8 _popup_.run.xml" "b/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build dependencies_arm64v8 ci_PR_arm64v8 _popup_.run.xml" new file mode 100644 index 000000000..8ee973a88 --- /dev/null +++ "b/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build dependencies_arm64v8 ci_PR_arm64v8 _popup_.run.xml" @@ -0,0 +1,19 @@ + + + + \ No newline at end of file diff --git "a/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build dependencies-general dependencies (BUILD MATRIX SUBSET).run.xml" "b/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build dependencies-general dependencies (BUILD MATRIX SUBSET).run.xml" new file mode 100644 index 000000000..823d98b48 --- /dev/null +++ "b/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build dependencies-general dependencies (BUILD MATRIX SUBSET).run.xml" @@ -0,0 +1,19 @@ + + + + \ No newline at end of file diff --git "a/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build test_compilation__ (Release).run.xml" "b/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build test_compilation__ (Release).run.xml" new file mode 100644 index 000000000..a134c5df9 --- /dev/null +++ "b/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build test_compilation__ (Release).run.xml" @@ -0,0 +1,19 @@ + + + + \ No newline at end of file diff --git "a/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build test_compilation_prefixed_path (BUILD MATRIX SUBSET).run.xml" "b/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build test_compilation_prefixed_path (BUILD MATRIX SUBSET).run.xml" new file mode 100644 index 000000000..19fb1cd5c --- /dev/null +++ "b/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build test_compilation_prefixed_path (BUILD MATRIX SUBSET).run.xml" @@ -0,0 +1,19 @@ + + + + \ No newline at end of file diff --git "a/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build&push dependencies-general dependencies (AS IN TC).run.xml" "b/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build&push dependencies-general dependencies (AS IN TC).run.xml" new file mode 100644 index 000000000..d01cd46b8 --- /dev/null +++ "b/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build&push dependencies-general dependencies (AS IN TC).run.xml" @@ -0,0 +1,19 @@ + + + + \ No newline at end of file diff --git a/build_system/.jetbrains_run_config/cwd tree + docker system disk usage.run.xml b/build_system/.jetbrains_run_config/cwd tree + docker system disk usage.run.xml new file mode 100644 index 000000000..3234c0a3a --- /dev/null +++ b/build_system/.jetbrains_run_config/cwd tree + docker system disk usage.run.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/build_system/.jetbrains_run_config/interactive.run.xml b/build_system/.jetbrains_run_config/interactive.run.xml new file mode 100644 index 000000000..fb5838f03 --- /dev/null +++ b/build_system/.jetbrains_run_config/interactive.run.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/build_system/.jetbrains_run_config/list docker images + container.run.xml b/build_system/.jetbrains_run_config/list docker images + container.run.xml new file mode 100644 index 000000000..9894da234 --- /dev/null +++ b/build_system/.jetbrains_run_config/list docker images + container.run.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git "a/build_system/.jetbrains_run_config/lpm_execute_compose.bash \342\200\272 lpm_execute_compose.bash -- build.run.xml" "b/build_system/.jetbrains_run_config/lpm_execute_compose.bash \342\200\272 lpm_execute_compose.bash -- build.run.xml" new file mode 100644 index 000000000..4e1411d75 --- /dev/null +++ "b/build_system/.jetbrains_run_config/lpm_execute_compose.bash \342\200\272 lpm_execute_compose.bash -- build.run.xml" @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git "a/build_system/.jetbrains_run_config/lpm_execute_compose.bash \342\200\272 lpm_execute_compose.bash \342\200\272 test flag (popup).run.xml" "b/build_system/.jetbrains_run_config/lpm_execute_compose.bash \342\200\272 lpm_execute_compose.bash \342\200\272 test flag (popup).run.xml" new file mode 100644 index 000000000..d2c9d64e9 --- /dev/null +++ "b/build_system/.jetbrains_run_config/lpm_execute_compose.bash \342\200\272 lpm_execute_compose.bash \342\200\272 test flag (popup).run.xml" @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git "a/build_system/.jetbrains_run_config/lpm_execute_compose_over_build_matrix.bash \342\200\272 test flag (popup).run.xml" "b/build_system/.jetbrains_run_config/lpm_execute_compose_over_build_matrix.bash \342\200\272 test flag (popup).run.xml" new file mode 100644 index 000000000..e4e8e5047 --- /dev/null +++ "b/build_system/.jetbrains_run_config/lpm_execute_compose_over_build_matrix.bash \342\200\272 test flag (popup).run.xml" @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git "a/build_system/.jetbrains_run_config/lpm_execute_compose_over_build_matrix.bash \342\200\272 test flag override (popup).run.xml" "b/build_system/.jetbrains_run_config/lpm_execute_compose_over_build_matrix.bash \342\200\272 test flag override (popup).run.xml" new file mode 100644 index 000000000..3bd3e0d3b --- /dev/null +++ "b/build_system/.jetbrains_run_config/lpm_execute_compose_over_build_matrix.bash \342\200\272 test flag override (popup).run.xml" @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/build_system/.jetbrains_run_config/run and open a terminal in a Ubuntu 20.04 container.run.xml b/build_system/.jetbrains_run_config/run and open a terminal in a Ubuntu 20.04 container.run.xml new file mode 100644 index 000000000..d2ac23c8b --- /dev/null +++ b/build_system/.jetbrains_run_config/run and open a terminal in a Ubuntu 20.04 container.run.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file From 2f09b3e34f191c7b86b690207850baff07daf430 Mon Sep 17 00:00:00 2001 From: RedLeaderOne Date: Wed, 29 Nov 2023 16:56:23 -0500 Subject: [PATCH 040/124] fix: build-system side unstable compilation issue fix [NMO-402] - refactor environment variable prefix to match norlab-build-system lib - change the name for the call to repository version master branch current version from "head" to "latest" - fix the norlab-build-system path resolution in files from the `lpm_utility_script.bash` --- build_system/.env | 8 +- build_system/.env.build_matrix | 5 + build_system/.env.prompt | 38 ++-- ...ompose._ \342\200\272 --help menu.run.xml" | 4 +- ...r build & run IamBuildSystemTester.run.xml | 2 +- ...d_matrix.bash \342\200\272 config.run.xml" | 4 +- ....bash \342\200\272 config --quiet.run.xml" | 4 +- ...bash \342\200\272 build --dry-run.run.xml" | 4 +- ...\200\272 build _service_ _popup_.run.xml" | 6 +- ...ies_arm64v8 ci_PR_arm64v8 _popup_.run.xml" | 6 +- ...ependencies (BUILD MATRIX SUBSET).run.xml" | 6 +- ...uild test_compilation__ (Release).run.xml" | 6 +- ...efixed_path (BUILD MATRIX SUBSET).run.xml" | 6 +- ...s-general dependencies (AS IN TC).run.xml" | 6 +- .../.jetbrains_run_config/interactive.run.xml | 2 +- ...lpm_execute_compose.bash -- build.run.xml" | 4 +- ...sh \342\200\272 test flag (popup).run.xml" | 4 +- ...sh \342\200\272 test flag (popup).run.xml" | 4 +- ...00\272 test flag override (popup).run.xml" | 4 +- .../docker-compose.libpointmatcher.yaml | 38 ++-- .../lpm_utility_script/lpm_bashrc_config.bash | 96 +++++----- .../lpm_export_which_architecture.bash | 81 ++++---- .../lpm_install_docker_tools.bash | 175 ++++++++++-------- ..._compose.bash => nbs_execute_compose.bash} | 34 ++-- ...bs_execute_compose_over_build_matrix.bash} | 59 +++--- build_system/readme_test.md | 5 - .../test/Dockerfile.build_system_test | 6 +- ...st_build_and_run_IamBuildSystemTester.bash | 4 +- build_system/ubuntu/Dockerfile.dependencies | 21 ++- .../ubuntu/Dockerfile.dependencies_doc | 10 +- .../ubuntu/Dockerfile.libpointmatcher | 18 +- .../ubuntu/Dockerfile.libpointmatcher_ci_PR | 12 +- ...ockerfile.libpointmatcher_ci_SITREP_matrix | 14 +- ...ockerfile.libpointmatcher_test_compilation | 32 ++-- build_system/ubuntu/entrypoint.bash | 2 +- ..._test_libpointmatcher_checkout_branch.bash | 4 +- .../entrypoint_execute_lpm_unittest.bash | 8 +- .../lpm_execute_libpointmatcher_unittest.bash | 4 +- ...m_install_dependencies_general_ubuntu.bash | 8 +- ...m_install_dependencies_libnabo_ubuntu.bash | 22 +-- .../lpm_install_doc_dependencies_ubuntu.bash | 8 +- .../lpm_install_libpointmatcher_ubuntu.bash | 76 ++++---- build_system/version.norlab_build_system.txt | 1 + 43 files changed, 451 insertions(+), 410 deletions(-) rename build_system/{lpm_execute_compose.bash => nbs_execute_compose.bash} (86%) rename build_system/{lpm_execute_compose_over_build_matrix.bash => nbs_execute_compose_over_build_matrix.bash} (85%) delete mode 100644 build_system/readme_test.md create mode 100644 build_system/version.norlab_build_system.txt diff --git a/build_system/.env b/build_system/.env index 30a73b0f3..9b80e43c7 100644 --- a/build_system/.env +++ b/build_system/.env @@ -2,7 +2,7 @@ # # Dockerhub or self hosted hub domain name # -LPM_PROJECT_DOCKERHUB=norlabulaval +NBS_DOCKERHUB_NAMESPACE=norlabulaval # # Repository url @@ -11,14 +11,14 @@ LPM_PROJECT_DOCKERHUB=norlabulaval # - Original repo: https://github.com/ethz-asl/libpointmatcher # - DEV repo: https://github.com/norlab-ulaval/libpointmatcher-build-system -LPM_LIBPOINTMATCHER_SRC_DOMAIN=norlab-ulaval +NBS_REPOSITORY_DOMAIN=norlab-ulaval -LPM_LIBPOINTMATCHER_SRC_REPO_NAME=libpointmatcher +NBS_REPOSITORY_NAME=libpointmatcher # # Install script variables # -LPM_INSTALLED_LIBRARIES_PATH=/opt/percep3d_libraries +NBS_LIB_INSTALL_PATH=/opt/percep3d_libraries # # Docker built-in environment variable (do not change the variable name diff --git a/build_system/.env.build_matrix b/build_system/.env.build_matrix index 3dedd5f43..48f596b0f 100644 --- a/build_system/.env.build_matrix +++ b/build_system/.env.build_matrix @@ -2,6 +2,11 @@ # Build matrix variables # +# +# The compose file on which the build matrix will be crawled +# +NBS_EXECUTE_BUILD_MATRIX_OVER_COMPOSE_FILE=docker-compose.libpointmatcher.yaml + # # Libpointmatcher version # diff --git a/build_system/.env.prompt b/build_system/.env.prompt index b4a01d917..e02f741a1 100644 --- a/build_system/.env.prompt +++ b/build_system/.env.prompt @@ -1,14 +1,14 @@ -# (NICE TO HAVE) ToDo: refactor (ref task NMO-304 ♻︎ → Refactor .env.prompt variables prefixed by LPM_ to MSG_) -LPM_PROMPT_NAME="LPM" -LPM_SPLASH_NAME="Libpoinmatcher" -LPM_BUILD_SYSTEM_SPLASH_NAME="Libpoinmatcher Build System" +# (NICE TO HAVE) ToDo: refactor (ref task NMO-304 ♻︎ → Refactor .env.prompt variables prefixed by NBS_ to MSG_) +NBS_PROMPT_NAME="LPM" +NBS_SPLASH_NAME="Libpoinmatcher" +NBS_BUILD_SYSTEM_SPLASH_NAME="Libpoinmatcher Build System" -LPM_LINE_CHAR_BUILDER_LVL1='▉' -LPM_LINE_CHAR_BUILDER_LVL2='⣿' -LPM_LINE_CHAR_INSTALLER=':' -LPM_LINE_CHAR_UTIL='.' -LPM_LINE_CHAR_TEST=' ' +NBS_LINE_CHAR_BUILDER_LVL1='▉' +NBS_LINE_CHAR_BUILDER_LVL2='⣿' +NBS_LINE_CHAR_INSTALLER=':' +NBS_LINE_CHAR_UTIL='.' +NBS_LINE_CHAR_TEST=' ' # # Formating environment variables @@ -33,12 +33,12 @@ MSG_DONE_FORMAT="\033[1;32m" MSG_WARNING_FORMAT="\033[1;33m" MSG_END_FORMAT="\033[0m" -MSG_AWAITING_INPUT="${MSG_BASE_FORMAT}[${LPM_PROMPT_NAME} awaiting input]${MSG_END_FORMAT}" -MSG_BASE="${MSG_BASE_FORMAT}[${LPM_PROMPT_NAME}]${MSG_END_FORMAT}" -#MSG_DONE="\033[1;32m[${LPM_PROMPT_NAME} done]${MSG_END_FORMAT}" -MSG_DONE="${MSG_DONE_FORMAT}[${LPM_PROMPT_NAME} done]${MSG_END_FORMAT}" -MSG_WARNING="${MSG_WARNING_FORMAT}[${LPM_PROMPT_NAME} warning]${MSG_END_FORMAT}" -MSG_ERROR="${MSG_ERROR_FORMAT}[${LPM_PROMPT_NAME} error]${MSG_END_FORMAT}" +MSG_AWAITING_INPUT="${MSG_BASE_FORMAT}[${NBS_PROMPT_NAME} awaiting input]${MSG_END_FORMAT}" +MSG_BASE="${MSG_BASE_FORMAT}[${NBS_PROMPT_NAME}]${MSG_END_FORMAT}" +#MSG_DONE="\033[1;32m[${NBS_PROMPT_NAME} done]${MSG_END_FORMAT}" +MSG_DONE="${MSG_DONE_FORMAT}[${NBS_PROMPT_NAME} done]${MSG_END_FORMAT}" +MSG_WARNING="${MSG_WARNING_FORMAT}[${NBS_PROMPT_NAME} warning]${MSG_END_FORMAT}" +MSG_ERROR="${MSG_ERROR_FORMAT}[${NBS_PROMPT_NAME} error]${MSG_END_FORMAT}" # # TeamCity service message version @@ -47,13 +47,13 @@ MSG_DIMMED_FORMAT_TEAMCITY="|[1;2m" MSG_BASE_FORMAT_TEAMCITY="|[1m" MSG_ERROR_FORMAT_TEAMCITY="|[1;31m" MSG_WARNING_FORMAT_TEAMCITY="|[1;33m" -#MSG_LPM_STEP_FORMAT_TEAMCITY="|[1;104m" -MSG_LPM_STEP_FORMAT_TEAMCITY="|[30;107m" +#MSG_NBS_STEP_FORMAT_TEAMCITY="|[1;104m" +MSG_NBS_STEP_FORMAT_TEAMCITY="|[30;107m" MSG_END_FORMAT_TEAMCITY="|[0m" # (!) Note: substitution fail in the TeamCity Overview tab when using -# >>> MSG_BASE_TEAMCITY="${MSG_BASE_FORMAT_TEAMCITY}|[${LPM_PROMPT_NAME}|]${MSG_END_FORMAT_TEAMCITY}" -MSG_BASE_TEAMCITY="|[${LPM_PROMPT_NAME}|]" +# >>> MSG_BASE_TEAMCITY="${MSG_BASE_FORMAT_TEAMCITY}|[${NBS_PROMPT_NAME}|]${MSG_END_FORMAT_TEAMCITY}" +MSG_BASE_TEAMCITY="|[${NBS_PROMPT_NAME}|]" # # References: diff --git "a/build_system/.jetbrains_run_config/(HELP) bash lpm_execute_compose._ \342\200\272 --help menu.run.xml" "b/build_system/.jetbrains_run_config/(HELP) bash lpm_execute_compose._ \342\200\272 --help menu.run.xml" index 1c701be1f..ca3fafd64 100644 --- "a/build_system/.jetbrains_run_config/(HELP) bash lpm_execute_compose._ \342\200\272 --help menu.run.xml" +++ "b/build_system/.jetbrains_run_config/(HELP) bash lpm_execute_compose._ \342\200\272 --help menu.run.xml" @@ -1,6 +1,6 @@ - - diff --git "a/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build&push dependencies-general dependencies (AS IN TC).run.xml" "b/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build&push dependencies-general dependencies (AS IN TC).run.xml" index d01cd46b8..9f1ccbf91 100644 --- "a/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build&push dependencies-general dependencies (AS IN TC).run.xml" +++ "b/build_system/.jetbrains_run_config/bash lpm_execute_compose_over_build_matrix.bash \342\200\272 build&push dependencies-general dependencies (AS IN TC).run.xml" @@ -1,6 +1,6 @@ - - \ No newline at end of file + diff --git a/build_system/.jetbrains_run_config/interactive.run.xml b/build_system/.jetbrains_run_config/interactive.run.xml index fb5838f03..1a0a0dd3c 100644 --- a/build_system/.jetbrains_run_config/interactive.run.xml +++ b/build_system/.jetbrains_run_config/interactive.run.xml @@ -1,5 +1,5 @@ - +