# Files to copy over
include_files = [
    (r'include/outcome/experimental/status-code/include/(.*)', r'include/boost/outcome/experimental/\1'),
    (r'include/(.*)', r'include/boost/\1'),
    r'^doc/src/.*$',
    r'^test/.*$',
    r'^\.clang-.*$',
    r'^\.gitattributes$',
    r'^index.html$',
]
exclude_files = [
    r'.*quickcpplib.*',
    r'^include/outcome/experimental/status-code/(?!include)',
    r'^include/outcome.ixx',
    r'.*\.natvis$',
    r'.*\.vs.*',
    r'^test/single-header-test.cpp$',
    r'^test/constexprs/.*',
    r'^doc/src/themes/boostdoc/.git',
    r'^doc/src/themes/docdock.*',
    r'^doc/src/layouts/partials/.*',
]
overlay_files = [
    (r'boostify', r''),
]

def fix_auto_test_case(x):
    # Collapse spaces until comma found, replacing any / or - with _
    ret = ''
    remove_spaces = True
    for l in x.group(0):
        if l == ',':
            remove_spaces = False
        if remove_spaces:
            if l == ' ':
                continue;
            if l == '/' or l == '-':
                l = '_'
        ret += l
    ret += '\n'
    return ret

# Regexs to replace
core_macros = {
    r'^OUTCOME_': r'BOOST_OUTCOME_',
    r'([^_])OUTCOME_': r'\1BOOST_OUTCOME_',
    r'^SYSTEM_ERROR2_': r'BOOST_OUTCOME_SYSTEM_ERROR2_',
    r'([^_])SYSTEM_ERROR2_': r'\1BOOST_OUTCOME_SYSTEM_ERROR2_',
    r'<outcome/([^>]+)': r'<boost/outcome/\1',
    r'status-code/include/': r'',
    r'// Boost.Outcome ' : r'',
    r'CXX_': r'BOOST_OUTCOME_C_',
}
source_macros = {
    r'DOXYGEN_': r'BOOST_OUTCOME_DOXYGEN_',
    r'STANDARDESE_': r'BOOST_OUTCOME_STANDARDESE_',
    r'\.\./include/outcome' : r'../include/boost/outcome',
    r'#include "quickcpplib/boost/test/unit_test.hpp"' : r'#include <boost/test/unit_test.hpp>\n#include <boost/test/unit_test_monitor.hpp>',
    r'BOOST_OUTCOME_AUTO_TEST_CASE\((.*)' : fix_auto_test_case,
    r'#include "quickcpplib/execinfo_win64.h"' : r'#error This example can only compile on POSIX',
    r'#ifdef __cpp_exceptions' : r'#ifndef BOOST_NO_EXCEPTIONS',
}
source_macros.update(core_macros)
transforms = {
    r'^test/tests/.*\.cpp$': {
      r'"[^"]+/\.\./include/outcome/([^"]+)"': r'<boost/outcome/\1>',
      r'"[^"]+/\.\./include/outcome.hpp"': r'<boost/outcome.hpp>',
      r'std::errc([^:])': r'boost::system::errc::errc_t\1',
      r'std::errc::': r'boost::system::errc::',
      r'std::error_code': r'boost::system::error_code',
      r'std::make_error_code': r'make_error_code',
      r'std::generic_category': r'boost::system::generic_category',
      r'std::system_category': r'boost::system::system_category',
      r'std::system_error': r'boost::system::system_error',
      r'std::exception_ptr': r'boost::exception_ptr',
      r'std::make_exception_ptr': r'boost::copy_exception',
      r'std::current_exception': r'boost::current_exception',
      r'std::rethrow_exception': r'boost::rethrow_exception',
    },
    r'^test/expected-pass\.cpp$': {
      r'"\.\./include/outcome/([^"]+)"': r'<boost/outcome/\1>',
    },
    r'^.*\.hpp$' : source_macros,
    r'^.*\.ipp$' : source_macros,
    r'^.*\.cpp$' : source_macros,
    r'^.*\.h$': source_macros,
    r'^.*\.md$': core_macros,
}
