From 69ba1ff1dbe712e2a760a7a202674a60392f5f06 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 27 Jun 2022 15:59:36 +0800 Subject: [PATCH 01/51] init Signed-off-by: Chen Lihui --- CONTRIBUTING.md | 18 ++ LICENSE | 202 ++++++++++++++++++ README.md | 5 + common_content_filter/CMakeLists.txt | 79 +++++++ common_content_filter/README.md | 0 .../include/common_content_filter/test.h | 53 +++++ .../visibility_control.h | 58 +++++ common_content_filter/package.xml | 23 ++ common_content_filter/src/test.cpp | 118 ++++++++++ 9 files changed, 556 insertions(+) create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 common_content_filter/CMakeLists.txt create mode 100644 common_content_filter/README.md create mode 100644 common_content_filter/include/common_content_filter/test.h create mode 100644 common_content_filter/include/common_content_filter/visibility_control.h create mode 100644 common_content_filter/package.xml create mode 100644 common_content_filter/src/test.cpp diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..cfba094 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,18 @@ +Any contribution that you make to this repository will +be under the Apache 2 License, as dictated by that +[license](http://www.apache.org/licenses/LICENSE-2.0.html): + +~~~ +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. +~~~ + +Contributors must sign-off each commit by adding a `Signed-off-by: ...` +line to commit messages to certify that they have the right to submit +the code they are contributing to the project according to the +[Developer Certificate of Origin (DCO)](https://developercertificate.org/). diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a100f2a --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# common_content_filter + +This repository contains packages to support content filter fallback used in rcl. + + - [common_content_filter](common_content_filter/README.md) diff --git a/common_content_filter/CMakeLists.txt b/common_content_filter/CMakeLists.txt new file mode 100644 index 0000000..508767f --- /dev/null +++ b/common_content_filter/CMakeLists.txt @@ -0,0 +1,79 @@ +cmake_minimum_required(VERSION 3.8) +project(common_content_filter) + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# find dependencies +find_package(ament_cmake REQUIRED) +find_package(rcutils REQUIRED) +find_package(rcpputils REQUIRED) +find_package(rmw REQUIRED) +find_package(rosidl_runtime_cpp REQUIRED) + +ament_export_dependencies(ament_cmake_core) +ament_export_dependencies(rcpputils) +ament_export_dependencies(rcutils) +ament_export_dependencies(rmw) + +add_library(${PROJECT_NAME}_library SHARED + src/test.cpp) + +set_target_properties(${PROJECT_NAME}_library + PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) +target_link_libraries(${PROJECT_NAME}_library PUBLIC + rcutils::rcutils + rmw::rmw) +target_link_libraries(${PROJECT_NAME}_library PRIVATE + rcpputils::rcpputils) +target_include_directories(${PROJECT_NAME}_library + PUBLIC + "$" + "$") + +# # Wait for all rosidl generators to finish before building this library +# add_dependencies(${PROJECT_NAME}_library +# ${PROJECT_NAME}) + +# Depend on the generated C++ messages +# rosidl_get_typesupport_target(cpp_typesupport_target "${PROJECT_NAME}" "rosidl_typesupport_cpp") +# target_link_libraries(${PROJECT_NAME}_library PUBLIC +# ${cpp_typesupport_target}) + +# Causes the visibility macros to use dllexport rather than dllimport, +# which is appropriate when building the dll but not consuming it. +target_compile_definitions(${PROJECT_NAME}_library + PRIVATE "COMMON_CONTENT_FILTER_BUILDING_LIBRARY") + +install( + TARGETS ${PROJECT_NAME}_library EXPORT ${PROJECT_NAME}_library + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin +) + +# Export old-style CMake variables +ament_export_include_directories("include/${PROJECT_NAME}") +ament_export_libraries(${PROJECT_NAME}_library) + +# Export modern CMake targets +ament_export_targets(${PROJECT_NAME}_library) + +install( + DIRECTORY include/ + DESTINATION include/${PROJECT_NAME}) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # comment the line when a copyright and license is added to all source files + set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # comment the line when this package is in a git repo and when + # a copyright and license is added to all source files + set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package() diff --git a/common_content_filter/README.md b/common_content_filter/README.md new file mode 100644 index 0000000..e69de29 diff --git a/common_content_filter/include/common_content_filter/test.h b/common_content_filter/include/common_content_filter/test.h new file mode 100644 index 0000000..37d3bd1 --- /dev/null +++ b/common_content_filter/include/common_content_filter/test.h @@ -0,0 +1,53 @@ +// Copyright 2022 Open Source Robotics Foundation, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef COMMON_CONTENT_FILTER__TEST_HPP_ +#define COMMON_CONTENT_FILTER__TEST_HPP_ + +#include "common_content_filter/visibility_control.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef void common_content_filter_factory_t; +typedef void common_content_filter_t; + +COMMON_CONTENT_FILTER_PUBLIC +void * +create_common_content_filter_factory(); + +COMMON_CONTENT_FILTER_PUBLIC +void +test_common_content_filter_factory(void *); + +COMMON_CONTENT_FILTER_PUBLIC +void +test_func_c(); + +COMMON_CONTENT_FILTER_PUBLIC +common_content_filter_t * +create_common_content_filter(); + +COMMON_CONTENT_FILTER_PUBLIC +void +test_common_content_filter(void *); + +#ifdef __cplusplus +} +#endif + + +#endif // COMMON_CONTENT_FILTER__TEST_HPP_ diff --git a/common_content_filter/include/common_content_filter/visibility_control.h b/common_content_filter/include/common_content_filter/visibility_control.h new file mode 100644 index 0000000..79fb0e2 --- /dev/null +++ b/common_content_filter/include/common_content_filter/visibility_control.h @@ -0,0 +1,58 @@ +// Copyright 2022 Open Source Robotics Foundation, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef COMMON_CONTENT_FILTER__VISIBILITY_CONTROL_H_ +#define COMMON_CONTENT_FILTER__VISIBILITY_CONTROL_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +// This logic was borrowed (then namespaced) from the examples on the gcc wiki: +// https://gcc.gnu.org/wiki/Visibility + +#if defined _WIN32 || defined __CYGWIN__ + #ifdef __GNUC__ + #define COMMON_CONTENT_FILTER_EXPORT __attribute__ ((dllexport)) + #define COMMON_CONTENT_FILTER_IMPORT __attribute__ ((dllimport)) + #else + #define COMMON_CONTENT_FILTER_EXPORT __declspec(dllexport) + #define COMMON_CONTENT_FILTER_IMPORT __declspec(dllimport) + #endif + #ifdef COMMON_CONTENT_FILTER_BUILDING_LIBRARY + #define COMMON_CONTENT_FILTER_PUBLIC COMMON_CONTENT_FILTER_EXPORT + #else + #define COMMON_CONTENT_FILTER_PUBLIC COMMON_CONTENT_FILTER_IMPORT + #endif + #define COMMON_CONTENT_FILTER_PUBLIC_TYPE COMMON_CONTENT_FILTER_PUBLIC + #define COMMON_CONTENT_FILTER_LOCAL +#else + #define COMMON_CONTENT_FILTER_EXPORT __attribute__ ((visibility("default"))) + #define COMMON_CONTENT_FILTER_IMPORT + #if __GNUC__ >= 4 + #define COMMON_CONTENT_FILTER_PUBLIC __attribute__ ((visibility("default"))) + #define COMMON_CONTENT_FILTER_LOCAL __attribute__ ((visibility("hidden"))) + #else + #define COMMON_CONTENT_FILTER_PUBLIC + #define COMMON_CONTENT_FILTER_LOCAL + #endif + #define COMMON_CONTENT_FILTER_PUBLIC_TYPE +#endif + +#ifdef __cplusplus +} +#endif + +#endif // COMMON_CONTENT_FILTER__VISIBILITY_CONTROL_H_ diff --git a/common_content_filter/package.xml b/common_content_filter/package.xml new file mode 100644 index 0000000..5c1d7d4 --- /dev/null +++ b/common_content_filter/package.xml @@ -0,0 +1,23 @@ + + + + common_content_filter + 0.0.0 + TODO: Package description + chenlh + TODO: License declaration + + ament_cmake + + rcutils + rcpputils + rmw + rosidl_runtime_cpp + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/common_content_filter/src/test.cpp b/common_content_filter/src/test.cpp new file mode 100644 index 0000000..26f2062 --- /dev/null +++ b/common_content_filter/src/test.cpp @@ -0,0 +1,118 @@ +// Copyright 2022 Open Source Robotics Foundation, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "common_content_filter/test.h" + +#include // for printf + +namespace common_content_filter { + +const int MAGIC = 0x333646; // cft + +void +test_func_cpp() +{ + printf("test_func_cpp\n"); +} + +class ContentFilterFactory { +public: + ContentFilterFactory() + : magic_(MAGIC) {}; + ~ContentFilterFactory() {}; + + int magic() { + return magic_; + } + void test() { + printf("to call test in ContentFilterFactory : %p\n", (void*)this); + } + +private: + int magic_; +}; + +class ContentFilter { +public: + ContentFilter() + : magic_(MAGIC) {}; + ~ContentFilter() {}; + + int magic() { + return magic_; + } + void test() { + printf("to call test in ContentFilter : %p\n", (void*)this); + } + +private: + int magic_; +}; + +} // namespace common_content_filter + + +#ifdef __cplusplus +extern "C" +{ +#endif + +void +test_func_c() { + return common_content_filter::test_func_cpp(); +} + + +void * +create_common_content_filter_factory() { + common_content_filter::ContentFilterFactory * content_filter_factory = + new common_content_filter::ContentFilterFactory; + return content_filter_factory; +} + + +void +test_common_content_filter_factory(void * instance) { + common_content_filter::ContentFilterFactory * content_filter_factory = + static_cast(instance); + if (!content_filter_factory || content_filter_factory->magic() != common_content_filter::MAGIC ) { + printf("the instance is not valid\n"); + return; + } + + content_filter_factory->test(); +} + + +void * +create_common_content_filter() { + common_content_filter::ContentFilter * content_filter = new common_content_filter::ContentFilter; + return content_filter; +} + +void +test_common_content_filter(void * instance) { + common_content_filter::ContentFilter * content_filter = + static_cast(instance); + if (!content_filter || content_filter->magic() != common_content_filter::MAGIC ) { + printf("the instance is not valid\n"); + return; + } + + content_filter->test(); +} + +#ifdef __cplusplus +} +#endif \ No newline at end of file From af121d181425d5ba77b1b46ce2a6a9a345b0e570 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 28 Jun 2022 16:25:11 +0800 Subject: [PATCH 02/51] move files from FastDDS, make building and calling some functions successfully Signed-off-by: Chen Lihui --- common_content_filter/CMakeLists.txt | 21 +- .../include/common_content_filter/test.h | 24 +- .../src/DDSFilterCompoundCondition.cpp | 113 ++++ .../src/DDSFilterCompoundCondition.hpp | 84 +++ .../src/DDSFilterCondition.hpp | 135 ++++ .../src/DDSFilterConditionState.hpp | 47 ++ .../src/DDSFilterEmptyExpression.hpp | 52 ++ .../src/DDSFilterExpression.cpp | 98 +++ .../src/DDSFilterExpression.hpp | 100 +++ .../src/DDSFilterExpressionParser.cpp | 151 +++++ .../src/DDSFilterExpressionParser.hpp | 68 ++ .../DDSFilterExpressionParserImpl/Readme.md | 7 + .../identifiers.hpp | 239 +++++++ .../literal_values.hpp | 96 +++ .../parameters.hpp | 38 ++ .../rearrange.hpp | 73 +++ .../src/DDSFilterFactory.cpp | 589 ++++++++++++++++++ .../src/DDSFilterFactory.hpp | 104 ++++ common_content_filter/src/DDSFilterField.cpp | 195 ++++++ common_content_filter/src/DDSFilterField.hpp | 155 +++++ .../src/DDSFilterGrammar.hpp | 122 ++++ .../src/DDSFilterParameter.cpp | 46 ++ .../src/DDSFilterParameter.hpp | 55 ++ .../src/DDSFilterParseNode.hpp | 71 +++ .../src/DDSFilterPredicate.cpp | 105 ++++ .../src/DDSFilterPredicate.hpp | 97 +++ common_content_filter/src/DDSFilterValue.cpp | 366 +++++++++++ common_content_filter/src/DDSFilterValue.hpp | 233 +++++++ common_content_filter/src/IContentFilter.hpp | 76 +++ .../src/IContentFilterFactory.hpp | 106 ++++ common_content_filter/src/Log.hpp | 14 + common_content_filter/src/ObjectPool.hpp | 100 +++ common_content_filter/src/test.cpp | 176 ++++-- .../thirdparty/taocpp-pegtl/pegtl.hpp | 46 ++ .../pegtl/analysis/analyze_cycles.hpp | 135 ++++ .../taocpp-pegtl/pegtl/analysis/counted.hpp | 31 + .../taocpp-pegtl/pegtl/analysis/generic.hpp | 43 ++ .../pegtl/analysis/grammar_info.hpp | 40 ++ .../pegtl/analysis/insert_guard.hpp | 68 ++ .../taocpp-pegtl/pegtl/analysis/rule_info.hpp | 37 ++ .../taocpp-pegtl/pegtl/analysis/rule_type.hpp | 35 ++ .../thirdparty/taocpp-pegtl/pegtl/analyze.hpp | 25 + .../taocpp-pegtl/pegtl/apply_mode.hpp | 27 + .../taocpp-pegtl/pegtl/argv_input.hpp | 57 ++ .../thirdparty/taocpp-pegtl/pegtl/ascii.hpp | 71 +++ .../taocpp-pegtl/pegtl/buffer_input.hpp | 222 +++++++ .../taocpp-pegtl/pegtl/change_action.hpp | 42 ++ .../pegtl/change_action_and_state.hpp | 73 +++ .../pegtl/change_action_and_states.hpp | 83 +++ .../taocpp-pegtl/pegtl/change_control.hpp | 40 ++ .../taocpp-pegtl/pegtl/change_state.hpp | 72 +++ .../taocpp-pegtl/pegtl/change_states.hpp | 81 +++ .../thirdparty/taocpp-pegtl/pegtl/config.hpp | 20 + .../taocpp-pegtl/pegtl/contrib/abnf.hpp | 43 ++ .../taocpp-pegtl/pegtl/contrib/alphabet.hpp | 75 +++ .../taocpp-pegtl/pegtl/contrib/changes.hpp | 90 +++ .../taocpp-pegtl/pegtl/contrib/counter.hpp | 58 ++ .../taocpp-pegtl/pegtl/contrib/http.hpp | 282 +++++++++ .../pegtl/contrib/icu/internal.hpp | 76 +++ .../taocpp-pegtl/pegtl/contrib/icu/utf16.hpp | 212 +++++++ .../taocpp-pegtl/pegtl/contrib/icu/utf32.hpp | 212 +++++++ .../taocpp-pegtl/pegtl/contrib/icu/utf8.hpp | 117 ++++ .../taocpp-pegtl/pegtl/contrib/if_then.hpp | 61 ++ .../taocpp-pegtl/pegtl/contrib/integer.hpp | 108 ++++ .../taocpp-pegtl/pegtl/contrib/json.hpp | 98 +++ .../pegtl/contrib/json_pointer.hpp | 41 ++ .../taocpp-pegtl/pegtl/contrib/parse_tree.hpp | 517 +++++++++++++++ .../pegtl/contrib/parse_tree_to_dot.hpp | 116 ++++ .../taocpp-pegtl/pegtl/contrib/raw_string.hpp | 234 +++++++ .../pegtl/contrib/remove_first_state.hpp | 62 ++ .../pegtl/contrib/remove_last_states.hpp | 106 ++++ .../pegtl/contrib/rep_one_min_max.hpp | 68 ++ .../taocpp-pegtl/pegtl/contrib/rep_string.hpp | 47 ++ .../pegtl/contrib/shuffle_states.hpp | 174 ++++++ .../taocpp-pegtl/pegtl/contrib/to_string.hpp | 42 ++ .../taocpp-pegtl/pegtl/contrib/tracer.hpp | 253 ++++++++ .../taocpp-pegtl/pegtl/contrib/unescape.hpp | 207 ++++++ .../taocpp-pegtl/pegtl/contrib/uri.hpp | 115 ++++ .../taocpp-pegtl/pegtl/cstream_input.hpp | 39 ++ .../taocpp-pegtl/pegtl/disable_action.hpp | 39 ++ .../taocpp-pegtl/pegtl/discard_input.hpp | 41 ++ .../pegtl/discard_input_on_failure.hpp | 43 ++ .../pegtl/discard_input_on_success.hpp | 43 ++ .../taocpp-pegtl/pegtl/enable_action.hpp | 39 ++ .../thirdparty/taocpp-pegtl/pegtl/eol.hpp | 41 ++ .../taocpp-pegtl/pegtl/eol_pair.hpp | 22 + .../taocpp-pegtl/pegtl/file_input.hpp | 50 ++ .../taocpp-pegtl/pegtl/input_error.hpp | 51 ++ .../taocpp-pegtl/pegtl/internal/action.hpp | 59 ++ .../pegtl/internal/action_input.hpp | 120 ++++ .../taocpp-pegtl/pegtl/internal/alnum.hpp | 26 + .../taocpp-pegtl/pegtl/internal/alpha.hpp | 26 + .../pegtl/internal/always_false.hpp | 29 + .../taocpp-pegtl/pegtl/internal/any.hpp | 66 ++ .../taocpp-pegtl/pegtl/internal/apply.hpp | 94 +++ .../taocpp-pegtl/pegtl/internal/apply0.hpp | 92 +++ .../pegtl/internal/apply0_single.hpp | 42 ++ .../pegtl/internal/apply_single.hpp | 42 ++ .../taocpp-pegtl/pegtl/internal/at.hpp | 67 ++ .../taocpp-pegtl/pegtl/internal/bof.hpp | 41 ++ .../taocpp-pegtl/pegtl/internal/bol.hpp | 41 ++ .../taocpp-pegtl/pegtl/internal/bump.hpp | 53 ++ .../taocpp-pegtl/pegtl/internal/bump_help.hpp | 63 ++ .../taocpp-pegtl/pegtl/internal/bytes.hpp | 46 ++ .../taocpp-pegtl/pegtl/internal/control.hpp | 59 ++ .../pegtl/internal/cr_crlf_eol.hpp | 40 ++ .../taocpp-pegtl/pegtl/internal/cr_eol.hpp | 40 ++ .../taocpp-pegtl/pegtl/internal/crlf_eol.hpp | 40 ++ .../pegtl/internal/cstream_reader.hpp | 50 ++ .../pegtl/internal/cstring_reader.hpp | 49 ++ .../taocpp-pegtl/pegtl/internal/demangle.hpp | 85 +++ .../pegtl/internal/demangle_cxxabi.hpp | 41 ++ .../pegtl/internal/demangle_nop.hpp | 28 + .../pegtl/internal/demangle_sanitise.hpp | 48 ++ .../taocpp-pegtl/pegtl/internal/disable.hpp | 59 ++ .../taocpp-pegtl/pegtl/internal/discard.hpp | 43 ++ .../pegtl/internal/dusel_mode.hpp | 31 + .../pegtl/internal/duseltronik.hpp | 188 ++++++ .../taocpp-pegtl/pegtl/internal/enable.hpp | 59 ++ .../taocpp-pegtl/pegtl/internal/endian.hpp | 70 +++ .../pegtl/internal/endian_gcc.hpp | 214 +++++++ .../pegtl/internal/endian_win.hpp | 115 ++++ .../taocpp-pegtl/pegtl/internal/eof.hpp | 41 ++ .../taocpp-pegtl/pegtl/internal/eol.hpp | 41 ++ .../taocpp-pegtl/pegtl/internal/eolf.hpp | 42 ++ .../pegtl/internal/file_mapper_posix.hpp | 95 +++ .../pegtl/internal/file_mapper_win32.hpp | 226 +++++++ .../pegtl/internal/file_opener.hpp | 78 +++ .../pegtl/internal/file_reader.hpp | 109 ++++ .../taocpp-pegtl/pegtl/internal/has_apply.hpp | 33 + .../pegtl/internal/has_apply0.hpp | 33 + .../taocpp-pegtl/pegtl/internal/has_match.hpp | 53 ++ .../pegtl/internal/identifier.hpp | 30 + .../taocpp-pegtl/pegtl/internal/if_apply.hpp | 118 ++++ .../pegtl/internal/if_missing.hpp | 72 +++ .../taocpp-pegtl/pegtl/internal/if_must.hpp | 58 ++ .../pegtl/internal/if_must_else.hpp | 27 + .../pegtl/internal/if_then_else.hpp | 61 ++ .../pegtl/internal/input_pair.hpp | 37 ++ .../pegtl/internal/integer_sequence.hpp | 86 +++ .../pegtl/internal/istream_reader.hpp | 47 ++ .../taocpp-pegtl/pegtl/internal/istring.hpp | 107 ++++ .../taocpp-pegtl/pegtl/internal/iterator.hpp | 60 ++ .../pegtl/internal/lf_crlf_eol.hpp | 45 ++ .../taocpp-pegtl/pegtl/internal/lf_eol.hpp | 40 ++ .../taocpp-pegtl/pegtl/internal/list.hpp | 27 + .../taocpp-pegtl/pegtl/internal/list_must.hpp | 28 + .../taocpp-pegtl/pegtl/internal/list_tail.hpp | 28 + .../pegtl/internal/list_tail_pad.hpp | 30 + .../taocpp-pegtl/pegtl/internal/marker.hpp | 99 +++ .../taocpp-pegtl/pegtl/internal/mmap_file.hpp | 42 ++ .../pegtl/internal/mmap_file_win32.hpp | 244 ++++++++ .../taocpp-pegtl/pegtl/internal/must.hpp | 70 +++ .../taocpp-pegtl/pegtl/internal/not_at.hpp | 67 ++ .../taocpp-pegtl/pegtl/internal/one.hpp | 77 +++ .../taocpp-pegtl/pegtl/internal/opt.hpp | 69 ++ .../taocpp-pegtl/pegtl/internal/pad.hpp | 27 + .../taocpp-pegtl/pegtl/internal/pad_opt.hpp | 28 + .../taocpp-pegtl/pegtl/internal/peek_char.hpp | 40 ++ .../pegtl/internal/peek_mask_uint.hpp | 62 ++ .../pegtl/internal/peek_mask_uint8.hpp | 42 ++ .../taocpp-pegtl/pegtl/internal/peek_uint.hpp | 53 ++ .../pegtl/internal/peek_uint8.hpp | 41 ++ .../pegtl/internal/peek_utf16.hpp | 62 ++ .../pegtl/internal/peek_utf32.hpp | 51 ++ .../taocpp-pegtl/pegtl/internal/peek_utf8.hpp | 97 +++ .../pegtl/internal/pegtl_string.hpp | 103 +++ .../taocpp-pegtl/pegtl/internal/plus.hpp | 68 ++ .../taocpp-pegtl/pegtl/internal/raise.hpp | 63 ++ .../taocpp-pegtl/pegtl/internal/range.hpp | 58 ++ .../taocpp-pegtl/pegtl/internal/ranges.hpp | 100 +++ .../taocpp-pegtl/pegtl/internal/read_uint.hpp | 85 +++ .../taocpp-pegtl/pegtl/internal/rematch.hpp | 86 +++ .../taocpp-pegtl/pegtl/internal/rep.hpp | 80 +++ .../taocpp-pegtl/pegtl/internal/rep_min.hpp | 28 + .../pegtl/internal/rep_min_max.hpp | 91 +++ .../taocpp-pegtl/pegtl/internal/rep_opt.hpp | 61 ++ .../taocpp-pegtl/pegtl/internal/require.hpp | 52 ++ .../pegtl/internal/result_on_found.hpp | 27 + .../taocpp-pegtl/pegtl/internal/rules.hpp | 61 ++ .../taocpp-pegtl/pegtl/internal/seq.hpp | 91 +++ .../pegtl/internal/skip_control.hpp | 35 ++ .../taocpp-pegtl/pegtl/internal/sor.hpp | 76 +++ .../taocpp-pegtl/pegtl/internal/star.hpp | 62 ++ .../taocpp-pegtl/pegtl/internal/star_must.hpp | 27 + .../taocpp-pegtl/pegtl/internal/state.hpp | 96 +++ .../taocpp-pegtl/pegtl/internal/string.hpp | 68 ++ .../taocpp-pegtl/pegtl/internal/trivial.hpp | 42 ++ .../pegtl/internal/try_catch_type.hpp | 76 +++ .../taocpp-pegtl/pegtl/internal/until.hpp | 98 +++ .../taocpp-pegtl/pegtl/istream_input.hpp | 39 ++ .../thirdparty/taocpp-pegtl/pegtl/match.hpp | 71 +++ .../taocpp-pegtl/pegtl/memory_input.hpp | 378 +++++++++++ .../taocpp-pegtl/pegtl/mmap_input.hpp | 85 +++ .../thirdparty/taocpp-pegtl/pegtl/normal.hpp | 96 +++ .../thirdparty/taocpp-pegtl/pegtl/nothing.hpp | 24 + .../thirdparty/taocpp-pegtl/pegtl/parse.hpp | 57 ++ .../taocpp-pegtl/pegtl/parse_error.hpp | 51 ++ .../taocpp-pegtl/pegtl/position.hpp | 54 ++ .../taocpp-pegtl/pegtl/read_input.hpp | 80 +++ .../taocpp-pegtl/pegtl/require_apply.hpp | 20 + .../taocpp-pegtl/pegtl/require_apply0.hpp | 20 + .../taocpp-pegtl/pegtl/rewind_mode.hpp | 29 + .../thirdparty/taocpp-pegtl/pegtl/rules.hpp | 71 +++ .../taocpp-pegtl/pegtl/string_input.hpp | 72 +++ .../taocpp-pegtl/pegtl/tracking_mode.hpp | 27 + .../thirdparty/taocpp-pegtl/pegtl/uint16.hpp | 66 ++ .../thirdparty/taocpp-pegtl/pegtl/uint32.hpp | 66 ++ .../thirdparty/taocpp-pegtl/pegtl/uint64.hpp | 67 ++ .../thirdparty/taocpp-pegtl/pegtl/uint8.hpp | 44 ++ .../thirdparty/taocpp-pegtl/pegtl/utf16.hpp | 53 ++ .../thirdparty/taocpp-pegtl/pegtl/utf32.hpp | 53 ++ .../thirdparty/taocpp-pegtl/pegtl/utf8.hpp | 36 ++ .../thirdparty/taocpp-pegtl/pegtl/version.hpp | 19 + 214 files changed, 17176 insertions(+), 51 deletions(-) create mode 100644 common_content_filter/src/DDSFilterCompoundCondition.cpp create mode 100644 common_content_filter/src/DDSFilterCompoundCondition.hpp create mode 100644 common_content_filter/src/DDSFilterCondition.hpp create mode 100644 common_content_filter/src/DDSFilterConditionState.hpp create mode 100644 common_content_filter/src/DDSFilterEmptyExpression.hpp create mode 100644 common_content_filter/src/DDSFilterExpression.cpp create mode 100644 common_content_filter/src/DDSFilterExpression.hpp create mode 100644 common_content_filter/src/DDSFilterExpressionParser.cpp create mode 100644 common_content_filter/src/DDSFilterExpressionParser.hpp create mode 100644 common_content_filter/src/DDSFilterExpressionParserImpl/Readme.md create mode 100644 common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp create mode 100644 common_content_filter/src/DDSFilterExpressionParserImpl/literal_values.hpp create mode 100644 common_content_filter/src/DDSFilterExpressionParserImpl/parameters.hpp create mode 100644 common_content_filter/src/DDSFilterExpressionParserImpl/rearrange.hpp create mode 100644 common_content_filter/src/DDSFilterFactory.cpp create mode 100644 common_content_filter/src/DDSFilterFactory.hpp create mode 100644 common_content_filter/src/DDSFilterField.cpp create mode 100644 common_content_filter/src/DDSFilterField.hpp create mode 100644 common_content_filter/src/DDSFilterGrammar.hpp create mode 100644 common_content_filter/src/DDSFilterParameter.cpp create mode 100644 common_content_filter/src/DDSFilterParameter.hpp create mode 100644 common_content_filter/src/DDSFilterParseNode.hpp create mode 100644 common_content_filter/src/DDSFilterPredicate.cpp create mode 100644 common_content_filter/src/DDSFilterPredicate.hpp create mode 100644 common_content_filter/src/DDSFilterValue.cpp create mode 100644 common_content_filter/src/DDSFilterValue.hpp create mode 100644 common_content_filter/src/IContentFilter.hpp create mode 100644 common_content_filter/src/IContentFilterFactory.hpp create mode 100644 common_content_filter/src/Log.hpp create mode 100644 common_content_filter/src/ObjectPool.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/analyze_cycles.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/counted.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/generic.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/grammar_info.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/insert_guard.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/rule_info.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/rule_type.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/analyze.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/apply_mode.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/argv_input.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/ascii.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/buffer_input.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action_and_state.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action_and_states.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_control.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_state.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_states.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/config.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/abnf.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/alphabet.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/changes.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/counter.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/http.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/internal.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf16.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf32.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf8.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/if_then.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/integer.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/json.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/json_pointer.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/parse_tree.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/parse_tree_to_dot.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/raw_string.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/remove_first_state.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/remove_last_states.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/rep_one_min_max.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/rep_string.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/shuffle_states.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/to_string.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/tracer.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/unescape.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/uri.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/cstream_input.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/disable_action.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input_on_failure.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input_on_success.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/enable_action.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/eol.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/eol_pair.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/file_input.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/input_error.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/action.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/action_input.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/alnum.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/alpha.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/always_false.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/any.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply0.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply0_single.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply_single.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/at.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bof.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bol.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bump.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bump_help.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bytes.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/control.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cr_crlf_eol.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cr_eol.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/crlf_eol.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cstream_reader.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cstring_reader.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_cxxabi.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_nop.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_sanitise.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/disable.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/discard.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/dusel_mode.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/duseltronik.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/enable.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian_gcc.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian_win.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eof.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eol.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eolf.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_mapper_posix.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_mapper_win32.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_opener.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_reader.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_apply.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_apply0.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_match.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/identifier.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_apply.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_missing.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_must.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_must_else.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_then_else.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/input_pair.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/integer_sequence.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/istream_reader.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/istring.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/iterator.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/lf_crlf_eol.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/lf_eol.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_must.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_tail.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_tail_pad.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/marker.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/mmap_file.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/mmap_file_win32.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/must.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/not_at.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/one.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/opt.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pad.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pad_opt.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_char.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_mask_uint.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_mask_uint8.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_uint.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_uint8.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf16.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf32.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf8.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pegtl_string.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/plus.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/raise.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/range.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/ranges.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/read_uint.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rematch.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_min.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_min_max.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_opt.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/require.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/result_on_found.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rules.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/seq.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/skip_control.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/sor.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/star.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/star_must.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/state.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/string.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/trivial.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/try_catch_type.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/until.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/istream_input.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/match.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/memory_input.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/mmap_input.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/normal.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/nothing.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/parse.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/parse_error.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/position.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/read_input.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/require_apply.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/require_apply0.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/rewind_mode.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/rules.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/string_input.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/tracking_mode.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint16.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint32.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint64.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint8.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf16.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf32.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf8.hpp create mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/version.hpp diff --git a/common_content_filter/CMakeLists.txt b/common_content_filter/CMakeLists.txt index 508767f..9ec4ca2 100644 --- a/common_content_filter/CMakeLists.txt +++ b/common_content_filter/CMakeLists.txt @@ -1,6 +1,11 @@ cmake_minimum_required(VERSION 3.8) project(common_content_filter) + +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) +endif() + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif() @@ -18,7 +23,16 @@ ament_export_dependencies(rcutils) ament_export_dependencies(rmw) add_library(${PROJECT_NAME}_library SHARED - src/test.cpp) + src/DDSFilterCompoundCondition.cpp + src/DDSFilterExpression.cpp + src/DDSFilterExpressionParser.cpp + src/DDSFilterFactory.cpp + src/DDSFilterField.cpp + src/DDSFilterParameter.cpp + src/DDSFilterPredicate.cpp + src/DDSFilterValue.cpp + src/test.cpp + ) set_target_properties(${PROJECT_NAME}_library PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) @@ -30,7 +44,10 @@ target_link_libraries(${PROJECT_NAME}_library PRIVATE target_include_directories(${PROJECT_NAME}_library PUBLIC "$" - "$") + "$" + PRIVATE + ${PROJECT_SOURCE_DIR}/thirdparty/taocpp-pegtl + ) # # Wait for all rosidl generators to finish before building this library # add_dependencies(${PROJECT_NAME}_library diff --git a/common_content_filter/include/common_content_filter/test.h b/common_content_filter/include/common_content_filter/test.h index 37d3bd1..3343212 100644 --- a/common_content_filter/include/common_content_filter/test.h +++ b/common_content_filter/include/common_content_filter/test.h @@ -17,13 +17,18 @@ #include "common_content_filter/visibility_control.h" +#include "rosidl_runtime_c/message_type_support_struct.h" +#include "rmw/subscription_content_filter_options.h" + + #ifdef __cplusplus extern "C" { #endif -typedef void common_content_filter_factory_t; -typedef void common_content_filter_t; +COMMON_CONTENT_FILTER_PUBLIC +void +test_func_c(); COMMON_CONTENT_FILTER_PUBLIC void * @@ -35,15 +40,22 @@ test_common_content_filter_factory(void *); COMMON_CONTENT_FILTER_PUBLIC void -test_func_c(); +destroy_common_content_filter_factory(void *); + +COMMON_CONTENT_FILTER_PUBLIC +void * +create_common_content_filter( + const rosidl_message_type_support_t * type_support, + rmw_subscription_content_filter_options_t * options +); COMMON_CONTENT_FILTER_PUBLIC -common_content_filter_t * -create_common_content_filter(); +bool +common_content_filter_evaluate(void * instance, void * ros_data); COMMON_CONTENT_FILTER_PUBLIC void -test_common_content_filter(void *); +destroy_common_content_filter(void *); #ifdef __cplusplus } diff --git a/common_content_filter/src/DDSFilterCompoundCondition.cpp b/common_content_filter/src/DDSFilterCompoundCondition.cpp new file mode 100644 index 0000000..2c3ca96 --- /dev/null +++ b/common_content_filter/src/DDSFilterCompoundCondition.cpp @@ -0,0 +1,113 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterCompoundCondition.cpp + */ + +#include "DDSFilterCompoundCondition.hpp" + +#include +#include + +#include "DDSFilterCondition.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +DDSFilterCompoundCondition::DDSFilterCompoundCondition( + OperationKind op, + std::unique_ptr&& left, + std::unique_ptr&& right) + : op_(op) + , left_(std::move(left)) + , right_(std::move(right)) +{ + assert(left_); + assert(right_ || OperationKind::NOT == op_); + + left_->set_parent(this); + if (right_) + { + right_->set_parent(this); + } +} + +void DDSFilterCompoundCondition::propagate_reset() noexcept +{ + num_children_decided_ = 0; + + left_->reset(); + if (right_) + { + right_->reset(); + } +} + +void DDSFilterCompoundCondition::child_has_changed( + const DDSFilterCondition& child) noexcept +{ + DDSFilterConditionState child_state = child.get_state(); + assert(DDSFilterConditionState::UNDECIDED != child_state); + + ++num_children_decided_; + + if (DDSFilterConditionState::UNDECIDED == get_state()) + { + switch (op_) + { + case OperationKind::NOT: + set_result(DDSFilterConditionState::RESULT_FALSE == child_state); + break; + + case OperationKind::AND: + if (DDSFilterConditionState::RESULT_FALSE == child_state) + { + set_result(false); + } + else + { + if (2 == num_children_decided_) + { + set_result(true); + } + } + break; + + case OperationKind::OR: + if (DDSFilterConditionState::RESULT_TRUE == child_state) + { + set_result(true); + } + else + { + if (2 == num_children_decided_) + { + set_result(false); + } + } + break; + + default: + assert(false); + } + } +} + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common diff --git a/common_content_filter/src/DDSFilterCompoundCondition.hpp b/common_content_filter/src/DDSFilterCompoundCondition.hpp new file mode 100644 index 0000000..585aaa5 --- /dev/null +++ b/common_content_filter/src/DDSFilterCompoundCondition.hpp @@ -0,0 +1,84 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterCompoundCondition.hpp + */ + +#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCOMPOUNDCONDITION_HPP_ +#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCOMPOUNDCONDITION_HPP_ + +#include + +#include "DDSFilterCondition.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +/** + * A DDSFilterCondition that performs a logical operation over one or two DDSFilterCondition objects. + */ +class DDSFilterCompoundCondition final : public DDSFilterCondition +{ + +public: + + /** + * Possible kinds of logical operations + */ + enum class OperationKind : uint8_t + { + NOT, ///< NOT left + AND, ///< left AND right + OR ///< left OR right + }; + + /** + * Construct a DDSFilterCompoundCondition. + * + * @param[in] op Operation to perform. + * @param[in] left Left operand. + * @param[in] right Right operand. + */ + DDSFilterCompoundCondition( + OperationKind op, + std::unique_ptr&& left, + std::unique_ptr&& right); + + virtual ~DDSFilterCompoundCondition() = default; + +protected: + + void propagate_reset() noexcept final; + + void child_has_changed( + const DDSFilterCondition& child) noexcept final; + +private: + + OperationKind op_; + std::unique_ptr left_; + std::unique_ptr right_; + uint8_t num_children_decided_ = 0; + +}; + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common + +#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCOMPOUNDCONDITION_HPP_ diff --git a/common_content_filter/src/DDSFilterCondition.hpp b/common_content_filter/src/DDSFilterCondition.hpp new file mode 100644 index 0000000..13474bc --- /dev/null +++ b/common_content_filter/src/DDSFilterCondition.hpp @@ -0,0 +1,135 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterCondition.hpp + */ + +#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCONDITION_HPP_ +#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCONDITION_HPP_ + +#include "DDSFilterConditionState.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +/** + * Base class for conditions on a filter expression. + */ +class DDSFilterCondition +{ + +public: + + friend class DDSFilterCompoundCondition; + + virtual ~DDSFilterCondition() = default; + + /** + * @return the current state of this condition. + */ + inline DDSFilterConditionState get_state() const noexcept + { + return state_; + } + + /** + * Instruct this condition to reset. + * Will propagate the reset command down the expression tree. + * + * @post The state of this condition will be UNDECIDED. + */ + inline void reset() noexcept + { + state_ = DDSFilterConditionState::UNDECIDED; + propagate_reset(); + } + +protected: + + /** + * Set a new state for this condition. + * May propagate the change up the expression tree by calling + * @ref child_has_changed on the parent of this condition. + * + * @param[in] state New state for this condition. + * + * @post The state of this condition will be @c state. + */ + inline void set_state( + DDSFilterConditionState state) noexcept + { + if (state != state_) + { + state_ = state; + if (nullptr != parent_) + { + parent_->child_has_changed(*this); + } + } + } + + /** + * Set the result of this condition. + * + * @param[in] result The result to be set. + * + * @post The state of this condition will not be UNDECIDED. + */ + inline void set_result( + bool result) noexcept + { + set_state(result ? DDSFilterConditionState::RESULT_TRUE : DDSFilterConditionState::RESULT_FALSE); + } + + /** + * Set a new parent for this condition. + * + * @param parent New parent to set. + */ + inline void set_parent( + DDSFilterCondition* parent) noexcept + { + parent_ = parent; + } + + /** + * Propagates the reset command down the expression tree. + */ + virtual void propagate_reset() noexcept = 0; + + + /** + * A child condition will call this method whenever its state is changed. + * + * @param[in] child The child condition + */ + virtual void child_has_changed( + const DDSFilterCondition& child) noexcept = 0; + +private: + + DDSFilterConditionState state_ = DDSFilterConditionState::UNDECIDED; + DDSFilterCondition* parent_ = nullptr; + +}; + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common + +#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCONDITION_HPP_ diff --git a/common_content_filter/src/DDSFilterConditionState.hpp b/common_content_filter/src/DDSFilterConditionState.hpp new file mode 100644 index 0000000..0ea3307 --- /dev/null +++ b/common_content_filter/src/DDSFilterConditionState.hpp @@ -0,0 +1,47 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterConditionState.hpp + */ + +#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCONDITIONSTATE_HPP_ +#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCONDITIONSTATE_HPP_ + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +/** + * Possible states of a DDSFilterCondition. + */ +enum class DDSFilterConditionState : char +{ + /// Initial state of the DDSFilterCondition, indicating there is no result. + UNDECIDED, + + /// State indicating that the DDSFilterCondition evaluates to @c false. + RESULT_FALSE, + + /// State indicating that the DDSFilterCondition evaluates to @c true. + RESULT_TRUE +}; + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common + +#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCONDITIONSTATE_HPP_ diff --git a/common_content_filter/src/DDSFilterEmptyExpression.hpp b/common_content_filter/src/DDSFilterEmptyExpression.hpp new file mode 100644 index 0000000..ca6883d --- /dev/null +++ b/common_content_filter/src/DDSFilterEmptyExpression.hpp @@ -0,0 +1,52 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterEmptyExpression.hpp + */ + +#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREMPTYEXPRESSION_HPP_ +#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREMPTYEXPRESSION_HPP_ + +#include "IContentFilter.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +/** + * An IContentFilter for empty expressions that always evaluates to true. + */ +class DDSFilterEmptyExpression final : public IContentFilter +{ + +public: + + bool evaluate( + const void * payload) const final + { + static_cast(payload); + + return true; + } + +}; + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common + +#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREMPTYEXPRESSION_HPP_ diff --git a/common_content_filter/src/DDSFilterExpression.cpp b/common_content_filter/src/DDSFilterExpression.cpp new file mode 100644 index 0000000..abbe703 --- /dev/null +++ b/common_content_filter/src/DDSFilterExpression.cpp @@ -0,0 +1,98 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterExpression.cpp + */ + +#include "DDSFilterExpression.hpp" + +#include +#include +#include +#include + +// #include +// #include +// #include +// #include +// #include +// #include + +#include "DDSFilterCondition.hpp" + +#include "DDSFilterField.hpp" +#include "DDSFilterParameter.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +bool DDSFilterExpression::evaluate( + const void * payload) const +{ + // static_cast(sample_info); + // static_cast(reader_guid); + + // using namespace eprosima_common::fastrtps::types; + // using namespace eprosima_common::fastcdr; + + // dyn_data_->clear_all_values(); + // try + // { + // FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + // Cdr deser(fastbuffer, eprosima_common::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima_common::fastcdr::Cdr::DDS_CDR); + // deser.read_encapsulation(); + // dyn_data_->deserialize(deser); + // } + // catch (eprosima_common::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + // { + // return false; + // } + + // root->reset(); + // for (auto it = fields.begin(); + // it != fields.end() && DDSFilterConditionState::UNDECIDED == root->get_state(); + // ++it) + // { + // if (!it->second->set_value(*dyn_data_)) + // { + // return false; + // } + // } + + return DDSFilterConditionState::RESULT_TRUE == root->get_state(); +} + +void DDSFilterExpression::clear() +{ + // dyn_data_.reset(); + // dyn_type_.reset(); + parameters.clear(); + fields.clear(); + root.reset(); +} + +void DDSFilterExpression::set_type( + const void * type) +{ + // dyn_type_ = type; + // dyn_data_.reset(eprosima_common::fastrtps::types::DynamicDataFactory::get_instance()->create_data(type)); +} + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common diff --git a/common_content_filter/src/DDSFilterExpression.hpp b/common_content_filter/src/DDSFilterExpression.hpp new file mode 100644 index 0000000..238b627 --- /dev/null +++ b/common_content_filter/src/DDSFilterExpression.hpp @@ -0,0 +1,100 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterExpression.hpp + */ + +#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREXPRESSION_HPP_ +#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREXPRESSION_HPP_ + +#include +#include +#include +#include + +// #include +// #include +// #include +// #include + +#include "IContentFilter.hpp" + +#include "DDSFilterCondition.hpp" +#include "DDSFilterField.hpp" +#include "DDSFilterParameter.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +/** + * An IContentFilter that evaluates DDS-SQL filter expressions + */ +class DDSFilterExpression final : public IContentFilter +{ + +public: + + bool evaluate( + const void * payload) const final; + + /** + * Clear the information held by this object. + */ + void clear(); + + /** + * Set the DynamicType to be used when evaluating this expression. + * + * @param [in] type The DynamicType to assign. + */ + void set_type( + const void * type); + + /// The root condition of the expression tree. + std::unique_ptr root; + /// The fields referenced by this expression. + std::map> fields; + /// The parameters referenced by this expression. + std::vector> parameters; + +private: + + // class DynDataDeleter + // { + + // public: + + // void operator ()( + // eprosima_common::fastrtps::types::DynamicData* ptr) + // { + // eprosima_common::fastrtps::types::DynamicDataFactory::get_instance()->delete_data(ptr); + // } + + // }; + + /// The Dynamic type used to deserialize the payloads + // eprosima_common::fastrtps::types::DynamicType_ptr dyn_type_; + /// The Dynamic data used to deserialize the payloads + // std::unique_ptr dyn_data_; +}; + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common + +#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREXPRESSION_HPP_ diff --git a/common_content_filter/src/DDSFilterExpressionParser.cpp b/common_content_filter/src/DDSFilterExpressionParser.cpp new file mode 100644 index 0000000..d2e0151 --- /dev/null +++ b/common_content_filter/src/DDSFilterExpressionParser.cpp @@ -0,0 +1,151 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterExpressionParser.cpp + */ + +#include "DDSFilterExpressionParser.hpp" + +#include + +#include "Log.hpp" + +// #include +// #include +// #include + +#include "pegtl.hpp" +#include "pegtl/contrib/parse_tree.hpp" + +#include "DDSFilterGrammar.hpp" +#include "DDSFilterParseNode.hpp" + +#include "DDSFilterValue.hpp" +#include "DDSFilterField.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { +namespace parser { + +using namespace tao::TAO_PEGTL_NAMESPACE; +// using namespace eprosima_common::fastrtps::types; + +#include "DDSFilterExpressionParserImpl/rearrange.hpp" +#include "DDSFilterExpressionParserImpl/literal_values.hpp" +#include "DDSFilterExpressionParserImpl/identifiers.hpp" +#include "DDSFilterExpressionParserImpl/parameters.hpp" + +// select which rules in the grammar will produce parse tree nodes: +template< typename Rule > +using selector = parse_tree::selector < + Rule, + literal_value_processor::on< + true_value, + false_value, + hex_value, + integer_value, + float_value, + char_value, + string_value >, + parameter_processor::on< + parameter_value>, + parse_tree::store_content::on< + string_content, + integer, + index_part, + identifier >, + parse_tree::remove_content::on< + eq_op, + gt_op, + ge_op, + lt_op, + le_op, + ne_op, + like_op, + match_op, + and_op, + or_op, + not_op, + dot_op, + between_op, + not_between_op >, + rearrange::on< + boolean_value, + ComparisonPredicate, + BetweenPredicate, + Range, + Condition, + FilterExpression >, + identifier_processor::on< + fieldname_part, + fieldname > + >; + +std::unique_ptr parse_filter_expression( + const char* expression, + const void* type_object) +{ + memory_input<> in(expression, ""); + try + { + CurrentIdentifierState identifier_state { type_object, nullptr, {} }; + return parse_tree::parse< FilterExpressionGrammar, ParseNode, selector >(in, identifier_state); + } + catch (const parse_error& e) + { + const auto p = e.positions.front(); + logError(DDSSQLFILTER, "PARSE ERROR: " << e.what() << std::endl + << in.line_at(p) << std::endl + << std::string(p.byte_in_line, ' ') << '^'); + } + catch (const std::exception& e) + { + logError(DDSSQLFILTER, "ERROR '" << e.what() << "' while parsing " << expression); + } + + return nullptr; +} + +std::unique_ptr parse_literal_value( + const char* expression) +{ + memory_input<> in(expression, ""); + try + { + CurrentIdentifierState identifier_state{ nullptr, nullptr, {} }; + return parse_tree::parse< LiteralGrammar, ParseNode, selector >(in, identifier_state); + } + catch (const parse_error& e) + { + const auto p = e.positions.front(); + logError(DDSSQLFILTER, "PARSE ERROR: " << e.what() << std::endl + << in.line_at(p) << std::endl + << std::string(p.byte_in_line, ' ') << '^'); + } + catch (const std::exception& e) + { + logError(DDSSQLFILTER, "ERROR '" << e.what() << "' while parsing " << expression); + } + + return nullptr; +} + +} // namespace parser +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common diff --git a/common_content_filter/src/DDSFilterExpressionParser.hpp b/common_content_filter/src/DDSFilterExpressionParser.hpp new file mode 100644 index 0000000..146d473 --- /dev/null +++ b/common_content_filter/src/DDSFilterExpressionParser.hpp @@ -0,0 +1,68 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterExpressionParser.hpp + */ + +#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREXPRESSIONPARSER_HPP_ +#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREXPRESSIONPARSER_HPP_ + +#include + +// #include + +#include "DDSFilterParseNode.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { +namespace parser { + +/** + * Performs parsing of a string containing a DDS-SQL filter expression. + * + * @param[in] expression The string to parse. + * @param[in] type_object The TypeObject representing the type of the topic being filtered. + * + * @return nullptr when there is a parsing error. + * @return A pointer to the root node of the AST tree for the expression. + */ +// std::unique_ptr parse_filter_expression( +// const char* expression, +// const eprosima_common::fastrtps::types::TypeObject* type_object); +std::unique_ptr parse_filter_expression( + const char* expression, + const void* type_object); + +/** + * Performs parsing of a string containing a literal value. + * This method is used to perform parsing of parameter values. + * + * @param[in] value The string to parse. + * + * @return nullptr when there is a parsing error. + * @return A simple tree consisting of a root node, with a single child that contains the generated DDSFilterValue. + */ +std::unique_ptr parse_literal_value( + const char* value); + +} // namespace parser +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common + +#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREXPRESSIONPARSER_HPP_ diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/Readme.md b/common_content_filter/src/DDSFilterExpressionParserImpl/Readme.md new file mode 100644 index 0000000..2e88d50 --- /dev/null +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/Readme.md @@ -0,0 +1,7 @@ +## Internal support classes for DataReaderImpl + +This folder contains the declaration of several internal support classes to improve +maintenance and readability of DDSFilterExpressionParser.hpp. + +They are not meant to be used outside DDSFilterExpressionParser and their functionality should be +fully covered by the unit tests of DDSFilterFactory. diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp new file mode 100644 index 0000000..4d0d74a --- /dev/null +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp @@ -0,0 +1,239 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file identifiers.hpp + * + * Note: this is an implementation file, designed to be included inside the + * DDSFilterExpressionParser.hpp file of the parent folder. + */ + + + +struct CurrentIdentifierState +{ + // TODO. const rosidl_message_type_support_t * type_support, + const void* type_object; + + // ? + const void* current_type; + std::vector access_path; +}; + +struct identifier_processor + : parse_tree::apply< identifier_processor > +{ + template + static constexpr size_t process_bound( + _TSize bound) + { + return 0 == bound ? std::numeric_limits::max() : static_cast(bound); + } + + template + static size_t process_bounds( + const _BSeq& bound_seq) + { + if (1 != bound_seq.size()) + { + return 0; + } + + return process_bound(bound_seq[0]); + } + + // static bool type_should_be_indexed( + // const TypeIdentifier& ti, + // const TypeIdentifier*& out_type, + // size_t& max_size) + // { + // max_size = 0; + + // switch (ti._d()) + // { + // case TI_PLAIN_ARRAY_SMALL: + // out_type = ti.array_sdefn().element_identifier(); + // max_size = process_bounds(ti.array_sdefn().array_bound_seq()); + // return true; + + // case TI_PLAIN_ARRAY_LARGE: + // out_type = ti.array_ldefn().element_identifier(); + // max_size = process_bounds(ti.array_ldefn().array_bound_seq()); + // return true; + + // case TI_PLAIN_SEQUENCE_SMALL: + // out_type = ti.seq_sdefn().element_identifier(); + // max_size = process_bound(ti.seq_sdefn().bound()); + // return true; + + // case TI_PLAIN_SEQUENCE_LARGE: + // out_type = ti.seq_ldefn().element_identifier(); + // max_size = process_bound(ti.seq_ldefn().bound()); + // return true; + // } + + // out_type = &ti; + // return false; + // } + + // static void add_member_access( + // std::unique_ptr< ParseNode >& n, + // CurrentIdentifierState& identifier_state, + // const CompleteTypeObject& complete) + // { + // if (TK_STRUCTURE != complete._d()) + // { + // throw parse_error("trying to access field on a non-struct type", n->begin()); + // } + + // const ParseNode& name_node = n->left(); + // std::string name = name_node.content(); + // size_t member_index; + // const CompleteStructMemberSeq& members = complete.struct_type().member_seq(); + // for (member_index = 0; member_index < members.size(); ++member_index) + // { + // if (members[member_index].detail().name() == name) + // { + // break; + // } + // } + + // if (member_index == members.size()) + // { + // throw parse_error("field not found", name_node.begin()); + // } + + // const TypeIdentifier& ti = members[member_index].common().member_type_id(); + // bool has_index = n->children.size() > 1; + // size_t max_size = 0; + // size_t array_index = std::numeric_limits::max(); + // if (type_should_be_indexed(ti, identifier_state.current_type, max_size)) + // { + // if (!has_index) + // { + // throw parse_error("field should have an index (i.e. [n])", n->left().end()); + // } + + // array_index = static_cast(std::stoul(n->right().left().content())); + // if (max_size <= array_index) + // { + // throw parse_error("index is greater than maximum size", n->right().end()); + // } + // } + // else + // { + // if (has_index) + // { + // throw parse_error("field is not an array or sequence", n->right().begin()); + // } + // } + + // identifier_state.access_path.emplace_back(DDSFilterField::FieldAccessor{ member_index, array_index }); + // } + + // static DDSFilterValue::ValueKind get_value_kind( + // const TypeIdentifier& ti, + // const position& pos) + // { + // switch (ti._d()) + // { + // case TK_BOOLEAN: + // return DDSFilterValue::ValueKind::BOOLEAN; + + // case TK_CHAR8: + // return DDSFilterValue::ValueKind::CHAR; + + // case TK_STRING8: + // case TI_STRING8_SMALL: + // case TI_STRING8_LARGE: + // return DDSFilterValue::ValueKind::STRING; + + // case TK_INT16: + // case TK_INT32: + // case TK_INT64: + // return DDSFilterValue::ValueKind::SIGNED_INTEGER; + + // case TK_BYTE: + // case TK_UINT16: + // case TK_UINT32: + // case TK_UINT64: + // return DDSFilterValue::ValueKind::UNSIGNED_INTEGER; + + // case TK_FLOAT32: + // return DDSFilterValue::ValueKind::FLOAT_FIELD; + + // case TK_FLOAT64: + // return DDSFilterValue::ValueKind::DOUBLE_FIELD; + + // case TK_FLOAT128: + // return DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD; + + // case EK_COMPLETE: + // const TypeObject* type_object = TypeObjectFactory::get_instance()->get_type_object(&ti); + // if (TK_ENUM == type_object->complete()._d()) + // { + // return DDSFilterValue::ValueKind::ENUM; + // } + // break; + + // } + + // throw parse_error("type is not primitive", pos); + // } + + template< typename ... States > + static void transform( + std::unique_ptr< ParseNode >& n, + CurrentIdentifierState& state, + States&&... /*st*/) + { + + // if (n->is()) + // { + // // Set data for fieldname node + // n->field_kind = get_value_kind(*state.current_type, n->end()); + // n->field_access_path = state.access_path; + // n->type_id = state.current_type; + + // // Reset parser state + // state.access_path.clear(); + // state.current_type = nullptr; + // } + // else + // { + // if (nullptr == state.current_type) + // { + // add_member_access(n, state, state.type_object->complete()); + // } + // else + // { + // if (EK_COMPLETE != state.current_type->_d()) + // { + // throw parse_error("trying to access field on a non-complete type", n->begin()); + // } + + // const TypeObject* type_object = TypeObjectFactory::get_instance()->get_type_object(state.current_type); + // if (nullptr == type_object) + // { + // throw parse_error("could not find type object definition", n->begin()); + // } + + // add_member_access(n, state, type_object->complete()); + // } + // } + + // n->children.clear(); + } + +}; diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/literal_values.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/literal_values.hpp new file mode 100644 index 0000000..db1b3c1 --- /dev/null +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/literal_values.hpp @@ -0,0 +1,96 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file literal_values.hpp + * + * Note: this is an implementation file, designed to be included inside the + * DDSFilterExpressionParser.hpp file of the parent folder. + */ + +struct literal_value_processor + : parse_tree::apply< literal_value_processor > +{ + template< typename ... States > + static void transform( + std::unique_ptr< ParseNode >& n, + States&&... /*st*/) + { + logError(DDSSQLFILTER, "PARSE literal_value_processor begin"); + + n->value.reset(new DDSFilterValue()); + if (n->is()) + { + + n->value->kind = DDSFilterValue::ValueKind::BOOLEAN; + n->value->boolean_value = true; + logError(DDSSQLFILTER, "PARSE literal_value_processor true"); + } + else if (n->is()) + { + + n->value->kind = DDSFilterValue::ValueKind::BOOLEAN; + n->value->boolean_value = false; + logError(DDSSQLFILTER, "PARSE literal_value_processor false"); + } + else if (n->is() || n->is()) + { + + if (n->m_begin.data[0] == '-') + { + n->value->kind = DDSFilterValue::ValueKind::SIGNED_INTEGER; + n->value->signed_integer_value = std::stoll(n->content(), nullptr, 0); + logError(DDSSQLFILTER, "PARSE literal_value_processor integer " << n->value->signed_integer_value); + } + else + { + n->value->kind = DDSFilterValue::ValueKind::UNSIGNED_INTEGER; + n->value->unsigned_integer_value = std::stoull(n->content(), nullptr, 0); + logError(DDSSQLFILTER, "PARSE literal_value_processor integer " << n->value->unsigned_integer_value); + } + } + else if (n->is()) + { + + n->value->kind = DDSFilterValue::ValueKind::FLOAT_CONST; + n->value->float_value = std::stold(n->content()); + logError(DDSSQLFILTER, "PARSE literal_value_processor float " << n->value->float_value); + } + else if (n->is()) + { + + n->value->kind = DDSFilterValue::ValueKind::CHAR; + n->value->char_value = n->m_begin.data[1]; + logError(DDSSQLFILTER, "PARSE literal_value_processor char " << n->value->char_value); + } + else if (n->is()) + { + + const ParseNode& content_node = n->left(); + size_t str_len = content_node.m_end.byte - content_node.m_begin.byte; + if (sizeof(n->value->string_value) < str_len) + { + throw parse_error("string constant has more than 255 characters", n->end()); + } + n->value->kind = DDSFilterValue::ValueKind::STRING; + memcpy(n->value->string_value, content_node.m_begin.data, str_len); + // n->value->string_value.assign(content_node.m_begin.data, str_len); + + logError(DDSSQLFILTER, "PARSE literal_value_processor string " << n->value->string_value); + } + + n->children.clear(); + } + +}; diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/parameters.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/parameters.hpp new file mode 100644 index 0000000..c3b94c5 --- /dev/null +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/parameters.hpp @@ -0,0 +1,38 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file parameters.hpp + * + * Note: this is an implementation file, designed to be included inside the + * DDSFilterExpressionParser.hpp file of the parent folder. + */ + +struct parameter_processor + : parse_tree::apply< parameter_processor > +{ + template< typename ... States > + static void transform( + std::unique_ptr< ParseNode >& n, + States&&... /*st*/) + { + n->parameter_index = static_cast(n->m_begin.data[1] - '0'); + if (n->m_end.byte - n->m_begin.byte == 3) + { + n->parameter_index *= 10; + n->parameter_index += static_cast(n->m_begin.data[2] - '0'); + } + } + +}; diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/rearrange.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/rearrange.hpp new file mode 100644 index 0000000..b1353ca --- /dev/null +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/rearrange.hpp @@ -0,0 +1,73 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file rearrange.hpp + * + * Note: this is an implementation file, designed to be included inside the + * DDSFilterExpressionParser.hpp file of the parent folder. + */ + +// after a node is stored successfully, you can add an optional transformer like this: +struct rearrange + : parse_tree::apply< rearrange > // allows bulk selection, see selector<...> +{ + // recursively rearrange nodes. the basic principle is: + // + // from: SEQ_BASED_RULE + // / | \ (LHS... may be one or more children, followed by OP,) + // LHS... OP RHS (which is one operator, and RHS, which is a single child) + // + // to: OP + // / \ (OP now has two children, the original PROD/EXPR and RHS) + // SEQ_BASED_RULE RHS (Note that PROD/EXPR has two fewer children now) + // | + // LHS... + // + // if only one child is left for LHS..., replace the SEQ_BASED_RULE with the child directly. + // otherwise, perform the above transformation, then apply it recursively until LHS... + // becomes a single child, which then replaces the parent node and the recursion ends. + template< typename ... States > + static void transform( + std::unique_ptr< ParseNode >& n, + States&&... st) + { + if (n->children.size() == 1) + { + n = std::move(n->children.back()); + } + else + { + n->remove_content(); + auto& c = n->children; + auto r = std::move(c.back()); + c.pop_back(); + auto o = std::move(c.back()); + c.pop_back(); + if (c.empty()) + { + o->children.emplace_back(std::move(r)); + n = std::move(o); + } + else + { + o->children.emplace_back(std::move(n)); + o->children.emplace_back(std::move(r)); + n = std::move(o); + transform(n->children.front(), st ...); + } + } + } + +}; diff --git a/common_content_filter/src/DDSFilterFactory.cpp b/common_content_filter/src/DDSFilterFactory.cpp new file mode 100644 index 0000000..d44ff4e --- /dev/null +++ b/common_content_filter/src/DDSFilterFactory.cpp @@ -0,0 +1,589 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterFactory.cpp + */ + +#include "DDSFilterFactory.hpp" + +#include +#include +#include + +// #include +// #include +// #include + +// #include +// #include + +#include "IContentFilter.hpp" +#include "IContentFilterFactory.hpp" + +#include "DDSFilterGrammar.hpp" +#include "DDSFilterExpressionParser.hpp" +#include "DDSFilterParseNode.hpp" + +#include "DDSFilterExpression.hpp" +#include "DDSFilterCompoundCondition.hpp" +#include "DDSFilterCondition.hpp" +#include "DDSFilterConditionState.hpp" +#include "DDSFilterEmptyExpression.hpp" +#include "DDSFilterExpression.hpp" +#include "DDSFilterField.hpp" +#include "DDSFilterParameter.hpp" +#include "DDSFilterPredicate.hpp" +#include "DDSFilterValue.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +static IContentFilterFactory::ReturnCode_t transform_enum( + std::shared_ptr& value, + const void* type, + const std::string& string_value) +{ + // const char* str_value = string_value.c_str(); + // auto type_obj = eprosima_common::fastrtps::types::TypeObjectFactory::get_instance()->get_type_object(type); + // for (const auto& enum_value : type_obj->complete().enumerated_type().literal_seq()) + // { + // if (enum_value.detail().name() == str_value) + // { + // value->kind = DDSFilterValue::ValueKind::SIGNED_INTEGER; + // value->signed_integer_value = enum_value.common().value(); + // return IContentFilterFactory::ReturnCode_t::RETCODE_OK; + // } + // } + + return IContentFilterFactory::ReturnCode_t::RETCODE_BAD_PARAMETER; +} + +static IContentFilterFactory::ReturnCode_t transform_enums( + std::shared_ptr& left_value, + const void* left_type, + std::shared_ptr& right_value, + const void* right_type) +{ + if ((DDSFilterValue::ValueKind::ENUM == left_value->kind) && + (DDSFilterValue::ValueKind::STRING == right_value->kind)) + { + return transform_enum(right_value, left_type, right_value->string_value); + } + + if ((DDSFilterValue::ValueKind::ENUM == right_value->kind) && + (DDSFilterValue::ValueKind::STRING == left_value->kind)) + { + return transform_enum(left_value, right_type, left_value->string_value); + } + + return IContentFilterFactory::ReturnCode_t::RETCODE_OK; +} + +static bool check_value_compatibility( + DDSFilterValue::ValueKind left, + DDSFilterValue::ValueKind right, + bool ignore_enum) +{ + if (!ignore_enum && DDSFilterValue::ValueKind::ENUM == right) + { + return DDSFilterValue::ValueKind::ENUM == left || + DDSFilterValue::ValueKind::SIGNED_INTEGER == left || + DDSFilterValue::ValueKind::UNSIGNED_INTEGER == left || + DDSFilterValue::ValueKind::STRING == left; + } + + switch (left) + { + case DDSFilterValue::ValueKind::BOOLEAN: + return DDSFilterValue::ValueKind::BOOLEAN == right || + DDSFilterValue::ValueKind::SIGNED_INTEGER == right || + DDSFilterValue::ValueKind::UNSIGNED_INTEGER == right; + + case DDSFilterValue::ValueKind::SIGNED_INTEGER: + case DDSFilterValue::ValueKind::UNSIGNED_INTEGER: + return DDSFilterValue::ValueKind::SIGNED_INTEGER == right || + DDSFilterValue::ValueKind::UNSIGNED_INTEGER == right || + DDSFilterValue::ValueKind::BOOLEAN == right || + DDSFilterValue::ValueKind::FLOAT_CONST == right || + DDSFilterValue::ValueKind::FLOAT_FIELD == right || + DDSFilterValue::ValueKind::DOUBLE_FIELD == right || + DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD == right; + + case DDSFilterValue::ValueKind::CHAR: + case DDSFilterValue::ValueKind::STRING: + return DDSFilterValue::ValueKind::CHAR == right || + DDSFilterValue::ValueKind::STRING == right; + + case DDSFilterValue::ValueKind::FLOAT_CONST: + case DDSFilterValue::ValueKind::FLOAT_FIELD: + case DDSFilterValue::ValueKind::DOUBLE_FIELD: + case DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD: + return DDSFilterValue::ValueKind::FLOAT_CONST == right || + DDSFilterValue::ValueKind::FLOAT_FIELD == right || + DDSFilterValue::ValueKind::DOUBLE_FIELD == right || + DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD == right || + DDSFilterValue::ValueKind::SIGNED_INTEGER == right || + DDSFilterValue::ValueKind::UNSIGNED_INTEGER == right; + + case DDSFilterValue::ValueKind::ENUM: + if (!ignore_enum) + { + return DDSFilterValue::ValueKind::ENUM == right || + DDSFilterValue::ValueKind::SIGNED_INTEGER == right || + DDSFilterValue::ValueKind::UNSIGNED_INTEGER == right || + DDSFilterValue::ValueKind::STRING == right; + } + } + + return false; +} + +static DDSFilterPredicate::OperationKind get_predicate_op( + const parser::ParseNode& node) +{ + DDSFilterPredicate::OperationKind ret_val = DDSFilterPredicate::OperationKind::EQUAL; + if (node.is()) + { + ret_val = DDSFilterPredicate::OperationKind::EQUAL; + } + else if (node.is()) + { + ret_val = DDSFilterPredicate::OperationKind::NOT_EQUAL; + } + else if (node.is()) + { + ret_val = DDSFilterPredicate::OperationKind::LESS_THAN; + } + else if (node.is()) + { + ret_val = DDSFilterPredicate::OperationKind::LESS_EQUAL; + } + else if (node.is()) + { + ret_val = DDSFilterPredicate::OperationKind::GREATER_THAN; + } + else if (node.is()) + { + ret_val = DDSFilterPredicate::OperationKind::GREATER_EQUAL; + } + else if (node.is()) + { + ret_val = DDSFilterPredicate::OperationKind::LIKE; + } + else if (node.is()) + { + ret_val = DDSFilterPredicate::OperationKind::MATCH; + } + else + { + assert(false); + } + + return ret_val; +} + +struct ExpressionParsingState +{ + const void* type_object; + const IContentFilterFactory::ParameterSeq& filter_parameters; + DDSFilterExpression* filter; +}; + +template<> +IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( + ExpressionParsingState& state, + std::unique_ptr& condition, + const parser::ParseNode& node); + + +template<> +IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( + ExpressionParsingState& state, + std::shared_ptr& value, + const parser::ParseNode& node) +{ + if (node.value) + { + value = std::make_shared(); + value->copy_from(*node.value.get(), true); + } + else if (nullptr != node.type_id) + { + std::string field_name = node.content(); + auto it = state.filter->fields.find(field_name); + if (it == state.filter->fields.end()) + { + value = state.filter->fields[field_name] = + std::make_shared(node.type_id, node.field_access_path, node.field_kind); + } + else + { + value = it->second; + } + } + else + { + // Check parameter index + if (node.parameter_index >= state.filter_parameters.size()) + { + return ReturnCode_t::RETCODE_BAD_PARAMETER; + } + + if (state.filter->parameters[node.parameter_index]) + { + value = state.filter->parameters[node.parameter_index]; + } + else + { + auto param_value = std::make_shared(); + if (!param_value->set_value(state.filter_parameters[node.parameter_index].c_str())) + { + return ReturnCode_t::RETCODE_BAD_PARAMETER; + } + value = state.filter->parameters[node.parameter_index] = param_value; + } + } + + return ReturnCode_t::RETCODE_OK; +} + +template<> +IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( + ExpressionParsingState& state, + std::unique_ptr& condition, + const parser::ParseNode& node) +{ + std::shared_ptr left; + std::shared_ptr right; + ReturnCode_t ret = convert_tree(state, left, node.left()); + if (ReturnCode_t::RETCODE_OK == ret) + { + ret = convert_tree(state, right, node.right()); + if (ReturnCode_t::RETCODE_OK == ret) + { + bool ignore_enum = false; + if (node.is() || node.is()) + { + // At least one fieldname should be a string + if ( !((node.left().is() && (DDSFilterValue::ValueKind::STRING == left->kind)) || + (node.right().is() && (DDSFilterValue::ValueKind::STRING == right->kind)))) + { + return ReturnCode_t::RETCODE_BAD_PARAMETER; + } + + ignore_enum = true; + } + + if ((DDSFilterValue::ValueKind::ENUM == left->kind) && (DDSFilterValue::ValueKind::ENUM == right->kind)) + { + if (node.left().type_id != node.right().type_id) + { + return ReturnCode_t::RETCODE_BAD_PARAMETER; + } + } + else if (!check_value_compatibility(left->kind, right->kind, ignore_enum)) + { + return ReturnCode_t::RETCODE_BAD_PARAMETER; + } + + ret = transform_enums(left, node.left().type_id, right, node.right().type_id); + if (ReturnCode_t::RETCODE_OK == ret) + { + condition.reset(new DDSFilterPredicate(get_predicate_op(node), left, right)); + } + } + } + + return ret; +} + +template<> +IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( + ExpressionParsingState& state, + std::unique_ptr& condition, + const parser::ParseNode& node) +{ + /* The nodes here will be in the following situation: + * + * between_op + * / \ + * fieldname and_op + * / \ + * op1 op2 + */ + + std::shared_ptr field; + ReturnCode_t ret = convert_tree(state, field, node.left()); + if (ReturnCode_t::RETCODE_OK == ret) + { + const parser::ParseNode& and_node = node.right(); + assert(and_node.is()); + + std::shared_ptr op1; + std::shared_ptr op2; + + ret = convert_tree(state, op1, and_node.left()); + if (ReturnCode_t::RETCODE_OK == ret) + { + ret = convert_tree(state, op2, and_node.right()); + } + + if (ReturnCode_t::RETCODE_OK == ret) + { + if (!check_value_compatibility(field->kind, op1->kind, false) || + !check_value_compatibility(field->kind, op2->kind, false) || + !check_value_compatibility(op1->kind, op2->kind, false)) + { + return ReturnCode_t::RETCODE_BAD_PARAMETER; + } + + ret = transform_enums(field, node.left().type_id, op1, and_node.left().type_id); + if (ReturnCode_t::RETCODE_OK == ret) + { + ret = transform_enums(field, node.left().type_id, op2, and_node.right().type_id); + } + } + + if (ReturnCode_t::RETCODE_OK == ret) + { + DDSFilterPredicate::OperationKind binary_op = node.is() ? + DDSFilterPredicate::OperationKind::LESS_EQUAL : + DDSFilterPredicate::OperationKind::GREATER_THAN; + DDSFilterCompoundCondition::OperationKind logical_op = node.is() ? + DDSFilterCompoundCondition::OperationKind::AND : + DDSFilterCompoundCondition::OperationKind::OR; + + std::unique_ptr left_cond(new DDSFilterPredicate(binary_op, op1, field)); + std::unique_ptr right_cond(new DDSFilterPredicate(binary_op, field, op2)); + auto cond = new DDSFilterCompoundCondition(logical_op, std::move(left_cond), std::move(right_cond)); + condition.reset(cond); + } + } + + return ret; +} + +template<> +IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( + ExpressionParsingState& state, + std::unique_ptr& condition, + const parser::ParseNode& node) +{ + ReturnCode_t ret = ReturnCode_t::RETCODE_UNSUPPORTED; + DDSFilterCompoundCondition::OperationKind op = DDSFilterCompoundCondition::OperationKind::NOT; + std::unique_ptr left; + std::unique_ptr right; + + if (node.is()) + { + op = DDSFilterCompoundCondition::OperationKind::NOT; + ret = convert_tree(state, left, node.left()); + } + else if (node.is()) + { + op = DDSFilterCompoundCondition::OperationKind::AND; + ret = convert_tree(state, left, node.left()); + if (ReturnCode_t::RETCODE_OK == ret) + { + ret = convert_tree(state, right, node.right()); + } + } + else if (node.is()) + { + op = DDSFilterCompoundCondition::OperationKind::OR; + ret = convert_tree(state, left, node.left()); + if (ReturnCode_t::RETCODE_OK == ret) + { + ret = convert_tree(state, right, node.right()); + } + } + else + { + assert(false); + } + + if (ReturnCode_t::RETCODE_OK == ret) + { + condition.reset(new DDSFilterCompoundCondition(op, std::move(left), std::move(right))); + } + + return ret; +} + +template<> +IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( + ExpressionParsingState& state, + std::unique_ptr& condition, + const parser::ParseNode& node) +{ + if (node.is() || node.is() || node.is()) + { + return convert_tree(state, condition, node); + } + else if (node.is() || node.is()) + { + return convert_tree(state, condition, node); + } + + return convert_tree(state, condition, node); +} + +DDSFilterFactory::~DDSFilterFactory() +{ + auto& pool = expression_pool_.collection(); + for (DDSFilterExpression* item : pool) + { + delete item; + } + pool.clear(); +} + +IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( + const char* filter_class_name, + const char* type_name, + const void* data_type, + const char* filter_expression, + const IContentFilterFactory::ParameterSeq& filter_parameters, + IContentFilter*& filter_instance) +{ + + static_cast(data_type); + + ReturnCode_t ret = ReturnCode_t::RETCODE_UNSUPPORTED; + + if (nullptr == filter_expression) + { + if (nullptr == filter_instance) + { + ret = ReturnCode_t::RETCODE_BAD_PARAMETER; + } + else + { + ret = ReturnCode_t::RETCODE_OK; + if (&empty_expression_ != filter_instance) + { + auto expr = static_cast(filter_instance); + auto n_params = expr->parameters.size(); + if (filter_parameters.size() < n_params) + { + ret = ReturnCode_t::RETCODE_BAD_PARAMETER; + } + else + { + std::vector old_values(n_params); + size_t n = n_params; + while ((n > 0) && (ReturnCode_t::RETCODE_OK == ret)) + { + --n; + if (expr->parameters[n]) + { + old_values[n].copy_from(*(expr->parameters[n]), true); + if (!expr->parameters[n]->set_value(filter_parameters[n].c_str())) + { + ret = ReturnCode_t::RETCODE_BAD_PARAMETER; + } + } + } + + if (ReturnCode_t::RETCODE_OK != ret) + { + while (n < n_params) + { + expr->parameters[n]->copy_from(old_values[n], true); + ++n; + } + } + } + } + } + } + else if (std::strlen(filter_expression) == 0) + { + delete_content_filter(filter_class_name, filter_instance); + filter_instance = &empty_expression_; + ret = ReturnCode_t::RETCODE_OK; + } + else + { + // auto type_object = TypeObjectFactory::get_instance()->get_type_object(type_name, true); + // if (!type_object) + // { + // logError(DDSSQLFILTER, "No TypeObject found for type " << type_name); + // ret = ReturnCode_t::RETCODE_BAD_PARAMETER; + // } + // else + { + auto node = parser::parse_filter_expression(filter_expression, nullptr); + if (node) + { + // auto type_id = TypeObjectFactory::get_instance()->get_type_identifier(type_name, true); + // auto dyn_type = TypeObjectFactory::get_instance()->build_dynamic_type(type_name, type_id, type_object); + DDSFilterExpression* expr = get_expression(); + // TODO. set `const rosidl_message_type_support_t * type_support` from subscription in the rcl. + // expr->set_type(dyn_type); + size_t n_params = filter_parameters.size(); + expr->parameters.reserve(n_params); + while (expr->parameters.size() < n_params) + { + expr->parameters.emplace_back(); + } + ExpressionParsingState state{ nullptr, filter_parameters, expr }; + ret = convert_tree(state, expr->root, *(node->children[0])); + if (ReturnCode_t::RETCODE_OK == ret) + { + delete_content_filter(filter_class_name, filter_instance); + filter_instance = expr; + } + else + { + delete_content_filter(filter_class_name, expr); + } + } + else + { + ret = ReturnCode_t::RETCODE_BAD_PARAMETER; + } + } + } + + return ret; +} + +IContentFilterFactory::ReturnCode_t DDSFilterFactory::delete_content_filter( + const char* filter_class_name, + IContentFilter* filter_instance) +{ + static_cast(filter_class_name); + + if (nullptr == filter_instance) + { + return ReturnCode_t::RETCODE_BAD_PARAMETER; + } + + if (&empty_expression_ != filter_instance) + { + auto expr = static_cast(filter_instance); + expr->clear(); + expression_pool_.put(expr); + } + return ReturnCode_t::RETCODE_OK; +} + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common diff --git a/common_content_filter/src/DDSFilterFactory.hpp b/common_content_filter/src/DDSFilterFactory.hpp new file mode 100644 index 0000000..dc3246a --- /dev/null +++ b/common_content_filter/src/DDSFilterFactory.hpp @@ -0,0 +1,104 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterFactory.hpp + */ + +#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERFACTORY_HPP_ +#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERFACTORY_HPP_ + +// #include +// #include +// #include + + +#include "IContentFilterFactory.hpp" + +#include "IContentFilter.hpp" + +#include "ObjectPool.hpp" +#include "DDSFilterEmptyExpression.hpp" +#include "DDSFilterExpression.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +// class IContentFilter; + +/** + * An IContentFilterFactory that processes DDS-SQL filter expressions. + */ +class DDSFilterFactory final : public IContentFilterFactory +{ + +public: + + ~DDSFilterFactory(); + + ReturnCode_t create_content_filter( + const char* filter_class_name, + const char* type_name, + const void* data_type, + const char* filter_expression, + const ParameterSeq& filter_parameters, + IContentFilter*& filter_instance) override; + + ReturnCode_t delete_content_filter( + const char* filter_class_name, + IContentFilter* filter_instance) override; + +private: + + /** + * Retrieve a DDSFilterExpression from the pool. + * + * @return A pointer to an empty DDSFilterExpression. + */ + DDSFilterExpression* get_expression() + { + return expression_pool_.get([] + { + return new DDSFilterExpression(); + }); + } + + /** + * Generic method to perform processing of an AST node resulting from the parsing of a DDS-SQL filter expression. + * Provides a generic mechanism for methods that perform post-processing of the generated AST tree, so they could + * have access to the private fields of DDSFilterFactory. + * + * @return return code indicating the conversion result. + */ + template + ReturnCode_t convert_tree( + _State& state, + _Output& parse_output, + const _ParserNode& node); + + /// Empty expressions content filter + DDSFilterEmptyExpression empty_expression_; + /// Pool of DDSFilterExpression objects + ObjectPool expression_pool_; + +}; + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common + +#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERFACTORY_HPP_ diff --git a/common_content_filter/src/DDSFilterField.cpp b/common_content_filter/src/DDSFilterField.cpp new file mode 100644 index 0000000..ee70f83 --- /dev/null +++ b/common_content_filter/src/DDSFilterField.cpp @@ -0,0 +1,195 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterField.cpp + */ + +#include "DDSFilterField.hpp" + +#include +#include +#include + +// #include +// #include +// #include +// #include + +#include "DDSFilterPredicate.hpp" +#include "DDSFilterValue.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +bool DDSFilterField::set_value( + const void * data, + size_t n) +{ + // using namespace eprosima_common::fastrtps::types; + + // uint32_t index = static_cast(access_path_[n].member_index); + // auto member_id = data.get_member_id_at_index(index); + // bool last_step = access_path_.size() - 1 == n; + bool ret = false; + + // if (access_path_[n].array_index < MEMBER_ID_INVALID) + // { + // DynamicData* array_data = data.loan_value(member_id); + // if (nullptr != array_data) + // { + // member_id = static_cast(access_path_[n].array_index); + // if (array_data->get_item_count() > member_id) + // { + // if (last_step) + // { + // ret = set_value(array_data, member_id); + // } + // else + // { + // DynamicData* struct_data = array_data->loan_value(member_id); + // if (nullptr != struct_data) + // { + // ret = set_value(*struct_data, n + 1); + // array_data->return_loaned_value(struct_data); + // } + // } + // } + // data.return_loaned_value(array_data); + // } + // } + // else + // { + // if (last_step) + // { + // ret = set_value(&data, member_id); + // } + // else + // { + // DynamicData* struct_data = data.loan_value(member_id); + // if (nullptr != struct_data) + // { + // ret = set_value(*struct_data, n + 1); + // data.return_loaned_value(struct_data); + // } + // } + // } + + // if (ret && last_step) + // { + // has_value_ = true; + // value_has_changed(); + + // // Inform parent predicates + // for (DDSFilterPredicate* parent : parents_) + // { + // parent->value_has_changed(); + // } + // } + + return ret; +} + +bool DDSFilterField::set_value( + const void * data, + int member_id) +{ + // using namespace eprosima_common::fastrtps::types; + + bool ret = true; + // try + // { + // switch (type_id_->_d()) + // { + // case TK_BOOLEAN: + // boolean_value = data->get_bool_value(member_id); + // break; + + // case TK_CHAR8: + // char_value = data->get_char8_value(member_id); + // break; + + // case TK_STRING8: + // case TI_STRING8_SMALL: + // case TI_STRING8_LARGE: + // string_value = data->get_string_value(member_id); + // break; + + // case TK_INT16: + // signed_integer_value = data->get_int16_value(member_id); + // break; + + // case TK_INT32: + // signed_integer_value = data->get_int32_value(member_id); + // break; + + // case TK_INT64: + // signed_integer_value = data->get_int64_value(member_id); + // break; + + // case TK_BYTE: + // unsigned_integer_value = data->get_uint8_value(member_id); + // break; + + // case TK_UINT16: + // unsigned_integer_value = data->get_uint16_value(member_id); + // break; + + // case TK_UINT32: + // unsigned_integer_value = data->get_uint32_value(member_id); + // break; + + // case TK_UINT64: + // unsigned_integer_value = data->get_uint64_value(member_id); + // break; + + // case TK_FLOAT32: + // float_value = data->get_float32_value(member_id); + // break; + + // case TK_FLOAT64: + // float_value = data->get_float64_value(member_id); + // break; + + // case TK_FLOAT128: + // float_value = data->get_float128_value(member_id); + // break; + + // case EK_COMPLETE: + // { + // uint32_t enum_value; + // ret = !!data->get_enum_value(enum_value, member_id); + // signed_integer_value = enum_value; + // break; + // } + + // default: + // ret = false; + // break; + // } + // } + // catch (...) + // { + // ret = false; + // } + + return ret; +} + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common diff --git a/common_content_filter/src/DDSFilterField.hpp b/common_content_filter/src/DDSFilterField.hpp new file mode 100644 index 0000000..de32625 --- /dev/null +++ b/common_content_filter/src/DDSFilterField.hpp @@ -0,0 +1,155 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterField.hpp + */ + +#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERFIELD_HPP_ +#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERFIELD_HPP_ + +#include +#include +#include + +// #include +// #include +// #include +// #include + +#include "DDSFilterPredicate.hpp" +#include "DDSFilterValue.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +/** + * A DDSFilterValue for fieldname-based expression values. + */ +class DDSFilterField final : public DDSFilterValue +{ + +public: + + /** + * An element on the access path to the final field. + */ + struct FieldAccessor final + { + // TODO. use pos instead, the `array_index` might be used + + + /// Index of the member to access + size_t member_index; + + /// Element index for array / sequence members + size_t array_index; + }; + + /** + * Construct a DDSFilterField. + * + * @param[in] type_id TypeIdentifier representing the primitive data type of the fieldname. + * @param[in] access_path Access path to the field. + * @param[in] data_kind Kind of data the field represents. + */ + DDSFilterField( + const void* type_id, + const std::vector& access_path, + ValueKind data_kind) + : DDSFilterValue(data_kind) + , access_path_(access_path) + // , type_id_(type_id) + { + } + + virtual ~DDSFilterField() = default; + + /** + * This method is used by a DDSFilterPredicate to check if this DDSFilterField can be used. + * + * @return whether this DDSFilterField has a value that can be used on a predicate. + */ + inline bool has_value() const noexcept final + { + return has_value_; + } + + /** + * Instruct this value to reset. + */ + inline void reset() noexcept final + { + has_value_ = false; + } + + /** + * Perform the deserialization of the field represented by this DDSFilterField. + * Will notify the predicates where this DDSFilterField is being used. + * + * @param[in] data The dynamic representation of the payload being filtered. + * + * @return Whether the deserialization process succeeded. + * + * @post Method @c has_value returns true. + */ + inline bool set_value( + const void * data_value) + { + return set_value(data_value, 0); + } + + /** + * Perform the deserialization of a specific step of the access path. + * + * @param[in] data The dynamic representation of the step being processed. + * @param[in] n The step on the access path being processed. + * + * @return Whether the deserialization process succeeded. + * + * @post Method @c has_value returns true. + */ + bool set_value( + const void * data_value, + size_t n); + +protected: + + inline void add_parent( + DDSFilterPredicate* parent) final + { + assert(nullptr != parent); + parents_.emplace(parent); + } + +private: + + bool set_value( + const void * data_value, + int member_id); + + bool has_value_ = false; + std::vector access_path_; + const void* type_id_ = nullptr; + std::unordered_set parents_; +}; + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common + +#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERFIELD_HPP_ diff --git a/common_content_filter/src/DDSFilterGrammar.hpp b/common_content_filter/src/DDSFilterGrammar.hpp new file mode 100644 index 0000000..d745313 --- /dev/null +++ b/common_content_filter/src/DDSFilterGrammar.hpp @@ -0,0 +1,122 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterGrammar.hpp + */ + +#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERGRAMMAR_HPP_ +#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERGRAMMAR_HPP_ + +#include "pegtl.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +using namespace tao::TAO_PEGTL_NAMESPACE; + +// *INDENT-OFF* Allow curly braces on the same line to improve grammar readability + +// Some basic constructs +struct sign : one< '+', '-'> {}; +struct integer : plus< digit > {}; + +// FIELDNAME +struct dot_op : one< '.' > {}; +struct index_part : seq< one<'['>, integer, one<']'> > {}; +struct fieldname_part : seq< identifier, opt< index_part > > {}; +struct fieldname : list {}; + +// CHARVALUE, STRING, ENUMERATEDVALUE +struct open_quote : one< '`', '\'' > {}; +struct close_quote : one< '\'' > {}; +struct char_value : seq< open_quote, any, close_quote > {}; +struct string_content : star< not_one< '\'', '\r', '\n'> > {}; +struct string_value : seq< open_quote, string_content, close_quote > {}; + +// BOOLEANVALUE +struct false_value : pad< sor< TAO_PEGTL_KEYWORD("FALSE"), TAO_PEGTL_KEYWORD("false") >, space > {}; +struct true_value : pad< sor< TAO_PEGTL_KEYWORD("TRUE"), TAO_PEGTL_KEYWORD("true") >, space > {}; +struct boolean_value : sor {}; + +// INTEGERVALUE, FLOATVALUE +struct integer_value : seq< opt< sign >, integer > {}; +struct fractional : seq< dot_op, integer > {}; +struct exponent : seq< one< 'e', 'E' >, integer_value > {}; +struct float_value : seq < opt< sign >, integer, sor < exponent, seq< fractional, opt< exponent > > > > {}; +struct hex_value : seq< opt< sign >, one< '0' >, one< 'x', 'X' >, plus< xdigit > > {}; + +// PARAMETER +struct parameter_value : seq< one< '%' >, digit, opt< digit > > {}; + +// Keyword based operators +struct and_op : pad< sor< TAO_PEGTL_KEYWORD("AND"), TAO_PEGTL_KEYWORD("and") >, space > {}; +struct or_op : pad< sor< TAO_PEGTL_KEYWORD("OR"), TAO_PEGTL_KEYWORD("or") >, space> {}; +struct not_op : pad< sor< TAO_PEGTL_KEYWORD("NOT"), TAO_PEGTL_KEYWORD("not") >, space> {}; +struct between_op : pad< sor< TAO_PEGTL_KEYWORD("BETWEEN"), TAO_PEGTL_KEYWORD("between") >, space> {}; +struct not_between_op : pad< sor< TAO_PEGTL_KEYWORD("NOT BETWEEN"), TAO_PEGTL_KEYWORD("not between") >, space> {}; + +// RelOp +struct eq_op : pad< one<'='>, space> {}; +struct gt_op : pad< one<'>'>, space> {}; +struct ge_op : pad< TAO_PEGTL_KEYWORD(">="), space> {}; +struct lt_op : pad< one<'<'>, space> {}; +struct le_op : pad< TAO_PEGTL_KEYWORD("<="), space> {}; +struct ne_op : pad< sor< TAO_PEGTL_KEYWORD("<>"), TAO_PEGTL_KEYWORD("!=") >, space> {}; +struct like_op : pad< sor< TAO_PEGTL_KEYWORD("LIKE"), TAO_PEGTL_KEYWORD("like") >, space> {}; +struct match_op : pad< sor< TAO_PEGTL_KEYWORD("MATCH"), TAO_PEGTL_KEYWORD("match") >, space> {}; +struct rel_op : sor< match_op, like_op, ne_op, le_op, ge_op, lt_op, gt_op, eq_op > {}; + +// Parameter, Range +struct Literal : sor< boolean_value, float_value, hex_value, integer_value, char_value, string_value > {}; +struct Parameter : sor< Literal, parameter_value > {}; +struct Range : seq< Parameter, and_op, Parameter > {}; + +// Predicates +struct BetweenPredicate : seq< fieldname, sor< not_between_op, between_op >, Range > {}; +struct ComparisonPredicate : sor< + seq< Parameter, rel_op, fieldname >, + seq< fieldname, rel_op, Parameter >, + seq< fieldname, rel_op, fieldname > + > {}; +struct Predicate : sor< ComparisonPredicate, BetweenPredicate > {}; + +// Brackets +struct open_bracket : seq< one< '(' >, star< space > > {}; +struct close_bracket : seq< star< space >, one< ')' > > {}; + +// Condition, FilterExpression +struct Condition; +struct ConditionList : list_must< Condition, sor< and_op, or_op > > {}; +struct Condition : sor< + seq< open_bracket, ConditionList, close_bracket >, + seq< not_op, ConditionList >, + Predicate + > {}; +struct FilterExpression : ConditionList {}; + +// Main grammar +struct FilterExpressionGrammar : must< FilterExpression, tao::TAO_PEGTL_NAMESPACE::eof > {}; +struct LiteralGrammar : must< Literal, tao::TAO_PEGTL_NAMESPACE::eof > {}; + +// *INDENT-ON* + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common + +#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERGRAMMAR_HPP_ diff --git a/common_content_filter/src/DDSFilterParameter.cpp b/common_content_filter/src/DDSFilterParameter.cpp new file mode 100644 index 0000000..3829721 --- /dev/null +++ b/common_content_filter/src/DDSFilterParameter.cpp @@ -0,0 +1,46 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterParameter.cpp + */ + +#include "DDSFilterParameter.hpp" + +#include "DDSFilterExpressionParser.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +bool DDSFilterParameter::set_value( + const char* parameter) +{ + auto node = parser::parse_literal_value(parameter); + if (!node) + { + return false; + } + + copy_from(*node->left().value, false); + value_has_changed(); + + return true; +} + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common diff --git a/common_content_filter/src/DDSFilterParameter.hpp b/common_content_filter/src/DDSFilterParameter.hpp new file mode 100644 index 0000000..8c4bf32 --- /dev/null +++ b/common_content_filter/src/DDSFilterParameter.hpp @@ -0,0 +1,55 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterParameter.hpp + */ + +#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPARAMETER_HPP_ +#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPARAMETER_HPP_ + +#include "DDSFilterValue.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +/** + * A DDSFilterValue for expression parameters (i.e. %nn). + */ +class DDSFilterParameter final : public DDSFilterValue +{ + +public: + + virtual ~DDSFilterParameter() = default; + + /** + * Sets the value of this DDSFilterParameter given from an input string. + * + * @param[in] parameter The string from which to set the value. + * + * @return whether the parsing of the string correspond to a valid literal value. + */ + bool set_value( + const char* parameter); +}; + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common + +#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPARAMETER_HPP_ diff --git a/common_content_filter/src/DDSFilterParseNode.hpp b/common_content_filter/src/DDSFilterParseNode.hpp new file mode 100644 index 0000000..be648b2 --- /dev/null +++ b/common_content_filter/src/DDSFilterParseNode.hpp @@ -0,0 +1,71 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterParseNode.hpp + */ + +#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPARSENODE_HPP_ +#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPARSENODE_HPP_ + +#include +#include + +// #include + +#include "pegtl/contrib/parse_tree.hpp" + +#include "DDSFilterField.hpp" +#include "DDSFilterValue.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { +namespace parser { + +using namespace tao::TAO_PEGTL_NAMESPACE; + +struct ParseNode : parse_tree::basic_node< ParseNode > +{ + // When the node is a literal value, it will hold a pointer to it + std::unique_ptr value; + + // When the node is a fieldname, it will hold the access path to the field, the data kind, and the type id + std::vector field_access_path; + DDSFilterValue::ValueKind field_kind = DDSFilterValue::ValueKind::STRING; + const void* type_id = nullptr; + + // When the node is a parameter, it will hold the parameter index + int32_t parameter_index = 0; + + const ParseNode& left() const + { + return *(children[0]); + } + + const ParseNode& right() const + { + return *(children[1]); + } + +}; + +} // namespace parser +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common + +#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPARSENODE_HPP_ diff --git a/common_content_filter/src/DDSFilterPredicate.cpp b/common_content_filter/src/DDSFilterPredicate.cpp new file mode 100644 index 0000000..2eeadef --- /dev/null +++ b/common_content_filter/src/DDSFilterPredicate.cpp @@ -0,0 +1,105 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterPredicate.cpp + */ + +#include "DDSFilterPredicate.hpp" + +#include +#include + +#include "DDSFilterValue.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +DDSFilterPredicate::DDSFilterPredicate( + OperationKind op, + const std::shared_ptr& left, + const std::shared_ptr& right) + : op_(op) + , left_(left) + , right_(right) +{ + assert(left_); + assert(right_); + + left_->add_parent(this); + right_->add_parent(this); + + if (OperationKind::LIKE == op_) + { + right_->as_regular_expression(true); + } + else if (OperationKind::MATCH == op_) + { + right_->as_regular_expression(false); + } +} + +void DDSFilterPredicate::value_has_changed() +{ + if (left_->has_value() && right_->has_value()) + { + switch (op_) + { + case OperationKind::EQUAL: + set_result(*left_ == *right_); + break; + + case OperationKind::NOT_EQUAL: + set_result(*left_ != *right_); + break; + + case OperationKind::LESS_THAN: + set_result(*left_ < *right_); + break; + + case OperationKind::LESS_EQUAL: + set_result(*left_ <= *right_); + break; + + case OperationKind::GREATER_THAN: + set_result(*left_ > *right_); + break; + + case OperationKind::GREATER_EQUAL: + set_result(*left_ >= *right_); + break; + + case OperationKind::LIKE: + case OperationKind::MATCH: + set_result(left_->is_like(*right_)); + break; + + default: + assert(false); + } + } +} + +void DDSFilterPredicate::propagate_reset() noexcept +{ + left_->reset(); + right_->reset(); +} + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common diff --git a/common_content_filter/src/DDSFilterPredicate.hpp b/common_content_filter/src/DDSFilterPredicate.hpp new file mode 100644 index 0000000..52e483a --- /dev/null +++ b/common_content_filter/src/DDSFilterPredicate.hpp @@ -0,0 +1,97 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterPredicate.hpp + */ + +#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPREDICATE_HPP_ +#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPREDICATE_HPP_ + +#include + +#include "DDSFilterCondition.hpp" +#include "DDSFilterValue.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +/** + * A DDSFilterCondition for binary predicates (i.e. ). + */ +class DDSFilterPredicate final : public DDSFilterCondition +{ + +public: + + /** + * Possible kinds of binary operations + */ + enum class OperationKind : uint8_t + { + EQUAL, ///< left = right + NOT_EQUAL, ///< left <> right + LESS_THAN, ///< left < right + LESS_EQUAL, ///< left <= right + GREATER_THAN, ///< left > right + GREATER_EQUAL, ///< left >= right + LIKE, ///< left LIKE right + MATCH ///< left MATCH right + }; + + /** + * Construct a DDSFilterPredicate. + * + * @param[in] op Operation to perform. + * @param[in] left Left operand. + * @param[in] right Right operand. + */ + DDSFilterPredicate( + OperationKind op, + const std::shared_ptr& left, + const std::shared_ptr& right); + + virtual ~DDSFilterPredicate() = default; + + /** + * Called when the value of an operand is changed. + */ + void value_has_changed(); + +protected: + + void propagate_reset() noexcept final; + + void child_has_changed( + const DDSFilterCondition& child) noexcept final + { + static_cast(child); + } + +private: + + OperationKind op_; + std::shared_ptr left_; + std::shared_ptr right_; + +}; + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common + +#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPREDICATE_HPP_ diff --git a/common_content_filter/src/DDSFilterValue.cpp b/common_content_filter/src/DDSFilterValue.cpp new file mode 100644 index 0000000..ca77b92 --- /dev/null +++ b/common_content_filter/src/DDSFilterValue.cpp @@ -0,0 +1,366 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterValue.cpp + */ + +#include "DDSFilterValue.hpp" + +#include +#include +#include +#include + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +template +int compare_values( + T lvalue, + T rvalue) +{ + return lvalue < rvalue ? -1 : + lvalue > rvalue ? 1 : 0; +} + +/** + * Check if a value is negative. + * Only used during promotion to UNSIGNED_INTEGER. + */ +static bool is_negative( + const DDSFilterValue& value) +{ + switch (value.kind) + { + case DDSFilterValue::ValueKind::BOOLEAN: + return false; + + case DDSFilterValue::ValueKind::ENUM: + case DDSFilterValue::ValueKind::SIGNED_INTEGER: + return value.signed_integer_value < 0; + + // The rest of the types shall never be promoted to UNSIGNED_INTEGER + default: + assert(false); + } + + return false; +} + +/** + * Performs promotion to SIGNED_INTEGER + */ +static int64_t to_signed_integer( + const DDSFilterValue& value) +{ + switch (value.kind) + { + case DDSFilterValue::ValueKind::BOOLEAN: + return value.boolean_value ? 1 : 0; + + case DDSFilterValue::ValueKind::ENUM: + return value.signed_integer_value; + + // The rest of the types shall never be promoted to SIGNED_INTEGER + default: + assert(false); + } + + return 0; +} + +/** + * Performs promotion to UNSIGNED_INTEGER + */ +static uint64_t to_unsigned_integer( + const DDSFilterValue& value) +{ + switch (value.kind) + { + case DDSFilterValue::ValueKind::BOOLEAN: + return value.boolean_value ? 1 : 0; + + case DDSFilterValue::ValueKind::ENUM: + case DDSFilterValue::ValueKind::SIGNED_INTEGER: + return static_cast(value.signed_integer_value); + + // The rest of the types shall never be promoted to UNSIGNED_INTEGER + default: + assert(false); + } + + return 0; +} + +/** + * Performs promotion to FLOAT + */ +static long double to_float( + const DDSFilterValue& value) +{ + switch (value.kind) + { + case DDSFilterValue::ValueKind::ENUM: + case DDSFilterValue::ValueKind::SIGNED_INTEGER: + return static_cast(value.signed_integer_value); + + case DDSFilterValue::ValueKind::UNSIGNED_INTEGER: + return static_cast(value.unsigned_integer_value); + + case DDSFilterValue::ValueKind::FLOAT_CONST: + case DDSFilterValue::ValueKind::FLOAT_FIELD: + case DDSFilterValue::ValueKind::DOUBLE_FIELD: + case DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD: + return value.float_value; + + // The rest of the types shall never be promoted to FLOAT + default: + assert(false); + } + + return 0; +} + +/** + * Performs promotion to STRING + */ +static void to_string_value( + const DDSFilterValue& in, + std::string& out) +{ + assert(DDSFilterValue::ValueKind::CHAR == in.kind); + out.assign(&in.char_value, 1); +} + +void DDSFilterValue::copy_from( + const DDSFilterValue& other, + bool copy_regular_expression) noexcept +{ + kind = other.kind; + switch (kind) + { + case ValueKind::BOOLEAN: + boolean_value = other.boolean_value; + break; + + case ValueKind::CHAR: + char_value = other.char_value; + break; + + case ValueKind::ENUM: + case ValueKind::SIGNED_INTEGER: + signed_integer_value = other.signed_integer_value; + break; + + case ValueKind::UNSIGNED_INTEGER: + unsigned_integer_value = other.unsigned_integer_value; + break; + + case ValueKind::FLOAT_CONST: + case ValueKind::FLOAT_FIELD: + case ValueKind::DOUBLE_FIELD: + case ValueKind::LONG_DOUBLE_FIELD: + float_value = other.float_value; + break; + + case ValueKind::STRING: + memcpy(string_value, other.string_value, sizeof(string_value)); + break; + + default: + assert(false); + } + + if (copy_regular_expression) + { + regular_expr_kind_ = other.regular_expr_kind_; + if (has_value()) + { + value_has_changed(); + } + } +} + +int DDSFilterValue::compare( + const DDSFilterValue& lhs, + const DDSFilterValue& rhs) noexcept +{ + if (lhs.kind == rhs.kind) + { + switch (lhs.kind) + { + case ValueKind::BOOLEAN: + return lhs.boolean_value - rhs.boolean_value; + + case ValueKind::CHAR: + return lhs.char_value - rhs.char_value; + + case ValueKind::SIGNED_INTEGER: + case ValueKind::ENUM: + return compare_values(lhs.signed_integer_value, rhs.signed_integer_value); + + case ValueKind::UNSIGNED_INTEGER: + return compare_values(lhs.unsigned_integer_value, rhs.unsigned_integer_value); + + case ValueKind::FLOAT_FIELD: + return compare_values(static_cast(lhs.float_value), static_cast(rhs.float_value)); + + case ValueKind::DOUBLE_FIELD: + return compare_values(static_cast(lhs.float_value), static_cast(rhs.float_value)); + + case ValueKind::LONG_DOUBLE_FIELD: + return compare_values(lhs.float_value, rhs.float_value); + + case ValueKind::STRING: + return std::strcmp(lhs.string_value, rhs.string_value); + + // As the grammar does not allow constant vs constant comparisons, FLOAT_CONST should never reach here + case ValueKind::FLOAT_CONST: + default: + assert(false); + } + } + else if (lhs.kind < rhs.kind) + { + // We want to always promote rhs + return -compare(rhs, lhs); + } + else + { + /* Type promotion rules are enforced during the construction of the expression tree on + * DDSFilterFactory. For the types on which promotion is supported, a corresponding to_xxx method exists + * that will assert if an invalid promotion is performed. + */ + switch (lhs.kind) + { + case ValueKind::ENUM: + case ValueKind::SIGNED_INTEGER: + { + return compare_values(lhs.signed_integer_value, to_signed_integer(rhs)); + } + + case ValueKind::UNSIGNED_INTEGER: + return is_negative(rhs) ? 1 : compare_values(lhs.unsigned_integer_value, to_unsigned_integer(rhs)); + + case ValueKind::FLOAT_CONST: + case ValueKind::FLOAT_FIELD: + return compare_values(static_cast(lhs.float_value), static_cast(to_float(rhs))); + + case ValueKind::DOUBLE_FIELD: + return compare_values(static_cast(lhs.float_value), static_cast(to_float(rhs))); + + case ValueKind::LONG_DOUBLE_FIELD: + return compare_values(lhs.float_value, to_float(rhs)); + + case ValueKind::STRING: + { + std::string rvalue; + to_string_value(rhs, rvalue); + return std::strcmp(lhs.string_value, rvalue.c_str()); + } + + // Promotion to boolean or char are not allowed. + case ValueKind::BOOLEAN: + case ValueKind::CHAR: + default: + assert(false); + break; + } + } + + return 0; +} + +void DDSFilterValue::as_regular_expression( + bool is_like_operand) +{ + regular_expr_kind_ = is_like_operand ? RegExpKind::LIKE : RegExpKind::MATCH; + if (has_value()) + { + value_has_changed(); + } +} + +void DDSFilterValue::value_has_changed() +{ + if (RegExpKind::NONE != regular_expr_kind_) + { + std::string expr; + + switch (kind) + { + case ValueKind::CHAR: + expr = char_value; + break; + + case ValueKind::STRING: + expr = string_value; + break; + + default: + assert(false); + } + + if (RegExpKind::LIKE == regular_expr_kind_) + { + expr = std::regex_replace(expr, std::regex("\\*"), ".*"); + expr = std::regex_replace(expr, std::regex("\\?"), "."); + expr = std::regex_replace(expr, std::regex("%"), ".*"); + expr = std::regex_replace(expr, std::regex("_"), "."); + } + + regular_expr_.reset(new std::regex(expr)); + } +} + +bool DDSFilterValue::is_like( + const DDSFilterValue& other) const noexcept +{ + assert(other.regular_expr_); + + std::string char_string_value; + + switch (kind) + { + case ValueKind::CHAR: + assert(ValueKind::STRING == other.kind); + to_string_value(*this, char_string_value); + return std::regex_match(char_string_value.c_str(), *other.regular_expr_); + + case ValueKind::STRING: + switch (other.kind) + { + case ValueKind::CHAR: + case ValueKind::STRING: + return std::regex_match(string_value, *other.regular_expr_); + + default: + assert(false); + } + break; + + default: + assert(false); + } + + return false; +} + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common diff --git a/common_content_filter/src/DDSFilterValue.hpp b/common_content_filter/src/DDSFilterValue.hpp new file mode 100644 index 0000000..584af10 --- /dev/null +++ b/common_content_filter/src/DDSFilterValue.hpp @@ -0,0 +1,233 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file DDSFilterValue.hpp + */ + +#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERVALUE_HPP_ +#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERVALUE_HPP_ + +#include +#include + +// #include + +namespace eprosima_common { +namespace fastdds { +namespace dds { +namespace DDSSQLFilter { + +class DDSFilterPredicate; + +/** + * Represents a value (either constant, parameter or fieldname) on a filter expression. + */ +class DDSFilterValue +{ + +public: + + // DDSFilterPredicate needs to call protected method add_parent + friend class DDSFilterPredicate; + + /** + * The high-level kind of a DDSFilterValue. + * Please note that the constants here should follow the promotion order. + */ + enum class ValueKind + { + BOOLEAN, ///< Value is a bool + ENUM, ///< Value is an int32_t with the value of an enumeration + SIGNED_INTEGER, ///< Value is a int16_t, int32_t, or int64_t + UNSIGNED_INTEGER, ///< Value is a uint8_t, uint16_t, uint32_t, or uint64_t + FLOAT_CONST, ///< Value is a long double constant + FLOAT_FIELD, ///< Value is a float field + DOUBLE_FIELD, ///< Value is a double field + LONG_DOUBLE_FIELD, ///< Value is a long double field + CHAR, ///< Value is a char + STRING ///< Value is a string + }; + + /// The kind of value held by this DDSFilterValue + ValueKind kind; + + union + { + bool boolean_value; ///< Value when kind == BOOL + char char_value; ///< Value when kind == CHAR + int64_t signed_integer_value; ///< Value when kind == SIGNED_INTEGER / ENUM + uint64_t unsigned_integer_value; ///< Value when kind == UNSIGNED_INTEGER + long double float_value; ///< Value when kind == FLOAT + char string_value[255]; ///< Value when kind == STRING + }; + + /** + * Default constructor. + * Constructs an empty string DDSFilterValue + */ + DDSFilterValue() noexcept + : kind(ValueKind::STRING) + , string_value() + { + } + + /** + * Explicit kind constructor. + * Constructs a zero-valued, specific kind DDSFilterValue. + * + * @param[in] kind The kind with which to construct the DDSFilterValue. + */ + explicit DDSFilterValue( + ValueKind data_kind) noexcept + : kind(data_kind) + , string_value() + { + } + + // *INDENT-OFF* + DDSFilterValue(const DDSFilterValue&) = delete; + DDSFilterValue& operator=(const DDSFilterValue&) = delete; + DDSFilterValue(DDSFilterValue&&) = default; + DDSFilterValue& operator=(DDSFilterValue&&) = default; + // *INDENT-ON* + + virtual ~DDSFilterValue() = default; + + /** + * Copy the state of this object from another one. + * + * @param [in] other The DDSFilterValue from where to copy the state. + * @param [in] copy_regular_expression Whether the regular expression state should be copied or not + */ + void copy_from( + const DDSFilterValue& other, + bool copy_regular_expression) noexcept; + + /** + * This method is used by a DDSFilterPredicate to check if this DDSFilterValue can be used. + * Constants and parameters will always have a value, but fieldname-based values can only be + * used after deserialization. + * + * @return whether this DDSFilterValue has a value that can be used on a predicate. + */ + virtual bool has_value() const noexcept + { + return true; + } + + /** + * Instruct this value to reset. + * Will only have effect on fieldname-based values. + */ + virtual void reset() noexcept + { + } + + /** + * Mark that this value should be handled as a regular expression. + * + * @param [in] is_like_operand Whether this value is used on a LIKE or MATCH operation. + */ + void as_regular_expression( + bool is_like_operand); + + /** + * @name Comparison operations + * Methods implementing the comparison operators of binary predicates. + * Should only be called against a DDSFilterValue of a compatible kind, + * according to the type promotion restrictions. + */ + ///@{ + inline bool operator ==( + const DDSFilterValue& other) const noexcept + { + return compare(*this, other) == 0; + } + + inline bool operator !=( + const DDSFilterValue& other) const noexcept + { + return compare(*this, other) != 0; + } + + inline bool operator <( + const DDSFilterValue& other) const noexcept + { + return compare(*this, other) < 0; + } + + inline bool operator <=( + const DDSFilterValue& other) const noexcept + { + return compare(*this, other) <= 0; + } + + inline bool operator >( + const DDSFilterValue& other) const noexcept + { + return compare(*this, other) > 0; + } + + inline bool operator >=( + const DDSFilterValue& other) const noexcept + { + return compare(*this, other) >= 0; + } + + bool is_like( + const DDSFilterValue& other) const noexcept; + ///@} + +protected: + + /** + * Called when this DDSFilterValue is used on a DDSFilterPredicate. + * + * @param parent [in] The DDSFilterPredicate referencing this DDSFilterValue. + */ + virtual void add_parent( + DDSFilterPredicate* parent) + { + static_cast(parent); + } + + /** + * Called when the value of this DDSFilterValue has changed. + * Will regenerate the regular expression object if as_regular_expression was called. + */ + void value_has_changed(); + +private: + + enum class RegExpKind + { + NONE, LIKE, MATCH + }; + + RegExpKind regular_expr_kind_ = RegExpKind::NONE; + std::unique_ptr regular_expr_; + + static int compare( + const DDSFilterValue& lhs, + const DDSFilterValue& rhs) noexcept; + +}; + +} // namespace DDSSQLFilter +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common + +#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERVALUE_HPP_ diff --git a/common_content_filter/src/IContentFilter.hpp b/common_content_filter/src/IContentFilter.hpp new file mode 100644 index 0000000..f99c62d --- /dev/null +++ b/common_content_filter/src/IContentFilter.hpp @@ -0,0 +1,76 @@ +// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file IContentFilter.hpp + */ + +#ifndef _FASTDDS_DDS_TOPIC_ICONTENTFILTER_HPP_ +#define _FASTDDS_DDS_TOPIC_ICONTENTFILTER_HPP_ + +// #include + +// #include + +// #include +// #include +// #include + +// #include +// #include + +namespace eprosima_common { +namespace fastdds { +namespace dds { + +/** + * The interface that content filter objects should implement. + */ +struct IContentFilter +{ + // using SerializedPayload = eprosima_common::fastrtps::rtps::SerializedPayload_t; + // using GUID_t = fastrtps::rtps::GUID_t; + + /** + * Selected information from the cache change that is passed to the content filter object on + * payload evaluation. + */ + // struct FilterSampleInfo + // { + // using SampleIdentity = eprosima_common::fastrtps::rtps::SampleIdentity; + + // /// Identity of the sample being filtered. + // SampleIdentity sample_identity; + // /// Identity of a sample related to the one being filtered. + // SampleIdentity related_sample_identity; + // }; + + /** + * Evaluate if a serialized payload should be accepted by certain reader. + * + * @param [in] payload The serialized payload of the sample being evaluated. + * @param [in] sample_info The accompanying sample information. + * @param [in] reader_guid The GUID of the reader for which the filter is being evaluated. + * + * @return whether the sample should be accepted for the specified reader. + */ + virtual bool evaluate( + const void * payload) const = 0; +}; + +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common + +#endif // _FASTDDS_DDS_TOPIC_ICONTENTFILTER_HPP_ diff --git a/common_content_filter/src/IContentFilterFactory.hpp b/common_content_filter/src/IContentFilterFactory.hpp new file mode 100644 index 0000000..1951bf2 --- /dev/null +++ b/common_content_filter/src/IContentFilterFactory.hpp @@ -0,0 +1,106 @@ +// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file IContentFilter.hpp + */ + +#ifndef _FASTDDS_DDS_TOPIC_ICONTENTFILTERFACTORY_HPP_ +#define _FASTDDS_DDS_TOPIC_ICONTENTFILTERFACTORY_HPP_ + +// #include + +// #include +// #include +// #include + +// #include + +#include +#include + +#include "IContentFilter.hpp" + +namespace eprosima_common { +namespace fastdds { +namespace dds { + +/** + * The interface that a factory of IContentFilter objects should implement. + */ +struct IContentFilterFactory +{ + enum ReturnCode_t { + RETCODE_OK, + RETCODE_BAD_PARAMETER, + RETCODE_UNSUPPORTED, + }; + + using ParameterSeq = std::vector; + // using TypeDescriptor = eprosima_common::fastrtps::types::TypeDescriptor; + + /** + * Create or update an IContentFilter instance. + * + * @param [in] filter_class_name Filter class name for which the factory is being called. + * Allows using the same factory for different filter classes. + * @param [in] type_name Type name of the topic being filtered. + * @param [in] data_type Type support object of the topic being filtered. + * @param [in] filter_expression Content filter expression. + * May be nullptr when updating the parameters of a filter instance. + * @param [in] filter_parameters Values to set for the filter parameters (%n on the filter expression). + * @param [in, out] filter_instance When a filter is being created, it will be nullptr on input, + * and will have the pointer to the created filter instance on output. + * The caller takes ownership of the filter instance returned. + * When a filter is being updated, it will have a previously returned pointer + * on input. The method takes ownership of the filter instance during its + * execution, and can update the filter instance or even destroy it and + * create a new one. + * The caller takes ownership of the filter instance returned. + * It should always have a valid pointer upon return. + * The original state of the filter instance should be preserved when an + * error is returned. + * + * @return A return code indicating the result of the operation. + */ + virtual ReturnCode_t create_content_filter( + const char* filter_class_name, + const char* type_name, + const void* data_type, + const char* filter_expression, + const ParameterSeq& filter_parameters, + IContentFilter*& filter_instance) = 0; + + /** + * Delete an IContentFilter instance. + * + * @param [in] filter_class_name Filter class name for which the factory is being called. + * Allows using the same factory for different filter classes. + * @param [in] filter_instance A pointer to a filter instance previously returned by create_content_filter. + * The factory takes ownership of the filter instance, and can decide to destroy + * it or keep it for future use. + * In case of deletion, note this pointer must be downcasted to the derived class. + * + * @return A return code indicating the result of the operation. + */ + virtual ReturnCode_t delete_content_filter( + const char* filter_class_name, + IContentFilter* filter_instance) = 0; +}; + +} // namespace dds +} // namespace fastdds +} // namespace eprosima_common + +#endif // _FASTDDS_DDS_TOPIC_ICONTENTFILTERFACTORY_HPP_ diff --git a/common_content_filter/src/Log.hpp b/common_content_filter/src/Log.hpp new file mode 100644 index 0000000..e0e8549 --- /dev/null +++ b/common_content_filter/src/Log.hpp @@ -0,0 +1,14 @@ + +// TODO. use rcutil log instead +#include + +#define common_content_filter_log_(cat, msg) \ + { \ + std::stringstream log_ss_tmp__; \ + log_ss_tmp__ << msg; \ + std::cout << "[" << #cat << "] " << log_ss_tmp__.str() << std::endl; \ + } + +#define logInfo common_content_filter_log_ +#define logWarning common_content_filter_log_ +#define logError common_content_filter_log_ diff --git a/common_content_filter/src/ObjectPool.hpp b/common_content_filter/src/ObjectPool.hpp new file mode 100644 index 0000000..9ed47a3 --- /dev/null +++ b/common_content_filter/src/ObjectPool.hpp @@ -0,0 +1,100 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file ObjectPool.hpp + * + */ + +#ifndef FASTRTPS_UTILS_COLLECTIONS_OBJECTPOOL_HPP_ +#define FASTRTPS_UTILS_COLLECTIONS_OBJECTPOOL_HPP_ + +#include +#include +#include + +namespace eprosima_common { +namespace fastdds { + +/** + * A generic pool of objects. + * + * This template class holds a circular queue of fixed size. Pushing a new element to a full queue + * will result in an error. + * + * @tparam _Ty Element type. + * @tparam _Alloc Allocator to use on the underlying collection type, defaults to std::allocator<_Ty>. + * @tparam _Collection Underlying collection type, defaults to std::vector<_Ty, _Alloc> + * + * @ingroup UTILITIES_MODULE + */ +template < + typename _Ty, + typename _Alloc = std::allocator<_Ty>, + typename _Collection = std::vector<_Ty, _Alloc>> +struct ObjectPool final +{ + using allocator_type = _Alloc; + using value_type = _Ty; + + /** + * Construct an ObjectPool. + */ + ObjectPool( + const allocator_type& alloc = allocator_type()) + : collection_(alloc) + { + } + + const _Collection& collection() const noexcept + { + return collection_; + } + + _Collection& collection() noexcept + { + return collection_; + } + + template + value_type get( + _DefaultGetter _Default) + { + if (collection_.empty()) + { + return _Default(); + } + + value_type ret = collection_.back(); + collection_.pop_back(); + return ret; + } + + template + void put( + _Valty&&... _Val) + { + collection_.emplace_back(std::forward<_Valty>(_Val)...); + } + +private: + + _Collection collection_; + +}; + +} // namespace fastdds +} // namespace eprosima_common + +#endif /* FASTRTPS_UTILS_COLLECTIONS_OBJECTPOOL_HPP_ */ diff --git a/common_content_filter/src/test.cpp b/common_content_filter/src/test.cpp index 26f2062..f9d4097 100644 --- a/common_content_filter/src/test.cpp +++ b/common_content_filter/src/test.cpp @@ -14,40 +14,102 @@ #include "common_content_filter/test.h" +#include "rmw/subscription_content_filter_options.h" + #include // for printf +#include // for abort + +#include + +#include "DDSFilterGrammar.hpp" +#include "DDSFilterExpressionParser.hpp" +#include "DDSFilterFactory.hpp" +#include "Log.hpp" + + + +using namespace eprosima_common::fastdds::dds; +using namespace eprosima_common::fastdds::dds::DDSSQLFilter; +using namespace eprosima_common::fastdds::dds::DDSSQLFilter::parser; + namespace common_content_filter { -const int MAGIC = 0x333646; // cft +const int MAGIC = 0x333644; // cft void test_func_cpp() { printf("test_func_cpp\n"); -} -class ContentFilterFactory { -public: - ContentFilterFactory() - : magic_(MAGIC) {}; - ~ContentFilterFactory() {}; + struct sign s; + printf("test_func_cpp, %p\n", (void*)&s); + logError(DDSSQLFILTER, "ERROR " << MAGIC); - int magic() { - return magic_; - } - void test() { - printf("to call test in ContentFilterFactory : %p\n", (void*)this); - } + std::string filter_expression = "id > 0"; + // std::string filter_expression = "id > 0 or a.b = 'def' and name=%0"; + // std::string filter_expression = "id=%0"; + // std::string filter_expression = "name[0]=%0"; -private: - int magic_; -}; + logInfo(DDSSQLFILTER, "filter_expression: " << filter_expression); + + // std::unique_ptr node = parse_filter_expression(filter_expression.c_str(), nullptr); + + DDSFilterFactory factory; + IContentFilter * filter_instance; + + DDSFilterFactory::ReturnCode_t ret = factory.create_content_filter( + "filter_class_name", + "type_name", + nullptr, + filter_expression.c_str(), + {"'test'"}, + filter_instance); + + logInfo(DDSSQLFILTER, "factory.create_content_filter ret: " << ret); + + + + ret = factory.delete_content_filter( + "filter_class_name", + filter_instance); + + logInfo(DDSSQLFILTER, "factory.delete_content_filter ret: " << ret); + +} + +// class ContentFilterFactory { +// public: +// ContentFilterFactory() +// : magic_(MAGIC) +// { +// printf("ContentFilterFactory ctor : %p\n", (void*)this); +// } +// ~ContentFilterFactory() { +// printf("ContentFilterFactory dtor : %p\n", (void*)this); +// } + +// int magic() { +// return magic_; +// } +// void test() { +// printf("to call test in ContentFilterFactory : %p\n", (void*)this); +// } + +// private: +// int magic_; +// }; class ContentFilter { public: ContentFilter() - : magic_(MAGIC) {}; - ~ContentFilter() {}; + : magic_(MAGIC) + { + printf("ContentFilter ctor : %p\n", (void*)this); + }; + ~ContentFilter() { + printf("ContentFilter dtor : %p\n", (void*)this); + }; int magic() { return magic_; @@ -74,43 +136,71 @@ test_func_c() { } -void * -create_common_content_filter_factory() { - common_content_filter::ContentFilterFactory * content_filter_factory = - new common_content_filter::ContentFilterFactory; - return content_filter_factory; +// TODO. deprecated, factory not exported outside. use a static instance in this library. +eprosima_common::fastdds::dds::DDSSQLFilter::DDSFilterFactory * +get_common_content_filter_factory() { + // TODO. only one factory or one context one factory + static eprosima_common::fastdds::dds::DDSSQLFilter::DDSFilterFactory content_filter_factory; + return &content_filter_factory; } +void * +create_common_content_filter( + const rosidl_message_type_support_t * type_support, + rmw_subscription_content_filter_options_t * options +) { -void -test_common_content_filter_factory(void * instance) { - common_content_filter::ContentFilterFactory * content_filter_factory = - static_cast(instance); - if (!content_filter_factory || content_filter_factory->magic() != common_content_filter::MAGIC ) { - printf("the instance is not valid\n"); - return; + if (!type_support || !options) { + return NULL; } - content_filter_factory->test(); + logInfo(DDSSQLFILTER, "create_common_content_filter options: " << options->filter_expression); + + IContentFilter * filter_instance; + + std::vector expression_parameters; + for (size_t i = 0; i < options->expression_parameters.size; ++i) { + expression_parameters.push_back(options->expression_parameters.data[i]); + } + + DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->create_content_filter( + "DDSSQL", + "type_name", + type_support, + options->filter_expression, + expression_parameters, + filter_instance); + + logInfo(DDSSQLFILTER, "factory.create_content_filter ret: " << ret); + + return filter_instance; } +bool +common_content_filter_evaluate(void * instance, void * ros_data) { + eprosima_common::fastdds::dds::IContentFilter * content_filter = + static_cast(instance); -void * -create_common_content_filter() { - common_content_filter::ContentFilter * content_filter = new common_content_filter::ContentFilter; - return content_filter; + bool ret = content_filter->evaluate(ros_data); + return ret; } void -test_common_content_filter(void * instance) { - common_content_filter::ContentFilter * content_filter = - static_cast(instance); - if (!content_filter || content_filter->magic() != common_content_filter::MAGIC ) { - printf("the instance is not valid\n"); - return; - } +destroy_common_content_filter(void * instance) { + eprosima_common::fastdds::dds::IContentFilter * content_filter = + static_cast(instance); + // if (!content_filter || content_filter->magic() != common_content_filter::MAGIC ) { + // printf("the instance is invalid\n"); + // return; + // } + // delete content_filter; + + DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->delete_content_filter( + "DDSSQL", + content_filter); + + logInfo(DDSSQLFILTER, "factory.delete_content_filter ret: " << ret); - content_filter->test(); } #ifdef __cplusplus diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl.hpp new file mode 100644 index 0000000..e2e5d9e --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl.hpp @@ -0,0 +1,46 @@ +// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#ifndef TAO_PEGTL_HPP +#define TAO_PEGTL_HPP + +#include "pegtl/internal/demangle.hpp" +#include "pegtl/parse.hpp" +#include "pegtl/version.hpp" + +#include "pegtl/ascii.hpp" +#include "pegtl/rules.hpp" +#include "pegtl/utf8.hpp" + +#include "pegtl/argv_input.hpp" +#include "pegtl/buffer_input.hpp" +#include "pegtl/cstream_input.hpp" +#include "pegtl/istream_input.hpp" +#include "pegtl/memory_input.hpp" +#include "pegtl/read_input.hpp" +#include "pegtl/string_input.hpp" + +// This has to be included *after* the above inputs, +// otherwise the amalgamated header will not work! +#include "pegtl/file_input.hpp" + +#include "pegtl/change_action.hpp" +#include "pegtl/change_action_and_state.hpp" +#include "pegtl/change_action_and_states.hpp" +#include "pegtl/change_control.hpp" +#include "pegtl/change_state.hpp" +#include "pegtl/change_states.hpp" + +#include "pegtl/disable_action.hpp" +#include "pegtl/enable_action.hpp" + +#include "pegtl/discard_input.hpp" +#include "pegtl/discard_input_on_failure.hpp" +#include "pegtl/discard_input_on_success.hpp" + +#if defined( __cpp_exceptions ) +#include "pegtl/internal/if_must.hpp" +#endif + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/analyze_cycles.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/analyze_cycles.hpp new file mode 100644 index 0000000..6222b04 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/analyze_cycles.hpp @@ -0,0 +1,135 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_ANALYSIS_ANALYZE_CYCLES_HPP +#define TAO_PEGTL_ANALYSIS_ANALYZE_CYCLES_HPP + +#include + +#include +#include +#include + +#include +#include + +#include "../config.hpp" + +#include "grammar_info.hpp" +#include "insert_guard.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace analysis + { + class analyze_cycles_impl + { + protected: + explicit analyze_cycles_impl( const bool verbose ) noexcept + : m_verbose( verbose ), + m_problems( 0 ) + { + } + + const bool m_verbose; + unsigned m_problems; + grammar_info m_info; + std::set< std::string > m_stack; + std::map< std::string, bool > m_cache; + std::map< std::string, bool > m_results; + + std::map< std::string, rule_info >::const_iterator find( const std::string& name ) const noexcept + { + const auto iter = m_info.map.find( name ); + assert( iter != m_info.map.end() ); + return iter; + } + + bool work( const std::map< std::string, rule_info >::const_iterator& start, const bool accum ) + { + const auto j = m_cache.find( start->first ); + + if( j != m_cache.end() ) { + return j->second; + } + if( const auto g = make_insert_guard( m_stack, start->first ) ) { + switch( start->second.type ) { + case rule_type::any: { + bool a = false; + for( const auto& r : start->second.rules ) { + a = a || work( find( r ), accum || a ); + } + return m_cache[ start->first ] = true; + } + case rule_type::opt: { + bool a = false; + for( const auto& r : start->second.rules ) { + a = a || work( find( r ), accum || a ); + } + return m_cache[ start->first ] = false; + } + case rule_type::seq: { + bool a = false; + for( const auto& r : start->second.rules ) { + a = a || work( find( r ), accum || a ); + } + return m_cache[ start->first ] = a; + } + case rule_type::sor: { + bool a = true; + for( const auto& r : start->second.rules ) { + a = a && work( find( r ), accum ); + } + return m_cache[ start->first ] = a; + } + } + throw std::logic_error( "code should be unreachable: invalid rule_type value" ); // NOLINT, LCOV_EXCL_LINE + } + if( !accum ) { + ++m_problems; + if( m_verbose ) { + std::cout << "problem: cycle without progress detected at rule class " << start->first << std::endl; // LCOV_EXCL_LINE + } + } + return m_cache[ start->first ] = accum; + } + }; + + template< typename Grammar > + class analyze_cycles + : private analyze_cycles_impl + { + public: + explicit analyze_cycles( const bool verbose ) + : analyze_cycles_impl( verbose ) + { + Grammar::analyze_t::template insert< Grammar >( m_info ); + } + + std::size_t problems() + { + for( auto i = m_info.map.begin(); i != m_info.map.end(); ++i ) { + m_results[ i->first ] = work( i, false ); + m_cache.clear(); + } + return m_problems; + } + + template< typename Rule > + bool consumes() const noexcept + { + const auto i = m_results.find( internal::demangle< Rule >() ); + assert( i != m_results.end() ); + return i->second; + } + }; + + } // namespace analysis + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/counted.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/counted.hpp new file mode 100644 index 0000000..6428e18 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/counted.hpp @@ -0,0 +1,31 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_ANALYSIS_COUNTED_HPP +#define TAO_PEGTL_ANALYSIS_COUNTED_HPP + +#include "../config.hpp" + +#include + +#include "generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace analysis + { + template< rule_type Type, std::size_t Count, typename... Rules > + struct counted + : generic< ( Count != 0 ) ? Type : rule_type::opt, Rules... > + { + }; + + } // namespace analysis + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/generic.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/generic.hpp new file mode 100644 index 0000000..dc38b9f --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/generic.hpp @@ -0,0 +1,43 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_ANALYSIS_GENERIC_HPP +#define TAO_PEGTL_ANALYSIS_GENERIC_HPP + +#include "../config.hpp" + +#include "grammar_info.hpp" +#include "rule_type.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace analysis + { + template< rule_type Type, typename... Rules > + struct generic + { + template< typename Name > + static std::string insert( grammar_info& g ) + { + const auto r = g.insert< Name >( Type ); + if( r.second ) { +#ifdef __cpp_fold_expressions + ( r.first->second.rules.push_back( Rules::analyze_t::template insert< Rules >( g ) ), ... ); +#else + using swallow = bool[]; + (void)swallow{ ( r.first->second.rules.push_back( Rules::analyze_t::template insert< Rules >( g ) ), true )..., true }; +#endif + } + return r.first->first; + } + }; + + } // namespace analysis + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/grammar_info.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/grammar_info.hpp new file mode 100644 index 0000000..8c183d9 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/grammar_info.hpp @@ -0,0 +1,40 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_ANALYSIS_GRAMMAR_INFO_HPP +#define TAO_PEGTL_ANALYSIS_GRAMMAR_INFO_HPP + +#include +#include +#include + +#include "../config.hpp" +#include "../internal/demangle.hpp" + +#include "rule_info.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace analysis + { + struct grammar_info + { + using map_t = std::map< std::string, rule_info >; + map_t map; + + template< typename Name > + std::pair< map_t::iterator, bool > insert( const rule_type type ) + { + return map.insert( map_t::value_type( internal::demangle< Name >(), rule_info( type ) ) ); + } + }; + + } // namespace analysis + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/insert_guard.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/insert_guard.hpp new file mode 100644 index 0000000..b56daff --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/insert_guard.hpp @@ -0,0 +1,68 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_ANALYSIS_INSERT_GUARD_HPP +#define TAO_PEGTL_ANALYSIS_INSERT_GUARD_HPP + +#include + +#include "../config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace analysis + { + template< typename C > + class insert_guard + { + public: + insert_guard( C& container, const typename C::value_type& value ) + : m_i( container.insert( value ) ), + m_c( &container ) + { + } + + insert_guard( const insert_guard& ) = delete; + + insert_guard( insert_guard&& other ) noexcept + : m_i( other.m_i ), + m_c( other.m_c ) + { + other.m_c = nullptr; + } + + ~insert_guard() + { + if( m_c && m_i.second ) { + m_c->erase( m_i.first ); + } + } + + void operator=( const insert_guard& ) = delete; + void operator=( insert_guard&& ) = delete; + + explicit operator bool() const noexcept + { + return m_i.second; + } + + private: + const std::pair< typename C::iterator, bool > m_i; + C* m_c; + }; + + template< typename C > + insert_guard< C > make_insert_guard( C& container, const typename C::value_type& value ) + { + return insert_guard< C >( container, value ); + } + + } // namespace analysis + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/rule_info.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/rule_info.hpp new file mode 100644 index 0000000..a222839 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/rule_info.hpp @@ -0,0 +1,37 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_ANALYSIS_RULE_INFO_HPP +#define TAO_PEGTL_ANALYSIS_RULE_INFO_HPP + +#include +#include + +#include "../config.hpp" + +#include "rule_type.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace analysis + { + struct rule_info + { + explicit rule_info( const rule_type in_type ) noexcept + : type( in_type ) + { + } + + rule_type type; + std::vector< std::string > rules; + }; + + } // namespace analysis + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/rule_type.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/rule_type.hpp new file mode 100644 index 0000000..a0eff9a --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/rule_type.hpp @@ -0,0 +1,35 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_ANALYSIS_RULE_TYPE_HPP +#define TAO_PEGTL_ANALYSIS_RULE_TYPE_HPP + +#include "../config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace analysis + { + enum class rule_type : char + { + any, // Consumption-on-success is always true; assumes bounded repetition of conjunction of sub-rules. + opt, // Consumption-on-success not necessarily true; assumes bounded repetition of conjunction of sub-rules. + seq, // Consumption-on-success depends on consumption of (non-zero bounded repetition of) conjunction of sub-rules. + sor, // Consumption-on-success depends on consumption of (non-zero bounded repetition of) disjunction of sub-rules. + + // Compatibility, remove with 3.0.0 + ANY = any, + OPT = opt, + SEQ = seq, + SOR = sor + }; + + } // namespace analysis + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analyze.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analyze.hpp new file mode 100644 index 0000000..bf50dc5 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analyze.hpp @@ -0,0 +1,25 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_ANALYZE_HPP +#define TAO_PEGTL_ANALYZE_HPP + +#include "config.hpp" + +#include "analysis/analyze_cycles.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + template< typename Rule > + std::size_t analyze( const bool verbose = true ) + { + return analysis::analyze_cycles< Rule >( verbose ).problems(); + } + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/apply_mode.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/apply_mode.hpp new file mode 100644 index 0000000..92c1335 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/apply_mode.hpp @@ -0,0 +1,27 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_APPLY_MODE_HPP +#define TAO_PEGTL_APPLY_MODE_HPP + +#include "config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + enum class apply_mode : bool + { + action = true, + nothing = false, + + // Compatibility, remove with 3.0.0 + ACTION = action, + NOTHING = nothing + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/argv_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/argv_input.hpp new file mode 100644 index 0000000..75744a3 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/argv_input.hpp @@ -0,0 +1,57 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_ARGV_INPUT_HPP +#define TAO_PEGTL_ARGV_INPUT_HPP + +#include +#include +#include +#include + +#include "config.hpp" +#include "eol.hpp" +#include "memory_input.hpp" +#include "tracking_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + inline std::string make_argv_source( const std::size_t argn ) + { + std::ostringstream os; + os << "argv[" << argn << ']'; + return os.str(); + } + + } // namespace internal + + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > + struct argv_input + : public memory_input< P, Eol > + { + template< typename T > + argv_input( char** argv, const std::size_t argn, T&& in_source ) + : memory_input< P, Eol >( static_cast< const char* >( argv[ argn ] ), std::forward< T >( in_source ) ) + { + } + + argv_input( char** argv, const std::size_t argn ) + : argv_input( argv, argn, internal::make_argv_source( argn ) ) + { + } + }; + +#ifdef __cpp_deduction_guides + template< typename... Ts > + argv_input( Ts&&... )->argv_input<>; +#endif + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/ascii.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/ascii.hpp new file mode 100644 index 0000000..51cb0e4 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/ascii.hpp @@ -0,0 +1,71 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_ASCII_HPP +#define TAO_PEGTL_ASCII_HPP + +#include "config.hpp" +#include "eol.hpp" + +#include "internal/always_false.hpp" +#include "internal/result_on_found.hpp" +#include "internal/rules.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + inline namespace ascii + { + // clang-format off + struct alnum : internal::alnum {}; + struct alpha : internal::alpha {}; + struct any : internal::any< internal::peek_char > {}; + struct blank : internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > {}; + struct digit : internal::range< internal::result_on_found::success, internal::peek_char, '0', '9' > {}; + struct ellipsis : internal::string< '.', '.', '.' > {}; + struct eolf : internal::eolf {}; + template< char... Cs > struct forty_two : internal::rep< 42, internal::one< internal::result_on_found::success, internal::peek_char, Cs... > > {}; + struct identifier_first : internal::identifier_first {}; + struct identifier_other : internal::identifier_other {}; + struct identifier : internal::identifier {}; + template< char... Cs > struct istring : internal::istring< Cs... > {}; + template< char... Cs > struct keyword : internal::seq< internal::string< Cs... >, internal::not_at< internal::identifier_other > > {}; + struct lower : internal::range< internal::result_on_found::success, internal::peek_char, 'a', 'z' > {}; + template< char... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_char, Cs... > {}; + template< char Lo, char Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_char, Lo, Hi > {}; + struct nul : internal::one< internal::result_on_found::success, internal::peek_char, char( 0 ) > {}; + template< char... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_char, Cs... > {}; + struct print : internal::range< internal::result_on_found::success, internal::peek_char, char( 32 ), char( 126 ) > {}; + template< char Lo, char Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_char, Lo, Hi > {}; + template< char... Cs > struct ranges : internal::ranges< internal::peek_char, Cs... > {}; + struct seven : internal::range< internal::result_on_found::success, internal::peek_char, char( 0 ), char( 127 ) > {}; + struct shebang : internal::if_must< false, internal::string< '#', '!' >, internal::until< internal::eolf > > {}; + struct space : internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\n', '\r', '\t', '\v', '\f' > {}; + template< char... Cs > struct string : internal::string< Cs... > {}; + template< char C > struct three : internal::string< C, C, C > {}; + template< char C > struct two : internal::string< C, C > {}; + struct upper : internal::range< internal::result_on_found::success, internal::peek_char, 'A', 'Z' > {}; + struct xdigit : internal::ranges< internal::peek_char, '0', '9', 'a', 'f', 'A', 'F' > {}; + // clang-format on + + template<> + struct keyword<> + { + template< typename Input > + static bool match( Input& /*unused*/ ) noexcept + { + static_assert( internal::always_false< Input >::value, "empty keywords not allowed" ); + return false; + } + }; + + } // namespace ascii + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#include "internal/pegtl_string.hpp" + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/buffer_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/buffer_input.hpp new file mode 100644 index 0000000..f43513a --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/buffer_input.hpp @@ -0,0 +1,222 @@ +// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_BUFFER_INPUT_HPP +#define TAO_PEGTL_BUFFER_INPUT_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "config.hpp" +#include "eol.hpp" +#include "memory_input.hpp" +#include "position.hpp" +#include "tracking_mode.hpp" + +#include "internal/action_input.hpp" +#include "internal/bump.hpp" +#include "internal/iterator.hpp" +#include "internal/marker.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + template< typename Reader, typename Eol = eol::lf_crlf, typename Source = std::string, std::size_t Chunk = 64 > + class buffer_input + { + public: + using reader_t = Reader; + + using eol_t = Eol; + using source_t = Source; + + using iterator_t = internal::iterator; + + using action_t = internal::action_input< buffer_input >; + + static constexpr std::size_t chunk_size = Chunk; + static constexpr tracking_mode tracking_mode_v = tracking_mode::eager; + + template< typename T, typename... As > + buffer_input( T&& in_source, const std::size_t maximum, As&&... as ) + : m_reader( std::forward< As >( as )... ), + m_maximum( maximum + Chunk ), + m_buffer( new char[ maximum + Chunk ] ), + m_current( m_buffer.get() ), + m_end( m_buffer.get() ), + m_source( std::forward< T >( in_source ) ) + { + static_assert( Chunk != 0, "zero chunk size not implemented" ); + assert( m_maximum > maximum ); // Catches overflow; change to >= when zero chunk size is implemented. + } + + buffer_input( const buffer_input& ) = delete; + buffer_input( buffer_input&& ) = delete; + + ~buffer_input() = default; + + void operator=( const buffer_input& ) = delete; + void operator=( buffer_input&& ) = delete; + + bool empty() + { + require( 1 ); + return m_current.data == m_end; + } + + std::size_t size( const std::size_t amount ) + { + require( amount ); + return buffer_occupied(); + } + + const char* current() const noexcept + { + return m_current.data; + } + + const char* end( const std::size_t amount ) + { + require( amount ); + return m_end; + } + + std::size_t byte() const noexcept + { + return m_current.byte; + } + + std::size_t line() const noexcept + { + return m_current.line; + } + + std::size_t byte_in_line() const noexcept + { + return m_current.byte_in_line; + } + + const Source& source() const noexcept + { + return m_source; + } + + char peek_char( const std::size_t offset = 0 ) const noexcept + { + return m_current.data[ offset ]; + } + + std::uint8_t peek_uint8( const std::size_t offset = 0 ) const noexcept + { + return static_cast< std::uint8_t >( peek_char( offset ) ); + } + + // Compatibility, remove with 3.0.0 + std::uint8_t peek_byte( const std::size_t offset = 0 ) const noexcept + { + return static_cast< std::uint8_t >( peek_char( offset ) ); + } + + void bump( const std::size_t in_count = 1 ) noexcept + { + internal::bump( m_current, in_count, Eol::ch ); + } + + void bump_in_this_line( const std::size_t in_count = 1 ) noexcept + { + internal::bump_in_this_line( m_current, in_count ); + } + + void bump_to_next_line( const std::size_t in_count = 1 ) noexcept + { + internal::bump_to_next_line( m_current, in_count ); + } + + void discard() noexcept + { + if( m_current.data > m_buffer.get() + Chunk ) { + const auto s = m_end - m_current.data; + std::memmove( m_buffer.get(), m_current.data, s ); + m_current.data = m_buffer.get(); + m_end = m_buffer.get() + s; + } + } + + void require( const std::size_t amount ) + { + if( m_current.data + amount <= m_end ) { + return; + } + if( m_current.data + amount > m_buffer.get() + m_maximum ) { + throw std::overflow_error( "require beyond end of buffer" ); + } + if( const auto r = m_reader( m_end, ( std::min )( buffer_free_after_end(), ( std::max )( amount - buffer_occupied(), Chunk ) ) ) ) { + m_end += r; + } + } + + template< rewind_mode M > + internal::marker< iterator_t, M > mark() noexcept + { + return internal::marker< iterator_t, M >( m_current ); + } + + TAO_PEGTL_NAMESPACE::position position( const iterator_t& it ) const + { + return TAO_PEGTL_NAMESPACE::position( it, m_source ); + } + + TAO_PEGTL_NAMESPACE::position position() const + { + return position( m_current ); + } + + const iterator_t& iterator() const noexcept + { + return m_current; + } + + std::size_t buffer_capacity() const noexcept + { + return m_maximum; + } + + std::size_t buffer_occupied() const noexcept + { + assert( m_end >= m_current.data ); + return std::size_t( m_end - m_current.data ); + } + + std::size_t buffer_free_before_current() const noexcept + { + assert( m_current.data >= m_buffer.get() ); + return std::size_t( m_current.data - m_buffer.get() ); + } + + std::size_t buffer_free_after_end() const noexcept + { + assert( m_buffer.get() + m_maximum >= m_end ); + return std::size_t( m_buffer.get() + m_maximum - m_end ); + } + + private: + Reader m_reader; + std::size_t m_maximum; + std::unique_ptr< char[] > m_buffer; // NOLINT + iterator_t m_current; + char* m_end; + const Source m_source; + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action.hpp new file mode 100644 index 0000000..1766e93 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action.hpp @@ -0,0 +1,42 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CHANGE_ACTION_HPP +#define TAO_PEGTL_CHANGE_ACTION_HPP + +#include + +#include "apply_mode.hpp" +#include "config.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + template< template< typename... > class NewAction > + struct change_action + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + static_assert( !std::is_same< Action< void >, NewAction< void > >::value, "old and new action class templates are identical" ); + return Control< Rule >::template match< A, M, NewAction, Control >( in, st... ); + } + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action_and_state.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action_and_state.hpp new file mode 100644 index 0000000..f76eb31 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action_and_state.hpp @@ -0,0 +1,73 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CHANGE_ACTION_AND_STATE_HPP +#define TAO_PEGTL_CHANGE_ACTION_AND_STATE_HPP + +#include + +#include "apply_mode.hpp" +#include "config.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + template< template< typename... > class NewAction, typename NewState > + struct change_action_and_state + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static auto match( Input& in, States&&... st ) + -> typename std::enable_if< ( A == apply_mode::action ), bool >::type + { + static_assert( !std::is_same< Action< void >, NewAction< void > >::value, "old and new action class templates are identical" ); + NewState s( static_cast< const Input& >( in ), st... ); + if( Control< Rule >::template match< A, M, NewAction, Control >( in, s ) ) { + Action< Rule >::success( static_cast< const Input& >( in ), s, st... ); + return true; + } + return false; + } + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States, + int = 1 > + static auto match( Input& in, States&&... st ) + -> typename std::enable_if< ( A == apply_mode::nothing ), bool >::type + { + static_assert( !std::is_same< Action< void >, NewAction< void > >::value, "old and new action class templates are identical" ); + NewState s( static_cast< const Input& >( in ), st... ); + return Control< Rule >::template match< A, M, NewAction, Control >( in, s ); + } + + template< typename Input, + typename... States > + static void success( const Input& in, NewState& s, States&&... st ) noexcept( noexcept( s.success( in, st... ) ) ) + { + s.success( in, st... ); + } + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action_and_states.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action_and_states.hpp new file mode 100644 index 0000000..42d51e9 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action_and_states.hpp @@ -0,0 +1,83 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CHANGE_ACTION_AND_STATES_HPP +#define TAO_PEGTL_CHANGE_ACTION_AND_STATES_HPP + +#include +#include + +#include "apply_mode.hpp" +#include "config.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +#include "internal/integer_sequence.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + template< template< typename... > class NewAction, typename... NewStates > + struct change_action_and_states + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + std::size_t... Ns, + typename Input, + typename... States > + static bool match( TAO_PEGTL_NAMESPACE::internal::index_sequence< Ns... >, Input& in, States&&... st ) + { + auto t = std::tie( st... ); + if( Control< Rule >::template match< A, M, NewAction, Control >( in, std::get< Ns >( t )... ) ) { + Action< Rule >::success( static_cast< const Input& >( in ), st... ); + return true; + } + return false; + } + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static auto match( Input& in, States&&... st ) + -> typename std::enable_if< ( A == apply_mode::action ), bool >::type + { + static_assert( !std::is_same< Action< void >, NewAction< void > >::value, "old and new action class templates are identical" ); + return match< Rule, A, M, Action, Control >( TAO_PEGTL_NAMESPACE::internal::index_sequence_for< NewStates... >(), in, NewStates()..., st... ); + } + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States, + int = 1 > + static auto match( Input& in, States&&... /*unused*/ ) + -> typename std::enable_if< ( A == apply_mode::nothing ), bool >::type + { + static_assert( !std::is_same< Action< void >, NewAction< void > >::value, "old and new action class templates are identical" ); + return Control< Rule >::template match< A, M, NewAction, Control >( in, NewStates()... ); + } + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_control.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_control.hpp new file mode 100644 index 0000000..ba9251f --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_control.hpp @@ -0,0 +1,40 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CHANGE_CONTROL_HPP +#define TAO_PEGTL_CHANGE_CONTROL_HPP + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + template< template< typename... > class NewControl > + struct change_control + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, NewControl >( in, st... ); + } + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_state.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_state.hpp new file mode 100644 index 0000000..3f8e4d5 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_state.hpp @@ -0,0 +1,72 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CHANGE_STATE_HPP +#define TAO_PEGTL_CHANGE_STATE_HPP + +#include + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + template< typename NewState > + struct change_state + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static auto match( Input& in, States&&... st ) + -> typename std::enable_if< ( A == apply_mode::action ), bool >::type + { + NewState s( static_cast< const Input& >( in ), st... ); + if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, s ) ) { + Action< Rule >::success( static_cast< const Input& >( in ), s, st... ); + return true; + } + return false; + } + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States, + int = 1 > + static auto match( Input& in, States&&... st ) + -> typename std::enable_if< ( A == apply_mode::nothing ), bool >::type + { + NewState s( static_cast< const Input& >( in ), st... ); + return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, s ); + } + + template< typename Input, + typename... States > + static void success( const Input& in, NewState& s, States&&... st ) noexcept( noexcept( s.success( in, st... ) ) ) + { + s.success( in, st... ); + } + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_states.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_states.hpp new file mode 100644 index 0000000..151f410 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_states.hpp @@ -0,0 +1,81 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CHANGE_STATES_HPP +#define TAO_PEGTL_CHANGE_STATES_HPP + +#include + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +#include "internal/integer_sequence.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + template< typename... NewStates > + struct change_states + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + std::size_t... Ns, + typename Input, + typename... States > + static bool match( TAO_PEGTL_NAMESPACE::internal::index_sequence< Ns... >, Input& in, States&&... st ) + { + auto t = std::tie( st... ); + if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, std::get< Ns >( t )... ) ) { + Action< Rule >::success( static_cast< const Input& >( in ), st... ); + return true; + } + return false; + } + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static auto match( Input& in, States&&... st ) + -> typename std::enable_if< ( A == apply_mode::action ), bool >::type + { + return match< Rule, A, M, Action, Control >( TAO_PEGTL_NAMESPACE::internal::index_sequence_for< NewStates... >(), in, NewStates()..., st... ); + } + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States, + int = 1 > + static auto match( Input& in, States&&... /*unused*/ ) + -> typename std::enable_if< ( A == apply_mode::nothing ), bool >::type + { + return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, NewStates()... ); + } + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/config.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/config.hpp new file mode 100644 index 0000000..4e47aba --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/config.hpp @@ -0,0 +1,20 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONFIG_HPP +#define TAO_PEGTL_CONFIG_HPP + +// Compatibility, remove with 3.0.0 +#ifdef TAOCPP_PEGTL_NAMESPACE +#define TAO_PEGTL_NAMESPACE TAOCPP_PEGTL_NAMESPACE +#endif + +#ifndef TAO_PEGTL_NAMESPACE +#define TAO_PEGTL_NAMESPACE pegtl +#endif + +// Enable some improvements to the readability of +// demangled type names under some circumstances. +// #define TAO_PEGTL_PRETTY_DEMANGLE + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/abnf.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/abnf.hpp new file mode 100644 index 0000000..5fcd0d2 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/abnf.hpp @@ -0,0 +1,43 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_ABNF_HPP +#define TAO_PEGTL_CONTRIB_ABNF_HPP + +#include "../config.hpp" +#include "../internal/rules.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace abnf + { + // Core ABNF rules according to RFC 5234, Appendix B + + // clang-format off + struct ALPHA : internal::ranges< internal::peek_char, 'a', 'z', 'A', 'Z' > {}; + struct BIT : internal::one< internal::result_on_found::success, internal::peek_char, '0', '1' > {}; + struct CHAR : internal::range< internal::result_on_found::success, internal::peek_char, char( 1 ), char( 127 ) > {}; + struct CR : internal::one< internal::result_on_found::success, internal::peek_char, '\r' > {}; + struct CRLF : internal::string< '\r', '\n' > {}; + struct CTL : internal::ranges< internal::peek_char, char( 0 ), char( 31 ), char( 127 ) > {}; + struct DIGIT : internal::range< internal::result_on_found::success, internal::peek_char, '0', '9' > {}; + struct DQUOTE : internal::one< internal::result_on_found::success, internal::peek_char, '"' > {}; + struct HEXDIG : internal::ranges< internal::peek_char, '0', '9', 'a', 'f', 'A', 'F' > {}; + struct HTAB : internal::one< internal::result_on_found::success, internal::peek_char, '\t' > {}; + struct LF : internal::one< internal::result_on_found::success, internal::peek_char, '\n' > {}; + struct LWSP : internal::star< internal::sor< internal::string< '\r', '\n' >, internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > >, internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > > {}; + struct OCTET : internal::any< internal::peek_char > {}; + struct SP : internal::one< internal::result_on_found::success, internal::peek_char, ' ' > {}; + struct VCHAR : internal::range< internal::result_on_found::success, internal::peek_char, char( 33 ), char( 126 ) > {}; + struct WSP : internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > {}; + // clang-format on + + } // namespace abnf + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/alphabet.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/alphabet.hpp new file mode 100644 index 0000000..35f6a7c --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/alphabet.hpp @@ -0,0 +1,75 @@ +// Copyright (c) 2015-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_ALPHABET_HPP +#define TAO_PEGTL_CONTRIB_ALPHABET_HPP + +#include "../config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace alphabet + { + static const int a = 'a'; // NOLINT + static const int b = 'b'; // NOLINT + static const int c = 'c'; // NOLINT + static const int d = 'd'; // NOLINT + static const int e = 'e'; // NOLINT + static const int f = 'f'; // NOLINT + static const int g = 'g'; // NOLINT + static const int h = 'h'; // NOLINT + static const int i = 'i'; // NOLINT + static const int j = 'j'; // NOLINT + static const int k = 'k'; // NOLINT + static const int l = 'l'; // NOLINT + static const int m = 'm'; // NOLINT + static const int n = 'n'; // NOLINT + static const int o = 'o'; // NOLINT + static const int p = 'p'; // NOLINT + static const int q = 'q'; // NOLINT + static const int r = 'r'; // NOLINT + static const int s = 's'; // NOLINT + static const int t = 't'; // NOLINT + static const int u = 'u'; // NOLINT + static const int v = 'v'; // NOLINT + static const int w = 'w'; // NOLINT + static const int x = 'x'; // NOLINT + static const int y = 'y'; // NOLINT + static const int z = 'z'; // NOLINT + + static const int A = 'A'; // NOLINT + static const int B = 'B'; // NOLINT + static const int C = 'C'; // NOLINT + static const int D = 'D'; // NOLINT + static const int E = 'E'; // NOLINT + static const int F = 'F'; // NOLINT + static const int G = 'G'; // NOLINT + static const int H = 'H'; // NOLINT + static const int I = 'I'; // NOLINT + static const int J = 'J'; // NOLINT + static const int K = 'K'; // NOLINT + static const int L = 'L'; // NOLINT + static const int M = 'M'; // NOLINT + static const int N = 'N'; // NOLINT + static const int O = 'O'; // NOLINT + static const int P = 'P'; // NOLINT + static const int Q = 'Q'; // NOLINT + static const int R = 'R'; // NOLINT + static const int S = 'S'; // NOLINT + static const int T = 'T'; // NOLINT + static const int U = 'U'; // NOLINT + static const int V = 'V'; // NOLINT + static const int W = 'W'; // NOLINT + static const int X = 'X'; // NOLINT + static const int Y = 'Y'; // NOLINT + static const int Z = 'Z'; // NOLINT + + } // namespace alphabet + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/changes.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/changes.hpp new file mode 100644 index 0000000..3da10ee --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/changes.hpp @@ -0,0 +1,90 @@ +// Copyright (c) 2015-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_CHANGES_HPP +#define TAO_PEGTL_CONTRIB_CHANGES_HPP + +#include + +#include "../config.hpp" +#include "../normal.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct dummy_disabled_state + { + template< typename... Ts > + void success( Ts&&... /*unused*/ ) const noexcept + { + } + }; + + template< apply_mode A, typename NewState > + using state_disable_helper = typename std::conditional< A == apply_mode::action, NewState, dummy_disabled_state >::type; + + } // namespace internal + + template< typename Rule, typename NewState, template< typename... > class Base = normal > + struct change_state + : public Base< Rule > + { + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + internal::state_disable_helper< A, NewState > s; + + if( Base< Rule >::template match< A, M, Action, Control >( in, s ) ) { + s.success( st... ); + return true; + } + return false; + } + }; + + template< typename Rule, template< typename... > class NewAction, template< typename... > class Base = normal > + struct change_action + : public Base< Rule > + { + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + return Base< Rule >::template match< A, M, NewAction, Control >( in, st... ); + } + }; + + template< template< typename... > class NewAction, template< typename... > class Base > + struct change_both_helper + { + template< typename T > + using change_action = change_action< T, NewAction, Base >; + }; + + template< typename Rule, typename NewState, template< typename... > class NewAction, template< typename... > class Base = normal > + struct change_state_and_action + : public change_state< Rule, NewState, change_both_helper< NewAction, Base >::template change_action > + { + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/counter.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/counter.hpp new file mode 100644 index 0000000..fc0c969 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/counter.hpp @@ -0,0 +1,58 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_COUNTER_HPP +#define TAO_PEGTL_CONTRIB_COUNTER_HPP + +#include +#include + +#include "../config.hpp" +#include "../normal.hpp" + +#include "../internal/demangle.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + struct counter_data + { + unsigned start = 0; + unsigned success = 0; + unsigned failure = 0; + }; + + struct counter_state + { + std::map< std::string, counter_data > counts; + }; + + template< typename Rule > + struct counter + : normal< Rule > + { + template< typename Input > + static void start( const Input& /*unused*/, counter_state& ts ) + { + ++ts.counts[ internal::demangle< Rule >() ].start; + } + + template< typename Input > + static void success( const Input& /*unused*/, counter_state& ts ) + { + ++ts.counts[ internal::demangle< Rule >() ].success; + } + + template< typename Input > + static void failure( const Input& /*unused*/, counter_state& ts ) + { + ++ts.counts[ internal::demangle< Rule >() ].failure; + } + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/http.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/http.hpp new file mode 100644 index 0000000..829b40c --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/http.hpp @@ -0,0 +1,282 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_HTTP_HPP +#define TAO_PEGTL_CONTRIB_HTTP_HPP + +#include "../ascii.hpp" +#include "../config.hpp" +#include "../nothing.hpp" +#include "../rules.hpp" +#include "../utf8.hpp" + +#include "abnf.hpp" +#include "remove_first_state.hpp" +#include "uri.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace http + { + // HTTP 1.1 grammar according to RFC 7230. + + // This grammar is a direct PEG translation of the original HTTP grammar. + // It should be considered experimental -- in case of any issues, in particular + // missing rules for attached actions, please contact the developers. + + using OWS = star< abnf::WSP >; // optional whitespace + using RWS = plus< abnf::WSP >; // required whitespace + using BWS = OWS; // "bad" whitespace + + using obs_text = not_range< 0x00, 0x7F >; + using obs_fold = seq< abnf::CRLF, plus< abnf::WSP > >; + + // clang-format off + struct tchar : sor< abnf::ALPHA, abnf::DIGIT, one< '!', '#', '$', '%', '&', '\'', '*', '+', '-', '.', '^', '_', '`', '|', '~' > > {}; + struct token : plus< tchar > {}; + + struct field_name : token {}; + + struct field_vchar : sor< abnf::VCHAR, obs_text > {}; + struct field_content : list< field_vchar, plus< abnf::WSP > > {}; + struct field_value : star< sor< field_content, obs_fold > > {}; + + struct header_field : seq< field_name, one< ':' >, OWS, field_value, OWS > {}; + + struct method : token {}; + + struct absolute_path : plus< one< '/' >, uri::segment > {}; + + struct origin_form : seq< absolute_path, uri::opt_query > {}; + struct absolute_form : uri::absolute_URI {}; + struct authority_form : uri::authority {}; + struct asterisk_form : one< '*' > {}; + + struct request_target : sor< origin_form, absolute_form, authority_form, asterisk_form > {}; + + struct status_code : rep< 3, abnf::DIGIT > {}; + struct reason_phrase : star< sor< abnf::VCHAR, obs_text, abnf::WSP > > {}; + + struct HTTP_version : if_must< string< 'H', 'T', 'T', 'P', '/' >, abnf::DIGIT, one< '.' >, abnf::DIGIT > {}; + + struct request_line : if_must< method, abnf::SP, request_target, abnf::SP, HTTP_version, abnf::CRLF > {}; + struct status_line : if_must< HTTP_version, abnf::SP, status_code, abnf::SP, reason_phrase, abnf::CRLF > {}; + struct start_line : sor< status_line, request_line > {}; + + struct message_body : star< abnf::OCTET > {}; + struct HTTP_message : seq< start_line, star< header_field, abnf::CRLF >, abnf::CRLF, opt< message_body > > {}; + + struct Content_Length : plus< abnf::DIGIT > {}; + + struct uri_host : uri::host {}; + struct port : uri::port {}; + + struct Host : seq< uri_host, opt< one< ':' >, port > > {}; + + // PEG are different from CFGs! (this replaces ctext and qdtext) + using text = sor< abnf::HTAB, range< 0x20, 0x7E >, obs_text >; + + struct quoted_pair : if_must< one< '\\' >, sor< abnf::VCHAR, obs_text, abnf::WSP > > {}; + struct quoted_string : if_must< abnf::DQUOTE, until< abnf::DQUOTE, sor< quoted_pair, text > > > {}; + + struct transfer_parameter : seq< token, BWS, one< '=' >, BWS, sor< token, quoted_string > > {}; + struct transfer_extension : seq< token, star< OWS, one< ';' >, OWS, transfer_parameter > > {}; + struct transfer_coding : sor< istring< 'c', 'h', 'u', 'n', 'k', 'e', 'd' >, + istring< 'c', 'o', 'm', 'p', 'r', 'e', 's', 's' >, + istring< 'd', 'e', 'f', 'l', 'a', 't', 'e' >, + istring< 'g', 'z', 'i', 'p' >, + transfer_extension > {}; + + struct rank : sor< seq< one< '0' >, opt< one< '.' >, rep_opt< 3, abnf::DIGIT > > >, + seq< one< '1' >, opt< one< '.' >, rep_opt< 3, one< '0' > > > > > {}; + + struct t_ranking : seq< OWS, one< ';' >, OWS, one< 'q', 'Q' >, one< '=' >, rank > {}; + struct t_codings : sor< istring< 't', 'r', 'a', 'i', 'l', 'e', 'r', 's' >, seq< transfer_coding, opt< t_ranking > > > {}; + + struct TE : opt< sor< one< ',' >, t_codings >, star< OWS, one< ',' >, opt< OWS, t_codings > > > {}; + + template< typename T > + using make_comma_list = seq< star< one< ',' >, OWS >, T, star< OWS, one< ',' >, opt< OWS, T > > >; + + struct connection_option : token {}; + struct Connection : make_comma_list< connection_option > {}; + + struct Trailer : make_comma_list< field_name > {}; + + struct Transfer_Encoding : make_comma_list< transfer_coding > {}; + + struct protocol_name : token {}; + struct protocol_version : token {}; + struct protocol : seq< protocol_name, opt< one< '/' >, protocol_version > > {}; + struct Upgrade : make_comma_list< protocol > {}; + + struct pseudonym : token {}; + + struct received_protocol : seq< opt< protocol_name, one< '/' > >, protocol_version > {}; + struct received_by : sor< seq< uri_host, opt< one< ':' >, port > >, pseudonym > {}; + + struct comment : if_must< one< '(' >, until< one< ')' >, sor< comment, quoted_pair, text > > > {}; + + struct Via : make_comma_list< seq< received_protocol, RWS, received_by, opt< RWS, comment > > > {}; + + struct http_URI : if_must< istring< 'h', 't', 't', 'p', ':', '/', '/' >, uri::authority, uri::path_abempty, uri::opt_query, uri::opt_fragment > {}; + struct https_URI : if_must< istring< 'h', 't', 't', 'p', 's', ':', '/', '/' >, uri::authority, uri::path_abempty, uri::opt_query, uri::opt_fragment > {}; + + struct partial_URI : seq< uri::relative_part, uri::opt_query > {}; + + // clang-format on + struct chunk_size + { + using analyze_t = plus< abnf::HEXDIG >::analyze_t; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, std::size_t& size, States&&... /*unused*/ ) + { + size = 0; + std::size_t i = 0; + while( in.size( i + 1 ) >= i + 1 ) { + const auto c = in.peek_char( i ); + if( ( '0' <= c ) && ( c <= '9' ) ) { + size <<= 4; + size |= std::size_t( c - '0' ); + ++i; + continue; + } + if( ( 'a' <= c ) && ( c <= 'f' ) ) { + size <<= 4; + size |= std::size_t( c - 'a' + 10 ); + ++i; + continue; + } + if( ( 'A' <= c ) && ( c <= 'F' ) ) { + size <<= 4; + size |= std::size_t( c - 'A' + 10 ); + ++i; + continue; + } + break; + } + in.bump_in_this_line( i ); + return i > 0; + } + }; + // clang-format off + + struct chunk_ext_name : token {}; + struct chunk_ext_val : sor< quoted_string, token > {}; + struct chunk_ext : star_must< one< ';' >, chunk_ext_name, if_must< one< '=' >, chunk_ext_val > > {}; + + // clang-format on + struct chunk_data + { + using analyze_t = star< abnf::OCTET >::analyze_t; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, const std::size_t size, States&&... /*unused*/ ) + { + if( in.size( size ) >= size ) { + in.bump( size ); + return true; + } + return false; + } + }; + + namespace internal + { + namespace chunk_helper + { + template< typename Base > + struct control; + + template< template< typename... > class Control, typename Rule > + struct control< Control< Rule > > + : Control< Rule > + { + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class, + typename Input, + typename State, + typename... States > + static bool match( Input& in, State&& /*unused*/, States&&... st ) + { + return Control< Rule >::template match< A, M, Action, Control >( in, st... ); + } + }; + + template< template< typename... > class Control > + struct control< Control< chunk_size > > + : remove_first_state< Control< chunk_size > > + {}; + + template< template< typename... > class Control > + struct control< Control< chunk_data > > + : remove_first_state< Control< chunk_data > > + {}; + + template< template< typename... > class Control > + struct bind + { + template< typename Rule > + using type = control< Control< Rule > >; + }; + + } // namespace chunk_helper + + } // namespace internal + + struct chunk + { + using impl = seq< chunk_size, chunk_ext, abnf::CRLF, chunk_data, abnf::CRLF >; + using analyze_t = impl::analyze_t; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + std::size_t size{}; + return impl::template match< A, M, Action, internal::chunk_helper::bind< Control >::template type >( in, size, st... ); + } + }; + + // clang-format off + struct last_chunk : seq< plus< one< '0' > >, not_at< digit >, chunk_ext, abnf::CRLF > {}; + + struct trailer_part : star< header_field, abnf::CRLF > {}; + + struct chunked_body : seq< until< last_chunk, chunk >, trailer_part, abnf::CRLF > {}; + // clang-format on + + } // namespace http + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/internal.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/internal.hpp new file mode 100644 index 0000000..d5bc93c --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/internal.hpp @@ -0,0 +1,76 @@ +// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_ICU_INTERNAL_HPP +#define TAO_PEGTL_CONTRIB_ICU_INTERNAL_HPP + +#include + +#include "../../config.hpp" + +#include "../../analysis/generic.hpp" +#include "../../internal/skip_control.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + namespace icu + { + template< typename Peek, UProperty P, bool V = true > + struct binary_property + { + using analyze_t = analysis::generic< analysis::rule_type::any >; + + template< typename Input > + static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) ) + { + if( const auto r = Peek::peek( in ) ) { + if( u_hasBinaryProperty( r.data, P ) == V ) { + in.bump( r.size ); + return true; + } + } + return false; + } + }; + + template< typename Peek, UProperty P, int V > + struct property_value + { + using analyze_t = analysis::generic< analysis::rule_type::any >; + + template< typename Input > + static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) ) + { + if( const auto r = Peek::peek( in ) ) { + if( u_getIntPropertyValue( r.data, P ) == V ) { + in.bump( r.size ); + return true; + } + } + return false; + } + }; + + } // namespace icu + + template< typename Peek, UProperty P, bool V > + struct skip_control< icu::binary_property< Peek, P, V > > : std::true_type + { + }; + + template< typename Peek, UProperty P, int V > + struct skip_control< icu::property_value< Peek, P, V > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf16.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf16.hpp new file mode 100644 index 0000000..bf2540c --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf16.hpp @@ -0,0 +1,212 @@ +// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_ICU_UTF16_HPP +#define TAO_PEGTL_CONTRIB_ICU_UTF16_HPP + +#include "internal.hpp" + +#include "../../config.hpp" +#include "../../utf16.hpp" + +#include "../../internal/peek_utf16.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace utf16_be + { + namespace icu + { + template< UProperty P, bool V = true > + struct binary_property + : internal::icu::binary_property< internal::peek_utf16_be, P, V > + { + }; + + template< UProperty P, int V > + struct property_value + : internal::icu::property_value< internal::peek_utf16_be, P, V > + { + }; + + // clang-format off + struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; + struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; + struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; + struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; + struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; + struct dash : binary_property< UCHAR_DASH > {}; + struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; + struct deprecated : binary_property< UCHAR_DEPRECATED > {}; + struct diacritic : binary_property< UCHAR_DIACRITIC > {}; + struct extender : binary_property< UCHAR_EXTENDER > {}; + struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; + struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; + struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; + struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; + struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; + struct hyphen : binary_property< UCHAR_HYPHEN > {}; + struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; + struct id_start : binary_property< UCHAR_ID_START > {}; + struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; + struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; + struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; + struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; + struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; + struct lowercase : binary_property< UCHAR_LOWERCASE > {}; + struct math : binary_property< UCHAR_MATH > {}; + struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; + struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; + struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; + struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; + struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; + struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; + struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; + struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; + struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; + struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; + struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; + struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; + struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; + struct radical : binary_property< UCHAR_RADICAL > {}; + struct s_term : binary_property< UCHAR_S_TERM > {}; + struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; + struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; + struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; + struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; + struct uppercase : binary_property< UCHAR_UPPERCASE > {}; + struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; + struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; + struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; + struct xid_start : binary_property< UCHAR_XID_START > {}; + + template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; + template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; + template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; + template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; + template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; + template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; + template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; + template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; + template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; + template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; + // UNormalizationCheckResult requires an additional header : + // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; + template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; + template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; + template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; + + template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; + // clang-format on + + } // namespace icu + + } // namespace utf16_be + + namespace utf16_le + { + namespace icu + { + template< UProperty P, bool V = true > + struct binary_property + : internal::icu::binary_property< internal::peek_utf16_le, P, V > + { + }; + + template< UProperty P, int V > + struct property_value + : internal::icu::property_value< internal::peek_utf16_le, P, V > + { + }; + + // clang-format off + struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; + struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; + struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; + struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; + struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; + struct dash : binary_property< UCHAR_DASH > {}; + struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; + struct deprecated : binary_property< UCHAR_DEPRECATED > {}; + struct diacritic : binary_property< UCHAR_DIACRITIC > {}; + struct extender : binary_property< UCHAR_EXTENDER > {}; + struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; + struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; + struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; + struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; + struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; + struct hyphen : binary_property< UCHAR_HYPHEN > {}; + struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; + struct id_start : binary_property< UCHAR_ID_START > {}; + struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; + struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; + struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; + struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; + struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; + struct lowercase : binary_property< UCHAR_LOWERCASE > {}; + struct math : binary_property< UCHAR_MATH > {}; + struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; + struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; + struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; + struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; + struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; + struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; + struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; + struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; + struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; + struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; + struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; + struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; + struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; + struct radical : binary_property< UCHAR_RADICAL > {}; + struct s_term : binary_property< UCHAR_S_TERM > {}; + struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; + struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; + struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; + struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; + struct uppercase : binary_property< UCHAR_UPPERCASE > {}; + struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; + struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; + struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; + struct xid_start : binary_property< UCHAR_XID_START > {}; + + template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; + template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; + template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; + template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; + template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; + template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; + template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; + template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; + template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; + template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; + // UNormalizationCheckResult requires an additional header : + // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; + template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; + template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; + template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; + + template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; + // clang-format on + + } // namespace icu + + } // namespace utf16_le + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf32.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf32.hpp new file mode 100644 index 0000000..ca35819 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf32.hpp @@ -0,0 +1,212 @@ +// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_ICU_UTF32_HPP +#define TAO_PEGTL_CONTRIB_ICU_UTF32_HPP + +#include "internal.hpp" + +#include "../../config.hpp" +#include "../../utf32.hpp" + +#include "../../internal/peek_utf32.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace utf32_be + { + namespace icu + { + template< UProperty P, bool V = true > + struct binary_property + : internal::icu::binary_property< internal::peek_utf32_be, P, V > + { + }; + + template< UProperty P, int V > + struct property_value + : internal::icu::property_value< internal::peek_utf32_be, P, V > + { + }; + + // clang-format off + struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; + struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; + struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; + struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; + struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; + struct dash : binary_property< UCHAR_DASH > {}; + struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; + struct deprecated : binary_property< UCHAR_DEPRECATED > {}; + struct diacritic : binary_property< UCHAR_DIACRITIC > {}; + struct extender : binary_property< UCHAR_EXTENDER > {}; + struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; + struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; + struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; + struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; + struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; + struct hyphen : binary_property< UCHAR_HYPHEN > {}; + struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; + struct id_start : binary_property< UCHAR_ID_START > {}; + struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; + struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; + struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; + struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; + struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; + struct lowercase : binary_property< UCHAR_LOWERCASE > {}; + struct math : binary_property< UCHAR_MATH > {}; + struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; + struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; + struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; + struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; + struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; + struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; + struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; + struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; + struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; + struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; + struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; + struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; + struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; + struct radical : binary_property< UCHAR_RADICAL > {}; + struct s_term : binary_property< UCHAR_S_TERM > {}; + struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; + struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; + struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; + struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; + struct uppercase : binary_property< UCHAR_UPPERCASE > {}; + struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; + struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; + struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; + struct xid_start : binary_property< UCHAR_XID_START > {}; + + template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; + template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; + template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; + template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; + template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; + template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; + template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; + template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; + template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; + template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; + // UNormalizationCheckResult requires an additional header : + // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; + template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; + template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; + template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; + + template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; + // clang-format on + + } // namespace icu + + } // namespace utf32_be + + namespace utf32_le + { + namespace icu + { + template< UProperty P, bool V = true > + struct binary_property + : internal::icu::binary_property< internal::peek_utf32_le, P, V > + { + }; + + template< UProperty P, int V > + struct property_value + : internal::icu::property_value< internal::peek_utf32_le, P, V > + { + }; + + // clang-format off + struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; + struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; + struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; + struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; + struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; + struct dash : binary_property< UCHAR_DASH > {}; + struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; + struct deprecated : binary_property< UCHAR_DEPRECATED > {}; + struct diacritic : binary_property< UCHAR_DIACRITIC > {}; + struct extender : binary_property< UCHAR_EXTENDER > {}; + struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; + struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; + struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; + struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; + struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; + struct hyphen : binary_property< UCHAR_HYPHEN > {}; + struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; + struct id_start : binary_property< UCHAR_ID_START > {}; + struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; + struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; + struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; + struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; + struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; + struct lowercase : binary_property< UCHAR_LOWERCASE > {}; + struct math : binary_property< UCHAR_MATH > {}; + struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; + struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; + struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; + struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; + struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; + struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; + struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; + struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; + struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; + struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; + struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; + struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; + struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; + struct radical : binary_property< UCHAR_RADICAL > {}; + struct s_term : binary_property< UCHAR_S_TERM > {}; + struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; + struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; + struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; + struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; + struct uppercase : binary_property< UCHAR_UPPERCASE > {}; + struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; + struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; + struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; + struct xid_start : binary_property< UCHAR_XID_START > {}; + + template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; + template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; + template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; + template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; + template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; + template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; + template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; + template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; + template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; + template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; + // UNormalizationCheckResult requires an additional header : + // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; + template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; + template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; + template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; + + template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; + // clang-format on + + } // namespace icu + + } // namespace utf32_le + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf8.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf8.hpp new file mode 100644 index 0000000..089130d --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf8.hpp @@ -0,0 +1,117 @@ +// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_ICU_UTF8_HPP +#define TAO_PEGTL_CONTRIB_ICU_UTF8_HPP + +#include "internal.hpp" + +#include "../../config.hpp" +#include "../../utf8.hpp" + +#include "../../internal/peek_utf8.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace utf8 + { + namespace icu + { + template< UProperty P, bool V = true > + struct binary_property + : internal::icu::binary_property< internal::peek_utf8, P, V > + { + }; + + template< UProperty P, int V > + struct property_value + : internal::icu::property_value< internal::peek_utf8, P, V > + { + }; + + // clang-format off + struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; + struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; + struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; + struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; + struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; + struct dash : binary_property< UCHAR_DASH > {}; + struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; + struct deprecated : binary_property< UCHAR_DEPRECATED > {}; + struct diacritic : binary_property< UCHAR_DIACRITIC > {}; + struct extender : binary_property< UCHAR_EXTENDER > {}; + struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; + struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; + struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; + struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; + struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; + struct hyphen : binary_property< UCHAR_HYPHEN > {}; + struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; + struct id_start : binary_property< UCHAR_ID_START > {}; + struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; + struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; + struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; + struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; + struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; + struct lowercase : binary_property< UCHAR_LOWERCASE > {}; + struct math : binary_property< UCHAR_MATH > {}; + struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; + struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; + struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; + struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; + struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; + struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; + struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; + struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; + struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; + struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; + struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; + struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; + struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; + struct radical : binary_property< UCHAR_RADICAL > {}; + struct s_term : binary_property< UCHAR_S_TERM > {}; + struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; + struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; + struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; + struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; + struct uppercase : binary_property< UCHAR_UPPERCASE > {}; + struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; + struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; + struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; + struct xid_start : binary_property< UCHAR_XID_START > {}; + + template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; + template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; + template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; + template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; + template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; + template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; + template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; + template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; + template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; + template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; + // UNormalizationCheckResult requires an additional header : + // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; + template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; + template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; + template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; + + template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; + // clang-format on + + } // namespace icu + + } // namespace utf8 + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/if_then.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/if_then.hpp new file mode 100644 index 0000000..b861aa7 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/if_then.hpp @@ -0,0 +1,61 @@ +// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_IF_THEN_HPP +#define TAO_PEGTL_CONTRIB_IF_THEN_HPP + +#include + +#include "../config.hpp" + +#include "../internal/if_then_else.hpp" +#include "../internal/seq.hpp" +#include "../internal/skip_control.hpp" +#include "../internal/trivial.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Cond, typename Then > + struct if_pair + { + }; + + template< typename... Pairs > + struct if_then; + + template< typename Cond, typename Then, typename... Pairs > + struct if_then< if_pair< Cond, Then >, Pairs... > + : if_then_else< Cond, Then, if_then< Pairs... > > + { + template< typename ElseCond, typename... Thens > + using else_if_then = if_then< if_pair< Cond, Then >, Pairs..., if_pair< ElseCond, seq< Thens... > > >; + + template< typename... Thens > + using else_then = if_then_else< Cond, Then, if_then< Pairs..., if_pair< trivial< true >, seq< Thens... > > > >; + }; + + template<> + struct if_then<> + : trivial< false > + { + }; + + template< typename... Pairs > + struct skip_control< if_then< Pairs... > > : std::true_type + { + }; + + } // namespace internal + + template< typename Cond, typename... Thens > + using if_then = internal::if_then< internal::if_pair< Cond, internal::seq< Thens... > > >; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/integer.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/integer.hpp new file mode 100644 index 0000000..5c83145 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/integer.hpp @@ -0,0 +1,108 @@ +// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_INTEGER_HPP +#define TAO_PEGTL_CONTRIB_INTEGER_HPP + +#include +#include + +#include "../ascii.hpp" +#include "../parse_error.hpp" +#include "../rules.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace integer + { + namespace internal + { + template< typename I, I Limit, typename Input > + I actual_convert( const Input& in, std::size_t index ) + { + static constexpr I cutoff = Limit / 10; + static constexpr I cutlim = Limit % 10; + + I out = in.peek_char( index ) - '0'; + while( ++index < in.size() ) { + const I c = in.peek_char( index ) - '0'; + if( ( out > cutoff ) || ( ( out == cutoff ) && ( c > cutlim ) ) ) { + throw parse_error( "integer out of range", in ); + } + out *= 10; + out += c; + } + return out; + } + + template< typename I, typename Input > + I convert_positive( const Input& in, std::size_t index ) + { + static constexpr I limit = ( std::numeric_limits< I >::max )(); + return actual_convert< I, limit >( in, index ); + } + + template< typename I, typename Input > + I convert_negative( const Input& in, std::size_t index ) + { + using U = typename std::make_unsigned< I >::type; + static constexpr U limit = static_cast< U >( ( std::numeric_limits< I >::max )() ) + 1; + return static_cast< I >( ~actual_convert< U, limit >( in, index ) ) + 1; + } + + } // namespace internal + + struct unsigned_rule + : plus< digit > + { + }; + + struct unsigned_action + { + // Assumes that 'in' contains a non-empty sequence of ASCII digits. + + template< typename Input, typename State, typename... States > + static void apply( const Input& in, State& st, States&&... /*unused*/ ) + { + using T = typename std::decay< decltype( st.converted ) >::type; + static_assert( std::is_integral< T >::value, "need integral type" ); + static_assert( std::is_unsigned< T >::value, "need unsigned type" ); + st.converted = internal::convert_positive< T >( in, 0 ); + } + }; + + struct signed_rule + : seq< opt< one< '+', '-' > >, plus< digit > > + { + }; + + struct signed_action + { + // Assumes that 'in' contains a non-empty sequence of ASCII digits, + // with optional leading sign; with sign, in.size() must be >= 2. + + template< typename Input, typename State, typename... States > + static void apply( const Input& in, State& st, States&&... /*unused*/ ) + { + using T = typename std::decay< decltype( st.converted ) >::type; + static_assert( std::is_integral< T >::value, "need integral type" ); + static_assert( std::is_signed< T >::value, "need signed type" ); + const auto c = in.peek_char(); + if( c == '-' ) { + st.converted = internal::convert_negative< T >( in, 1 ); + } + else { + st.converted = internal::convert_positive< T >( in, std::size_t( c == '+' ) ); + } + } + }; + + } // namespace integer + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/json.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/json.hpp new file mode 100644 index 0000000..cd71148 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/json.hpp @@ -0,0 +1,98 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_JSON_HPP +#define TAO_PEGTL_CONTRIB_JSON_HPP + +#include "../ascii.hpp" +#include "../config.hpp" +#include "../rules.hpp" +#include "../utf8.hpp" + +#include "abnf.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace json + { + // JSON grammar according to RFC 8259 + + // clang-format off + struct ws : one< ' ', '\t', '\n', '\r' > {}; + + template< typename R, typename P = ws > + struct padr : internal::seq< R, internal::star< P > > {}; + + struct begin_array : padr< one< '[' > > {}; + struct begin_object : padr< one< '{' > > {}; + struct end_array : one< ']' > {}; + struct end_object : one< '}' > {}; + struct name_separator : pad< one< ':' >, ws > {}; + struct value_separator : padr< one< ',' > > {}; + + struct false_ : string< 'f', 'a', 'l', 's', 'e' > {}; // NOLINT + struct null : string< 'n', 'u', 'l', 'l' > {}; + struct true_ : string< 't', 'r', 'u', 'e' > {}; // NOLINT + + struct digits : plus< abnf::DIGIT > {}; + struct exp : seq< one< 'e', 'E' >, opt< one< '-', '+'> >, must< digits > > {}; + struct frac : if_must< one< '.' >, digits > {}; + struct int_ : sor< one< '0' >, digits > {}; // NOLINT + struct number : seq< opt< one< '-' > >, int_, opt< frac >, opt< exp > > {}; + + struct xdigit : abnf::HEXDIG {}; + struct unicode : list< seq< one< 'u' >, rep< 4, must< xdigit > > >, one< '\\' > > {}; + struct escaped_char : one< '"', '\\', '/', 'b', 'f', 'n', 'r', 't' > {}; + struct escaped : sor< escaped_char, unicode > {}; + struct unescaped : utf8::range< 0x20, 0x10FFFF > {}; + struct char_ : if_then_else< one< '\\' >, must< escaped >, unescaped > {}; // NOLINT + + struct string_content : until< at< one< '"' > >, must< char_ > > {}; + struct string : seq< one< '"' >, must< string_content >, any > + { + using content = string_content; + }; + + struct key_content : until< at< one< '"' > >, must< char_ > > {}; + struct key : seq< one< '"' >, must< key_content >, any > + { + using content = key_content; + }; + + struct value; + + struct array_element; + struct array_content : opt< list_must< array_element, value_separator > > {}; + struct array : seq< begin_array, array_content, must< end_array > > + { + using begin = begin_array; + using end = end_array; + using element = array_element; + using content = array_content; + }; + + struct member : if_must< key, name_separator, value > {}; + struct object_content : opt< list_must< member, value_separator > > {}; + struct object : seq< begin_object, object_content, must< end_object > > + { + using begin = begin_object; + using end = end_object; + using element = member; + using content = object_content; + }; + + struct value : padr< sor< string, number, object, array, false_, true_, null > > {}; + struct array_element : seq< value > {}; + + struct text : seq< star< ws >, value > {}; + // clang-format on + + } // namespace json + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/json_pointer.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/json_pointer.hpp new file mode 100644 index 0000000..1e4307c --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/json_pointer.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_JSON_POINTER_HPP +#define TAO_PEGTL_CONTRIB_JSON_POINTER_HPP + +#include "../ascii.hpp" +#include "../config.hpp" +#include "../rules.hpp" +#include "../utf8.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace json_pointer + { + // JSON pointer grammar according to RFC 6901 + + // clang-format off + struct unescaped : utf8::ranges< 0x0, 0x2E, 0x30, 0x7D, 0x7F, 0x10FFFF > {}; + struct escaped : seq< one< '~' >, one< '0', '1' > > {}; + + struct reference_token : star< sor< unescaped, escaped > > {}; + struct json_pointer : star< one< '/' >, reference_token > {}; + // clang-format on + + // relative JSON pointer, see ... + + // clang-format off + struct non_negative_integer : sor< one< '0' >, plus< digit > > {}; + struct relative_json_pointer : seq< non_negative_integer, sor< one< '#' >, json_pointer > > {}; + // clang-format on + + } // namespace json_pointer + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/parse_tree.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/parse_tree.hpp new file mode 100644 index 0000000..4abe7eb --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/parse_tree.hpp @@ -0,0 +1,517 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_PARSE_TREE_HPP +#define TAO_PEGTL_CONTRIB_PARSE_TREE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "remove_first_state.hpp" +#include "shuffle_states.hpp" + +#include "../apply_mode.hpp" +#include "../config.hpp" +#include "../memory_input.hpp" +#include "../normal.hpp" +#include "../nothing.hpp" +#include "../parse.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/counted.hpp" +#include "../analysis/generic.hpp" +#include "../internal/demangle.hpp" +#include "../internal/integer_sequence.hpp" +#include "../internal/iterator.hpp" +#include "../internal/skip_control.hpp" +#include "../internal/try_catch_type.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace parse_tree + { + template< typename T > + struct basic_node + { + using node_t = T; + using children_t = std::vector< std::unique_ptr< node_t > >; + children_t children; + + std::type_index id = std::type_index( typeid( void ) ); + std::string source; + + TAO_PEGTL_NAMESPACE::internal::iterator m_begin; + TAO_PEGTL_NAMESPACE::internal::iterator m_end; + + // each node will be default constructed + basic_node() = default; + + // no copy/move is necessary + // (nodes are always owned/handled by a std::unique_ptr) + basic_node( const basic_node& ) = delete; + basic_node( basic_node&& ) = delete; + + ~basic_node() = default; + + // no assignment either + basic_node& operator=( const basic_node& ) = delete; + basic_node& operator=( basic_node&& ) = delete; + + bool is_root() const noexcept + { + return id == typeid( void ); + } + + template< typename U > + bool is() const noexcept + { + return id == typeid( U ); + } + + std::string name() const + { + assert( !is_root() ); + return TAO_PEGTL_NAMESPACE::internal::demangle( id.name() ); + } + + position begin() const + { + return position( m_begin, source ); + } + + position end() const + { + return position( m_end, source ); + } + + bool has_content() const noexcept + { + return m_end.data != nullptr; + } + + std::string string() const + { + assert( has_content() ); + return std::string( m_begin.data, m_end.data ); + } + + // Compatibility, remove with 3.0.0 + std::string content() const + { + return string(); + } + + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > + memory_input< P, Eol > as_memory_input() const + { + assert( has_content() ); + return { m_begin.data, m_end.data, source, m_begin.byte, m_begin.line, m_begin.byte_in_line }; + } + + template< typename... States > + void remove_content( States&&... /*unused*/ ) noexcept + { + m_end.reset(); + } + + // all non-root nodes are initialized by calling this method + template< typename Rule, typename Input, typename... States > + void start( const Input& in, States&&... /*unused*/ ) + { + id = typeid( Rule ); + source = in.source(); + m_begin = TAO_PEGTL_NAMESPACE::internal::iterator( in.iterator() ); + } + + // if parsing of the rule succeeded, this method is called + template< typename Rule, typename Input, typename... States > + void success( const Input& in, States&&... /*unused*/ ) noexcept + { + m_end = TAO_PEGTL_NAMESPACE::internal::iterator( in.iterator() ); + } + + // if parsing of the rule failed, this method is called + template< typename Rule, typename Input, typename... States > + void failure( const Input& /*unused*/, States&&... /*unused*/ ) noexcept + { + } + + // if parsing succeeded and the (optional) transform call + // did not discard the node, it is appended to its parent. + // note that "child" is the node whose Rule just succeeded + // and "*this" is the parent where the node should be appended. + template< typename... States > + void emplace_back( std::unique_ptr< node_t >&& child, States&&... /*unused*/ ) + { + assert( child ); + children.emplace_back( std::move( child ) ); + } + }; + + struct node + : basic_node< node > + { + }; + + namespace internal + { + template< typename > + struct is_try_catch_type + : std::false_type + { + }; + + template< typename Exception, typename... Rules > + struct is_try_catch_type< TAO_PEGTL_NAMESPACE::internal::try_catch_type< Exception, Rules... > > + : std::true_type + { + }; + + template< typename Node > + struct state + { + std::vector< std::unique_ptr< Node > > stack; + + state() + { + emplace_back(); + } + + void emplace_back() + { + stack.emplace_back( std::unique_ptr< Node >( new Node ) ); + } + + std::unique_ptr< Node >& back() noexcept + { + assert( !stack.empty() ); + return stack.back(); + } + + void pop_back() noexcept + { + assert( !stack.empty() ); + return stack.pop_back(); + } + }; + + template< typename Selector, typename... Parameters > + void transform( Parameters&&... /*unused*/ ) noexcept + { + } + + template< typename Selector, typename Input, typename Node, typename... States > + auto transform( const Input& in, std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( Selector::transform( in, n, st... ) ) ) + -> decltype( Selector::transform( in, n, st... ), void() ) + { + Selector::transform( in, n, st... ); + } + + template< typename Selector, typename Input, typename Node, typename... States > + auto transform( const Input& /*unused*/, std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( Selector::transform( n, st... ) ) ) + -> decltype( Selector::transform( n, st... ), void() ) + { + Selector::transform( n, st... ); + } + + template< typename Rule, template< typename... > class Selector > + struct is_selected_node + : std::integral_constant< bool, !TAO_PEGTL_NAMESPACE::internal::skip_control< Rule >::value && Selector< Rule >::value > + { + }; + + template< unsigned Level, typename Analyse, template< typename... > class Selector > + struct is_leaf + : std::false_type + { + }; + + template< analysis::rule_type Type, template< typename... > class Selector > + struct is_leaf< 0, analysis::generic< Type >, Selector > + : std::true_type + { + }; + + template< analysis::rule_type Type, std::size_t Count, template< typename... > class Selector > + struct is_leaf< 0, analysis::counted< Type, Count >, Selector > + : std::true_type + { + }; + + template< analysis::rule_type Type, typename... Rules, template< typename... > class Selector > + struct is_leaf< 0, analysis::generic< Type, Rules... >, Selector > + : std::false_type + { + }; + + template< analysis::rule_type Type, std::size_t Count, typename... Rules, template< typename... > class Selector > + struct is_leaf< 0, analysis::counted< Type, Count, Rules... >, Selector > + : std::false_type + { + }; + + template< bool... > + struct bool_sequence; + + template< bool... Bs > + struct is_all + : std::is_same< bool_sequence< Bs..., true >, bool_sequence< true, Bs... > > + { + }; + + template< bool... Bs > + struct is_none + : std::integral_constant< bool, !is_all< !Bs... >::value > + { + }; + + template< unsigned Level, typename Rule, template< typename... > class Selector > + using is_unselected_leaf = std::integral_constant< bool, !is_selected_node< Rule, Selector >::value && is_leaf< Level, typename Rule::analyze_t, Selector >::value >; + + template< unsigned Level, analysis::rule_type Type, typename... Rules, template< typename... > class Selector > + struct is_leaf< Level, analysis::generic< Type, Rules... >, Selector > + : is_all< is_unselected_leaf< Level - 1, Rules, Selector >::value... > + { + }; + + template< unsigned Level, analysis::rule_type Type, std::size_t Count, typename... Rules, template< typename... > class Selector > + struct is_leaf< Level, analysis::counted< Type, Count, Rules... >, Selector > + : is_all< is_unselected_leaf< Level - 1, Rules, Selector >::value... > + { + }; + + template< typename Node, template< typename... > class Selector, template< typename... > class Control > + struct make_control + { + template< typename Rule, bool, bool > + struct state_handler; + + template< typename Rule > + using type = rotate_states_right< state_handler< Rule, is_selected_node< Rule, Selector >::value, is_leaf< 8, typename Rule::analyze_t, Selector >::value > >; + }; + + template< typename Node, template< typename... > class Selector, template< typename... > class Control > + template< typename Rule > + struct make_control< Node, Selector, Control >::state_handler< Rule, false, true > + : remove_first_state< Control< Rule > > + { + }; + + template< typename Node, template< typename... > class Selector, template< typename... > class Control > + template< typename Rule > + struct make_control< Node, Selector, Control >::state_handler< Rule, false, false > + : remove_first_state< Control< Rule > > + { + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control2, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + auto& state = std::get< sizeof...( st ) - 1 >( std::tie( st... ) ); + if( is_try_catch_type< Rule >::value ) { + internal::state< Node > tmp; + tmp.emplace_back(); + tmp.stack.swap( state.stack ); + const bool result = Control< Rule >::template match< A, M, Action, Control2 >( in, st... ); + tmp.stack.swap( state.stack ); + if( result ) { + for( auto& c : tmp.back()->children ) { + state.back()->children.emplace_back( std::move( c ) ); + } + } + return result; + } + state.emplace_back(); + const bool result = Control< Rule >::template match< A, M, Action, Control2 >( in, st... ); + if( result ) { + auto n = std::move( state.back() ); + state.pop_back(); + for( auto& c : n->children ) { + state.back()->children.emplace_back( std::move( c ) ); + } + } + else { + state.pop_back(); + } + return result; + } + }; + + template< typename Node, template< typename... > class Selector, template< typename... > class Control > + template< typename Rule, bool B > + struct make_control< Node, Selector, Control >::state_handler< Rule, true, B > + : remove_first_state< Control< Rule > > + { + template< typename Input, typename... States > + static void start( const Input& in, state< Node >& state, States&&... st ) + { + Control< Rule >::start( in, st... ); + state.emplace_back(); + state.back()->template start< Rule >( in, st... ); + } + + template< typename Input, typename... States > + static void success( const Input& in, state< Node >& state, States&&... st ) + { + Control< Rule >::success( in, st... ); + auto n = std::move( state.back() ); + state.pop_back(); + n->template success< Rule >( in, st... ); + transform< Selector< Rule > >( in, n, st... ); + if( n ) { + state.back()->emplace_back( std::move( n ), st... ); + } + } + + template< typename Input, typename... States > + static void failure( const Input& in, state< Node >& state, States&&... st ) noexcept( noexcept( Control< Rule >::failure( in, st... ) ) && noexcept( std::declval< Node& >().template failure< Rule >( in, st... ) ) ) + { + Control< Rule >::failure( in, st... ); + state.back()->template failure< Rule >( in, st... ); + state.pop_back(); + } + }; + + template< typename > + using store_all = std::true_type; + + template< typename > + struct selector; + + template<> + struct selector< std::tuple<> > + { + using type = std::false_type; + }; + + template< typename T > + struct selector< std::tuple< T > > + { + using type = typename T::type; + }; + + template< typename... Ts > + struct selector< std::tuple< Ts... > > + { + static_assert( sizeof...( Ts ) == 0, "multiple matches found" ); + }; + + template< typename Rule, typename Collection > + using select_tuple = typename std::conditional< Collection::template contains< Rule >::value, std::tuple< Collection >, std::tuple<> >::type; + + } // namespace internal + + template< typename Rule, typename... Collections > + struct selector + : internal::selector< decltype( std::tuple_cat( std::declval< internal::select_tuple< Rule, Collections > >()... ) ) >::type + {}; + + template< typename Base > + struct apply + : std::true_type + { + template< typename... Rules > + struct on + { + using type = Base; + + template< typename Rule > + using contains = internal::is_none< std::is_same< Rule, Rules >::value... >; + }; + }; + + struct store_content + : apply< store_content > + {}; + + // some nodes don't need to store their content + struct remove_content + : apply< remove_content > + { + template< typename Node, typename... States > + static void transform( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( n->Node::remove_content( st... ) ) ) + { + n->remove_content( st... ); + } + }; + + // if a node has only one child, replace the node with its child, otherwise remove content + struct fold_one + : apply< fold_one > + { + template< typename Node, typename... States > + static void transform( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( n->children.size(), n->Node::remove_content( st... ) ) ) + { + if( n->children.size() == 1 ) { + n = std::move( n->children.front() ); + } + else { + n->remove_content( st... ); + } + } + }; + + // if a node has no children, discard the node, otherwise remove content + struct discard_empty + : apply< discard_empty > + { + template< typename Node, typename... States > + static void transform( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( n->children.empty(), n->Node::remove_content( st... ) ) ) + { + if( n->children.empty() ) { + n.reset(); + } + else { + n->remove_content( st... ); + } + } + }; + + template< typename Rule, + typename Node, + template< typename... > class Selector = internal::store_all, + template< typename... > class Action = nothing, + template< typename... > class Control = normal, + typename Input, + typename... States > + std::unique_ptr< Node > parse( Input&& in, States&&... st ) + { + internal::state< Node > state; + if( !TAO_PEGTL_NAMESPACE::parse< Rule, Action, internal::make_control< Node, Selector, Control >::template type >( in, st..., state ) ) { + return nullptr; + } + assert( state.stack.size() == 1 ); + return std::move( state.back() ); + } + + template< typename Rule, + template< typename... > class Selector = internal::store_all, + template< typename... > class Action = nothing, + template< typename... > class Control = normal, + typename Input, + typename... States > + std::unique_ptr< node > parse( Input&& in, States&&... st ) + { + return parse< Rule, node, Selector, Action, Control >( in, st... ); + } + + } // namespace parse_tree + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/parse_tree_to_dot.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/parse_tree_to_dot.hpp new file mode 100644 index 0000000..cb6a6e0 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/parse_tree_to_dot.hpp @@ -0,0 +1,116 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_PARSE_TREE_TO_DOT_HPP +#define TAO_PEGTL_CONTRIB_PARSE_TREE_TO_DOT_HPP + +#include +#include +#include + +#include "parse_tree.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace parse_tree + { + namespace internal + { + inline void escape( std::ostream& os, const char* p, const std::size_t s ) + { + static const char* h = "0123456789abcdef"; + + const char* l = p; + const char* const e = p + s; + while( p != e ) { + const unsigned char c = *p; + if( c == '\\' ) { + os.write( l, p - l ); + l = ++p; + os << "\\\\"; + } + else if( c == '"' ) { + os.write( l, p - l ); + l = ++p; + os << "\\\""; + } + else if( c < 32 ) { + os.write( l, p - l ); + l = ++p; + switch( c ) { + case '\b': + os << "\\b"; + break; + case '\f': + os << "\\f"; + break; + case '\n': + os << "\\n"; + break; + case '\r': + os << "\\r"; + break; + case '\t': + os << "\\t"; + break; + default: + os << "\\u00" << h[ ( c & 0xf0 ) >> 4 ] << h[ c & 0x0f ]; + } + } + else if( c == 127 ) { + os.write( l, p - l ); + l = ++p; + os << "\\u007f"; + } + else { + ++p; + } + } + os.write( l, p - l ); + } + + inline void escape( std::ostream& os, const std::string& s ) + { + escape( os, s.data(), s.size() ); + } + + template< typename Node > + void print_dot_node( std::ostream& os, const Node& n, const std::string& s ) + { + os << " x" << &n << " [ label=\""; + escape( os, s ); + if( n.has_content() ) { + os << "\\n"; + escape( os, n.m_begin.data, n.m_end.data - n.m_begin.data ); + } + os << "\" ]\n"; + if( !n.children.empty() ) { + os << " x" << &n << " -> { "; + for( auto& up : n.children ) { + os << "x" << up.get() << ( ( up == n.children.back() ) ? " }\n" : ", " ); + } + for( auto& up : n.children ) { + print_dot_node( os, *up, up->name() ); + } + } + } + + } // namespace internal + + template< typename Node > + void print_dot( std::ostream& os, const Node& n ) + { + os << "digraph parse_tree\n{\n"; + internal::print_dot_node( os, n, n.is_root() ? "ROOT" : n.name() ); + os << "}\n"; + } + + } // namespace parse_tree + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/raw_string.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/raw_string.hpp new file mode 100644 index 0000000..1e66e3b --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/raw_string.hpp @@ -0,0 +1,234 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_RAW_STRING_HPP +#define TAO_PEGTL_CONTRIB_RAW_STRING_HPP + +#include +#include + +#include "../apply_mode.hpp" +#include "../config.hpp" +#include "../rewind_mode.hpp" + +#include "../internal/bytes.hpp" +#include "../internal/eof.hpp" +#include "../internal/eol.hpp" +#include "../internal/must.hpp" +#include "../internal/not_at.hpp" +#include "../internal/seq.hpp" +#include "../internal/skip_control.hpp" +#include "../internal/star.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< char Open, char Marker > + struct raw_string_open + { + using analyze_t = analysis::generic< analysis::rule_type::any >; + + template< apply_mode A, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, std::size_t& marker_size, States&&... /*unused*/ ) noexcept( noexcept( in.size( 0 ) ) ) + { + if( in.empty() || ( in.peek_char( 0 ) != Open ) ) { + return false; + } + for( std::size_t i = 1; i < in.size( i + 1 ); ++i ) { + switch( const auto c = in.peek_char( i ) ) { + case Open: + marker_size = i + 1; + in.bump_in_this_line( marker_size ); + eol::match( in ); + return true; + case Marker: + break; + default: + return false; + } + } + return false; + } + }; + + template< char Open, char Marker > + struct skip_control< raw_string_open< Open, Marker > > : std::true_type + { + }; + + template< char Marker, char Close > + struct at_raw_string_close + { + using analyze_t = analysis::generic< analysis::rule_type::opt >; + + template< apply_mode A, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, const std::size_t& marker_size, States&&... /*unused*/ ) noexcept( noexcept( in.size( 0 ) ) ) + { + if( in.size( marker_size ) < marker_size ) { + return false; + } + if( in.peek_char( 0 ) != Close ) { + return false; + } + if( in.peek_char( marker_size - 1 ) != Close ) { + return false; + } + for( std::size_t i = 0; i < ( marker_size - 2 ); ++i ) { + if( in.peek_char( i + 1 ) != Marker ) { + return false; + } + } + return true; + } + }; + + template< char Marker, char Close > + struct skip_control< at_raw_string_close< Marker, Close > > : std::true_type + { + }; + + template< typename Cond, typename... Rules > + struct raw_string_until; + + template< typename Cond > + struct raw_string_until< Cond > + { + using analyze_t = analysis::generic< analysis::rule_type::seq, star< not_at< Cond >, not_at< eof >, bytes< 1 > >, Cond >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, const std::size_t& marker_size, States&&... st ) + { + auto m = in.template mark< M >(); + + while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, marker_size, st... ) ) { + if( in.empty() ) { + return false; + } + in.bump(); + } + return m( true ); + } + }; + + template< typename Cond, typename... Rules > + struct raw_string_until + { + using analyze_t = analysis::generic< analysis::rule_type::seq, star< not_at< Cond >, not_at< eof >, Rules... >, Cond >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, const std::size_t& marker_size, States&&... st ) + { + auto m = in.template mark< M >(); + using m_t = decltype( m ); + + while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, marker_size, st... ) ) { + if( in.empty() || ( !Control< seq< Rules... > >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) ) { + return false; + } + } + return m( true ); + } + }; + + template< typename Cond, typename... Rules > + struct skip_control< raw_string_until< Cond, Rules... > > : std::true_type + { + }; + + } // namespace internal + + // raw_string matches Lua-style long literals. + // + // The following description was taken from the Lua documentation + // (see http://www.lua.org/docs.html): + // + // - An "opening long bracket of level n" is defined as an opening square + // bracket followed by n equal signs followed by another opening square + // bracket. So, an opening long bracket of level 0 is written as `[[`, + // an opening long bracket of level 1 is written as `[=[`, and so on. + // - A "closing long bracket" is defined similarly; for instance, a closing + // long bracket of level 4 is written as `]====]`. + // - A "long literal" starts with an opening long bracket of any level and + // ends at the first closing long bracket of the same level. It can + // contain any text except a closing bracket of the same level. + // - Literals in this bracketed form can run for several lines, do not + // interpret any escape sequences, and ignore long brackets of any other + // level. + // - For convenience, when the opening long bracket is immediately followed + // by a newline, the newline is not included in the string. + // + // Note that unlike Lua's long literal, a raw_string is customizable to use + // other characters than `[`, `=` and `]` for matching. Also note that Lua + // introduced newline-specific replacements in Lua 5.2, which we do not + // support on the grammar level. + + template< char Open, char Marker, char Close, typename... Contents > + struct raw_string + { + // This is used for binding the apply()-method and for error-reporting + // when a raw string is not closed properly or has invalid content. + struct content + : internal::raw_string_until< internal::at_raw_string_close< Marker, Close >, Contents... > + { + }; + + using analyze_t = typename internal::seq< internal::bytes< 1 >, content, internal::bytes< 1 > >::analyze_t; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + std::size_t marker_size; + if( internal::raw_string_open< Open, Marker >::template match< A, M, Action, Control >( in, marker_size, st... ) ) { + internal::must< content >::template match< A, M, Action, Control >( in, marker_size, st... ); + in.bump_in_this_line( marker_size ); + return true; + } + return false; + } + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/remove_first_state.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/remove_first_state.hpp new file mode 100644 index 0000000..bbd671b --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/remove_first_state.hpp @@ -0,0 +1,62 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_REMOVE_FIRST_STATE_HPP +#define TAO_PEGTL_CONTRIB_REMOVE_FIRST_STATE_HPP + +#include "../config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + // Applies to start(), success(), failure(), raise(), apply(), and apply0(): + // The first state is removed when the call is forwarded to Base. + template< typename Base > + struct remove_first_state + : Base + { + template< typename Input, typename State, typename... States > + static void start( const Input& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::start( in, st... ) ) ) + { + Base::start( in, st... ); + } + + template< typename Input, typename State, typename... States > + static void success( const Input& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::success( in, st... ) ) ) + { + Base::success( in, st... ); + } + + template< typename Input, typename State, typename... States > + static void failure( const Input& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::failure( in, st... ) ) ) + { + Base::failure( in, st... ); + } + + template< typename Input, typename State, typename... States > + static void raise( const Input& in, State&& /*unused*/, States&&... st ) + { + Base::raise( in, st... ); + } + + template< template< typename... > class Action, typename Iterator, typename Input, typename State, typename... States > + static auto apply( const Iterator& begin, const Input& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::template apply< Action >( begin, in, st... ) ) ) + -> decltype( Base::template apply< Action >( begin, in, st... ) ) + { + return Base::template apply< Action >( begin, in, st... ); + } + + template< template< typename... > class Action, typename Input, typename State, typename... States > + static auto apply0( const Input& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::template apply0< Action >( in, st... ) ) ) + -> decltype( Base::template apply0< Action >( in, st... ) ) + { + return Base::template apply0< Action >( in, st... ); + } + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/remove_last_states.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/remove_last_states.hpp new file mode 100644 index 0000000..c65cdc0 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/remove_last_states.hpp @@ -0,0 +1,106 @@ +// Copyright (c) 2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_REMOVE_LAST_STATES_HPP +#define TAO_PEGTL_CONTRIB_REMOVE_LAST_STATES_HPP + +#include +#include + +#include "../config.hpp" +#include "../internal/integer_sequence.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + // Remove the last N states of start(), success(), failure(), raise(), apply(), and apply0() + template< typename Base, std::size_t N > + struct remove_last_states + : Base + { + template< typename Input, typename Tuple, std::size_t... Is > + static void start_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::start( in, std::get< Is >( t )... ) ) ) + { + Base::start( in, std::get< Is >( t )... ); + } + + template< typename Input, typename... States > + static void start( const Input& in, States&&... st ) noexcept( noexcept( start_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ) ) ) + { + start_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ); + } + + template< typename Input, typename Tuple, std::size_t... Is > + static void success_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::success( in, std::get< Is >( t )... ) ) ) + { + Base::success( in, std::get< Is >( t )... ); + } + + template< typename Input, typename... States > + static void success( const Input& in, States&&... st ) noexcept( noexcept( success_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ) ) ) + { + success_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ); + } + + template< typename Input, typename Tuple, std::size_t... Is > + static void failure_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::failure( in, std::get< Is >( t )... ) ) ) + { + Base::failure( in, std::get< Is >( t )... ); + } + + template< typename Input, typename... States > + static void failure( const Input& in, States&&... st ) noexcept( noexcept( failure_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ) ) ) + { + failure_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ); + } + + template< typename Input, typename Tuple, std::size_t... Is > + static void raise_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) + { + Base::raise( in, std::get< Is >( t )... ); + } + + template< typename Input, typename... States > + static void raise( const Input& in, States&&... st ) + { + raise_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ); + } + + template< template< typename... > class Action, typename Iterator, typename Input, typename Tuple, std::size_t... Is > + static auto apply_impl( const Iterator& begin, const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::template apply< Action >( begin, in, std::get< Is >( t )... ) ) ) + -> decltype( Base::template apply< Action >( begin, in, std::get< Is >( t )... ) ) + { + return Base::template apply< Action >( begin, in, std::get< Is >( t )... ); + } + + template< template< typename... > class Action, typename Iterator, typename Input, typename... States > + static auto apply( const Iterator& begin, const Input& in, States&&... st ) noexcept( noexcept( apply_impl< Action >( begin, in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ) ) ) + -> decltype( apply_impl< Action >( begin, in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ) ) + { + return apply_impl< Action >( begin, in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ); + } + + template< template< typename... > class Action, typename Input, typename Tuple, std::size_t... Is > + static auto apply0_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::template apply0< Action >( in, std::get< Is >( t )... ) ) ) + -> decltype( Base::template apply0< Action >( in, std::get< Is >( t )... ) ) + { + return Base::template apply0< Action >( in, std::get< Is >( t )... ); + } + + template< template< typename... > class Action, typename Input, typename... States > + static auto apply0( const Input& in, States&&... st ) noexcept( noexcept( apply0_impl< Action >( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ) ) ) + -> decltype( apply0_impl< Action >( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ) ) + { + return apply0_impl< Action >( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ); + } + }; + + template< typename Base > + using remove_last_state = remove_last_states< Base, 1 >; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/rep_one_min_max.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/rep_one_min_max.hpp new file mode 100644 index 0000000..9173ad4 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/rep_one_min_max.hpp @@ -0,0 +1,68 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_REP_ONE_MIN_MAX_HPP +#define TAO_PEGTL_CONTRIB_REP_ONE_MIN_MAX_HPP + +#include + +#include "../config.hpp" + +#include "../analysis/counted.hpp" + +#include "../internal/bump_help.hpp" +#include "../internal/skip_control.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< unsigned Min, unsigned Max, char C > + struct rep_one_min_max + { + using analyze_t = analysis::counted< analysis::rule_type::any, Min >; + + static_assert( Min <= Max, "invalid rep_one_min_max rule (maximum number of repetitions smaller than minimum)" ); + + template< typename Input > + static bool match( Input& in ) + { + const auto size = in.size( Max + 1 ); + if( size < Min ) { + return false; + } + std::size_t i = 0; + while( ( i < size ) && ( in.peek_char( i ) == C ) ) { + ++i; + } + if( ( Min <= i ) && ( i <= Max ) ) { + bump_help< result_on_found::success, Input, char, C >( in, i ); + return true; + } + return false; + } + }; + + template< unsigned Min, unsigned Max, char C > + struct skip_control< rep_one_min_max< Min, Max, C > > : std::true_type + { + }; + + } // namespace internal + + inline namespace ascii + { + template< unsigned Min, unsigned Max, char C > + struct rep_one_min_max : internal::rep_one_min_max< Min, Max, C > + { + }; + + } // namespace ascii + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/rep_string.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/rep_string.hpp new file mode 100644 index 0000000..41fc369 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/rep_string.hpp @@ -0,0 +1,47 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_REP_STRING_HPP +#define TAO_PEGTL_CONTRIB_REP_STRING_HPP + +#include + +#include "../config.hpp" +#include "../internal/string.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< std::size_t, typename, char... > + struct make_rep_string; + + template< char... Ss, char... Cs > + struct make_rep_string< 0, string< Ss... >, Cs... > + { + using type = string< Ss... >; + }; + + template< std::size_t N, char... Ss, char... Cs > + struct make_rep_string< N, string< Ss... >, Cs... > + : make_rep_string< N - 1, string< Ss..., Cs... >, Cs... > + {}; + + } // namespace internal + + inline namespace ascii + { + template< std::size_t N, char... Cs > + struct rep_string + : internal::make_rep_string< N, internal::string<>, Cs... >::type + {}; + + } // namespace ascii + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/shuffle_states.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/shuffle_states.hpp new file mode 100644 index 0000000..57caee3 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/shuffle_states.hpp @@ -0,0 +1,174 @@ +// Copyright (c) 2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_SHUFFLE_STATES_HPP +#define TAO_PEGTL_CONTRIB_SHUFFLE_STATES_HPP + +#include +#include + +#include "../config.hpp" +#include "../internal/integer_sequence.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< std::size_t N > + struct rotate_left + { + template< std::size_t I, std::size_t S > + using type = std::integral_constant< std::size_t, ( I + N ) % S >; + }; + + template< std::size_t N > + struct rotate_right + { + template< std::size_t I, std::size_t S > + using type = std::integral_constant< std::size_t, ( I + S - N ) % S >; + }; + + struct reverse + { + template< std::size_t I, std::size_t S > + using type = std::integral_constant< std::size_t, ( S - 1 ) - I >; + }; + + } // namespace internal + + // Applies 'Shuffle' to the states of start(), success(), failure(), raise(), apply(), and apply0() + template< typename Base, typename Shuffle > + struct shuffle_states + : Base + { + template< typename Input, typename Tuple, std::size_t... Is > + static void start_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::start( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ) ) ) + { + Base::start( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ); + } + + template< typename Input, typename... States > + static void start( const Input& in, States&&... st ) noexcept( noexcept( start_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ) ) ) + { + start_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ); + } + + template< typename Input, typename State > + static void start( const Input& in, State&& st ) noexcept( noexcept( Base::start( in, st ) ) ) + { + Base::start( in, st ); + } + + template< typename Input, typename Tuple, std::size_t... Is > + static void success_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::success( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ) ) ) + { + Base::success( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ); + } + + template< typename Input, typename... States > + static void success( const Input& in, States&&... st ) noexcept( noexcept( success_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ) ) ) + { + success_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ); + } + + template< typename Input, typename State > + static void success( const Input& in, State&& st ) noexcept( noexcept( Base::success( in, st ) ) ) + { + Base::success( in, st ); + } + + template< typename Input, typename Tuple, std::size_t... Is > + static void failure_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::failure( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ) ) ) + { + Base::failure( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ); + } + + template< typename Input, typename... States > + static void failure( const Input& in, States&&... st ) noexcept( noexcept( failure_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ) ) ) + { + failure_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ); + } + + template< typename Input, typename State > + static void failure( const Input& in, State&& st ) noexcept( noexcept( Base::failure( in, st ) ) ) + { + Base::failure( in, st ); + } + + template< typename Input, typename Tuple, std::size_t... Is > + static void raise_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) + { + Base::raise( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ); + } + + template< typename Input, typename... States > + static void raise( const Input& in, States&&... st ) + { + raise_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ); + } + + template< typename Input, typename State > + static void raise( const Input& in, State&& st ) + { + Base::raise( in, st ); + } + + template< template< typename... > class Action, typename Iterator, typename Input, typename Tuple, std::size_t... Is > + static auto apply_impl( const Iterator& begin, const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::template apply< Action >( begin, in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ) ) ) + -> decltype( Base::template apply< Action >( begin, in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ) ) + { + return Base::template apply< Action >( begin, in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ); + } + + template< template< typename... > class Action, typename Iterator, typename Input, typename... States > + static auto apply( const Iterator& begin, const Input& in, States&&... st ) noexcept( noexcept( apply_impl< Action >( begin, in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ) ) ) + -> decltype( apply_impl< Action >( begin, in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ) ) + { + return apply_impl< Action >( begin, in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ); + } + + template< template< typename... > class Action, typename Iterator, typename Input, typename State > + static auto apply( const Iterator& begin, const Input& in, State&& st ) noexcept( noexcept( Base::template apply< Action >( begin, in, st ) ) ) + -> decltype( Base::template apply< Action >( begin, in, st ) ) + { + return Base::template apply< Action >( begin, in, st ); + } + + template< template< typename... > class Action, typename Input, typename Tuple, std::size_t... Is > + static auto apply0_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::template apply0< Action >( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ) ) ) + -> decltype( Base::template apply0< Action >( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ) ) + { + return Base::template apply0< Action >( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ); + } + + template< template< typename... > class Action, typename Input, typename... States > + static auto apply0( const Input& in, States&&... st ) noexcept( noexcept( apply0_impl< Action >( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ) ) ) + -> decltype( apply0_impl< Action >( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ) ) + { + return apply0_impl< Action >( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ); + } + + template< template< typename... > class Action, typename Input, typename State > + static auto apply0( const Input& in, State&& st ) noexcept( noexcept( Base::template apply0< Action >( in, st ) ) ) + -> decltype( Base::template apply0< Action >( in, st ) ) + { + return Base::template apply0< Action >( in, st ); + } + }; + + template< typename Base, std::size_t N = 1 > + using rotate_states_left = shuffle_states< Base, internal::rotate_left< N > >; + + template< typename Base, std::size_t N = 1 > + using rotate_states_right = shuffle_states< Base, internal::rotate_right< N > >; + + template< typename Base > + using reverse_states = shuffle_states< Base, internal::reverse >; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/to_string.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/to_string.hpp new file mode 100644 index 0000000..4d74384 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/to_string.hpp @@ -0,0 +1,42 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_TO_STRING_HPP +#define TAO_PEGTL_CONTRIB_TO_STRING_HPP + +#include + +#include "../config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename > + struct to_string; + + template< template< char... > class X, char... Cs > + struct to_string< X< Cs... > > + { + static std::string get() + { + const char s[] = { Cs..., 0 }; + return std::string( s, sizeof...( Cs ) ); + } + }; + + } // namespace internal + + template< typename T > + std::string to_string() + { + return internal::to_string< T >::get(); + } + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/tracer.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/tracer.hpp new file mode 100644 index 0000000..4174e91 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/tracer.hpp @@ -0,0 +1,253 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_TRACER_HPP +#define TAO_PEGTL_CONTRIB_TRACER_HPP + +#include +#include +#include +#include +#include + +#include "../config.hpp" +#include "../normal.hpp" + +#include "../internal/demangle.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Input > + void print_current( const Input& in ) + { + if( in.empty() ) { + std::cerr << ""; + } + else { + const auto c = in.peek_uint8(); + switch( c ) { + case 0: + std::cerr << " = "; + break; + case 9: + std::cerr << " = "; + break; + case 10: + std::cerr << " = "; + break; + case 13: + std::cerr << " = "; + break; + default: + if( isprint( c ) ) { + std::cerr << '\'' << c << "' = "; + } + } + std::cerr << "(char)" << unsigned( c ); + } + } + + } // namespace internal + + struct trace_state + { + unsigned rule = 0; + unsigned line = 0; + std::vector< unsigned > stack; + }; + +#if defined( _MSC_VER ) && ( _MSC_VER < 1910 ) + + template< typename Rule > + struct tracer + : normal< Rule > + { + template< typename Input, typename... States > + static void start( const Input& in, States&&... /*unused*/ ) + { + std::cerr << in.position() << " start " << internal::demangle< Rule >() << "; current "; + print_current( in ); + std::cerr << std::endl; + } + + template< typename Input, typename... States > + static void start( const Input& in, trace_state& ts, States&&... st ) + { + std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ++ts.rule << " "; + start( in, st... ); + ts.stack.push_back( ts.rule ); + } + + template< typename Input, typename... States > + static void success( const Input& in, States&&... /*unused*/ ) + { + std::cerr << in.position() << " success " << internal::demangle< Rule >() << "; next "; + print_current( in ); + std::cerr << std::endl; + } + + template< typename Input, typename... States > + static void success( const Input& in, trace_state& ts, States&&... st ) + { + assert( !ts.stack.empty() ); + std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ts.stack.back() << " "; + success( in, st... ); + ts.stack.pop_back(); + } + + template< typename Input, typename... States > + static void failure( const Input& in, States&&... /*unused*/ ) + { + std::cerr << in.position() << " failure " << internal::demangle< Rule >() << std::endl; + } + + template< typename Input, typename... States > + static void failure( const Input& in, trace_state& ts, States&&... st ) + { + assert( !ts.stack.empty() ); + std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ts.stack.back() << " "; + failure( in, st... ); + ts.stack.pop_back(); + } + + template< template< typename... > class Action, typename Iterator, typename Input, typename... States > + static auto apply( const Iterator& begin, const Input& in, States&&... st ) + -> decltype( normal< Rule >::template apply< Action >( begin, in, st... ) ) + { + std::cerr << in.position() << " apply " << internal::demangle< Rule >() << std::endl; + return normal< Rule >::template apply< Action >( begin, in, st... ); + } + + template< template< typename... > class Action, typename Iterator, typename Input, typename... States > + static auto apply( const Iterator& begin, const Input& in, trace_state& ts, States&&... st ) + -> decltype( apply< Action >( begin, in, st... ) ) + { + std::cerr << std::setw( 6 ) << ++ts.line << " "; + return apply< Action >( begin, in, st... ); + } + + template< template< typename... > class Action, typename Input, typename... States > + static auto apply0( const Input& in, States&&... st ) + -> decltype( normal< Rule >::template apply0< Action >( in, st... ) ) + { + std::cerr << in.position() << " apply0 " << internal::demangle< Rule >() << std::endl; + return normal< Rule >::template apply0< Action >( in, st... ); + } + + template< template< typename... > class Action, typename Input, typename... States > + static auto apply0( const Input& in, trace_state& ts, States&&... st ) + -> decltype( apply0< Action >( in, st... ) ) + { + std::cerr << std::setw( 6 ) << ++ts.line << " "; + return apply0< Action >( in, st... ); + } + }; + +#else + + template< template< typename... > class Base > + struct trace + { + template< typename Rule > + struct control + : Base< Rule > + { + template< typename Input, typename... States > + static void start( const Input& in, States&&... st ) + { + std::cerr << in.position() << " start " << internal::demangle< Rule >() << "; current "; + print_current( in ); + std::cerr << std::endl; + Base< Rule >::start( in, st... ); + } + + template< typename Input, typename... States > + static void start( const Input& in, trace_state& ts, States&&... st ) + { + std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ++ts.rule << " "; + start( in, st... ); + ts.stack.push_back( ts.rule ); + } + + template< typename Input, typename... States > + static void success( const Input& in, States&&... st ) + { + std::cerr << in.position() << " success " << internal::demangle< Rule >() << "; next "; + print_current( in ); + std::cerr << std::endl; + Base< Rule >::success( in, st... ); + } + + template< typename Input, typename... States > + static void success( const Input& in, trace_state& ts, States&&... st ) + { + assert( !ts.stack.empty() ); + std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ts.stack.back() << " "; + success( in, st... ); + ts.stack.pop_back(); + } + + template< typename Input, typename... States > + static void failure( const Input& in, States&&... st ) + { + std::cerr << in.position() << " failure " << internal::demangle< Rule >() << std::endl; + Base< Rule >::failure( in, st... ); + } + + template< typename Input, typename... States > + static void failure( const Input& in, trace_state& ts, States&&... st ) + { + assert( !ts.stack.empty() ); + std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ts.stack.back() << " "; + failure( in, st... ); + ts.stack.pop_back(); + } + + template< template< typename... > class Action, typename Iterator, typename Input, typename... States > + static auto apply( const Iterator& begin, const Input& in, States&&... st ) + -> decltype( Base< Rule >::template apply< Action >( begin, in, st... ) ) + { + std::cerr << in.position() << " apply " << internal::demangle< Rule >() << std::endl; + return Base< Rule >::template apply< Action >( begin, in, st... ); + } + + template< template< typename... > class Action, typename Iterator, typename Input, typename... States > + static auto apply( const Iterator& begin, const Input& in, trace_state& ts, States&&... st ) + -> decltype( apply< Action >( begin, in, st... ) ) + { + std::cerr << std::setw( 6 ) << ++ts.line << " "; + return apply< Action >( begin, in, st... ); + } + + template< template< typename... > class Action, typename Input, typename... States > + static auto apply0( const Input& in, States&&... st ) + -> decltype( Base< Rule >::template apply0< Action >( in, st... ) ) + { + std::cerr << in.position() << " apply0 " << internal::demangle< Rule >() << std::endl; + return Base< Rule >::template apply0< Action >( in, st... ); + } + + template< template< typename... > class Action, typename Input, typename... States > + static auto apply0( const Input& in, trace_state& ts, States&&... st ) + -> decltype( apply0< Action >( in, st... ) ) + { + std::cerr << std::setw( 6 ) << ++ts.line << " "; + return apply0< Action >( in, st... ); + } + }; + }; + + template< typename Rule > + using tracer = trace< normal >::control< Rule >; + +#endif + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/unescape.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/unescape.hpp new file mode 100644 index 0000000..9b6090a --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/unescape.hpp @@ -0,0 +1,207 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_UNESCAPE_HPP +#define TAO_PEGTL_CONTRIB_UNESCAPE_HPP + +#include +#include + +#include "../ascii.hpp" +#include "../config.hpp" +#include "../parse_error.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace unescape + { + // Utility functions for the unescape actions. + + inline bool utf8_append_utf32( std::string& string, const unsigned utf32 ) + { + if( utf32 <= 0x7f ) { + string += char( utf32 & 0xff ); + return true; + } + if( utf32 <= 0x7ff ) { + char tmp[] = { char( ( ( utf32 & 0x7c0 ) >> 6 ) | 0xc0 ), // NOLINT + char( ( ( utf32 & 0x03f ) ) | 0x80 ) }; + string.append( tmp, sizeof( tmp ) ); + return true; + } + if( utf32 <= 0xffff ) { + if( utf32 >= 0xd800 && utf32 <= 0xdfff ) { + // nope, this is a UTF-16 surrogate + return false; + } + char tmp[] = { char( ( ( utf32 & 0xf000 ) >> 12 ) | 0xe0 ), // NOLINT + char( ( ( utf32 & 0x0fc0 ) >> 6 ) | 0x80 ), + char( ( ( utf32 & 0x003f ) ) | 0x80 ) }; + string.append( tmp, sizeof( tmp ) ); + return true; + } + if( utf32 <= 0x10ffff ) { + char tmp[] = { char( ( ( utf32 & 0x1c0000 ) >> 18 ) | 0xf0 ), // NOLINT + char( ( ( utf32 & 0x03f000 ) >> 12 ) | 0x80 ), + char( ( ( utf32 & 0x000fc0 ) >> 6 ) | 0x80 ), + char( ( ( utf32 & 0x00003f ) ) | 0x80 ) }; + string.append( tmp, sizeof( tmp ) ); + return true; + } + return false; + } + + // This function MUST only be called for characters matching TAO_PEGTL_NAMESPACE::ascii::xdigit! + template< typename I > + I unhex_char( const char c ) + { + switch( c ) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return I( c - '0' ); + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + return I( c - 'a' + 10 ); + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + return I( c - 'A' + 10 ); + default: // LCOV_EXCL_LINE + throw std::runtime_error( "invalid character in unhex" ); // NOLINT, LCOV_EXCL_LINE + } + } + + template< typename I > + I unhex_string( const char* begin, const char* end ) + { + I r = 0; + while( begin != end ) { + r <<= 4; + r += unhex_char< I >( *begin++ ); + } + return r; + } + + // Actions for common unescape situations. + + struct append_all + { + template< typename Input > + static void apply( const Input& in, std::string& s ) + { + s.append( in.begin(), in.size() ); + } + }; + + // This action MUST be called for a character matching T which MUST be TAO_PEGTL_NAMESPACE::one< ... >. + template< typename T, char... Rs > + struct unescape_c + { + template< typename Input > + static void apply( const Input& in, std::string& s ) + { + assert( in.size() == 1 ); + s += apply_one( in, static_cast< const T* >( nullptr ) ); + } + + template< typename Input, char... Qs > + static char apply_one( const Input& in, const one< Qs... >* /*unused*/ ) + { + static_assert( sizeof...( Qs ) == sizeof...( Rs ), "size mismatch between escaped characters and their mappings" ); + return apply_two( in, { Qs... }, { Rs... } ); + } + + template< typename Input > + static char apply_two( const Input& in, const std::initializer_list< char >& q, const std::initializer_list< char >& r ) + { + const char c = *in.begin(); + for( std::size_t i = 0; i < q.size(); ++i ) { + if( *( q.begin() + i ) == c ) { + return *( r.begin() + i ); + } + } + throw parse_error( "invalid character in unescape", in ); // NOLINT, LCOV_EXCL_LINE + } + }; + + // See src/example/pegtl/unescape.cpp for why the following two actions + // skip the first input character. They also MUST be called + // with non-empty matched inputs! + + struct unescape_u + { + template< typename Input > + static void apply( const Input& in, std::string& s ) + { + assert( !in.empty() ); // First character MUST be present, usually 'u' or 'U'. + if( !utf8_append_utf32( s, unhex_string< unsigned >( in.begin() + 1, in.end() ) ) ) { + throw parse_error( "invalid escaped unicode code point", in ); + } + } + }; + + struct unescape_x + { + template< typename Input > + static void apply( const Input& in, std::string& s ) + { + assert( !in.empty() ); // First character MUST be present, usually 'x'. + s += unhex_string< char >( in.begin() + 1, in.end() ); + } + }; + + // The unescape_j action is similar to unescape_u, however unlike + // unescape_u it + // (a) assumes exactly 4 hexdigits per escape sequence, + // (b) accepts multiple consecutive escaped 16-bit values. + // When applied to more than one escape sequence, unescape_j + // translates UTF-16 surrogate pairs in the input into a single + // UTF-8 sequence in s, as required for JSON by RFC 8259. + + struct unescape_j + { + template< typename Input > + static void apply( const Input& in, std::string& s ) + { + assert( ( ( in.size() + 1 ) % 6 ) == 0 ); // Expects multiple "\\u1234", starting with the first "u". + for( const char* b = in.begin() + 1; b < in.end(); b += 6 ) { + const auto c = unhex_string< unsigned >( b, b + 4 ); + if( ( 0xd800 <= c ) && ( c <= 0xdbff ) && ( b + 6 < in.end() ) ) { + const auto d = unhex_string< unsigned >( b + 6, b + 10 ); + if( ( 0xdc00 <= d ) && ( d <= 0xdfff ) ) { + b += 6; + (void)utf8_append_utf32( s, ( ( ( c & 0x03ff ) << 10 ) | ( d & 0x03ff ) ) + 0x10000 ); + continue; + } + } + if( !utf8_append_utf32( s, c ) ) { + throw parse_error( "invalid escaped unicode code point", in ); + } + } + } + }; + + } // namespace unescape + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/uri.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/uri.hpp new file mode 100644 index 0000000..f86d2de --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/uri.hpp @@ -0,0 +1,115 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_URI_HPP +#define TAO_PEGTL_CONTRIB_URI_HPP + +#include "../ascii.hpp" +#include "../config.hpp" +#include "../rules.hpp" +#include "../utf8.hpp" + +#include "abnf.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace uri + { + // URI grammar according to RFC 3986. + + // This grammar is a direct PEG translation of the original URI grammar. + // It should be considered experimental -- in case of any issues, in particular + // missing rules for attached actions, please contact the developers. + + // Note that this grammar has multiple top-level rules. + + using dot = one< '.' >; + using colon = one< ':' >; + + // clang-format off + struct dec_octet : sor< one< '0' >, + rep_min_max< 1, 2, abnf::DIGIT >, + seq< one< '1' >, abnf::DIGIT, abnf::DIGIT >, + seq< one< '2' >, range< '0', '4' >, abnf::DIGIT >, + seq< string< '2', '5' >, range< '0', '5' > > > {}; + + struct IPv4address : seq< dec_octet, dot, dec_octet, dot, dec_octet, dot, dec_octet > {}; + + struct h16 : rep_min_max< 1, 4, abnf::HEXDIG > {}; + struct ls32 : sor< seq< h16, colon, h16 >, IPv4address > {}; + + struct dcolon : two< ':' > {}; + + struct IPv6address : sor< seq< rep< 6, h16, colon >, ls32 >, + seq< dcolon, rep< 5, h16, colon >, ls32 >, + seq< opt< h16 >, dcolon, rep< 4, h16, colon >, ls32 >, + seq< opt< h16, opt< colon, h16 > >, dcolon, rep< 3, h16, colon >, ls32 >, + seq< opt< h16, rep_opt< 2, colon, h16 > >, dcolon, rep< 2, h16, colon >, ls32 >, + seq< opt< h16, rep_opt< 3, colon, h16 > >, dcolon, h16, colon, ls32 >, + seq< opt< h16, rep_opt< 4, colon, h16 > >, dcolon, ls32 >, + seq< opt< h16, rep_opt< 5, colon, h16 > >, dcolon, h16 >, + seq< opt< h16, rep_opt< 6, colon, h16 > >, dcolon > > {}; + + struct gen_delims : one< ':', '/', '?', '#', '[', ']', '@' > {}; + struct sub_delims : one< '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=' > {}; + + struct unreserved : sor< abnf::ALPHA, abnf::DIGIT, one< '-', '.', '_', '~' > > {}; + struct reserved : sor< gen_delims, sub_delims > {}; + + struct IPvFuture : if_must< one< 'v' >, plus< abnf::HEXDIG >, dot, plus< sor< unreserved, sub_delims, colon > > > {}; + + struct IP_literal : if_must< one< '[' >, sor< IPvFuture, IPv6address >, one< ']' > > {}; + + struct pct_encoded : if_must< one< '%' >, abnf::HEXDIG, abnf::HEXDIG > {}; + struct pchar : sor< unreserved, pct_encoded, sub_delims, one< ':', '@' > > {}; + + struct query : star< sor< pchar, one< '/', '?' > > > {}; + struct fragment : star< sor< pchar, one< '/', '?' > > > {}; + + struct segment : star< pchar > {}; + struct segment_nz : plus< pchar > {}; + struct segment_nz_nc : plus< sor< unreserved, pct_encoded, sub_delims, one< '@' > > > {}; // non-zero-length segment without any colon ":" + + struct path_abempty : star< one< '/' >, segment > {}; + struct path_absolute : seq< one< '/' >, opt< segment_nz, star< one< '/' >, segment > > > {}; + struct path_noscheme : seq< segment_nz_nc, star< one< '/' >, segment > > {}; + struct path_rootless : seq< segment_nz, star< one< '/' >, segment > > {}; + struct path_empty : success {}; + + struct path : sor< path_noscheme, // begins with a non-colon segment + path_rootless, // begins with a segment + path_absolute, // begins with "/" but not "//" + path_abempty > {}; // begins with "/" or is empty + + struct reg_name : star< sor< unreserved, pct_encoded, sub_delims > > {}; + + struct port : star< abnf::DIGIT > {}; + struct host : sor< IP_literal, IPv4address, reg_name > {}; + struct userinfo : star< sor< unreserved, pct_encoded, sub_delims, colon > > {}; + struct opt_userinfo : opt< userinfo, one< '@' > > {}; + struct authority : seq< opt_userinfo, host, opt< colon, port > > {}; + + struct scheme : seq< abnf::ALPHA, star< sor< abnf::ALPHA, abnf::DIGIT, one< '+', '-', '.' > > > > {}; + + using dslash = two< '/' >; + using opt_query = opt_must< one< '?' >, query >; + using opt_fragment = opt_must< one< '#' >, fragment >; + + struct hier_part : sor< if_must< dslash, authority, path_abempty >, path_rootless, path_absolute, path_empty > {}; + struct relative_part : sor< if_must< dslash, authority, path_abempty >, path_noscheme, path_absolute, path_empty > {}; + struct relative_ref : seq< relative_part, opt_query, opt_fragment > {}; + + struct URI : seq< scheme, one< ':' >, hier_part, opt_query, opt_fragment > {}; + struct URI_reference : sor< URI, relative_ref > {}; + struct absolute_URI : seq< scheme, one< ':' >, hier_part, opt_query > {}; + // clang-format on + + } // namespace uri + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/cstream_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/cstream_input.hpp new file mode 100644 index 0000000..d14e828 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/cstream_input.hpp @@ -0,0 +1,39 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CSTREAM_INPUT_HPP +#define TAO_PEGTL_CSTREAM_INPUT_HPP + +#include + +#include "buffer_input.hpp" +#include "config.hpp" +#include "eol.hpp" + +#include "internal/cstream_reader.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + template< typename Eol = eol::lf_crlf, std::size_t Chunk = 64 > + struct cstream_input + : buffer_input< internal::cstream_reader, Eol, std::string, Chunk > + { + template< typename T > + cstream_input( std::FILE* in_stream, const std::size_t in_maximum, T&& in_source ) + : buffer_input< internal::cstream_reader, Eol, std::string, Chunk >( std::forward< T >( in_source ), in_maximum, in_stream ) + { + } + }; + +#ifdef __cpp_deduction_guides + template< typename... Ts > + cstream_input( Ts&&... )->cstream_input<>; +#endif + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/disable_action.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/disable_action.hpp new file mode 100644 index 0000000..de51f0b --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/disable_action.hpp @@ -0,0 +1,39 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_DISABLE_ACTION_HPP +#define TAO_PEGTL_DISABLE_ACTION_HPP + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + struct disable_action + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + return TAO_PEGTL_NAMESPACE::match< Rule, apply_mode::nothing, M, Action, Control >( in, st... ); + } + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input.hpp new file mode 100644 index 0000000..e2e226f --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_DISCARD_INPUT_HPP +#define TAO_PEGTL_DISCARD_INPUT_HPP + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + struct discard_input + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + const bool result = TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... ); + in.discard(); + return result; + } + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input_on_failure.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input_on_failure.hpp new file mode 100644 index 0000000..1be1bdb --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input_on_failure.hpp @@ -0,0 +1,43 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_DISCARD_INPUT_ON_FAILURE_HPP +#define TAO_PEGTL_DISCARD_INPUT_ON_FAILURE_HPP + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + struct discard_input_on_failure + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + const bool result = TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... ); + if( !result ) { + in.discard(); + } + return result; + } + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input_on_success.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input_on_success.hpp new file mode 100644 index 0000000..56cc1cb --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input_on_success.hpp @@ -0,0 +1,43 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_DISCARD_INPUT_ON_SUCCESS_HPP +#define TAO_PEGTL_DISCARD_INPUT_ON_SUCCESS_HPP + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + struct discard_input_on_success + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + const bool result = TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... ); + if( result ) { + in.discard(); + } + return result; + } + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/enable_action.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/enable_action.hpp new file mode 100644 index 0000000..12447c3 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/enable_action.hpp @@ -0,0 +1,39 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_ENABLE_ACTION_HPP +#define TAO_PEGTL_ENABLE_ACTION_HPP + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + struct enable_action + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + return TAO_PEGTL_NAMESPACE::match< Rule, apply_mode::action, M, Action, Control >( in, st... ); + } + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/eol.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/eol.hpp new file mode 100644 index 0000000..e815064 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/eol.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_EOL_HPP +#define TAO_PEGTL_EOL_HPP + +#include "config.hpp" + +#include "internal/eol.hpp" + +#include "internal/cr_crlf_eol.hpp" +#include "internal/cr_eol.hpp" +#include "internal/crlf_eol.hpp" +#include "internal/lf_crlf_eol.hpp" +#include "internal/lf_eol.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + inline namespace ascii + { + // this is both a rule and a pseudo-namespace for eol::cr, ... + struct eol : internal::eol + { + // clang-format off + struct cr : internal::cr_eol {}; + struct cr_crlf : internal::cr_crlf_eol {}; + struct crlf : internal::crlf_eol {}; + struct lf : internal::lf_eol {}; + struct lf_crlf : internal::lf_crlf_eol {}; + // clang-format on + }; + + } // namespace ascii + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/eol_pair.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/eol_pair.hpp new file mode 100644 index 0000000..5e3072b --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/eol_pair.hpp @@ -0,0 +1,22 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_EOL_PAIR_HPP +#define TAO_PEGTL_EOL_PAIR_HPP + +#include +#include + +#include "config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + using eol_pair = std::pair< bool, std::size_t >; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/file_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/file_input.hpp new file mode 100644 index 0000000..b2c66d9 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/file_input.hpp @@ -0,0 +1,50 @@ +// Copyright (c) 2015-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_FILE_INPUT_HPP +#define TAO_PEGTL_FILE_INPUT_HPP + +#include "config.hpp" +#include "eol.hpp" +#include "tracking_mode.hpp" + +#if defined( __unix__ ) || ( defined( __APPLE__ ) && defined( __MACH__ ) ) +#include // Required for _POSIX_MAPPED_FILES +#endif + +#if defined( _POSIX_MAPPED_FILES ) || defined( _WIN32 ) +#include "mmap_input.hpp" +#else +#include "read_input.hpp" +#endif + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { +#if defined( _POSIX_MAPPED_FILES ) || defined( _WIN32 ) + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > + struct file_input + : mmap_input< P, Eol > + { + using mmap_input< P, Eol >::mmap_input; + }; +#else + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > + struct file_input + : read_input< P, Eol > + { + using read_input< P, Eol >::read_input; + }; +#endif + +#ifdef __cpp_deduction_guides + template< typename... Ts > + explicit file_input( Ts&&... )->file_input<>; +#endif + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/input_error.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/input_error.hpp new file mode 100644 index 0000000..08cb00b --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/input_error.hpp @@ -0,0 +1,51 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INPUT_ERROR_HPP +#define TAO_PEGTL_INPUT_ERROR_HPP + +#include +#include +#include + +#include "config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + struct input_error + : std::runtime_error + { + input_error( const std::string& message, const int in_errorno ) + : std::runtime_error( message ), + errorno( in_errorno ) + { + } + + int errorno; + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#define TAO_PEGTL_INTERNAL_UNWRAP( ... ) __VA_ARGS__ + +#define TAO_PEGTL_THROW_INPUT_ERROR( MESSAGE ) \ + do { \ + const int errorno = errno; \ + std::ostringstream oss; \ + oss << "pegtl: " << TAO_PEGTL_INTERNAL_UNWRAP( MESSAGE ) << " errno " << errorno; \ + throw tao::TAO_PEGTL_NAMESPACE::input_error( oss.str(), errorno ); \ + } while( false ) + +#define TAO_PEGTL_THROW_INPUT_WIN32_ERROR( MESSAGE ) \ + do { \ + const int errorno = GetLastError(); \ + std::ostringstream oss; \ + oss << "pegtl: " << TAO_PEGTL_INTERNAL_UNWRAP( MESSAGE ) << " GetLastError() " << errorno; \ + throw tao::TAO_PEGTL_NAMESPACE::input_error( oss.str(), errorno ); \ + } while( false ) + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/action.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/action.hpp new file mode 100644 index 0000000..ac69362 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/action.hpp @@ -0,0 +1,59 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_ACTION_HPP +#define TAO_PEGTL_INTERNAL_ACTION_HPP + +#include "../config.hpp" + +#include "seq.hpp" +#include "skip_control.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< template< typename... > class Action, typename... Rules > + struct action + : action< Action, seq< Rules... > > + { + }; + + template< template< typename... > class Action, typename Rule > + struct action< Action, Rule > + { + using analyze_t = analysis::generic< analysis::rule_type::seq, Rule >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + return Control< Rule >::template match< A, M, Action, Control >( in, st... ); + } + }; + + template< template< typename... > class Action, typename... Rules > + struct skip_control< action< Action, Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/action_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/action_input.hpp new file mode 100644 index 0000000..023bae9 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/action_input.hpp @@ -0,0 +1,120 @@ +// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_ACTION_INPUT_HPP +#define TAO_PEGTL_INTERNAL_ACTION_INPUT_HPP + +#include +#include +#include + +#include "iterator.hpp" + +#include "../config.hpp" +#include "../position.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + inline const char* begin_c_ptr( const char* p ) noexcept + { + return p; + } + + inline const char* begin_c_ptr( const iterator& it ) noexcept + { + return it.data; + } + + template< typename Input > + class action_input + { + public: + using input_t = Input; + using iterator_t = typename Input::iterator_t; + + action_input( const iterator_t& in_begin, const Input& in_input ) noexcept + : m_begin( in_begin ), + m_input( in_input ) + { + } + + action_input( const action_input& ) = delete; + action_input( action_input&& ) = delete; + + ~action_input() = default; + + action_input& operator=( const action_input& ) = delete; + action_input& operator=( action_input&& ) = delete; + + const iterator_t& iterator() const noexcept + { + return m_begin; + } + + const Input& input() const noexcept + { + return m_input; + } + + const char* begin() const noexcept + { + return begin_c_ptr( iterator() ); + } + + const char* end() const noexcept + { + return input().current(); + } + + bool empty() const noexcept + { + return begin() == end(); + } + + std::size_t size() const noexcept + { + return std::size_t( end() - begin() ); + } + + std::string string() const + { + return std::string( begin(), end() ); + } + + char peek_char( const std::size_t offset = 0 ) const noexcept + { + return begin()[ offset ]; + } + + std::uint8_t peek_uint8( const std::size_t offset = 0 ) const noexcept + { + return static_cast< std::uint8_t >( peek_char( offset ) ); + } + + // Compatibility, remove with 3.0.0 + std::uint8_t peek_byte( const std::size_t offset = 0 ) const noexcept + { + return static_cast< std::uint8_t >( peek_char( offset ) ); + } + + TAO_PEGTL_NAMESPACE::position position() const + { + return input().position( iterator() ); // NOTE: Not efficient with lazy inputs. + } + + protected: + const iterator_t m_begin; + const Input& m_input; + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/alnum.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/alnum.hpp new file mode 100644 index 0000000..de96d3a --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/alnum.hpp @@ -0,0 +1,26 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_ALNUM_HPP +#define TAO_PEGTL_INTERNAL_ALNUM_HPP + +#include "../config.hpp" + +#include "peek_char.hpp" +#include "ranges.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + using alnum = ranges< peek_char, 'a', 'z', 'A', 'Z', '0', '9' >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/alpha.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/alpha.hpp new file mode 100644 index 0000000..aeeebfd --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/alpha.hpp @@ -0,0 +1,26 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_ALPHA_HPP +#define TAO_PEGTL_INTERNAL_ALPHA_HPP + +#include "../config.hpp" + +#include "peek_char.hpp" +#include "ranges.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + using alpha = ranges< peek_char, 'a', 'z', 'A', 'Z' >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/always_false.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/always_false.hpp new file mode 100644 index 0000000..8683cad --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/always_false.hpp @@ -0,0 +1,29 @@ +// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_ALWAYS_FALSE_HPP +#define TAO_PEGTL_INTERNAL_ALWAYS_FALSE_HPP + +#include "../config.hpp" + +#include + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename... > + struct always_false + : std::false_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/any.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/any.hpp new file mode 100644 index 0000000..b1aee22 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/any.hpp @@ -0,0 +1,66 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_ANY_HPP +#define TAO_PEGTL_INTERNAL_ANY_HPP + +#include "../config.hpp" + +#include "peek_char.hpp" +#include "skip_control.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Peek > + struct any; + + template<> + struct any< peek_char > + { + using analyze_t = analysis::generic< analysis::rule_type::any >; + + template< typename Input > + static bool match( Input& in ) noexcept( noexcept( in.empty() ) ) + { + if( !in.empty() ) { + in.bump(); + return true; + } + return false; + } + }; + + template< typename Peek > + struct any + { + using analyze_t = analysis::generic< analysis::rule_type::any >; + + template< typename Input > + static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) ) + { + if( const auto t = Peek::peek( in ) ) { + in.bump( t.size ); + return true; + } + return false; + } + }; + + template< typename Peek > + struct skip_control< any< Peek > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply.hpp new file mode 100644 index 0000000..a2d35d8 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply.hpp @@ -0,0 +1,94 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_APPLY_HPP +#define TAO_PEGTL_INTERNAL_APPLY_HPP + +#include "../config.hpp" + +#include "apply_single.hpp" +#include "skip_control.hpp" + +#include "../analysis/counted.hpp" +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< apply_mode A, typename... Actions > + struct apply_impl; + + template<> + struct apply_impl< apply_mode::action > + { + template< typename Input, typename... States > + static bool match( Input& /*unused*/, States&&... /*unused*/ ) + { + return true; + } + }; + + template< typename... Actions > + struct apply_impl< apply_mode::action, Actions... > + { + template< typename Input, typename... States > + static bool match( Input& in, States&&... st ) + { + using action_t = typename Input::action_t; + const action_t i2( in.iterator(), in ); // No data -- range is from begin to begin. +#ifdef __cpp_fold_expressions + return ( apply_single< Actions >::match( i2, st... ) && ... ); +#else + bool result = true; + using swallow = bool[]; + (void)swallow{ result = result && apply_single< Actions >::match( i2, st... )... }; + return result; +#endif + } + }; + + template< typename... Actions > + struct apply_impl< apply_mode::nothing, Actions... > + { + template< typename Input, typename... States > + static bool match( Input& /*unused*/, States&&... /*unused*/ ) + { + return true; + } + }; + + template< typename... Actions > + struct apply + { + using analyze_t = analysis::counted< analysis::rule_type::any, 0 >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + return apply_impl< A, Actions... >::match( in, st... ); + } + }; + + template< typename... Actions > + struct skip_control< apply< Actions... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply0.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply0.hpp new file mode 100644 index 0000000..192c9c5 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply0.hpp @@ -0,0 +1,92 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_APPLY0_HPP +#define TAO_PEGTL_INTERNAL_APPLY0_HPP + +#include "../config.hpp" + +#include "apply0_single.hpp" +#include "skip_control.hpp" + +#include "../analysis/counted.hpp" +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< apply_mode A, typename... Actions > + struct apply0_impl; + + template<> + struct apply0_impl< apply_mode::action > + { + template< typename... States > + static bool match( States&&... /*unused*/ ) noexcept + { + return true; + } + }; + + template< typename... Actions > + struct apply0_impl< apply_mode::action, Actions... > + { + template< typename... States > + static bool match( States&&... st ) + { +#ifdef __cpp_fold_expressions + return ( apply0_single< Actions >::match( st... ) && ... ); +#else + bool result = true; + using swallow = bool[]; + (void)swallow{ result = result && apply0_single< Actions >::match( st... )... }; + return result; +#endif + } + }; + + template< typename... Actions > + struct apply0_impl< apply_mode::nothing, Actions... > + { + template< typename... States > + static bool match( States&&... /*unused*/ ) noexcept + { + return true; + } + }; + + template< typename... Actions > + struct apply0 + { + using analyze_t = analysis::counted< analysis::rule_type::any, 0 >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& /*unused*/, States&&... st ) + { + return apply0_impl< A, Actions... >::match( st... ); + } + }; + + template< typename... Actions > + struct skip_control< apply0< Actions... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply0_single.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply0_single.hpp new file mode 100644 index 0000000..7fe8cac --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply0_single.hpp @@ -0,0 +1,42 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_APPLY0_SINGLE_HPP +#define TAO_PEGTL_INTERNAL_APPLY0_SINGLE_HPP + +#include "../config.hpp" + +#include + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Action > + struct apply0_single + { + template< typename... States > + static auto match( States&&... st ) + -> typename std::enable_if< std::is_same< decltype( Action::apply0( st... ) ), void >::value, bool >::type + { + Action::apply0( st... ); + return true; + } + + template< typename... States > + static auto match( States&&... st ) + -> typename std::enable_if< std::is_same< decltype( Action::apply0( st... ) ), bool >::value, bool >::type + { + return Action::apply0( st... ); + } + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply_single.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply_single.hpp new file mode 100644 index 0000000..5300cbc --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply_single.hpp @@ -0,0 +1,42 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_APPLY_SINGLE_HPP +#define TAO_PEGTL_INTERNAL_APPLY_SINGLE_HPP + +#include "../config.hpp" + +#include + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Action > + struct apply_single + { + template< typename Input, typename... States > + static auto match( const Input& i2, States&&... st ) + -> typename std::enable_if< std::is_same< decltype( Action::apply( i2, st... ) ), void >::value, bool >::type + { + Action::apply( i2, st... ); + return true; + } + + template< typename Input, typename... States > + static auto match( const Input& i2, States&&... st ) + -> typename std::enable_if< std::is_same< decltype( Action::apply( i2, st... ) ), bool >::value, bool >::type + { + return Action::apply( i2, st... ); + } + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/at.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/at.hpp new file mode 100644 index 0000000..688bda7 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/at.hpp @@ -0,0 +1,67 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_AT_HPP +#define TAO_PEGTL_INTERNAL_AT_HPP + +#include "../config.hpp" + +#include "seq.hpp" +#include "skip_control.hpp" +#include "trivial.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename... Rules > + struct at + : at< seq< Rules... > > + { + }; + + template<> + struct at<> + : trivial< true > + { + }; + + template< typename Rule > + struct at< Rule > + { + using analyze_t = analysis::generic< analysis::rule_type::opt, Rule >; + + template< apply_mode, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + const auto m = in.template mark< rewind_mode::required >(); + return Control< Rule >::template match< apply_mode::nothing, rewind_mode::active, Action, Control >( in, st... ); + } + }; + + template< typename... Rules > + struct skip_control< at< Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bof.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bof.hpp new file mode 100644 index 0000000..2f7327e --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bof.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_BOF_HPP +#define TAO_PEGTL_INTERNAL_BOF_HPP + +#include "../config.hpp" + +#include "skip_control.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct bof + { + using analyze_t = analysis::generic< analysis::rule_type::opt >; + + template< typename Input > + static bool match( Input& in ) noexcept + { + return in.byte() == 0; + } + }; + + template<> + struct skip_control< bof > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bol.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bol.hpp new file mode 100644 index 0000000..0eb3ef7 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bol.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_BOL_HPP +#define TAO_PEGTL_INTERNAL_BOL_HPP + +#include "../config.hpp" + +#include "skip_control.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct bol + { + using analyze_t = analysis::generic< analysis::rule_type::opt >; + + template< typename Input > + static bool match( Input& in ) noexcept + { + return in.byte_in_line() == 0; + } + }; + + template<> + struct skip_control< bol > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bump.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bump.hpp new file mode 100644 index 0000000..bbaeb0e --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bump.hpp @@ -0,0 +1,53 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_BUMP_HPP +#define TAO_PEGTL_INTERNAL_BUMP_HPP + +#include "../config.hpp" + +#include "iterator.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + inline void bump( iterator& iter, const std::size_t count, const int ch ) noexcept + { + for( std::size_t i = 0; i < count; ++i ) { + if( iter.data[ i ] == ch ) { + ++iter.line; + iter.byte_in_line = 0; + } + else { + ++iter.byte_in_line; + } + } + iter.byte += count; + iter.data += count; + } + + inline void bump_in_this_line( iterator& iter, const std::size_t count ) noexcept + { + iter.data += count; + iter.byte += count; + iter.byte_in_line += count; + } + + inline void bump_to_next_line( iterator& iter, const std::size_t count ) noexcept + { + ++iter.line; + iter.byte += count; + iter.byte_in_line = 0; + iter.data += count; + } + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bump_help.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bump_help.hpp new file mode 100644 index 0000000..fce2fad --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bump_help.hpp @@ -0,0 +1,63 @@ +// Copyright (c) 2015-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_BUMP_HELP_HPP +#define TAO_PEGTL_INTERNAL_BUMP_HELP_HPP + +#include +#include + +#include "../config.hpp" + +#include "result_on_found.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< bool > + struct bump_impl; + + template<> + struct bump_impl< true > + { + template< typename Input > + static void bump( Input& in, const std::size_t count ) noexcept + { + in.bump( count ); + } + }; + + template<> + struct bump_impl< false > + { + template< typename Input > + static void bump( Input& in, const std::size_t count ) noexcept + { + in.bump_in_this_line( count ); + } + }; + + template< bool... > + struct bool_list + { + }; + + template< bool... Bs > + using bool_and = std::is_same< bool_list< Bs..., true >, bool_list< true, Bs... > >; + + template< result_on_found R, typename Input, typename Char, Char... Cs > + void bump_help( Input& in, const std::size_t count ) noexcept + { + bump_impl< bool_and< ( Cs != Input::eol_t::ch )... >::value != bool( R ) >::bump( in, count ); + } + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bytes.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bytes.hpp new file mode 100644 index 0000000..10c6c85 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bytes.hpp @@ -0,0 +1,46 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_BYTES_HPP +#define TAO_PEGTL_INTERNAL_BYTES_HPP + +#include "../config.hpp" + +#include "skip_control.hpp" + +#include "../analysis/counted.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< unsigned Num > + struct bytes + { + using analyze_t = analysis::counted< analysis::rule_type::any, Num >; + + template< typename Input > + static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) ) + { + if( in.size( Num ) >= Num ) { + in.bump( Num ); + return true; + } + return false; + } + }; + + template< unsigned Num > + struct skip_control< bytes< Num > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/control.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/control.hpp new file mode 100644 index 0000000..dcef9a4 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/control.hpp @@ -0,0 +1,59 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_CONTROL_HPP +#define TAO_PEGTL_INTERNAL_CONTROL_HPP + +#include "../config.hpp" + +#include "seq.hpp" +#include "skip_control.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< template< typename... > class Control, typename... Rules > + struct control + : control< Control, seq< Rules... > > + { + }; + + template< template< typename... > class Control, typename Rule > + struct control< Control, Rule > + { + using analyze_t = analysis::generic< analysis::rule_type::seq, Rule >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + return Control< Rule >::template match< A, M, Action, Control >( in, st... ); + } + }; + + template< template< typename... > class Control, typename... Rules > + struct skip_control< control< Control, Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cr_crlf_eol.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cr_crlf_eol.hpp new file mode 100644 index 0000000..ee75ea3 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cr_crlf_eol.hpp @@ -0,0 +1,40 @@ +// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_CR_CRLF_EOL_HPP +#define TAO_PEGTL_INTERNAL_CR_CRLF_EOL_HPP + +#include "../config.hpp" +#include "../eol_pair.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct cr_crlf_eol + { + static constexpr int ch = '\r'; + + template< typename Input > + static eol_pair match( Input& in ) noexcept( noexcept( in.size( 2 ) ) ) + { + eol_pair p = { false, in.size( 2 ) }; + if( p.second ) { + if( in.peek_char() == '\r' ) { + in.bump_to_next_line( 1 + ( ( p.second > 1 ) && ( in.peek_char( 1 ) == '\n' ) ) ); + p.first = true; + } + } + return p; + } + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cr_eol.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cr_eol.hpp new file mode 100644 index 0000000..1ad25f8 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cr_eol.hpp @@ -0,0 +1,40 @@ +// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_CR_EOL_HPP +#define TAO_PEGTL_INTERNAL_CR_EOL_HPP + +#include "../config.hpp" +#include "../eol_pair.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct cr_eol + { + static constexpr int ch = '\r'; + + template< typename Input > + static eol_pair match( Input& in ) noexcept( noexcept( in.size( 1 ) ) ) + { + eol_pair p = { false, in.size( 1 ) }; + if( p.second ) { + if( in.peek_char() == '\r' ) { + in.bump_to_next_line(); + p.first = true; + } + } + return p; + } + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/crlf_eol.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/crlf_eol.hpp new file mode 100644 index 0000000..21556ad --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/crlf_eol.hpp @@ -0,0 +1,40 @@ +// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_CRLF_EOL_HPP +#define TAO_PEGTL_INTERNAL_CRLF_EOL_HPP + +#include "../config.hpp" +#include "../eol_pair.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct crlf_eol + { + static constexpr int ch = '\n'; + + template< typename Input > + static eol_pair match( Input& in ) noexcept( noexcept( in.size( 2 ) ) ) + { + eol_pair p = { false, in.size( 2 ) }; + if( p.second > 1 ) { + if( ( in.peek_char() == '\r' ) && ( in.peek_char( 1 ) == '\n' ) ) { + in.bump_to_next_line( 2 ); + p.first = true; + } + } + return p; + } + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cstream_reader.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cstream_reader.hpp new file mode 100644 index 0000000..412d45e --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cstream_reader.hpp @@ -0,0 +1,50 @@ +// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_CSTREAM_READER_HPP +#define TAO_PEGTL_INTERNAL_CSTREAM_READER_HPP + +#include +#include +#include + +#include "../config.hpp" +#include "../input_error.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct cstream_reader + { + explicit cstream_reader( std::FILE* s ) noexcept + : m_cstream( s ) + { + assert( m_cstream != nullptr ); + } + + std::size_t operator()( char* buffer, const std::size_t length ) const + { + if( const auto r = std::fread( buffer, 1, length, m_cstream ) ) { + return r; + } + if( std::feof( m_cstream ) != 0 ) { + return 0; + } + // Please contact us if you know how to provoke the following exception. + // The example on cppreference.com doesn't work, at least not on macOS. + TAO_PEGTL_THROW_INPUT_ERROR( "error in fread() from cstream" ); // LCOV_EXCL_LINE + } + + std::FILE* m_cstream; + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cstring_reader.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cstring_reader.hpp new file mode 100644 index 0000000..c3a8a08 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cstring_reader.hpp @@ -0,0 +1,49 @@ +// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_CSTRING_READER_HPP +#define TAO_PEGTL_INTERNAL_CSTRING_READER_HPP + +#include +#include + +#include "../config.hpp" +#include "../input_error.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct cstring_reader + { + explicit cstring_reader( const char* zero_terminated ) noexcept + : m_cstring( zero_terminated ) + { + assert( m_cstring != nullptr ); + } + + std::size_t operator()( char* buffer, const std::size_t length ) noexcept + { + std::size_t i = 0; + char c; + + while( ( i < length ) && ( ( c = m_cstring[ i ] ) != 0 ) ) { + *buffer++ = c; + ++i; + } + m_cstring += i; + return i; + } + + const char* m_cstring; + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle.hpp new file mode 100644 index 0000000..f0bd799 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle.hpp @@ -0,0 +1,85 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_DEMANGLE_HPP +#define TAO_PEGTL_INTERNAL_DEMANGLE_HPP + +#include +#include + +#include "../config.hpp" + +#if defined( __clang__ ) +#if __has_feature( cxx_rtti ) +#define TAO_PEGTL_RTTI_ENABLED +#endif +#elif defined( __GNUC__ ) +#if defined( __GXX_RTTI ) +#define TAO_PEGTL_RTTI_ENABLED +#endif +#elif defined( _MSC_VER ) +#if defined( _CPPRTTI ) +#define TAO_PEGTL_RTTI_ENABLED +#endif +#else +#define TAO_PEGTL_RTTI_ENABLED +#endif + +#if !defined( TAO_PEGTL_RTTI_ENABLED ) +#include +#include +#endif + +#if defined( TAO_PEGTL_RTTI_ENABLED ) +#if defined( __GLIBCXX__ ) +#define TAO_PEGTL_USE_CXXABI_DEMANGLE +#elif defined( __has_include ) +#if __has_include( ) +#define TAO_PEGTL_USE_CXXABI_DEMANGLE +#endif +#endif +#endif + +#if defined( TAO_PEGTL_USE_CXXABI_DEMANGLE ) +#include "demangle_cxxabi.hpp" +#undef TAO_PEGTL_USE_CXXABI_DEMANGLE +#else +#include "demangle_nop.hpp" +#endif + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename T > + std::string demangle() + { +#if defined( TAO_PEGTL_RTTI_ENABLED ) + return demangle( typeid( T ).name() ); +#else + const char* start = nullptr; + const char* stop = nullptr; +#if defined( __clang__ ) || defined( __GNUC__ ) + start = std::strchr( __PRETTY_FUNCTION__, '=' ) + 2; + stop = std::strrchr( start, ';' ); +#elif defined( _MSC_VER ) + start = std::strstr( __FUNCSIG__, "demangle<" ) + ( sizeof( "demangle<" ) - 1 ); + stop = std::strrchr( start, '>' ); +#else + static_assert( false, "expected to use rtti with this compiler" ); +#endif + assert( start != nullptr ); + assert( stop != nullptr ); + return { start, std::size_t( stop - start ) }; +#endif + } + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_cxxabi.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_cxxabi.hpp new file mode 100644 index 0000000..5027e7f --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_cxxabi.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_DEMANGLE_CXXABI_HPP +#define TAO_PEGTL_INTERNAL_DEMANGLE_CXXABI_HPP + +#include +#include +#include +#include + +#include "../config.hpp" + +#include "demangle_sanitise.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + inline std::string demangle( const char* symbol ) + { + const std::unique_ptr< char, decltype( &std::free ) > demangled( abi::__cxa_demangle( symbol, nullptr, nullptr, nullptr ), &std::free ); + if( !demangled ) { + return symbol; + } + std::string result( demangled.get() ); +#ifdef TAO_PEGTL_PRETTY_DEMANGLE + demangle_sanitise_chars( result ); // LCOV_EXCL_LINE +#endif + return result; + } + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_nop.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_nop.hpp new file mode 100644 index 0000000..caea50e --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_nop.hpp @@ -0,0 +1,28 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_DEMANGLE_NOP_HPP +#define TAO_PEGTL_INTERNAL_DEMANGLE_NOP_HPP + +#include + +#include "../config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + inline std::string demangle( const char* symbol ) + { + return symbol; + } + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_sanitise.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_sanitise.hpp new file mode 100644 index 0000000..378f5b0 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_sanitise.hpp @@ -0,0 +1,48 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_DEMANGLE_SANITISE_HPP +#define TAO_PEGTL_INTERNAL_DEMANGLE_SANITISE_HPP + +#include + +#include "../config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + inline void demangle_sanitise_chars( std::string& s ) + { + std::string::size_type p; + while( ( p = s.find( "(char)" ) ) != std::string::npos ) { + int c = 0; + std::string::size_type q; + for( q = p + 6; ( q < s.size() ) && ( s[ q ] >= '0' ) && ( s[ q ] <= '9' ); ++q ) { + c *= 10; + c += s[ q ] - '0'; + } + if( c == '\'' ) { + s.replace( p, q - p, "'\\''" ); + } + else if( c == '\\' ) { + s.replace( p, q - p, "'\\\\'" ); + } + else if( ( c < 32 ) || ( c > 126 ) ) { + s.replace( p, 6, std::string() ); + } + else { + s.replace( p, q - p, std::string( 1, '\'' ) + char( c ) + '\'' ); + } + } + } + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/disable.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/disable.hpp new file mode 100644 index 0000000..3f6238e --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/disable.hpp @@ -0,0 +1,59 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_DISABLE_HPP +#define TAO_PEGTL_INTERNAL_DISABLE_HPP + +#include "../config.hpp" + +#include "seq.hpp" +#include "skip_control.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename... Rules > + struct disable + : disable< seq< Rules... > > + { + }; + + template< typename Rule > + struct disable< Rule > + { + using analyze_t = analysis::generic< analysis::rule_type::seq, Rule >; + + template< apply_mode, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + return Control< Rule >::template match< apply_mode::nothing, M, Action, Control >( in, st... ); + } + }; + + template< typename... Rules > + struct skip_control< disable< Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/discard.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/discard.hpp new file mode 100644 index 0000000..05ca46f --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/discard.hpp @@ -0,0 +1,43 @@ +// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_DISCARD_HPP +#define TAO_PEGTL_INTERNAL_DISCARD_HPP + +#include "../config.hpp" + +#include "skip_control.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct discard + { + using analyze_t = analysis::generic< analysis::rule_type::opt >; + + template< typename Input > + static bool match( Input& in ) noexcept + { + static_assert( noexcept( in.discard() ), "an input's discard()-method must be noexcept" ); + in.discard(); + return true; + } + }; + + template<> + struct skip_control< discard > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/dusel_mode.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/dusel_mode.hpp new file mode 100644 index 0000000..a0e0aba --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/dusel_mode.hpp @@ -0,0 +1,31 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_DUSEL_MODE_HPP +#define TAO_PEGTL_INTERNAL_DUSEL_MODE_HPP + +#include "../config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + enum class dusel_mode : char + { + nothing = 0, + control = 1, + control_and_apply_void = 2, + control_and_apply_bool = 3, + control_and_apply0_void = 4, + control_and_apply0_bool = 5, + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/duseltronik.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/duseltronik.hpp new file mode 100644 index 0000000..fc58270 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/duseltronik.hpp @@ -0,0 +1,188 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_DUSELTRONIK_HPP +#define TAO_PEGTL_INTERNAL_DUSELTRONIK_HPP + +#include "../apply_mode.hpp" +#include "../config.hpp" +#include "../rewind_mode.hpp" + +#include "dusel_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + dusel_mode = dusel_mode::nothing > + struct duseltronik; + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control > + struct duseltronik< Rule, A, M, Action, Control, dusel_mode::nothing > + { + template< typename Input, typename... States > + static auto match( Input& in, States&&... st ) + -> decltype( Rule::template match< A, M, Action, Control >( in, st... ), true ) + { + return Rule::template match< A, M, Action, Control >( in, st... ); + } + + // NOTE: The additional "int = 0" is a work-around for missing expression SFINAE in VS2015. + + template< typename Input, typename... States, int = 0 > + static auto match( Input& in, States&&... /*unused*/ ) + -> decltype( Rule::match( in ), true ) + { + return Rule::match( in ); + } + }; + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control > + struct duseltronik< Rule, A, M, Action, Control, dusel_mode::control > + { + template< typename Input, typename... States > + static bool match( Input& in, States&&... st ) + { + Control< Rule >::start( static_cast< const Input& >( in ), st... ); + + if( duseltronik< Rule, A, M, Action, Control, dusel_mode::nothing >::match( in, st... ) ) { + Control< Rule >::success( static_cast< const Input& >( in ), st... ); + return true; + } + Control< Rule >::failure( static_cast< const Input& >( in ), st... ); + return false; + } + }; + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control > + struct duseltronik< Rule, A, M, Action, Control, dusel_mode::control_and_apply_void > + { + template< typename Input, typename... States > + static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< rewind_mode::required >(); + + Control< Rule >::start( static_cast< const Input& >( in ), st... ); + + if( duseltronik< Rule, A, rewind_mode::active, Action, Control, dusel_mode::nothing >::match( in, st... ) ) { + Control< Rule >::template apply< Action >( m.iterator(), static_cast< const Input& >( in ), st... ); + Control< Rule >::success( static_cast< const Input& >( in ), st... ); + return m( true ); + } + Control< Rule >::failure( static_cast< const Input& >( in ), st... ); + return false; + } + }; + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control > + struct duseltronik< Rule, A, M, Action, Control, dusel_mode::control_and_apply_bool > + { + template< typename Input, typename... States > + static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< rewind_mode::required >(); + + Control< Rule >::start( static_cast< const Input& >( in ), st... ); + + if( duseltronik< Rule, A, rewind_mode::active, Action, Control, dusel_mode::nothing >::match( in, st... ) ) { + if( Control< Rule >::template apply< Action >( m.iterator(), static_cast< const Input& >( in ), st... ) ) { + Control< Rule >::success( static_cast< const Input& >( in ), st... ); + return m( true ); + } + } + Control< Rule >::failure( static_cast< const Input& >( in ), st... ); + return false; + } + }; + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control > + struct duseltronik< Rule, A, M, Action, Control, dusel_mode::control_and_apply0_void > + { + template< typename Input, typename... States > + static bool match( Input& in, States&&... st ) + { + Control< Rule >::start( static_cast< const Input& >( in ), st... ); + + if( duseltronik< Rule, A, M, Action, Control, dusel_mode::nothing >::match( in, st... ) ) { + Control< Rule >::template apply0< Action >( static_cast< const Input& >( in ), st... ); + Control< Rule >::success( static_cast< const Input& >( in ), st... ); + return true; + } + Control< Rule >::failure( static_cast< const Input& >( in ), st... ); + return false; + } + }; + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control > + struct duseltronik< Rule, A, M, Action, Control, dusel_mode::control_and_apply0_bool > + { + template< typename Input, typename... States > + static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< rewind_mode::required >(); + + Control< Rule >::start( static_cast< const Input& >( in ), st... ); + + if( duseltronik< Rule, A, rewind_mode::active, Action, Control, dusel_mode::nothing >::match( in, st... ) ) { + if( Control< Rule >::template apply0< Action >( static_cast< const Input& >( in ), st... ) ) { + Control< Rule >::success( static_cast< const Input& >( in ), st... ); + return m( true ); + } + } + Control< Rule >::failure( static_cast< const Input& >( in ), st... ); + return false; + } + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/enable.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/enable.hpp new file mode 100644 index 0000000..0b7b2d4 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/enable.hpp @@ -0,0 +1,59 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_ENABLE_HPP +#define TAO_PEGTL_INTERNAL_ENABLE_HPP + +#include "../config.hpp" + +#include "seq.hpp" +#include "skip_control.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename... Rules > + struct enable + : enable< seq< Rules... > > + { + }; + + template< typename Rule > + struct enable< Rule > + { + using analyze_t = analysis::generic< analysis::rule_type::seq, Rule >; + + template< apply_mode, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + return Control< Rule >::template match< apply_mode::action, M, Action, Control >( in, st... ); + } + }; + + template< typename... Rules > + struct skip_control< enable< Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian.hpp new file mode 100644 index 0000000..2aa2c53 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian.hpp @@ -0,0 +1,70 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_ENDIAN_HPP +#define TAO_PEGTL_INTERNAL_ENDIAN_HPP + +#include +#include + +#include "../config.hpp" + +#if defined( _WIN32 ) && !defined( __MINGW32__ ) +#include "endian_win.hpp" +#else +#include "endian_gcc.hpp" +#endif + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename N > + N h_to_be( const N n ) noexcept + { + return N( to_and_from_be< sizeof( N ) >::convert( n ) ); + } + + template< typename N > + N be_to_h( const N n ) noexcept + { + return h_to_be( n ); + } + + template< typename N > + N be_to_h( const void* p ) noexcept + { + N n; + std::memcpy( &n, p, sizeof( n ) ); + return internal::be_to_h( n ); + } + + template< typename N > + N h_to_le( const N n ) noexcept + { + return N( to_and_from_le< sizeof( N ) >::convert( n ) ); + } + + template< typename N > + N le_to_h( const N n ) noexcept + { + return h_to_le( n ); + } + + template< typename N > + N le_to_h( const void* p ) noexcept + { + N n; + std::memcpy( &n, p, sizeof( n ) ); + return internal::le_to_h( n ); + } + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian_gcc.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian_gcc.hpp new file mode 100644 index 0000000..2e180f0 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian_gcc.hpp @@ -0,0 +1,214 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_ENDIAN_GCC_HPP +#define TAO_PEGTL_INTERNAL_ENDIAN_GCC_HPP + +#include +#include + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { +#if !defined( __BYTE_ORDER__ ) +#error No byte order defined! +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + + template< std::size_t S > + struct to_and_from_be + { + template< typename T > + static T convert( const T n ) noexcept + { + return n; + } + }; + + template< std::size_t S > + struct to_and_from_le; + + template<> + struct to_and_from_le< 1 > + { + static std::uint8_t convert( const std::uint8_t n ) noexcept + { + return n; + } + + static std::int8_t convert( const std::int8_t n ) noexcept + { + return n; + } + }; + + template<> + struct to_and_from_le< 2 > + { + static std::int16_t convert( const std::int16_t n ) noexcept + { + return static_cast< std::int16_t >( __builtin_bswap16( static_cast< std::uint16_t >( n ) ) ); + } + + static std::uint16_t convert( const std::uint16_t n ) noexcept + { + return __builtin_bswap16( n ); + } + }; + + template<> + struct to_and_from_le< 4 > + { + static float convert( float n ) noexcept + { + std::uint32_t u; + std::memcpy( &u, &n, 4 ); + u = convert( u ); + std::memcpy( &n, &u, 4 ); + return n; + } + + static std::int32_t convert( const std::int32_t n ) noexcept + { + return static_cast< std::int32_t >( __builtin_bswap32( static_cast< std::uint32_t >( n ) ) ); + } + + static std::uint32_t convert( const std::uint32_t n ) noexcept + { + return __builtin_bswap32( n ); + } + }; + + template<> + struct to_and_from_le< 8 > + { + static double convert( double n ) noexcept + { + std::uint64_t u; + std::memcpy( &u, &n, 8 ); + u = convert( u ); + std::memcpy( &n, &u, 8 ); + return n; + } + + static std::int64_t convert( const std::int64_t n ) noexcept + { + return static_cast< std::int64_t >( __builtin_bswap64( static_cast< std::uint64_t >( n ) ) ); + } + + static std::uint64_t convert( const std::uint64_t n ) noexcept + { + return __builtin_bswap64( n ); + } + }; + +#define TAO_PEGTL_NATIVE_ORDER be +#define TAO_PEGTL_NATIVE_UTF16 utf16_be +#define TAO_PEGTL_NATIVE_UTF32 utf32_be + +#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + + template< std::size_t S > + struct to_and_from_le + { + template< typename T > + static T convert( const T n ) noexcept + { + return n; + } + }; + + template< std::size_t S > + struct to_and_from_be; + + template<> + struct to_and_from_be< 1 > + { + static std::int8_t convert( const std::int8_t n ) noexcept + { + return n; + } + + static std::uint8_t convert( const std::uint8_t n ) noexcept + { + return n; + } + }; + + template<> + struct to_and_from_be< 2 > + { + static std::int16_t convert( const std::int16_t n ) noexcept + { + return static_cast< std::int16_t >( __builtin_bswap16( static_cast< std::uint16_t >( n ) ) ); + } + + static std::uint16_t convert( const std::uint16_t n ) noexcept + { + return __builtin_bswap16( n ); + } + }; + + template<> + struct to_and_from_be< 4 > + { + static float convert( float n ) noexcept + { + std::uint32_t u; + std::memcpy( &u, &n, 4 ); + u = convert( u ); + std::memcpy( &n, &u, 4 ); + return n; + } + + static std::int32_t convert( const std::int32_t n ) noexcept + { + return static_cast< std::int32_t >( __builtin_bswap32( static_cast< std::uint32_t >( n ) ) ); + } + + static std::uint32_t convert( const std::uint32_t n ) noexcept + { + return __builtin_bswap32( n ); + } + }; + + template<> + struct to_and_from_be< 8 > + { + static double convert( double n ) noexcept + { + std::uint64_t u; + std::memcpy( &u, &n, 8 ); + u = convert( u ); + std::memcpy( &n, &u, 8 ); + return n; + } + + static std::int64_t convert( const std::int64_t n ) noexcept + { + return static_cast< std::int64_t >( __builtin_bswap64( static_cast< std::uint64_t >( n ) ) ); + } + + static std::uint64_t convert( const std::uint64_t n ) noexcept + { + return __builtin_bswap64( n ); + } + }; + +#define TAO_PEGTL_NATIVE_ORDER le +#define TAO_PEGTL_NATIVE_UTF16 utf16_le +#define TAO_PEGTL_NATIVE_UTF32 utf32_le + +#else +#error Unknown host byte order! +#endif + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian_win.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian_win.hpp new file mode 100644 index 0000000..19d62aa --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian_win.hpp @@ -0,0 +1,115 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_ENDIAN_WIN_HPP +#define TAO_PEGTL_INTERNAL_ENDIAN_WIN_HPP + +#include +#include + +#include + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< std::size_t S > + struct to_and_from_le + { + template< typename T > + static T convert( const T t ) noexcept + { + return t; + } + }; + + template< std::size_t S > + struct to_and_from_be; + + template<> + struct to_and_from_be< 1 > + { + static std::int8_t convert( const std::int8_t n ) noexcept + { + return n; + } + + static std::uint8_t convert( const std::uint8_t n ) noexcept + { + return n; + } + }; + + template<> + struct to_and_from_be< 2 > + { + static std::int16_t convert( const std::int16_t n ) noexcept + { + return std::int16_t( _byteswap_ushort( std::uint16_t( n ) ) ); + } + + static std::uint16_t convert( const std::uint16_t n ) noexcept + { + return _byteswap_ushort( n ); + } + }; + + template<> + struct to_and_from_be< 4 > + { + static float convert( float n ) noexcept + { + std::uint32_t u; + std::memcpy( &u, &n, 4 ); + u = convert( u ); + std::memcpy( &n, &u, 4 ); + return n; + } + + static std::int32_t convert( const std::int32_t n ) noexcept + { + return std::int32_t( _byteswap_ulong( std::uint32_t( n ) ) ); + } + + static std::uint32_t convert( const std::uint32_t n ) noexcept + { + return _byteswap_ulong( n ); + } + }; + + template<> + struct to_and_from_be< 8 > + { + static double convert( double n ) noexcept + { + std::uint64_t u; + std::memcpy( &u, &n, 8 ); + u = convert( u ); + std::memcpy( &n, &u, 8 ); + return n; + } + + static std::int64_t convert( const std::int64_t n ) noexcept + { + return std::int64_t( _byteswap_uint64( std::uint64_t( n ) ) ); + } + + static std::uint64_t convert( const std::uint64_t n ) noexcept + { + return _byteswap_uint64( n ); + } + }; + +#define TAO_PEGTL_NATIVE_ORDER le +#define TAO_PEGTL_NATIVE_UTF16 utf16_le +#define TAO_PEGTL_NATIVE_UTF32 utf32_le + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eof.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eof.hpp new file mode 100644 index 0000000..b3a7542 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eof.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_EOF_HPP +#define TAO_PEGTL_INTERNAL_EOF_HPP + +#include "../config.hpp" + +#include "skip_control.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct eof + { + using analyze_t = analysis::generic< analysis::rule_type::opt >; + + template< typename Input > + static bool match( Input& in ) noexcept( noexcept( in.empty() ) ) + { + return in.empty(); + } + }; + + template<> + struct skip_control< eof > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eol.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eol.hpp new file mode 100644 index 0000000..3878f95 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eol.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_EOL_HPP +#define TAO_PEGTL_INTERNAL_EOL_HPP + +#include "../config.hpp" + +#include "skip_control.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct eol + { + using analyze_t = analysis::generic< analysis::rule_type::any >; + + template< typename Input > + static bool match( Input& in ) noexcept( noexcept( Input::eol_t::match( in ) ) ) + { + return Input::eol_t::match( in ).first; + } + }; + + template<> + struct skip_control< eol > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eolf.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eolf.hpp new file mode 100644 index 0000000..a3fae89 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eolf.hpp @@ -0,0 +1,42 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_EOLF_HPP +#define TAO_PEGTL_INTERNAL_EOLF_HPP + +#include "../config.hpp" + +#include "skip_control.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct eolf + { + using analyze_t = analysis::generic< analysis::rule_type::opt >; + + template< typename Input > + static bool match( Input& in ) noexcept( noexcept( Input::eol_t::match( in ) ) ) + { + const auto p = Input::eol_t::match( in ); + return p.first || ( !p.second ); + } + }; + + template<> + struct skip_control< eolf > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_mapper_posix.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_mapper_posix.hpp new file mode 100644 index 0000000..c77529e --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_mapper_posix.hpp @@ -0,0 +1,95 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_FILE_MAPPER_POSIX_HPP +#define TAO_PEGTL_INTERNAL_FILE_MAPPER_POSIX_HPP + +#include +#include + +#include "../config.hpp" + +#include "file_opener.hpp" + +#include "../input_error.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + class file_mapper + { + public: + explicit file_mapper( const char* filename ) + : file_mapper( file_opener( filename ) ) + { + } + + explicit file_mapper( const file_opener& reader ) + : m_size( reader.size() ), + m_data( static_cast< const char* >( ::mmap( nullptr, m_size, PROT_READ, MAP_PRIVATE, reader.m_fd, 0 ) ) ) + { + if( ( m_size != 0 ) && ( intptr_t( m_data ) == -1 ) ) { + TAO_PEGTL_THROW_INPUT_ERROR( "unable to mmap() file " << reader.m_source << " descriptor " << reader.m_fd ); + } + } + + file_mapper( const file_mapper& ) = delete; + file_mapper( file_mapper&& ) = delete; + + ~file_mapper() noexcept + { + // Legacy C interface requires pointer-to-mutable but does not write through the pointer. + ::munmap( const_cast< char* >( m_data ), m_size ); // NOLINT + } + + void operator=( const file_mapper& ) = delete; + void operator=( file_mapper&& ) = delete; + + bool empty() const noexcept + { + return m_size == 0; + } + + std::size_t size() const noexcept + { + return m_size; + } + + using iterator = const char*; + using const_iterator = const char*; + + iterator data() const noexcept + { + return m_data; + } + + iterator begin() const noexcept + { + return m_data; + } + + iterator end() const noexcept + { + return m_data + m_size; + } + + std::string string() const + { + return std::string( m_data, m_size ); + } + + private: + const std::size_t m_size; + const char* const m_data; + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_mapper_win32.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_mapper_win32.hpp new file mode 100644 index 0000000..a8cc1a4 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_mapper_win32.hpp @@ -0,0 +1,226 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_FILE_MAPPER_WIN32_HPP +#define TAO_PEGTL_INTERNAL_FILE_MAPPER_WIN32_HPP + +#if !defined( NOMINMAX ) +#define NOMINMAX +#define TAO_PEGTL_NOMINMAX_WAS_DEFINED +#endif + +#if !defined( WIN32_LEAN_AND_MEAN ) +#define WIN32_LEAN_AND_MEAN +#define TAO_PEGTL_WIN32_LEAN_AND_MEAN_WAS_DEFINED +#endif + +#include + +#if defined( TAO_PEGTL_NOMINMAX_WAS_DEFINED ) +#undef NOMINMAX +#undef TAO_PEGTL_NOMINMAX_WAS_DEFINED +#endif + +#if defined( TAO_PEGTL_WIN32_LEAN_AND_MEAN_WAS_DEFINED ) +#undef WIN32_LEAN_AND_MEAN +#undef TAO_PEGTL_WIN32_LEAN_AND_MEAN_WAS_DEFINED +#endif + +#include "../config.hpp" +#include "../input_error.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct win32_file_opener + { + explicit win32_file_opener( const char* filename ) + : m_source( filename ), + m_handle( open() ) + { + } + + win32_file_opener( const win32_file_opener& ) = delete; + win32_file_opener( win32_file_opener&& ) = delete; + + ~win32_file_opener() noexcept + { + ::CloseHandle( m_handle ); + } + + void operator=( const win32_file_opener& ) = delete; + void operator=( win32_file_opener&& ) = delete; + + std::size_t size() const + { + LARGE_INTEGER size; + if( !::GetFileSizeEx( m_handle, &size ) ) { + TAO_PEGTL_THROW_INPUT_WIN32_ERROR( "unable to GetFileSizeEx() file " << m_source << " handle " << m_handle ); + } + return std::size_t( size.QuadPart ); + } + + const char* const m_source; + const HANDLE m_handle; + + private: + HANDLE open() const + { + SetLastError( 0 ); + std::wstring ws( m_source, m_source + strlen( m_source ) ); + +#if( _WIN32_WINNT >= 0x0602 ) + const HANDLE handle = ::CreateFile2( ws.c_str(), + GENERIC_READ, + FILE_SHARE_READ, + OPEN_EXISTING, + nullptr ); + if( handle != INVALID_HANDLE_VALUE ) { + return handle; + } + TAO_PEGTL_THROW_INPUT_WIN32_ERROR( "CreateFile2() failed opening file " << m_source << " for reading" ); +#else + const HANDLE handle = ::CreateFileW( ws.c_str(), + GENERIC_READ, + FILE_SHARE_READ, + nullptr, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + nullptr ); + if( handle != INVALID_HANDLE_VALUE ) { + return handle; + } + TAO_PEGTL_THROW_INPUT_WIN32_ERROR( "CreateFileW() failed opening file " << m_source << " for reading" ); +#endif + } + }; + + struct win32_file_mapper + { + explicit win32_file_mapper( const char* filename ) + : win32_file_mapper( win32_file_opener( filename ) ) + { + } + + explicit win32_file_mapper( const win32_file_opener& reader ) + : m_size( reader.size() ), + m_handle( open( reader ) ) + { + } + + win32_file_mapper( const win32_file_mapper& ) = delete; + win32_file_mapper( win32_file_mapper&& ) = delete; + + ~win32_file_mapper() noexcept + { + ::CloseHandle( m_handle ); + } + + void operator=( const win32_file_mapper& ) = delete; + void operator=( win32_file_mapper&& ) = delete; + + const size_t m_size; + const HANDLE m_handle; + + private: + HANDLE open( const win32_file_opener& reader ) const + { + const uint64_t file_size = reader.size(); + SetLastError( 0 ); + // Use `CreateFileMappingW` because a) we're not specifying a + // mapping name, so the character type is of no consequence, and + // b) it's defined in `memoryapi.h`, unlike + // `CreateFileMappingA`(?!) + const HANDLE handle = ::CreateFileMappingW( reader.m_handle, + nullptr, + PAGE_READONLY, + DWORD( file_size >> 32 ), + DWORD( file_size & 0xffffffff ), + nullptr ); + if( handle != NULL || file_size == 0 ) { + return handle; + } + TAO_PEGTL_THROW_INPUT_WIN32_ERROR( "unable to CreateFileMappingW() file " << reader.m_source << " for reading" ); + } + }; + + class file_mapper + { + public: + explicit file_mapper( const char* filename ) + : file_mapper( win32_file_mapper( filename ) ) + { + } + + explicit file_mapper( const win32_file_mapper& mapper ) + : m_size( mapper.m_size ), + m_data( static_cast< const char* >( ::MapViewOfFile( mapper.m_handle, + FILE_MAP_READ, + 0, + 0, + 0 ) ) ) + { + if( ( m_size != 0 ) && ( intptr_t( m_data ) == 0 ) ) { + TAO_PEGTL_THROW_INPUT_WIN32_ERROR( "unable to MapViewOfFile() file mapping object with handle " << mapper.m_handle ); + } + } + + file_mapper( const file_mapper& ) = delete; + file_mapper( file_mapper&& ) = delete; + + ~file_mapper() noexcept + { + ::UnmapViewOfFile( LPCVOID( m_data ) ); + } + + void operator=( const file_mapper& ) = delete; + void operator=( file_mapper&& ) = delete; + + bool empty() const noexcept + { + return m_size == 0; + } + + std::size_t size() const noexcept + { + return m_size; + } + + using iterator = const char*; + using const_iterator = const char*; + + iterator data() const noexcept + { + return m_data; + } + + iterator begin() const noexcept + { + return m_data; + } + + iterator end() const noexcept + { + return m_data + m_size; + } + + std::string string() const + { + return std::string( m_data, m_size ); + } + + private: + const std::size_t m_size; + const char* const m_data; + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_opener.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_opener.hpp new file mode 100644 index 0000000..33eccb6 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_opener.hpp @@ -0,0 +1,78 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_FILE_OPENER_HPP +#define TAO_PEGTL_INTERNAL_FILE_OPENER_HPP + +#include +#include +#include +#include + +#include + +#include "../config.hpp" +#include "../input_error.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct file_opener + { + explicit file_opener( const char* filename ) + : m_source( filename ), + m_fd( open() ) + { + } + + file_opener( const file_opener& ) = delete; + file_opener( file_opener&& ) = delete; + + ~file_opener() noexcept + { + ::close( m_fd ); + } + + void operator=( const file_opener& ) = delete; + void operator=( file_opener&& ) = delete; + + std::size_t size() const + { + struct stat st; // NOLINT + errno = 0; + if( ::fstat( m_fd, &st ) < 0 ) { + TAO_PEGTL_THROW_INPUT_ERROR( "unable to fstat() file " << m_source << " descriptor " << m_fd ); + } + return std::size_t( st.st_size ); + } + + const char* const m_source; + const int m_fd; + + private: + int open() const + { + errno = 0; + const int fd = ::open( m_source, // NOLINT + O_RDONLY +#ifdef O_CLOEXEC + | O_CLOEXEC +#endif + ); + if( fd >= 0 ) { + return fd; + } + TAO_PEGTL_THROW_INPUT_ERROR( "unable to open() file " << m_source << " for reading" ); + } + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_reader.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_reader.hpp new file mode 100644 index 0000000..c309aef --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_reader.hpp @@ -0,0 +1,109 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_FILE_READER_HPP +#define TAO_PEGTL_INTERNAL_FILE_READER_HPP + +#include +#include +#include +#include + +#include "../config.hpp" +#include "../input_error.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + inline std::FILE* file_open( const char* filename ) + { + errno = 0; +#if defined( _MSC_VER ) + std::FILE* file; + if( ::fopen_s( &file, filename, "rb" ) == 0 ) +#elif defined( __MINGW32__ ) + if( auto* file = std::fopen( filename, "rb" ) ) // NOLINT +#else + if( auto* file = std::fopen( filename, "rbe" ) ) // NOLINT +#endif + { + return file; + } + TAO_PEGTL_THROW_INPUT_ERROR( "unable to fopen() file " << filename << " for reading" ); + } + + struct file_close + { + void operator()( FILE* f ) const noexcept + { + std::fclose( f ); // NOLINT + } + }; + + class file_reader + { + public: + explicit file_reader( const char* filename ) + : m_source( filename ), + m_file( file_open( m_source ) ) + { + } + + file_reader( FILE* file, const char* filename ) noexcept + : m_source( filename ), + m_file( file ) + { + } + + file_reader( const file_reader& ) = delete; + file_reader( file_reader&& ) = delete; + + ~file_reader() = default; + + void operator=( const file_reader& ) = delete; + void operator=( file_reader&& ) = delete; + + std::size_t size() const + { + errno = 0; + if( std::fseek( m_file.get(), 0, SEEK_END ) != 0 ) { + TAO_PEGTL_THROW_INPUT_ERROR( "unable to fseek() to end of file " << m_source ); // LCOV_EXCL_LINE + } + errno = 0; + const auto s = std::ftell( m_file.get() ); + if( s < 0 ) { + TAO_PEGTL_THROW_INPUT_ERROR( "unable to ftell() file size of file " << m_source ); // LCOV_EXCL_LINE + } + errno = 0; + if( std::fseek( m_file.get(), 0, SEEK_SET ) != 0 ) { + TAO_PEGTL_THROW_INPUT_ERROR( "unable to fseek() to beginning of file " << m_source ); // LCOV_EXCL_LINE + } + return std::size_t( s ); + } + + std::string read() const + { + std::string nrv; + nrv.resize( size() ); + errno = 0; + if( !nrv.empty() && ( std::fread( &nrv[ 0 ], nrv.size(), 1, m_file.get() ) != 1 ) ) { + TAO_PEGTL_THROW_INPUT_ERROR( "unable to fread() file " << m_source << " size " << nrv.size() ); // LCOV_EXCL_LINE + } + return nrv; + } + + private: + const char* const m_source; + const std::unique_ptr< std::FILE, file_close > m_file; + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_apply.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_apply.hpp new file mode 100644 index 0000000..f0daf96 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_apply.hpp @@ -0,0 +1,33 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_HAS_APPLY_HPP +#define TAO_PEGTL_INTERNAL_HAS_APPLY_HPP + +#include + +#include "../config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename, typename, template< typename... > class, typename... > + struct has_apply + : std::false_type + {}; + + template< typename C, template< typename... > class Action, typename... S > + struct has_apply< C, decltype( C::template apply< Action >( std::declval< S >()... ) ), Action, S... > + : std::true_type + {}; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_apply0.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_apply0.hpp new file mode 100644 index 0000000..b54c60b --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_apply0.hpp @@ -0,0 +1,33 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_HAS_APPLY0_HPP +#define TAO_PEGTL_INTERNAL_HAS_APPLY0_HPP + +#include + +#include "../config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename, typename, template< typename... > class, typename... > + struct has_apply0 + : std::false_type + {}; + + template< typename C, template< typename... > class Action, typename... S > + struct has_apply0< C, decltype( C::template apply0< Action >( std::declval< S >()... ) ), Action, S... > + : std::true_type + {}; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_match.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_match.hpp new file mode 100644 index 0000000..af3c2bb --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_match.hpp @@ -0,0 +1,53 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_HAS_MATCH_HPP +#define TAO_PEGTL_INTERNAL_HAS_MATCH_HPP + +#include +#include + +#include "../apply_mode.hpp" +#include "../config.hpp" +#include "../rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename, + typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + struct has_match + : std::false_type + {}; + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + struct has_match< decltype( Action< Rule >::template match< Rule, A, M, Action, Control >( std::declval< Input& >(), std::declval< States&& >()... ), void() ), Rule, A, M, Action, Control, Input, States... > + : std::true_type + {}; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/identifier.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/identifier.hpp new file mode 100644 index 0000000..8194266 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/identifier.hpp @@ -0,0 +1,30 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_IDENTIFIER_HPP +#define TAO_PEGTL_INTERNAL_IDENTIFIER_HPP + +#include "../config.hpp" + +#include "peek_char.hpp" +#include "ranges.hpp" +#include "seq.hpp" +#include "star.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + using identifier_first = ranges< peek_char, 'a', 'z', 'A', 'Z', '_' >; + using identifier_other = ranges< peek_char, 'a', 'z', 'A', 'Z', '0', '9', '_' >; + using identifier = seq< identifier_first, star< identifier_other > >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_apply.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_apply.hpp new file mode 100644 index 0000000..df2b306 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_apply.hpp @@ -0,0 +1,118 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_IF_APPLY_HPP +#define TAO_PEGTL_INTERNAL_IF_APPLY_HPP + +#include "../config.hpp" + +#include "apply_single.hpp" +#include "skip_control.hpp" + +#include "../analysis/counted.hpp" +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< apply_mode A, typename Rule, typename... Actions > + struct if_apply_impl; + + template< typename Rule > + struct if_apply_impl< apply_mode::action, Rule > + { + template< rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + return Control< Rule >::template match< apply_mode::action, M, Action, Control >( in, st... ); + } + }; + + template< typename Rule, typename... Actions > + struct if_apply_impl< apply_mode::action, Rule, Actions... > + { + template< rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + using action_t = typename Input::action_t; + + auto m = in.template mark< rewind_mode::required >(); + + if( Control< Rule >::template match< apply_mode::action, rewind_mode::active, Action, Control >( in, st... ) ) { + const action_t i2( m.iterator(), in ); +#ifdef __cpp_fold_expressions + return m( ( apply_single< Actions >::match( i2, st... ) && ... ) ); +#else + bool result = true; + using swallow = bool[]; + (void)swallow{ result = result && apply_single< Actions >::match( i2, st... )... }; + return m( result ); +#endif + } + return false; + } + }; + + template< typename Rule, typename... Actions > + struct if_apply_impl< apply_mode::nothing, Rule, Actions... > + { + template< rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + return Control< Rule >::template match< apply_mode::nothing, M, Action, Control >( in, st... ); + } + }; + + template< typename Rule, typename... Actions > + struct if_apply + { + using analyze_t = typename Rule::analyze_t; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + return if_apply_impl< A, Rule, Actions... >::template match< M, Action, Control >( in, st... ); + } + }; + + template< typename Rule, typename... Actions > + struct skip_control< if_apply< Rule, Actions... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_missing.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_missing.hpp new file mode 100644 index 0000000..d0aa8ab --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_missing.hpp @@ -0,0 +1,72 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_IF_MISSING_HPP +#define TAO_PEGTL_INTERNAL_IF_MISSING_HPP + +#include "../config.hpp" +#include "../rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< bool > + struct if_missing; + + template<> + struct if_missing< true > + { + template< typename Control, + template< typename... > + class Action, + typename Input, + typename... States > + static void apply( Input& in, States&&... st ) + { + auto m = in.template mark< rewind_mode::required >(); + Control::template apply< Action >( m.iterator(), in, st... ); + } + + template< typename Control, + template< typename... > + class Action, + typename Input, + typename... States > + static void apply0( Input& in, States&&... st ) + { + Control::template apply0< Action >( in, st... ); + } + }; + + template<> + struct if_missing< false > + { + template< typename Control, + template< typename... > + class Action, + typename Input, + typename... States > + static void apply( Input& /*unused*/, States&&... /*unused*/ ) + { + } + + template< typename Control, + template< typename... > + class Action, + typename Input, + typename... States > + static void apply0( Input& /*unused*/, States&&... /*unused*/ ) + { + } + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_must.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_must.hpp new file mode 100644 index 0000000..0cbd08c --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_must.hpp @@ -0,0 +1,58 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_IF_MUST_HPP +#define TAO_PEGTL_INTERNAL_IF_MUST_HPP + +#include "../config.hpp" + +#include "must.hpp" +#include "skip_control.hpp" +#include "trivial.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/counted.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< bool Default, typename Cond, typename... Rules > + struct if_must + { + using analyze_t = analysis::counted< analysis::rule_type::seq, Default ? 0 : 1, Cond, must< Rules... > >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + if( Control< Cond >::template match< A, M, Action, Control >( in, st... ) ) { + Control< must< Rules... > >::template match< A, M, Action, Control >( in, st... ); + return true; + } + return Default; + } + }; + + template< bool Default, typename Cond, typename... Rules > + struct skip_control< if_must< Default, Cond, Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_must_else.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_must_else.hpp new file mode 100644 index 0000000..74db045 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_must_else.hpp @@ -0,0 +1,27 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_IF_MUST_ELSE_HPP +#define TAO_PEGTL_INTERNAL_IF_MUST_ELSE_HPP + +#include "../config.hpp" + +#include "if_then_else.hpp" +#include "must.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Cond, typename Then, typename Else > + using if_must_else = if_then_else< Cond, must< Then >, must< Else > >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_then_else.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_then_else.hpp new file mode 100644 index 0000000..7d7b30f --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_then_else.hpp @@ -0,0 +1,61 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_IF_THEN_ELSE_HPP +#define TAO_PEGTL_INTERNAL_IF_THEN_ELSE_HPP + +#include "../config.hpp" + +#include "not_at.hpp" +#include "seq.hpp" +#include "skip_control.hpp" +#include "sor.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Cond, typename Then, typename Else > + struct if_then_else + { + using analyze_t = analysis::generic< analysis::rule_type::sor, seq< Cond, Then >, seq< not_at< Cond >, Else > >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< M >(); + using m_t = decltype( m ); + + if( Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { + return m( Control< Then >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ); + } + return m( Control< Else >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ); + } + }; + + template< typename Cond, typename Then, typename Else > + struct skip_control< if_then_else< Cond, Then, Else > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/input_pair.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/input_pair.hpp new file mode 100644 index 0000000..f586a05 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/input_pair.hpp @@ -0,0 +1,37 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_INPUT_PAIR_HPP +#define TAO_PEGTL_INTERNAL_INPUT_PAIR_HPP + +#include + +#include "../config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Data > + struct input_pair + { + Data data; + std::uint8_t size; + + using data_t = Data; + + explicit operator bool() const noexcept + { + return size > 0; + } + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/integer_sequence.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/integer_sequence.hpp new file mode 100644 index 0000000..74e461d --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/integer_sequence.hpp @@ -0,0 +1,86 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_INTEGER_SEQUENCE_HPP +#define TAO_PEGTL_INTERNAL_INTEGER_SEQUENCE_HPP + +#include +#include +#include + +#include "../config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename T, T... Ns > + struct integer_sequence + { + using value_type = T; + + static constexpr std::size_t size() noexcept + { + return sizeof...( Ns ); + } + }; + + template< std::size_t... Ns > + using index_sequence = integer_sequence< std::size_t, Ns... >; + + template< bool V, bool E > + struct generate_sequence; + + template<> + struct generate_sequence< false, true > + { + template< typename T, T M, T N, std::size_t S, T... Ns > + using f = integer_sequence< T, Ns... >; + }; + + template<> + struct generate_sequence< true, true > + { + template< typename T, T M, T N, std::size_t S, T... Ns > + using f = integer_sequence< T, Ns..., S >; + }; + + template<> + struct generate_sequence< false, false > + { + template< typename T, T M, T N, std::size_t S, T... Ns > + using f = typename generate_sequence< ( N & ( M / 2 ) ) != 0, ( M / 2 ) == 0 >::template f< T, M / 2, N, 2 * S, Ns..., ( Ns + S )... >; + }; + + template<> + struct generate_sequence< true, false > + { + template< typename T, T M, T N, std::size_t S, T... Ns > + using f = typename generate_sequence< ( N & ( M / 2 ) ) != 0, ( M / 2 ) == 0 >::template f< T, M / 2, N, 2 * S + 1, Ns..., ( Ns + S )..., 2 * S >; + }; + + template< typename T, T N > + struct memoize_sequence + { + static_assert( N < T( 1 << 20 ), "N too large" ); + using type = typename generate_sequence< false, false >::template f< T, ( N < T( 1 << 1 ) ) ? T( 1 << 1 ) : ( N < T( 1 << 2 ) ) ? T( 1 << 2 ) : ( N < T( 1 << 3 ) ) ? T( 1 << 3 ) : ( N < T( 1 << 4 ) ) ? T( 1 << 4 ) : ( N < T( 1 << 5 ) ) ? T( 1 << 5 ) : ( N < T( 1 << 6 ) ) ? T( 1 << 6 ) : ( N < T( 1 << 7 ) ) ? T( 1 << 7 ) : ( N < T( 1 << 8 ) ) ? T( 1 << 8 ) : ( N < T( 1 << 9 ) ) ? T( 1 << 9 ) : ( N < T( 1 << 10 ) ) ? T( 1 << 10 ) : ( N < T( 1 << 11 ) ) ? T( 1 << 11 ) : ( N < T( 1 << 12 ) ) ? T( 1 << 12 ) : ( N < T( 1 << 13 ) ) ? T( 1 << 13 ) : ( N < T( 1 << 14 ) ) ? T( 1 << 14 ) : ( N < T( 1 << 15 ) ) ? T( 1 << 15 ) : ( N < T( 1 << 16 ) ) ? T( 1 << 16 ) : ( N < T( 1 << 17 ) ) ? T( 1 << 17 ) : ( N < T( 1 << 18 ) ) ? T( 1 << 18 ) : ( N < T( 1 << 19 ) ) ? T( 1 << 19 ) : T( 1 << 20 ), N, 0 >; + }; + + template< typename T, T N > + using make_integer_sequence = typename memoize_sequence< T, N >::type; + + template< std::size_t N > + using make_index_sequence = make_integer_sequence< std::size_t, N >; + + template< typename... Ts > + using index_sequence_for = make_index_sequence< sizeof...( Ts ) >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/istream_reader.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/istream_reader.hpp new file mode 100644 index 0000000..77744e0 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/istream_reader.hpp @@ -0,0 +1,47 @@ +// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_ISTREAM_READER_HPP +#define TAO_PEGTL_INTERNAL_ISTREAM_READER_HPP + +#include + +#include "../config.hpp" +#include "../input_error.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct istream_reader + { + explicit istream_reader( std::istream& s ) noexcept + : m_istream( s ) + { + } + + std::size_t operator()( char* buffer, const std::size_t length ) + { + m_istream.read( buffer, std::streamsize( length ) ); + + if( const auto r = m_istream.gcount() ) { + return std::size_t( r ); + } + if( m_istream.eof() ) { + return 0; + } + TAO_PEGTL_THROW_INPUT_ERROR( "error in istream.read()" ); + } + + std::istream& m_istream; + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/istring.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/istring.hpp new file mode 100644 index 0000000..9aabba8 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/istring.hpp @@ -0,0 +1,107 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_ISTRING_HPP +#define TAO_PEGTL_INTERNAL_ISTRING_HPP + +#include + +#include "../config.hpp" + +#include "bump_help.hpp" +#include "result_on_found.hpp" +#include "skip_control.hpp" +#include "trivial.hpp" + +#include "../analysis/counted.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< char C > + using is_alpha = std::integral_constant< bool, ( ( 'a' <= C ) && ( C <= 'z' ) ) || ( ( 'A' <= C ) && ( C <= 'Z' ) ) >; + + template< char C, bool A = is_alpha< C >::value > + struct ichar_equal; + + template< char C > + struct ichar_equal< C, true > + { + static bool match( const char c ) noexcept + { + return ( C | 0x20 ) == ( c | 0x20 ); + } + }; + + template< char C > + struct ichar_equal< C, false > + { + static bool match( const char c ) noexcept + { + return c == C; + } + }; + + template< char... Cs > + struct istring_equal; + + template<> + struct istring_equal<> + { + static bool match( const char* /*unused*/ ) noexcept + { + return true; + } + }; + + template< char C, char... Cs > + struct istring_equal< C, Cs... > + { + static bool match( const char* r ) noexcept + { + return ichar_equal< C >::match( *r ) && istring_equal< Cs... >::match( r + 1 ); + } + }; + + template< char... Cs > + struct istring; + + template<> + struct istring<> + : trivial< true > + { + }; + + template< char... Cs > + struct istring + { + using analyze_t = analysis::counted< analysis::rule_type::any, sizeof...( Cs ) >; + + template< typename Input > + static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) ) + { + if( in.size( sizeof...( Cs ) ) >= sizeof...( Cs ) ) { + if( istring_equal< Cs... >::match( in.current() ) ) { + bump_help< result_on_found::success, Input, char, Cs... >( in, sizeof...( Cs ) ); + return true; + } + } + return false; + } + }; + + template< char... Cs > + struct skip_control< istring< Cs... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/iterator.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/iterator.hpp new file mode 100644 index 0000000..cf2cd98 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/iterator.hpp @@ -0,0 +1,60 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_ITERATOR_HPP +#define TAO_PEGTL_INTERNAL_ITERATOR_HPP + +#include + +#include "../config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct iterator + { + iterator() noexcept = default; + + explicit iterator( const char* in_data ) noexcept + : data( in_data ) + { + } + + iterator( const char* in_data, const std::size_t in_byte, const std::size_t in_line, const std::size_t in_byte_in_line ) noexcept + : data( in_data ), + byte( in_byte ), + line( in_line ), + byte_in_line( in_byte_in_line ) + { + } + + iterator( const iterator& ) = default; + iterator( iterator&& ) = default; + + ~iterator() = default; + + iterator& operator=( const iterator& ) = default; + iterator& operator=( iterator&& ) = default; + + void reset() noexcept + { + *this = iterator(); + } + + const char* data = nullptr; + + std::size_t byte = 0; + std::size_t line = 1; + std::size_t byte_in_line = 0; + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/lf_crlf_eol.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/lf_crlf_eol.hpp new file mode 100644 index 0000000..042c7be --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/lf_crlf_eol.hpp @@ -0,0 +1,45 @@ +// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_LF_CRLF_EOL_HPP +#define TAO_PEGTL_INTERNAL_LF_CRLF_EOL_HPP + +#include "../config.hpp" +#include "../eol_pair.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct lf_crlf_eol + { + static constexpr int ch = '\n'; + + template< typename Input > + static eol_pair match( Input& in ) noexcept( noexcept( in.size( 2 ) ) ) + { + eol_pair p = { false, in.size( 2 ) }; + if( p.second ) { + const auto a = in.peek_char(); + if( a == '\n' ) { + in.bump_to_next_line(); + p.first = true; + } + else if( ( a == '\r' ) && ( p.second > 1 ) && ( in.peek_char( 1 ) == '\n' ) ) { + in.bump_to_next_line( 2 ); + p.first = true; + } + } + return p; + } + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/lf_eol.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/lf_eol.hpp new file mode 100644 index 0000000..566442c --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/lf_eol.hpp @@ -0,0 +1,40 @@ +// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_LF_EOL_HPP +#define TAO_PEGTL_INTERNAL_LF_EOL_HPP + +#include "../config.hpp" +#include "../eol_pair.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct lf_eol + { + static constexpr int ch = '\n'; + + template< typename Input > + static eol_pair match( Input& in ) noexcept( noexcept( in.size( 1 ) ) ) + { + eol_pair p = { false, in.size( 1 ) }; + if( p.second ) { + if( in.peek_char() == '\n' ) { + in.bump_to_next_line(); + p.first = true; + } + } + return p; + } + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list.hpp new file mode 100644 index 0000000..c0a5c06 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list.hpp @@ -0,0 +1,27 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_LIST_HPP +#define TAO_PEGTL_INTERNAL_LIST_HPP + +#include "../config.hpp" + +#include "seq.hpp" +#include "star.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Rule, typename Sep > + using list = seq< Rule, star< Sep, Rule > >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_must.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_must.hpp new file mode 100644 index 0000000..9f03ed5 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_must.hpp @@ -0,0 +1,28 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_LIST_MUST_HPP +#define TAO_PEGTL_INTERNAL_LIST_MUST_HPP + +#include "../config.hpp" + +#include "must.hpp" +#include "seq.hpp" +#include "star.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Rule, typename Sep > + using list_must = seq< Rule, star< Sep, must< Rule > > >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_tail.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_tail.hpp new file mode 100644 index 0000000..fca4119 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_tail.hpp @@ -0,0 +1,28 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_LIST_TAIL_HPP +#define TAO_PEGTL_INTERNAL_LIST_TAIL_HPP + +#include "../config.hpp" + +#include "list.hpp" +#include "opt.hpp" +#include "seq.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Rule, typename Sep > + using list_tail = seq< list< Rule, Sep >, opt< Sep > >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_tail_pad.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_tail_pad.hpp new file mode 100644 index 0000000..006e3c1 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_tail_pad.hpp @@ -0,0 +1,30 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_LIST_TAIL_PAD_HPP +#define TAO_PEGTL_INTERNAL_LIST_TAIL_PAD_HPP + +#include "../config.hpp" + +#include "list.hpp" +#include "opt.hpp" +#include "pad.hpp" +#include "seq.hpp" +#include "star.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Rule, typename Sep, typename Pad > + using list_tail_pad = seq< list< Rule, pad< Sep, Pad > >, opt< star< Pad >, Sep > >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/marker.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/marker.hpp new file mode 100644 index 0000000..a358978 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/marker.hpp @@ -0,0 +1,99 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_MARKER_HPP +#define TAO_PEGTL_INTERNAL_MARKER_HPP + +#include "../config.hpp" +#include "../rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Iterator, rewind_mode M > + class marker + { + public: + static constexpr rewind_mode next_rewind_mode = M; + + explicit marker( const Iterator& /*unused*/ ) noexcept + { + } + + marker( const marker& ) = delete; + + marker( marker&& /*unused*/ ) noexcept + { + } + + ~marker() = default; + + void operator=( const marker& ) = delete; + void operator=( marker&& ) = delete; + + bool operator()( const bool result ) const noexcept + { + return result; + } + }; + + template< typename Iterator > + class marker< Iterator, rewind_mode::required > + { + public: + static constexpr rewind_mode next_rewind_mode = rewind_mode::active; + + explicit marker( Iterator& i ) noexcept + : m_saved( i ), + m_input( &i ) + { + } + + marker( const marker& ) = delete; + + marker( marker&& i ) noexcept + : m_saved( i.m_saved ), + m_input( i.m_input ) + { + i.m_input = nullptr; + } + + ~marker() noexcept + { + if( m_input != nullptr ) { + ( *m_input ) = m_saved; + } + } + + void operator=( const marker& ) = delete; + void operator=( marker&& ) = delete; + + bool operator()( const bool result ) noexcept + { + if( result ) { + m_input = nullptr; + return true; + } + return false; + } + + const Iterator& iterator() const noexcept + { + return m_saved; + } + + private: + const Iterator m_saved; + Iterator* m_input; + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/mmap_file.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/mmap_file.hpp new file mode 100644 index 0000000..83fa993 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/mmap_file.hpp @@ -0,0 +1,42 @@ +// Copyright (c) 2022 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#ifndef TAO_PEGTL_INTERNAL_MMAP_FILE_HPP +#define TAO_PEGTL_INTERNAL_MMAP_FILE_HPP + +#if defined( __unix__ ) || ( defined( __APPLE__ ) && defined( __MACH__ ) ) +#include // Required for _POSIX_MAPPED_FILES +#endif + +#if defined( _POSIX_MAPPED_FILES ) +#include "mmap_file_posix.hpp" +#elif defined( _WIN32 ) +#include "mmap_file_win32.hpp" +#else +#endif + +#include "filesystem.hpp" + +namespace tao::pegtl::internal +{ + struct mmap_file + { + const mmap_file_impl data; + + explicit mmap_file( const internal::filesystem::path& path ) + : data( path ) + {} + + mmap_file( const mmap_file& ) = delete; + mmap_file( mmap_file&& ) = delete; + + ~mmap_file() = default; + + mmap_file& operator=( const mmap_file& ) = delete; + mmap_file& operator=( mmap_file&& ) = delete; + }; + +} // namespace tao::pegtl::internal + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/mmap_file_win32.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/mmap_file_win32.hpp new file mode 100644 index 0000000..c82bc3f --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/mmap_file_win32.hpp @@ -0,0 +1,244 @@ +// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#ifndef TAO_PEGTL_INTERNAL_MMAP_FILE_WIN32_HPP +#define TAO_PEGTL_INTERNAL_MMAP_FILE_WIN32_HPP + +#if !defined( NOMINMAX ) +#define NOMINMAX +#define TAO_PEGTL_NOMINMAX_WAS_DEFINED +#endif + +#if !defined( WIN32_LEAN_AND_MEAN ) +#define WIN32_LEAN_AND_MEAN +#define TAO_PEGTL_WIN32_LEAN_AND_MEAN_WAS_DEFINED +#endif + +#include + +#if defined( TAO_PEGTL_NOMINMAX_WAS_DEFINED ) +#undef NOMINMAX +#undef TAO_PEGTL_NOMINMAX_WAS_DEFINED +#endif + +#if defined( TAO_PEGTL_WIN32_LEAN_AND_MEAN_WAS_DEFINED ) +#undef WIN32_LEAN_AND_MEAN +#undef TAO_PEGTL_WIN32_LEAN_AND_MEAN_WAS_DEFINED +#endif + +#if !defined( __cpp_exceptions ) +#include +#include +#endif + +#include "filesystem.hpp" + +namespace tao::pegtl::internal +{ + struct mmap_file_open + { + explicit mmap_file_open( const internal::filesystem::path& path ) + : m_path( path ), + m_handle( open() ) + {} + + mmap_file_open( const mmap_file_open& ) = delete; + mmap_file_open( mmap_file_open&& ) = delete; + + ~mmap_file_open() + { + ::CloseHandle( m_handle ); + } + + mmap_file_open& operator=( const mmap_file_open& ) = delete; + mmap_file_open& operator=( mmap_file_open&& ) = delete; + + [[nodiscard]] std::size_t size() const + { + LARGE_INTEGER size; + if( !::GetFileSizeEx( m_handle, &size ) ) { +#if defined( __cpp_exceptions ) + internal::error_code ec( ::GetLastError(), internal::system_category() ); + throw internal::filesystem::filesystem_error( "GetFileSizeEx() failed", m_path, ec ); +#else + std::perror( "GetFileSizeEx() failed" ); + std::terminate(); +#endif + } + return std::size_t( size.QuadPart ); + } + + const internal::filesystem::path m_path; + const HANDLE m_handle; + + private: + [[nodiscard]] HANDLE open() const + { + SetLastError( 0 ); +#if( _WIN32_WINNT >= 0x0602 ) + const HANDLE handle = ::CreateFile2( m_path.c_str(), + GENERIC_READ, + FILE_SHARE_READ, + OPEN_EXISTING, + nullptr ); + if( handle != INVALID_HANDLE_VALUE ) { + return handle; + } +#if defined( __cpp_exceptions ) + internal::error_code ec( ::GetLastError(), internal::system_category() ); + throw internal::filesystem::filesystem_error( "CreateFile2() failed", m_path, ec ); +#else + std::perror( "CreateFile2() failed" ); + std::terminate(); +#endif +#else + const HANDLE handle = ::CreateFileW( m_path.c_str(), + GENERIC_READ, + FILE_SHARE_READ, + nullptr, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + nullptr ); + if( handle != INVALID_HANDLE_VALUE ) { + return handle; + } +#if defined( __cpp_exceptions ) + internal::error_code ec( ::GetLastError(), internal::system_category() ); + throw internal::filesystem::filesystem_error( "CreateFileW()", m_path, ec ); +#else + std::perror( "CreateFileW() failed" ); + std::terminate(); +#endif +#endif + } + }; + + struct mmap_file_mmap + { + explicit mmap_file_mmap( const internal::filesystem::path& path ) + : mmap_file_mmap( mmap_file_open( path ) ) + {} + + explicit mmap_file_mmap( const mmap_file_open& reader ) + : m_size( reader.size() ), + m_handle( open( reader ) ) + {} + + mmap_file_mmap( const mmap_file_mmap& ) = delete; + mmap_file_mmap( mmap_file_mmap&& ) = delete; + + ~mmap_file_mmap() + { + ::CloseHandle( m_handle ); + } + + mmap_file_mmap& operator=( const mmap_file_mmap& ) = delete; + mmap_file_mmap& operator=( mmap_file_mmap&& ) = delete; + + const size_t m_size; + const HANDLE m_handle; + + private: + [[nodiscard]] HANDLE open( const mmap_file_open& reader ) const + { + const uint64_t file_size = reader.size(); + SetLastError( 0 ); + // Use `CreateFileMappingW` because a) we're not specifying a + // mapping name, so the character type is of no consequence, and + // b) it's defined in `memoryapi.h`, unlike + // `CreateFileMappingA`(?!) + const HANDLE handle = ::CreateFileMappingW( reader.m_handle, + nullptr, + PAGE_READONLY, + DWORD( file_size >> 32 ), + DWORD( file_size & 0xffffffff ), + nullptr ); + if( handle != NULL || file_size == 0 ) { + return handle; + } +#if defined( __cpp_exceptions ) + internal::error_code ec( ::GetLastError(), internal::system_category() ); + throw internal::filesystem::filesystem_error( "CreateFileMappingW() failed", reader.m_path, ec ); +#else + std::perror( "CreateFileMappingW() failed" ); + std::terminate(); +#endif + } + }; + + class mmap_file_win32 + { + public: + explicit mmap_file_win32( const internal::filesystem::path& path ) + : mmap_file_win32( mmap_file_mmap( path ) ) + {} + + explicit mmap_file_win32( const mmap_file_mmap& mapper ) + : m_size( mapper.m_size ), + m_data( static_cast< const char* >( ::MapViewOfFile( mapper.m_handle, + FILE_MAP_READ, + 0, + 0, + 0 ) ) ) + { + if( ( m_size != 0 ) && ( intptr_t( m_data ) == 0 ) ) { +#if defined( __cpp_exceptions ) + internal::error_code ec( ::GetLastError(), internal::system_category() ); + throw internal::filesystem::filesystem_error( "MapViewOfFile() failed", ec ); +#else + std::perror( "MapViewOfFile() failed" ); + std::terminate(); +#endif + } + } + + mmap_file_win32( const mmap_file_win32& ) = delete; + mmap_file_win32( mmap_file_win32&& ) = delete; + + ~mmap_file_win32() + { + ::UnmapViewOfFile( LPCVOID( m_data ) ); + } + + mmap_file_win32& operator=( const mmap_file_win32& ) = delete; + mmap_file_win32& operator=( mmap_file_win32&& ) = delete; + + [[nodiscard]] bool empty() const noexcept + { + return m_size == 0; + } + + [[nodiscard]] std::size_t size() const noexcept + { + return m_size; + } + + using iterator = const char*; + using const_iterator = const char*; + + [[nodiscard]] iterator data() const noexcept + { + return m_data; + } + + [[nodiscard]] iterator begin() const noexcept + { + return m_data; + } + + [[nodiscard]] iterator end() const noexcept + { + return m_data + m_size; + } + + private: + const std::size_t m_size; + const char* const m_data; + }; + + using mmap_file_impl = mmap_file_win32; + +} // namespace tao::pegtl::internal + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/must.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/must.hpp new file mode 100644 index 0000000..3572728 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/must.hpp @@ -0,0 +1,70 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_MUST_HPP +#define TAO_PEGTL_INTERNAL_MUST_HPP + +#include "../config.hpp" + +#include "raise.hpp" +#include "seq.hpp" +#include "skip_control.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + // The general case applies must<> to each of the + // rules in the 'Rules' parameter pack individually. + + template< typename... Rules > + struct must + : seq< must< Rules >... > + { + }; + + // While in theory the implementation for a single rule could + // be simplified to must< Rule > = sor< Rule, raise< Rule > >, this + // would result in some unnecessary run-time overhead. + + template< typename Rule > + struct must< Rule > + { + using analyze_t = typename Rule::analyze_t; + + template< apply_mode A, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + if( !Control< Rule >::template match< A, rewind_mode::dontcare, Action, Control >( in, st... ) ) { + raise< Rule >::template match< A, rewind_mode::dontcare, Action, Control >( in, st... ); + } + return true; + } + }; + + template< typename... Rules > + struct skip_control< must< Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/not_at.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/not_at.hpp new file mode 100644 index 0000000..e1ba9be --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/not_at.hpp @@ -0,0 +1,67 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_NOT_AT_HPP +#define TAO_PEGTL_INTERNAL_NOT_AT_HPP + +#include "../config.hpp" + +#include "seq.hpp" +#include "skip_control.hpp" +#include "trivial.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename... Rules > + struct not_at + : not_at< seq< Rules... > > + { + }; + + template<> + struct not_at<> + : trivial< false > + { + }; + + template< typename Rule > + struct not_at< Rule > + { + using analyze_t = analysis::generic< analysis::rule_type::opt, Rule >; + + template< apply_mode, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + const auto m = in.template mark< rewind_mode::required >(); + return !Control< Rule >::template match< apply_mode::nothing, rewind_mode::active, Action, Control >( in, st... ); + } + }; + + template< typename... Rules > + struct skip_control< not_at< Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/one.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/one.hpp new file mode 100644 index 0000000..9734be1 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/one.hpp @@ -0,0 +1,77 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_ONE_HPP +#define TAO_PEGTL_INTERNAL_ONE_HPP + +#include +#include + +#include "../config.hpp" + +#include "bump_help.hpp" +#include "result_on_found.hpp" +#include "skip_control.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Char > + bool contains( const Char c, const std::initializer_list< Char >& l ) noexcept + { + return std::find( l.begin(), l.end(), c ) != l.end(); + } + + template< result_on_found R, typename Peek, typename Peek::data_t... Cs > + struct one + { + using analyze_t = analysis::generic< analysis::rule_type::any >; + + template< typename Input > + static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) ) + { + if( const auto t = Peek::peek( in ) ) { + if( contains( t.data, { Cs... } ) == bool( R ) ) { + bump_help< R, Input, typename Peek::data_t, Cs... >( in, t.size ); + return true; + } + } + return false; + } + }; + + template< result_on_found R, typename Peek, typename Peek::data_t C > + struct one< R, Peek, C > + { + using analyze_t = analysis::generic< analysis::rule_type::any >; + + template< typename Input > + static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) ) + { + if( const auto t = Peek::peek( in ) ) { + if( ( t.data == C ) == bool( R ) ) { + bump_help< R, Input, typename Peek::data_t, C >( in, t.size ); + return true; + } + } + return false; + } + }; + + template< result_on_found R, typename Peek, typename Peek::data_t... Cs > + struct skip_control< one< R, Peek, Cs... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/opt.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/opt.hpp new file mode 100644 index 0000000..0877439 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/opt.hpp @@ -0,0 +1,69 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_OPT_HPP +#define TAO_PEGTL_INTERNAL_OPT_HPP + +#include + +#include "../config.hpp" + +#include "seq.hpp" +#include "skip_control.hpp" +#include "trivial.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename... Rules > + struct opt + : opt< seq< Rules... > > + { + }; + + template<> + struct opt<> + : trivial< true > + { + }; + + template< typename Rule > + struct opt< Rule > + { + using analyze_t = analysis::generic< analysis::rule_type::opt, Rule >; + + template< apply_mode A, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + Control< Rule >::template match< A, rewind_mode::required, Action, Control >( in, st... ); + return true; + } + }; + + template< typename... Rules > + struct skip_control< opt< Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pad.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pad.hpp new file mode 100644 index 0000000..bab590a --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pad.hpp @@ -0,0 +1,27 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_PAD_HPP +#define TAO_PEGTL_INTERNAL_PAD_HPP + +#include "../config.hpp" + +#include "seq.hpp" +#include "star.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Rule, typename Pad1, typename Pad2 = Pad1 > + using pad = seq< star< Pad1 >, Rule, star< Pad2 > >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pad_opt.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pad_opt.hpp new file mode 100644 index 0000000..38bab54 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pad_opt.hpp @@ -0,0 +1,28 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_PAD_OPT_HPP +#define TAO_PEGTL_INTERNAL_PAD_OPT_HPP + +#include "../config.hpp" + +#include "opt.hpp" +#include "seq.hpp" +#include "star.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Rule, typename Pad > + using pad_opt = seq< star< Pad >, opt< Rule, star< Pad > > >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_char.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_char.hpp new file mode 100644 index 0000000..2ef3f63 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_char.hpp @@ -0,0 +1,40 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_PEEK_CHAR_HPP +#define TAO_PEGTL_INTERNAL_PEEK_CHAR_HPP + +#include + +#include "../config.hpp" + +#include "input_pair.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct peek_char + { + using data_t = char; + using pair_t = input_pair< char >; + + template< typename Input > + static pair_t peek( Input& in ) noexcept( noexcept( in.empty() ) ) + { + if( in.empty() ) { + return { 0, 0 }; + } + return { in.peek_char(), 1 }; + } + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_mask_uint.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_mask_uint.hpp new file mode 100644 index 0000000..257a1cd --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_mask_uint.hpp @@ -0,0 +1,62 @@ +// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_PEEK_MASK_UINT_HPP +#define TAO_PEGTL_INTERNAL_PEEK_MASK_UINT_HPP + +#include +#include + +#include "../config.hpp" + +#include "input_pair.hpp" +#include "read_uint.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename R, typename R::type M > + struct peek_mask_uint_impl + { + using data_t = typename R::type; + using pair_t = input_pair< data_t >; + + template< typename Input > + static pair_t peek( Input& in ) noexcept( noexcept( in.size( sizeof( data_t ) ) ) ) + { + if( in.size( sizeof( data_t ) ) < sizeof( data_t ) ) { + return { 0, 0 }; + } + const data_t data = R::read( in.current() ) & M; + return { data, sizeof( data_t ) }; + } + }; + + template< std::uint16_t M > + using peek_mask_uint16_be = peek_mask_uint_impl< read_uint16_be, M >; + + template< std::uint16_t M > + using peek_mask_uint16_le = peek_mask_uint_impl< read_uint16_le, M >; + + template< std::uint32_t M > + using peek_mask_uint32_be = peek_mask_uint_impl< read_uint32_be, M >; + + template< std::uint32_t M > + using peek_mask_uint32_le = peek_mask_uint_impl< read_uint32_le, M >; + + template< std::uint64_t M > + using peek_mask_uint64_be = peek_mask_uint_impl< read_uint64_be, M >; + + template< std::uint64_t M > + using peek_mask_uint64_le = peek_mask_uint_impl< read_uint64_le, M >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_mask_uint8.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_mask_uint8.hpp new file mode 100644 index 0000000..a8db523 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_mask_uint8.hpp @@ -0,0 +1,42 @@ +// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_PEEK_MASK_UINT8_HPP +#define TAO_PEGTL_INTERNAL_PEEK_MASK_UINT8_HPP + +#include +#include + +#include "../config.hpp" + +#include "input_pair.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< std::uint8_t M > + struct peek_mask_uint8 + { + using data_t = std::uint8_t; + using pair_t = input_pair< std::uint8_t >; + + template< typename Input > + static pair_t peek( Input& in ) noexcept( noexcept( in.empty() ) ) + { + if( in.empty() ) { + return { 0, 0 }; + } + return { std::uint8_t( in.peek_uint8() & M ), 1 }; + } + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_uint.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_uint.hpp new file mode 100644 index 0000000..973a540 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_uint.hpp @@ -0,0 +1,53 @@ +// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_PEEK_UINT_HPP +#define TAO_PEGTL_INTERNAL_PEEK_UINT_HPP + +#include +#include + +#include "../config.hpp" + +#include "input_pair.hpp" +#include "read_uint.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename R > + struct peek_uint_impl + { + using data_t = typename R::type; + using pair_t = input_pair< data_t >; + + template< typename Input > + static pair_t peek( Input& in ) noexcept( noexcept( in.size( sizeof( data_t ) ) ) ) + { + if( in.size( sizeof( data_t ) ) < sizeof( data_t ) ) { + return { 0, 0 }; + } + const data_t data = R::read( in.current() ); + return { data, sizeof( data_t ) }; + } + }; + + using peek_uint16_be = peek_uint_impl< read_uint16_be >; + using peek_uint16_le = peek_uint_impl< read_uint16_le >; + + using peek_uint32_be = peek_uint_impl< read_uint32_be >; + using peek_uint32_le = peek_uint_impl< read_uint32_le >; + + using peek_uint64_be = peek_uint_impl< read_uint64_be >; + using peek_uint64_le = peek_uint_impl< read_uint64_le >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_uint8.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_uint8.hpp new file mode 100644 index 0000000..2b8fe07 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_uint8.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_PEEK_UINT8_HPP +#define TAO_PEGTL_INTERNAL_PEEK_UINT8_HPP + +#include +#include + +#include "../config.hpp" + +#include "input_pair.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct peek_uint8 + { + using data_t = std::uint8_t; + using pair_t = input_pair< std::uint8_t >; + + template< typename Input > + static pair_t peek( Input& in ) noexcept( noexcept( in.empty() ) ) + { + if( in.empty() ) { + return { 0, 0 }; + } + return { in.peek_uint8(), 1 }; + } + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf16.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf16.hpp new file mode 100644 index 0000000..490e8e3 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf16.hpp @@ -0,0 +1,62 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_PEEK_UTF16_HPP +#define TAO_PEGTL_INTERNAL_PEEK_UTF16_HPP + +#include + +#include "../config.hpp" + +#include "input_pair.hpp" +#include "read_uint.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename R > + struct peek_utf16_impl + { + using data_t = char32_t; + using pair_t = input_pair< char32_t >; + + using short_t = std::make_unsigned< char16_t >::type; + + static_assert( sizeof( short_t ) == 2, "expected size 2 for 16bit value" ); + static_assert( sizeof( char16_t ) == 2, "expected size 2 for 16bit value" ); + + template< typename Input > + static pair_t peek( Input& in ) noexcept( noexcept( in.size( 4 ) ) ) + { + if( in.size( 2 ) < 2 ) { + return { 0, 0 }; + } + const char32_t t = R::read( in.current() ); + if( ( t < 0xd800 ) || ( t > 0xdfff ) ) { + return { t, 2 }; + } + if( ( t >= 0xdc00 ) || ( in.size( 4 ) < 4 ) ) { + return { 0, 0 }; + } + const char32_t u = R::read( in.current() + 2 ); + if( ( u >= 0xdc00 ) && ( u <= 0xdfff ) ) { + const auto cp = ( ( ( t & 0x03ff ) << 10 ) | ( u & 0x03ff ) ) + 0x10000; + return { cp, 4 }; + } + return { 0, 0 }; + } + }; + + using peek_utf16_be = peek_utf16_impl< read_uint16_be >; + using peek_utf16_le = peek_utf16_impl< read_uint16_le >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf32.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf32.hpp new file mode 100644 index 0000000..7ddeba6 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf32.hpp @@ -0,0 +1,51 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_PEEK_UTF32_HPP +#define TAO_PEGTL_INTERNAL_PEEK_UTF32_HPP + +#include + +#include "../config.hpp" + +#include "input_pair.hpp" +#include "read_uint.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename R > + struct peek_utf32_impl + { + using data_t = char32_t; + using pair_t = input_pair< char32_t >; + + static_assert( sizeof( char32_t ) == 4, "expected size 4 for 32bit value" ); + + template< typename Input > + static pair_t peek( Input& in ) noexcept( noexcept( in.size( 4 ) ) ) + { + if( in.size( 4 ) < 4 ) { + return { 0, 0 }; + } + const char32_t t = R::read( in.current() ); + if( ( t <= 0x10ffff ) && !( t >= 0xd800 && t <= 0xdfff ) ) { + return { t, 4 }; + } + return { 0, 0 }; + } + }; + + using peek_utf32_be = peek_utf32_impl< read_uint32_be >; + using peek_utf32_le = peek_utf32_impl< read_uint32_le >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf8.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf8.hpp new file mode 100644 index 0000000..2c573e8 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf8.hpp @@ -0,0 +1,97 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_PEEK_UTF8_HPP +#define TAO_PEGTL_INTERNAL_PEEK_UTF8_HPP + +#include "../config.hpp" + +#include "input_pair.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct peek_utf8 + { + using data_t = char32_t; + using pair_t = input_pair< char32_t >; + + template< typename Input > + static pair_t peek( Input& in ) noexcept( noexcept( in.empty() ) ) + { + if( in.empty() ) { + return { 0, 0 }; + } + char32_t c0 = in.peek_uint8(); + if( ( c0 & 0x80 ) == 0 ) { + return { c0, 1 }; + } + return peek_impl( in, c0 ); + } + + private: + template< typename Input > + static pair_t peek_impl( Input& in, char32_t c0 ) noexcept( noexcept( in.size( 4 ) ) ) + { + if( ( c0 & 0xE0 ) == 0xC0 ) { + if( in.size( 2 ) >= 2 ) { + const char32_t c1 = in.peek_uint8( 1 ); + if( ( c1 & 0xC0 ) == 0x80 ) { + c0 &= 0x1F; + c0 <<= 6; + c0 |= ( c1 & 0x3F ); + if( c0 >= 0x80 ) { + return { c0, 2 }; + } + } + } + } + else if( ( c0 & 0xF0 ) == 0xE0 ) { + if( in.size( 3 ) >= 3 ) { + const char32_t c1 = in.peek_uint8( 1 ); + const char32_t c2 = in.peek_uint8( 2 ); + if( ( ( c1 & 0xC0 ) == 0x80 ) && ( ( c2 & 0xC0 ) == 0x80 ) ) { + c0 &= 0x0F; + c0 <<= 6; + c0 |= ( c1 & 0x3F ); + c0 <<= 6; + c0 |= ( c2 & 0x3F ); + if( c0 >= 0x800 && !( c0 >= 0xD800 && c0 <= 0xDFFF ) ) { + return { c0, 3 }; + } + } + } + } + else if( ( c0 & 0xF8 ) == 0xF0 ) { + if( in.size( 4 ) >= 4 ) { + const char32_t c1 = in.peek_uint8( 1 ); + const char32_t c2 = in.peek_uint8( 2 ); + const char32_t c3 = in.peek_uint8( 3 ); + if( ( ( c1 & 0xC0 ) == 0x80 ) && ( ( c2 & 0xC0 ) == 0x80 ) && ( ( c3 & 0xC0 ) == 0x80 ) ) { + c0 &= 0x07; + c0 <<= 6; + c0 |= ( c1 & 0x3F ); + c0 <<= 6; + c0 |= ( c2 & 0x3F ); + c0 <<= 6; + c0 |= ( c3 & 0x3F ); + if( c0 >= 0x10000 && c0 <= 0x10FFFF ) { + return { c0, 4 }; + } + } + } + } + return { 0, 0 }; + } + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pegtl_string.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pegtl_string.hpp new file mode 100644 index 0000000..f5700af --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pegtl_string.hpp @@ -0,0 +1,103 @@ +// Copyright (c) 2015-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_PEGTL_STRING_HPP +#define TAO_PEGTL_INTERNAL_PEGTL_STRING_HPP + +#include +#include + +#include "../ascii.hpp" +#include "../config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + // Inspired by https://github.com/irrequietus/typestring + // Rewritten and reduced to what is needed for the PEGTL + // and to work with Visual Studio 2015. + + namespace internal + { + template< typename, typename, typename, typename, typename, typename, typename, typename > + struct string_join; + + template< template< char... > class S, char... C0s, char... C1s, char... C2s, char... C3s, char... C4s, char... C5s, char... C6s, char... C7s > + struct string_join< S< C0s... >, S< C1s... >, S< C2s... >, S< C3s... >, S< C4s... >, S< C5s... >, S< C6s... >, S< C7s... > > + { + using type = S< C0s..., C1s..., C2s..., C3s..., C4s..., C5s..., C6s..., C7s... >; + }; + + template< template< char... > class S, char, bool > + struct string_at + { + using type = S<>; + }; + + template< template< char... > class S, char C > + struct string_at< S, C, true > + { + using type = S< C >; + }; + + template< typename T, std::size_t S > + struct string_max_length + { + static_assert( S <= 512, "String longer than 512 (excluding terminating \\0)!" ); + using type = T; + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#define TAO_PEGTL_INTERNAL_EMPTY() +#define TAO_PEGTL_INTERNAL_DEFER( X ) X TAO_PEGTL_INTERNAL_EMPTY() +#define TAO_PEGTL_INTERNAL_EXPAND( ... ) __VA_ARGS__ + +#define TAO_PEGTL_INTERNAL_STRING_AT( S, x, n ) \ + tao::TAO_PEGTL_NAMESPACE::internal::string_at< S, ( 0##n < ( sizeof( x ) / sizeof( char ) ) ) ? ( x )[ 0##n ] : 0, ( 0##n < ( sizeof( x ) / sizeof( char ) ) - 1 ) >::type + +#define TAO_PEGTL_INTERNAL_JOIN_8( M, S, x, n ) \ + tao::TAO_PEGTL_NAMESPACE::internal::string_join< TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##0 ), \ + TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##1 ), \ + TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##2 ), \ + TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##3 ), \ + TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##4 ), \ + TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##5 ), \ + TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##6 ), \ + TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##7 ) >::type + +#define TAO_PEGTL_INTERNAL_STRING_8( S, x, n ) \ + TAO_PEGTL_INTERNAL_JOIN_8( TAO_PEGTL_INTERNAL_STRING_AT, S, x, n ) + +#define TAO_PEGTL_INTERNAL_STRING_64( S, x, n ) \ + TAO_PEGTL_INTERNAL_JOIN_8( TAO_PEGTL_INTERNAL_STRING_8, S, x, n ) + +#define TAO_PEGTL_INTERNAL_STRING_512( S, x, n ) \ + TAO_PEGTL_INTERNAL_JOIN_8( TAO_PEGTL_INTERNAL_STRING_64, S, x, n ) + +#define TAO_PEGTL_INTERNAL_STRING( S, x ) \ + TAO_PEGTL_INTERNAL_EXPAND( \ + TAO_PEGTL_INTERNAL_EXPAND( \ + TAO_PEGTL_INTERNAL_EXPAND( \ + tao::TAO_PEGTL_NAMESPACE::internal::string_max_length< TAO_PEGTL_INTERNAL_STRING_512( S, x, ), sizeof( x ) - 1 >::type ) ) ) + +#define TAO_PEGTL_STRING( x ) \ + TAO_PEGTL_INTERNAL_STRING( tao::TAO_PEGTL_NAMESPACE::ascii::string, x ) + +#define TAO_PEGTL_ISTRING( x ) \ + TAO_PEGTL_INTERNAL_STRING( tao::TAO_PEGTL_NAMESPACE::ascii::istring, x ) + +#define TAO_PEGTL_KEYWORD( x ) \ + TAO_PEGTL_INTERNAL_STRING( tao::TAO_PEGTL_NAMESPACE::ascii::keyword, x ) + +// Compatibility, remove with 3.0.0 +#define TAOCPP_PEGTL_STRING( x ) TAO_PEGTL_STRING( x ) +#define TAOCPP_PEGTL_ISTRING( x ) TAO_PEGTL_ISTRING( x ) +#define TAOCPP_PEGTL_KEYWORD( x ) TAO_PEGTL_KEYWORD( x ) + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/plus.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/plus.hpp new file mode 100644 index 0000000..2454ec2 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/plus.hpp @@ -0,0 +1,68 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_PLUS_HPP +#define TAO_PEGTL_INTERNAL_PLUS_HPP + +#include + +#include "../config.hpp" + +#include "opt.hpp" +#include "seq.hpp" +#include "skip_control.hpp" +#include "star.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + // While plus<> could easily be implemented with + // seq< Rule, Rules ..., star< Rule, Rules ... > > we + // provide an explicit implementation to optimise away + // the otherwise created input mark. + + template< typename Rule, typename... Rules > + struct plus + : plus< seq< Rule, Rules... > > + { + }; + + template< typename Rule > + struct plus< Rule > + { + using analyze_t = analysis::generic< analysis::rule_type::seq, Rule, opt< plus > >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + return Control< Rule >::template match< A, M, Action, Control >( in, st... ) && Control< star< Rule > >::template match< A, M, Action, Control >( in, st... ); + } + }; + + template< typename Rule, typename... Rules > + struct skip_control< plus< Rule, Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/raise.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/raise.hpp new file mode 100644 index 0000000..d4f6643 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/raise.hpp @@ -0,0 +1,63 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_RAISE_HPP +#define TAO_PEGTL_INTERNAL_RAISE_HPP + +#include +#include +#include + +#include "../config.hpp" + +#include "skip_control.hpp" + +#include "../analysis/generic.hpp" +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename T > + struct raise + { + using analyze_t = analysis::generic< analysis::rule_type::any >; + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable : 4702 ) +#endif + template< apply_mode, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + Control< T >::raise( static_cast< const Input& >( in ), st... ); + throw std::logic_error( "code should be unreachable: Control< T >::raise() did not throw an exception" ); // NOLINT, LCOV_EXCL_LINE +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + } + }; + + template< typename T > + struct skip_control< raise< T > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/range.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/range.hpp new file mode 100644 index 0000000..650eb79 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/range.hpp @@ -0,0 +1,58 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_RANGE_HPP +#define TAO_PEGTL_INTERNAL_RANGE_HPP + +#include "../config.hpp" + +#include "bump_help.hpp" +#include "result_on_found.hpp" +#include "skip_control.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< result_on_found R, typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi > + struct range + { + static_assert( Lo <= Hi, "invalid range detected" ); + + using analyze_t = analysis::generic< analysis::rule_type::any >; + + template< int Eol > + struct can_match_eol + { + static constexpr bool value = ( ( ( Lo <= Eol ) && ( Eol <= Hi ) ) == bool( R ) ); + }; + + template< typename Input > + static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) ) + { + if( const auto t = Peek::peek( in ) ) { + if( ( ( Lo <= t.data ) && ( t.data <= Hi ) ) == bool( R ) ) { + bump_impl< can_match_eol< Input::eol_t::ch >::value >::bump( in, t.size ); + return true; + } + } + return false; + } + }; + + template< result_on_found R, typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi > + struct skip_control< range< R, Peek, Lo, Hi > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/ranges.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/ranges.hpp new file mode 100644 index 0000000..9621759 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/ranges.hpp @@ -0,0 +1,100 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_RANGES_HPP +#define TAO_PEGTL_INTERNAL_RANGES_HPP + +#include "../config.hpp" + +#include "bump_help.hpp" +#include "range.hpp" +#include "skip_control.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< int Eol, typename Char, Char... Cs > + struct ranges_impl; + + template< int Eol, typename Char > + struct ranges_impl< Eol, Char > + { + static constexpr bool can_match_eol = false; + + static bool match( const Char /*unused*/ ) noexcept + { + return false; + } + }; + + template< int Eol, typename Char, Char Eq > + struct ranges_impl< Eol, Char, Eq > + { + static constexpr bool can_match_eol = ( Eq == Eol ); + + static bool match( const Char c ) noexcept + { + return c == Eq; + } + }; + + template< int Eol, typename Char, Char Lo, Char Hi, Char... Cs > + struct ranges_impl< Eol, Char, Lo, Hi, Cs... > + { + static_assert( Lo <= Hi, "invalid range detected" ); + + static constexpr bool can_match_eol = ( ( ( Lo <= Eol ) && ( Eol <= Hi ) ) || ranges_impl< Eol, Char, Cs... >::can_match_eol ); + + static bool match( const Char c ) noexcept + { + return ( ( Lo <= c ) && ( c <= Hi ) ) || ranges_impl< Eol, Char, Cs... >::match( c ); + } + }; + + template< typename Peek, typename Peek::data_t... Cs > + struct ranges + { + using analyze_t = analysis::generic< analysis::rule_type::any >; + + template< int Eol > + struct can_match_eol + { + static constexpr bool value = ranges_impl< Eol, typename Peek::data_t, Cs... >::can_match_eol; + }; + + template< typename Input > + static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) ) + { + if( const auto t = Peek::peek( in ) ) { + if( ranges_impl< Input::eol_t::ch, typename Peek::data_t, Cs... >::match( t.data ) ) { + bump_impl< can_match_eol< Input::eol_t::ch >::value >::bump( in, t.size ); + return true; + } + } + return false; + } + }; + + template< typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi > + struct ranges< Peek, Lo, Hi > + : range< result_on_found::success, Peek, Lo, Hi > + { + }; + + template< typename Peek, typename Peek::data_t... Cs > + struct skip_control< ranges< Peek, Cs... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/read_uint.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/read_uint.hpp new file mode 100644 index 0000000..9e975ae --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/read_uint.hpp @@ -0,0 +1,85 @@ +// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_READ_UINT_HPP +#define TAO_PEGTL_INTERNAL_READ_UINT_HPP + +#include + +#include "../config.hpp" + +#include "endian.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct read_uint16_be + { + using type = std::uint16_t; + + static std::uint16_t read( const void* d ) noexcept + { + return be_to_h< std::uint16_t >( d ); + } + }; + + struct read_uint16_le + { + using type = std::uint16_t; + + static std::uint16_t read( const void* d ) noexcept + { + return le_to_h< std::uint16_t >( d ); + } + }; + + struct read_uint32_be + { + using type = std::uint32_t; + + static std::uint32_t read( const void* d ) noexcept + { + return be_to_h< std::uint32_t >( d ); + } + }; + + struct read_uint32_le + { + using type = std::uint32_t; + + static std::uint32_t read( const void* d ) noexcept + { + return le_to_h< std::uint32_t >( d ); + } + }; + + struct read_uint64_be + { + using type = std::uint64_t; + + static std::uint64_t read( const void* d ) noexcept + { + return be_to_h< std::uint64_t >( d ); + } + }; + + struct read_uint64_le + { + using type = std::uint64_t; + + static std::uint64_t read( const void* d ) noexcept + { + return le_to_h< std::uint64_t >( d ); + } + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rematch.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rematch.hpp new file mode 100644 index 0000000..a43ef89 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rematch.hpp @@ -0,0 +1,86 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_REMATCH_HPP +#define TAO_PEGTL_INTERNAL_REMATCH_HPP + +#include "../config.hpp" + +#include "skip_control.hpp" + +#include "../apply_mode.hpp" +#include "../memory_input.hpp" +#include "../rewind_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Head, typename... Rules > + struct rematch; + + template< typename Head > + struct rematch< Head > + { + using analyze_t = typename Head::analyze_t; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + return Control< Head >::template match< A, M, Action, Control >( in, st... ); + } + }; + + template< typename Head, typename Rule, typename... Rules > + struct rematch< Head, Rule, Rules... > + { + using analyze_t = typename Head::analyze_t; // NOTE: Rule and Rules are ignored for analyze(). + + template< apply_mode A, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< rewind_mode::required >(); + + if( Control< Head >::template match< A, rewind_mode::active, Action, Control >( in, st... ) ) { + memory_input< Input::tracking_mode_v, typename Input::eol_t, typename Input::source_t > i2( m.iterator(), in.current(), in.source() ); +#ifdef __cpp_fold_expressions + return m( ( Control< Rule >::template match< A, rewind_mode::active, Action, Control >( i2, st... ) && ... && ( i2.restart( m ), Control< Rules >::template match< A, rewind_mode::active, Action, Control >( i2, st... ) ) ) ); +#else + bool result = Control< Rule >::template match< A, rewind_mode::active, Action, Control >( i2, st... ); + using swallow = bool[]; + (void)swallow{ result = result && ( i2.restart( m ), Control< Rules >::template match< A, rewind_mode::active, Action, Control >( i2, st... ) )..., true }; + return m( result ); +#endif + } + return false; + } + }; + + template< typename Head, typename... Rules > + struct skip_control< rematch< Head, Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep.hpp new file mode 100644 index 0000000..58cddef --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep.hpp @@ -0,0 +1,80 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_REP_HPP +#define TAO_PEGTL_INTERNAL_REP_HPP + +#include "../config.hpp" + +#include "seq.hpp" +#include "skip_control.hpp" +#include "trivial.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/counted.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< unsigned Num, typename... Rules > + struct rep + : rep< Num, seq< Rules... > > + { + }; + + template< unsigned Num > + struct rep< Num > + : trivial< true > + { + }; + + template< typename Rule > + struct rep< 0, Rule > + : trivial< true > + { + }; + + template< unsigned Num, typename Rule > + struct rep< Num, Rule > + { + using analyze_t = analysis::counted< analysis::rule_type::seq, Num, Rule >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< M >(); + using m_t = decltype( m ); + + for( unsigned i = 0; i != Num; ++i ) { + if( !Control< Rule >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) { + return false; + } + } + return m( true ); + } + }; + + template< unsigned Num, typename... Rules > + struct skip_control< rep< Num, Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_min.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_min.hpp new file mode 100644 index 0000000..869ac11 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_min.hpp @@ -0,0 +1,28 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_REP_MIN_HPP +#define TAO_PEGTL_INTERNAL_REP_MIN_HPP + +#include "../config.hpp" + +#include "rep.hpp" +#include "seq.hpp" +#include "star.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< unsigned Min, typename Rule, typename... Rules > + using rep_min = seq< rep< Min, Rule, Rules... >, star< Rule, Rules... > >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_min_max.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_min_max.hpp new file mode 100644 index 0000000..e584969 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_min_max.hpp @@ -0,0 +1,91 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_REP_MIN_MAX_HPP +#define TAO_PEGTL_INTERNAL_REP_MIN_MAX_HPP + +#include + +#include "../config.hpp" + +#include "not_at.hpp" +#include "seq.hpp" +#include "skip_control.hpp" +#include "trivial.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/counted.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< unsigned Min, unsigned Max, typename... Rules > + struct rep_min_max + : rep_min_max< Min, Max, seq< Rules... > > + { + }; + + template< unsigned Min, unsigned Max > + struct rep_min_max< Min, Max > + : trivial< false > + { + static_assert( Min <= Max, "invalid rep_min_max rule (maximum number of repetitions smaller than minimum)" ); + }; + + template< typename Rule > + struct rep_min_max< 0, 0, Rule > + : not_at< Rule > + { + }; + + template< unsigned Min, unsigned Max, typename Rule > + struct rep_min_max< Min, Max, Rule > + { + using analyze_t = analysis::counted< analysis::rule_type::seq, Min, Rule >; + + static_assert( Min <= Max, "invalid rep_min_max rule (maximum number of repetitions smaller than minimum)" ); + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< M >(); + using m_t = decltype( m ); + + for( unsigned i = 0; i != Min; ++i ) { + if( !Control< Rule >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) { + return false; + } + } + for( unsigned i = Min; i != Max; ++i ) { + if( !Control< Rule >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { + return m( true ); + } + } + return m( Control< not_at< Rule > >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ); // NOTE that not_at<> will always rewind. + } + }; + + template< unsigned Min, unsigned Max, typename... Rules > + struct skip_control< rep_min_max< Min, Max, Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_opt.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_opt.hpp new file mode 100644 index 0000000..59ca8eb --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_opt.hpp @@ -0,0 +1,61 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_REP_OPT_HPP +#define TAO_PEGTL_INTERNAL_REP_OPT_HPP + +#include "../config.hpp" + +#include "seq.hpp" +#include "skip_control.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< unsigned Max, typename... Rules > + struct rep_opt + : rep_opt< Max, seq< Rules... > > + { + }; + + template< unsigned Max, typename Rule > + struct rep_opt< Max, Rule > + { + using analyze_t = analysis::generic< analysis::rule_type::opt, Rule >; + + template< apply_mode A, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + for( unsigned i = 0; ( i != Max ) && Control< Rule >::template match< A, rewind_mode::required, Action, Control >( in, st... ); ++i ) { + } + return true; + } + }; + + template< unsigned Max, typename... Rules > + struct skip_control< rep_opt< Max, Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/require.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/require.hpp new file mode 100644 index 0000000..043a5b7 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/require.hpp @@ -0,0 +1,52 @@ +// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_REQUIRE_HPP +#define TAO_PEGTL_INTERNAL_REQUIRE_HPP + +#include "../config.hpp" + +#include "skip_control.hpp" +#include "trivial.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< unsigned Amount > + struct require; + + template<> + struct require< 0 > + : trivial< true > + { + }; + + template< unsigned Amount > + struct require + { + using analyze_t = analysis::generic< analysis::rule_type::opt >; + + template< typename Input > + static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) ) + { + return in.size( Amount ) >= Amount; + } + }; + + template< unsigned Amount > + struct skip_control< require< Amount > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/result_on_found.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/result_on_found.hpp new file mode 100644 index 0000000..79a1976 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/result_on_found.hpp @@ -0,0 +1,27 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_RESULT_ON_FOUND_HPP +#define TAO_PEGTL_INTERNAL_RESULT_ON_FOUND_HPP + +#include "../config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + enum class result_on_found : bool + { + success = true, + failure = false, + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rules.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rules.hpp new file mode 100644 index 0000000..fc56a6e --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rules.hpp @@ -0,0 +1,61 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_RULES_HPP +#define TAO_PEGTL_INTERNAL_RULES_HPP + +#include "action.hpp" +#include "alnum.hpp" +#include "alpha.hpp" +#include "any.hpp" +#include "apply.hpp" +#include "apply0.hpp" +#include "at.hpp" +#include "bof.hpp" +#include "bol.hpp" +#include "bytes.hpp" +#include "control.hpp" +#include "disable.hpp" +#include "discard.hpp" +#include "enable.hpp" +#include "eof.hpp" +#include "eol.hpp" +#include "eolf.hpp" +#include "identifier.hpp" +#include "if_apply.hpp" +#include "if_must.hpp" +#include "if_must_else.hpp" +#include "if_then_else.hpp" +#include "istring.hpp" +#include "list.hpp" +#include "list_must.hpp" +#include "list_tail.hpp" +#include "list_tail_pad.hpp" +#include "must.hpp" +#include "not_at.hpp" +#include "one.hpp" +#include "opt.hpp" +#include "pad.hpp" +#include "pad_opt.hpp" +#include "plus.hpp" +#include "raise.hpp" +#include "range.hpp" +#include "ranges.hpp" +#include "rematch.hpp" +#include "rep.hpp" +#include "rep_min.hpp" +#include "rep_min_max.hpp" +#include "rep_opt.hpp" +#include "require.hpp" +#include "seq.hpp" +#include "skip_control.hpp" +#include "sor.hpp" +#include "star.hpp" +#include "star_must.hpp" +#include "state.hpp" +#include "string.hpp" +#include "trivial.hpp" +#include "try_catch_type.hpp" +#include "until.hpp" + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/seq.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/seq.hpp new file mode 100644 index 0000000..ab03575 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/seq.hpp @@ -0,0 +1,91 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_SEQ_HPP +#define TAO_PEGTL_INTERNAL_SEQ_HPP + +#include "../config.hpp" + +#include "skip_control.hpp" +#include "trivial.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename... Rules > + struct seq; + + template<> + struct seq<> + : trivial< true > + { + }; + + template< typename Rule > + struct seq< Rule > + { + using analyze_t = typename Rule::analyze_t; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + return Control< Rule >::template match< A, M, Action, Control >( in, st... ); + } + }; + + template< typename... Rules > + struct seq + { + using analyze_t = analysis::generic< analysis::rule_type::seq, Rules... >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< M >(); + using m_t = decltype( m ); +#ifdef __cpp_fold_expressions + return m( ( Control< Rules >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) && ... ) ); +#else + bool result = true; + using swallow = bool[]; + (void)swallow{ result = result && Control< Rules >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... )... }; + return m( result ); +#endif + } + + }; // namespace internal + + template< typename... Rules > + struct skip_control< seq< Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/skip_control.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/skip_control.hpp new file mode 100644 index 0000000..2375d4c --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/skip_control.hpp @@ -0,0 +1,35 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_SKIP_CONTROL_HPP +#define TAO_PEGTL_INTERNAL_SKIP_CONTROL_HPP + +#include + +#include "../config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + // This class is a simple tagging mechanism. + // By default, skip_control< Rule >::value + // is 'false'. Each internal (!) rule that should + // be hidden from the control and action class' + // callbacks simply specializes skip_control<> + // to return 'true' for the above expression. + + template< typename Rule > + struct skip_control : std::false_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/sor.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/sor.hpp new file mode 100644 index 0000000..7be085d --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/sor.hpp @@ -0,0 +1,76 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_SOR_HPP +#define TAO_PEGTL_INTERNAL_SOR_HPP + +#include "../config.hpp" + +#include "integer_sequence.hpp" +#include "skip_control.hpp" +#include "trivial.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename... Rules > + struct sor; + + template<> + struct sor<> + : trivial< false > + { + }; + + template< typename... Rules > + struct sor + : sor< index_sequence_for< Rules... >, Rules... > + { + }; + + template< std::size_t... Indices, typename... Rules > + struct sor< index_sequence< Indices... >, Rules... > + { + using analyze_t = analysis::generic< analysis::rule_type::sor, Rules... >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { +#ifdef __cpp_fold_expressions + return ( Control< Rules >::template match < A, ( Indices == ( sizeof...( Rules ) - 1 ) ) ? M : rewind_mode::required, Action, Control > ( in, st... ) || ... ); +#else + bool result = false; + using swallow = bool[]; + (void)swallow{ result = result || Control< Rules >::template match < A, ( Indices == ( sizeof...( Rules ) - 1 ) ) ? M : rewind_mode::required, Action, Control > ( in, st... )... }; + return result; +#endif + } + }; + + template< typename... Rules > + struct skip_control< sor< Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/star.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/star.hpp new file mode 100644 index 0000000..d46479f --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/star.hpp @@ -0,0 +1,62 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_STAR_HPP +#define TAO_PEGTL_INTERNAL_STAR_HPP + +#include + +#include "../config.hpp" + +#include "seq.hpp" +#include "skip_control.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Rule, typename... Rules > + struct star + : star< seq< Rule, Rules... > > + {}; + + template< typename Rule > + struct star< Rule > + { + using analyze_t = analysis::generic< analysis::rule_type::opt, Rule, star >; + + template< apply_mode A, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + while( Control< Rule >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { + } + return true; + } + }; + + template< typename Rule, typename... Rules > + struct skip_control< star< Rule, Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/star_must.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/star_must.hpp new file mode 100644 index 0000000..84e5a44 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/star_must.hpp @@ -0,0 +1,27 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_STAR_MUST_HPP +#define TAO_PEGTL_INTERNAL_STAR_MUST_HPP + +#include "../config.hpp" + +#include "if_must.hpp" +#include "star.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Cond, typename... Rules > + using star_must = star< if_must< false, Cond, Rules... > >; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/state.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/state.hpp new file mode 100644 index 0000000..891d80b --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/state.hpp @@ -0,0 +1,96 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_STATE_HPP +#define TAO_PEGTL_INTERNAL_STATE_HPP + +#include "../config.hpp" + +#include "seq.hpp" +#include "skip_control.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename State, typename... Rules > + struct state + : state< State, seq< Rules... > > + { + }; + + template< typename State, typename Rule > + struct state< State, Rule > + { + using analyze_t = analysis::generic< analysis::rule_type::seq, Rule >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static auto success( State& s, const Input& in, States&&... st ) + -> decltype( s.template success< A, M, Action, Control >( in, st... ), void() ) + { + s.template success< A, M, Action, Control >( in, st... ); + } + + // NOTE: The additional "int = 0" is a work-around for missing expression SFINAE in VS2015. + + template< apply_mode, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States, + int = 0 > + static auto success( State& s, const Input& in, States&&... st ) + -> decltype( s.success( in, st... ), void() ) + { + s.success( in, st... ); + } + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + State s( static_cast< const Input& >( in ), st... ); + + if( Control< Rule >::template match< A, M, Action, Control >( in, s ) ) { + success< A, M, Action, Control >( s, in, st... ); + return true; + } + return false; + } + }; + + template< typename State, typename... Rules > + struct skip_control< state< State, Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/string.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/string.hpp new file mode 100644 index 0000000..3190328 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/string.hpp @@ -0,0 +1,68 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_STRING_HPP +#define TAO_PEGTL_INTERNAL_STRING_HPP + +#include +#include + +#include "../config.hpp" + +#include "bump_help.hpp" +#include "result_on_found.hpp" +#include "skip_control.hpp" +#include "trivial.hpp" + +#include "../analysis/counted.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + inline bool unsafe_equals( const char* s, const std::initializer_list< char >& l ) noexcept + { + return std::memcmp( s, &*l.begin(), l.size() ) == 0; + } + + template< char... Cs > + struct string; + + template<> + struct string<> + : trivial< true > + { + }; + + template< char... Cs > + struct string + { + using analyze_t = analysis::counted< analysis::rule_type::any, sizeof...( Cs ) >; + + template< typename Input > + static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) ) + { + if( in.size( sizeof...( Cs ) ) >= sizeof...( Cs ) ) { + if( unsafe_equals( in.current(), { Cs... } ) ) { + bump_help< result_on_found::success, Input, char, Cs... >( in, sizeof...( Cs ) ); + return true; + } + } + return false; + } + }; + + template< char... Cs > + struct skip_control< string< Cs... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/trivial.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/trivial.hpp new file mode 100644 index 0000000..9b764dc --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/trivial.hpp @@ -0,0 +1,42 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_TRIVIAL_HPP +#define TAO_PEGTL_INTERNAL_TRIVIAL_HPP + +#include "../config.hpp" + +#include "skip_control.hpp" + +#include "../analysis/counted.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< bool Result > + struct trivial + { + using analyze_t = analysis::counted< analysis::rule_type::any, unsigned( !Result ) >; + + template< typename Input > + static bool match( Input& /*unused*/ ) noexcept + { + return Result; + } + }; + + template< bool Result > + struct skip_control< trivial< Result > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/try_catch_type.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/try_catch_type.hpp new file mode 100644 index 0000000..3612c19 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/try_catch_type.hpp @@ -0,0 +1,76 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_TRY_CATCH_TYPE_HPP +#define TAO_PEGTL_INTERNAL_TRY_CATCH_TYPE_HPP + +#include + +#include "../config.hpp" + +#include "seq.hpp" +#include "skip_control.hpp" +#include "trivial.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Exception, typename... Rules > + struct try_catch_type + : try_catch_type< Exception, seq< Rules... > > + { + }; + + template< typename Exception > + struct try_catch_type< Exception > + : trivial< true > + { + }; + + template< typename Exception, typename Rule > + struct try_catch_type< Exception, Rule > + { + using analyze_t = analysis::generic< analysis::rule_type::seq, Rule >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< M >(); + using m_t = decltype( m ); + + try { + return m( Control< Rule >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ); + } + catch( const Exception& ) { + return false; + } + } + }; + + template< typename Exception, typename... Rules > + struct skip_control< try_catch_type< Exception, Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/until.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/until.hpp new file mode 100644 index 0000000..3e44dc2 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/until.hpp @@ -0,0 +1,98 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_UNTIL_HPP +#define TAO_PEGTL_INTERNAL_UNTIL_HPP + +#include "../config.hpp" + +#include "bytes.hpp" +#include "eof.hpp" +#include "not_at.hpp" +#include "seq.hpp" +#include "skip_control.hpp" +#include "star.hpp" + +#include "../apply_mode.hpp" +#include "../rewind_mode.hpp" + +#include "../analysis/generic.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< typename Cond, typename... Rules > + struct until + : until< Cond, seq< Rules... > > + { + }; + + template< typename Cond > + struct until< Cond > + { + using analyze_t = analysis::generic< analysis::rule_type::seq, star< not_at< Cond >, not_at< eof >, bytes< 1 > >, Cond >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< M >(); + + while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { + if( in.empty() ) { + return false; + } + in.bump(); + } + return m( true ); + } + }; + + template< typename Cond, typename Rule > + struct until< Cond, Rule > + { + using analyze_t = analysis::generic< analysis::rule_type::seq, star< not_at< Cond >, not_at< eof >, Rule >, Cond >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< M >(); + using m_t = decltype( m ); + + while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { + if( !Control< Rule >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) { + return false; + } + } + return m( true ); + } + }; + + template< typename Cond, typename... Rules > + struct skip_control< until< Cond, Rules... > > : std::true_type + { + }; + + } // namespace internal + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/istream_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/istream_input.hpp new file mode 100644 index 0000000..4dfe01f --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/istream_input.hpp @@ -0,0 +1,39 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_ISTREAM_INPUT_HPP +#define TAO_PEGTL_ISTREAM_INPUT_HPP + +#include + +#include "buffer_input.hpp" +#include "config.hpp" +#include "eol.hpp" + +#include "internal/istream_reader.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + template< typename Eol = eol::lf_crlf, std::size_t Chunk = 64 > + struct istream_input + : buffer_input< internal::istream_reader, Eol, std::string, Chunk > + { + template< typename T > + istream_input( std::istream& in_stream, const std::size_t in_maximum, T&& in_source ) + : buffer_input< internal::istream_reader, Eol, std::string, Chunk >( std::forward< T >( in_source ), in_maximum, in_stream ) + { + } + }; + +#ifdef __cpp_deduction_guides + template< typename... Ts > + istream_input( Ts&&... )->istream_input<>; +#endif + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/match.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/match.hpp new file mode 100644 index 0000000..802e715 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/match.hpp @@ -0,0 +1,71 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_MATCH_HPP +#define TAO_PEGTL_MATCH_HPP + +#include + +#include "apply_mode.hpp" +#include "config.hpp" +#include "nothing.hpp" +#include "require_apply.hpp" +#include "require_apply0.hpp" +#include "rewind_mode.hpp" + +#include "internal/dusel_mode.hpp" +#include "internal/duseltronik.hpp" +#include "internal/has_apply.hpp" +#include "internal/has_apply0.hpp" +#include "internal/if_missing.hpp" +#include "internal/skip_control.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + bool match( Input& in, States&&... st ) + { + constexpr bool enable_control = !internal::skip_control< Rule >::value; + constexpr bool enable_action = enable_control && ( A == apply_mode::action ); + + using iterator_t = typename Input::iterator_t; + constexpr bool has_apply_void = enable_action && internal::has_apply< Control< Rule >, void, Action, const iterator_t&, const Input&, States... >::value; + constexpr bool has_apply_bool = enable_action && internal::has_apply< Control< Rule >, bool, Action, const iterator_t&, const Input&, States... >::value; + constexpr bool has_apply = has_apply_void || has_apply_bool; + + constexpr bool has_apply0_void = enable_action && internal::has_apply0< Control< Rule >, void, Action, const Input&, States... >::value; + constexpr bool has_apply0_bool = enable_action && internal::has_apply0< Control< Rule >, bool, Action, const Input&, States... >::value; + constexpr bool has_apply0 = has_apply0_void || has_apply0_bool; + + static_assert( !( has_apply && has_apply0 ), "both apply() and apply0() defined" ); + + constexpr bool is_nothing = std::is_base_of< nothing< Rule >, Action< Rule > >::value; + static_assert( !( has_apply && is_nothing ), "unexpected apply() defined" ); + static_assert( !( has_apply0 && is_nothing ), "unexpected apply0() defined" ); + + internal::if_missing< !has_apply && std::is_base_of< require_apply, Action< Rule > >::value >::template apply< Control< Rule >, Action >( in, st... ); + internal::if_missing< !has_apply0 && std::is_base_of< require_apply0, Action< Rule > >::value >::template apply0< Control< Rule >, Action >( in, st... ); + + constexpr bool validate_nothing = std::is_base_of< maybe_nothing, Action< void > >::value; + constexpr bool is_maybe_nothing = std::is_base_of< maybe_nothing, Action< Rule > >::value; + static_assert( !enable_action || !validate_nothing || is_nothing || is_maybe_nothing || has_apply || has_apply0, "either apply() or apply0() must be defined" ); + + constexpr auto mode = static_cast< internal::dusel_mode >( enable_control + has_apply_void + 2 * has_apply_bool + 3 * has_apply0_void + 4 * has_apply0_bool ); + return internal::duseltronik< Rule, A, M, Action, Control, mode >::match( in, st... ); + } + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/memory_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/memory_input.hpp new file mode 100644 index 0000000..0ce7890 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/memory_input.hpp @@ -0,0 +1,378 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_MEMORY_INPUT_HPP +#define TAO_PEGTL_MEMORY_INPUT_HPP + +#include +#include +#include +#include +#include +#include + +#include "config.hpp" +#include "eol.hpp" +#include "normal.hpp" +#include "nothing.hpp" +#include "position.hpp" +#include "tracking_mode.hpp" + +#include "internal/action_input.hpp" +#include "internal/at.hpp" +#include "internal/bump.hpp" +#include "internal/eolf.hpp" +#include "internal/iterator.hpp" +#include "internal/marker.hpp" +#include "internal/until.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + template< tracking_mode, typename Eol, typename Source > + class memory_input_base; + + template< typename Eol, typename Source > + class memory_input_base< tracking_mode::eager, Eol, Source > + { + public: + using iterator_t = internal::iterator; + + template< typename T > + memory_input_base( const iterator_t& in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) + : m_begin( in_begin.data ), + m_current( in_begin ), + m_end( in_end ), + m_source( std::forward< T >( in_source ) ) + { + } + + template< typename T > + memory_input_base( const char* in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) + : m_begin( in_begin ), + m_current( in_begin ), + m_end( in_end ), + m_source( std::forward< T >( in_source ) ) + { + } + + memory_input_base( const memory_input_base& ) = delete; + memory_input_base( memory_input_base&& ) = delete; + + ~memory_input_base() = default; + + memory_input_base operator=( const memory_input_base& ) = delete; + memory_input_base operator=( memory_input_base&& ) = delete; + + const char* current() const noexcept + { + return m_current.data; + } + + const char* begin() const noexcept + { + return m_begin; + } + + const char* end( const std::size_t /*unused*/ = 0 ) const noexcept + { + return m_end; + } + + std::size_t byte() const noexcept + { + return m_current.byte; + } + + std::size_t line() const noexcept + { + return m_current.line; + } + + std::size_t byte_in_line() const noexcept + { + return m_current.byte_in_line; + } + + void bump( const std::size_t in_count = 1 ) noexcept + { + internal::bump( m_current, in_count, Eol::ch ); + } + + void bump_in_this_line( const std::size_t in_count = 1 ) noexcept + { + internal::bump_in_this_line( m_current, in_count ); + } + + void bump_to_next_line( const std::size_t in_count = 1 ) noexcept + { + internal::bump_to_next_line( m_current, in_count ); + } + + TAO_PEGTL_NAMESPACE::position position( const iterator_t& it ) const + { + return TAO_PEGTL_NAMESPACE::position( it, m_source ); + } + + void restart( const std::size_t in_byte = 0, const std::size_t in_line = 1, const std::size_t in_byte_in_line = 0 ) + { + m_current.data = m_begin; + m_current.byte = in_byte; + m_current.line = in_line; + m_current.byte_in_line = in_byte_in_line; + } + + protected: + const char* const m_begin; + iterator_t m_current; + const char* const m_end; + const Source m_source; + }; + + template< typename Eol, typename Source > + class memory_input_base< tracking_mode::lazy, Eol, Source > + { + public: + using iterator_t = const char*; + + template< typename T > + memory_input_base( const internal::iterator& in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) + : m_begin( in_begin ), + m_current( in_begin.data ), + m_end( in_end ), + m_source( std::forward< T >( in_source ) ) + { + } + + template< typename T > + memory_input_base( const char* in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) + : m_begin( in_begin ), + m_current( in_begin ), + m_end( in_end ), + m_source( std::forward< T >( in_source ) ) + { + } + + memory_input_base( const memory_input_base& ) = delete; + memory_input_base( memory_input_base&& ) = delete; + + ~memory_input_base() = default; + + memory_input_base operator=( const memory_input_base& ) = delete; + memory_input_base operator=( memory_input_base&& ) = delete; + + const char* current() const noexcept + { + return m_current; + } + + const char* begin() const noexcept + { + return m_begin.data; + } + + const char* end( const std::size_t /*unused*/ = 0 ) const noexcept + { + return m_end; + } + + std::size_t byte() const noexcept + { + return std::size_t( current() - m_begin.data ); + } + + void bump( const std::size_t in_count = 1 ) noexcept + { + m_current += in_count; + } + + void bump_in_this_line( const std::size_t in_count = 1 ) noexcept + { + m_current += in_count; + } + + void bump_to_next_line( const std::size_t in_count = 1 ) noexcept + { + m_current += in_count; + } + + TAO_PEGTL_NAMESPACE::position position( const iterator_t it ) const + { + internal::iterator c( m_begin ); + internal::bump( c, std::size_t( it - m_begin.data ), Eol::ch ); + return TAO_PEGTL_NAMESPACE::position( c, m_source ); + } + + void restart() + { + m_current = m_begin.data; + } + + protected: + const internal::iterator m_begin; + iterator_t m_current; + const char* const m_end; + const Source m_source; + }; + + } // namespace internal + + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf, typename Source = std::string > + class memory_input + : public internal::memory_input_base< P, Eol, Source > + { + public: + static constexpr tracking_mode tracking_mode_v = P; + + using eol_t = Eol; + using source_t = Source; + + using typename internal::memory_input_base< P, Eol, Source >::iterator_t; + + using action_t = internal::action_input< memory_input >; + + using internal::memory_input_base< P, Eol, Source >::memory_input_base; + + template< typename T > + memory_input( const char* in_begin, const std::size_t in_size, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) + : memory_input( in_begin, in_begin + in_size, std::forward< T >( in_source ) ) + { + } + + template< typename T > + memory_input( const std::string& in_string, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) + : memory_input( in_string.data(), in_string.size(), std::forward< T >( in_source ) ) + { + } + + template< typename T > + memory_input( std::string&&, T&& ) = delete; + + template< typename T > + memory_input( const char* in_begin, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) + : memory_input( in_begin, std::strlen( in_begin ), std::forward< T >( in_source ) ) + { + } + + template< typename T > + memory_input( const char* in_begin, const char* in_end, T&& in_source, const std::size_t in_byte, const std::size_t in_line, const std::size_t in_byte_in_line ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) + : memory_input( { in_begin, in_byte, in_line, in_byte_in_line }, in_end, std::forward< T >( in_source ) ) + { + } + + memory_input( const memory_input& ) = delete; + memory_input( memory_input&& ) = delete; + + ~memory_input() = default; + + memory_input operator=( const memory_input& ) = delete; + memory_input operator=( memory_input&& ) = delete; + + const Source& source() const noexcept + { + return this->m_source; + } + + bool empty() const noexcept + { + return this->current() == this->end(); + } + + std::size_t size( const std::size_t /*unused*/ = 0 ) const noexcept + { + return std::size_t( this->end() - this->current() ); + } + + char peek_char( const std::size_t offset = 0 ) const noexcept + { + return this->current()[ offset ]; + } + + std::uint8_t peek_uint8( const std::size_t offset = 0 ) const noexcept + { + return static_cast< std::uint8_t >( peek_char( offset ) ); + } + + // Compatibility, remove with 3.0.0 + std::uint8_t peek_byte( const std::size_t offset = 0 ) const noexcept + { + return static_cast< std::uint8_t >( peek_char( offset ) ); + } + + iterator_t& iterator() noexcept + { + return this->m_current; + } + + const iterator_t& iterator() const noexcept + { + return this->m_current; + } + + using internal::memory_input_base< P, Eol, Source >::restart; + + template< rewind_mode M > + void restart( const internal::marker< iterator_t, M >& m ) + { + iterator() = m.iterator(); + } + + using internal::memory_input_base< P, Eol, Source >::position; + + TAO_PEGTL_NAMESPACE::position position() const + { + return position( iterator() ); + } + + void discard() const noexcept + { + } + + void require( const std::size_t /*unused*/ ) const noexcept + { + } + + template< rewind_mode M > + internal::marker< iterator_t, M > mark() noexcept + { + return internal::marker< iterator_t, M >( iterator() ); + } + + const char* at( const TAO_PEGTL_NAMESPACE::position& p ) const noexcept + { + return this->begin() + p.byte; + } + + const char* begin_of_line( const TAO_PEGTL_NAMESPACE::position& p ) const noexcept + { + return at( p ) - p.byte_in_line; + } + + const char* end_of_line( const TAO_PEGTL_NAMESPACE::position& p ) const noexcept + { + using input_t = memory_input< tracking_mode::lazy, Eol, const char* >; + input_t in( at( p ), this->end(), "" ); + using grammar = internal::until< internal::at< internal::eolf > >; + normal< grammar >::match< apply_mode::nothing, rewind_mode::dontcare, nothing, normal >( in ); + return in.current(); + } + + std::string line_at( const TAO_PEGTL_NAMESPACE::position& p ) const + { + return std::string( begin_of_line( p ), end_of_line( p ) ); + } + }; + +#ifdef __cpp_deduction_guides + template< typename... Ts > + memory_input( Ts&&... )->memory_input<>; +#endif + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/mmap_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/mmap_input.hpp new file mode 100644 index 0000000..f5f2b8c --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/mmap_input.hpp @@ -0,0 +1,85 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_MMAP_INPUT_HPP +#define TAO_PEGTL_MMAP_INPUT_HPP + +#include +#include + +#include "config.hpp" +#include "eol.hpp" +#include "memory_input.hpp" +#include "tracking_mode.hpp" + +#if defined( __unix__ ) || ( defined( __APPLE__ ) && defined( __MACH__ ) ) +#include // Required for _POSIX_MAPPED_FILES +#endif + +#if defined( _POSIX_MAPPED_FILES ) +#include "internal/file_mapper_posix.hpp" +#elif defined( _WIN32 ) +#include "internal/file_mapper_win32.hpp" +#else +#endif + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct mmap_holder + { + const std::string filename; + const file_mapper data; + + template< typename T > + explicit mmap_holder( T&& in_filename ) + : filename( std::forward< T >( in_filename ) ), + data( filename.c_str() ) + { + } + + mmap_holder( const mmap_holder& ) = delete; + mmap_holder( mmap_holder&& ) = delete; + + ~mmap_holder() = default; + + void operator=( const mmap_holder& ) = delete; + void operator=( mmap_holder&& ) = delete; + }; + + } // namespace internal + + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > + struct mmap_input + : private internal::mmap_holder, + public memory_input< P, Eol, const char* > + { + template< typename T > + explicit mmap_input( T&& in_filename ) + : internal::mmap_holder( std::forward< T >( in_filename ) ), + memory_input< P, Eol, const char* >( data.begin(), data.end(), filename.c_str() ) + { + } + + mmap_input( const mmap_input& ) = delete; + mmap_input( mmap_input&& ) = delete; + + ~mmap_input() = default; + + void operator=( const mmap_input& ) = delete; + void operator=( mmap_input&& ) = delete; + }; + +#ifdef __cpp_deduction_guides + template< typename... Ts > + explicit mmap_input( Ts&&... )->mmap_input<>; +#endif + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/normal.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/normal.hpp new file mode 100644 index 0000000..9db70d4 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/normal.hpp @@ -0,0 +1,96 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_NORMAL_HPP +#define TAO_PEGTL_NORMAL_HPP + +#include +#include + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "parse_error.hpp" +#include "rewind_mode.hpp" + +#include "internal/demangle.hpp" +#include "internal/has_match.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + template< typename Rule > + struct normal + { + template< typename Input, typename... States > + static void start( const Input& /*unused*/, States&&... /*unused*/ ) noexcept + { + } + + template< typename Input, typename... States > + static void success( const Input& /*unused*/, States&&... /*unused*/ ) noexcept + { + } + + template< typename Input, typename... States > + static void failure( const Input& /*unused*/, States&&... /*unused*/ ) noexcept + { + } + + template< typename Input, typename... States > + static void raise( const Input& in, States&&... /*unused*/ ) + { + throw parse_error( "parse error matching " + internal::demangle< Rule >(), in ); + } + + template< template< typename... > class Action, typename Input, typename... States > + static auto apply0( const Input& /*unused*/, States&&... st ) + -> decltype( Action< Rule >::apply0( st... ) ) + { + return Action< Rule >::apply0( st... ); + } + + template< template< typename... > class Action, typename Iterator, typename Input, typename... States > + static auto apply( const Iterator& begin, const Input& in, States&&... st ) + -> decltype( Action< Rule >::apply( std::declval< typename Input::action_t >(), st... ) ) + { + const typename Input::action_t action_input( begin, in ); + return Action< Rule >::apply( action_input, st... ); + } + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static auto match( Input& in, States&&... st ) + -> typename std::enable_if< internal::has_match< void, Rule, A, M, Action, Control, Input, States... >::value, bool >::type + { + return Action< Rule >::template match< Rule, A, M, Action, Control >( in, st... ); + } + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States, + int = 1 > + static auto match( Input& in, States&&... st ) + -> typename std::enable_if< !internal::has_match< void, Rule, A, M, Action, Control, Input, States... >::value, bool >::type + { + return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... ); + } + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/nothing.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/nothing.hpp new file mode 100644 index 0000000..974afdb --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/nothing.hpp @@ -0,0 +1,24 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_NOTHING_HPP +#define TAO_PEGTL_NOTHING_HPP + +#include "config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + template< typename Rule > + struct nothing + { + }; + + using maybe_nothing = nothing< void >; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/parse.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/parse.hpp new file mode 100644 index 0000000..d6093e0 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/parse.hpp @@ -0,0 +1,57 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_PARSE_HPP +#define TAO_PEGTL_PARSE_HPP + +#include + +#include "apply_mode.hpp" +#include "config.hpp" +#include "normal.hpp" +#include "nothing.hpp" +#include "parse_error.hpp" +#include "rewind_mode.hpp" + +#include "internal/action_input.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + template< typename Rule, + template< typename... > class Action = nothing, + template< typename... > class Control = normal, + apply_mode A = apply_mode::action, + rewind_mode M = rewind_mode::required, + typename Input, + typename... States > + bool parse( Input&& in, States&&... st ) + { + return Control< Rule >::template match< A, M, Action, Control >( in, st... ); + } + + template< typename Rule, + template< typename... > class Action = nothing, + template< typename... > class Control = normal, + apply_mode A = apply_mode::action, + rewind_mode M = rewind_mode::required, + typename Outer, + typename Input, + typename... States > + bool parse_nested( const Outer& oi, Input&& in, States&&... st ) + { + try { + return parse< Rule, Action, Control, A, M >( in, st... ); + } + catch( parse_error& e ) { + e.positions.push_back( oi.position() ); + throw; + } + } + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/parse_error.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/parse_error.hpp new file mode 100644 index 0000000..21ce850 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/parse_error.hpp @@ -0,0 +1,51 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_PARSE_ERROR_HPP +#define TAO_PEGTL_PARSE_ERROR_HPP + +#include +#include + +#include "config.hpp" +#include "position.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + struct parse_error + : public std::runtime_error + { + parse_error( const std::string& msg, std::vector< position >&& in_positions ) + : std::runtime_error( msg ), + positions( std::move( in_positions ) ) + { + } + + template< typename Input > + parse_error( const std::string& msg, const Input& in ) + : parse_error( msg, in.position() ) + { + } + + parse_error( const std::string& msg, const position& pos ) + : std::runtime_error( to_string( pos ) + ": " + msg ), + positions( 1, pos ) + { + } + + parse_error( const std::string& msg, position&& pos ) + : std::runtime_error( to_string( pos ) + ": " + msg ) + { + positions.emplace_back( std::move( pos ) ); + } + + std::vector< position > positions; + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/position.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/position.hpp new file mode 100644 index 0000000..46a982d --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/position.hpp @@ -0,0 +1,54 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_POSITION_HPP +#define TAO_PEGTL_POSITION_HPP + +#include +#include +#include +#include +#include + +#include "config.hpp" + +#include "internal/iterator.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + struct position + { + template< typename T > + position( const internal::iterator& in_iter, T&& in_source ) + : byte( in_iter.byte ), + line( in_iter.line ), + byte_in_line( in_iter.byte_in_line ), + source( std::forward< T >( in_source ) ) + { + } + + std::size_t byte; + std::size_t line; + std::size_t byte_in_line; + std::string source; + }; + + inline std::ostream& operator<<( std::ostream& o, const position& p ) + { + return o << p.source << ':' << p.line << ':' << p.byte_in_line << '(' << p.byte << ')'; + } + + inline std::string to_string( const position& p ) + { + std::ostringstream o; + o << p; + return o.str(); + } + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/read_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/read_input.hpp new file mode 100644 index 0000000..9e79358 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/read_input.hpp @@ -0,0 +1,80 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_READ_INPUT_HPP +#define TAO_PEGTL_READ_INPUT_HPP + +#include + +#include "config.hpp" +#include "eol.hpp" +#include "string_input.hpp" +#include "tracking_mode.hpp" + +#include "internal/file_reader.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct filename_holder + { + const std::string filename; + + template< typename T > + explicit filename_holder( T&& in_filename ) + : filename( std::forward< T >( in_filename ) ) + { + } + + filename_holder( const filename_holder& ) = delete; + filename_holder( filename_holder&& ) = delete; + + ~filename_holder() = default; + + void operator=( const filename_holder& ) = delete; + void operator=( filename_holder&& ) = delete; + }; + + } // namespace internal + + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > + struct read_input + : private internal::filename_holder, + public string_input< P, Eol, const char* > + { + template< typename T > + explicit read_input( T&& in_filename ) + : internal::filename_holder( std::forward< T >( in_filename ) ), + string_input< P, Eol, const char* >( internal::file_reader( filename.c_str() ).read(), filename.c_str() ) + { + } + + template< typename T > + read_input( FILE* in_file, T&& in_filename ) + : internal::filename_holder( std::forward< T >( in_filename ) ), + string_input< P, Eol, const char* >( internal::file_reader( in_file, filename.c_str() ).read(), filename.c_str() ) + { + } + + read_input( const read_input& ) = delete; + read_input( read_input&& ) = delete; + + ~read_input() = default; + + void operator=( const read_input& ) = delete; + void operator=( read_input&& ) = delete; + }; + +#ifdef __cpp_deduction_guides + template< typename... Ts > + explicit read_input( Ts&&... )->read_input<>; +#endif + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/require_apply.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/require_apply.hpp new file mode 100644 index 0000000..8e53de5 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/require_apply.hpp @@ -0,0 +1,20 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_REQUIRE_APPLY_HPP +#define TAO_PEGTL_REQUIRE_APPLY_HPP + +#include "config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + struct require_apply + {}; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/require_apply0.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/require_apply0.hpp new file mode 100644 index 0000000..e99afbb --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/require_apply0.hpp @@ -0,0 +1,20 @@ +// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_REQUIRE_APPLY0_HPP +#define TAO_PEGTL_REQUIRE_APPLY0_HPP + +#include "config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + struct require_apply0 + {}; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/rewind_mode.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/rewind_mode.hpp new file mode 100644 index 0000000..037b937 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/rewind_mode.hpp @@ -0,0 +1,29 @@ +// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_REWIND_MODE_HPP +#define TAO_PEGTL_REWIND_MODE_HPP + +#include "config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + enum class rewind_mode : char + { + active, + required, + dontcare, + + // Compatibility, remove with 3.0.0 + ACTIVE = active, + REQUIRED = required, + DONTCARE = dontcare + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/rules.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/rules.hpp new file mode 100644 index 0000000..8f0ce39 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/rules.hpp @@ -0,0 +1,71 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_RULES_HPP +#define TAO_PEGTL_RULES_HPP + +#include "config.hpp" +#include "parse_error.hpp" + +#include "internal/rules.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + // clang-format off + template< typename... Actions > struct apply : internal::apply< Actions... > {}; + template< typename... Actions > struct apply0 : internal::apply0< Actions... > {}; + template< template< typename... > class Action, typename... Rules > struct action : internal::action< Action, Rules... > {}; + template< typename... Rules > struct at : internal::at< Rules... > {}; + struct bof : internal::bof {}; + struct bol : internal::bol {}; + template< unsigned Num > struct bytes : internal::bytes< Num > {}; + template< template< typename... > class Control, typename... Rules > struct control : internal::control< Control, Rules... > {}; + template< typename... Rules > struct disable : internal::disable< Rules... > {}; + struct discard : internal::discard {}; + template< typename... Rules > struct enable : internal::enable< Rules... > {}; + struct eof : internal::eof {}; + struct failure : internal::trivial< false > {}; + template< typename Rule, typename... Actions > struct if_apply : internal::if_apply< Rule, Actions... > {}; + template< typename Cond, typename... Thens > struct if_must : internal::if_must< false, Cond, Thens... > {}; + template< typename Cond, typename Then, typename Else > struct if_must_else : internal::if_must_else< Cond, Then, Else > {}; + template< typename Cond, typename Then, typename Else > struct if_then_else : internal::if_then_else< Cond, Then, Else > {}; + template< typename Rule, typename Sep, typename Pad = void > struct list : internal::list< Rule, internal::pad< Sep, Pad > > {}; + template< typename Rule, typename Sep > struct list< Rule, Sep, void > : internal::list< Rule, Sep > {}; + template< typename Rule, typename Sep, typename Pad = void > struct list_must : internal::list_must< Rule, internal::pad< Sep, Pad > > {}; + template< typename Rule, typename Sep > struct list_must< Rule, Sep, void > : internal::list_must< Rule, Sep > {}; + template< typename Rule, typename Sep, typename Pad = void > struct list_tail : internal::list_tail_pad< Rule, Sep, Pad > {}; + template< typename Rule, typename Sep > struct list_tail< Rule, Sep, void > : internal::list_tail< Rule, Sep > {}; + template< typename M, typename S > struct minus : internal::rematch< M, internal::not_at< S, internal::eof > > {}; + template< typename... Rules > struct must : internal::must< Rules... > {}; + template< typename... Rules > struct not_at : internal::not_at< Rules... > {}; + template< typename... Rules > struct opt : internal::opt< Rules... > {}; + template< typename Cond, typename... Rules > struct opt_must : internal::if_must< true, Cond, Rules... > {}; + template< typename Rule, typename Pad1, typename Pad2 = Pad1 > struct pad : internal::pad< Rule, Pad1, Pad2 > {}; + template< typename Rule, typename Pad > struct pad_opt : internal::pad_opt< Rule, Pad > {}; + template< typename Rule, typename... Rules > struct plus : internal::plus< Rule, Rules... > {}; + template< typename Exception > struct raise : internal::raise< Exception > {}; + template< typename Head, typename... Rules > struct rematch : internal::rematch< Head, Rules... > {}; + template< unsigned Num, typename... Rules > struct rep : internal::rep< Num, Rules... > {}; + template< unsigned Max, typename... Rules > struct rep_max : internal::rep_min_max< 0, Max, Rules... > {}; + template< unsigned Min, typename Rule, typename... Rules > struct rep_min : internal::rep_min< Min, Rule, Rules... > {}; + template< unsigned Min, unsigned Max, typename... Rules > struct rep_min_max : internal::rep_min_max< Min, Max, Rules... > {}; + template< unsigned Max, typename... Rules > struct rep_opt : internal::rep_opt< Max, Rules... > {}; + template< unsigned Amount > struct require : internal::require< Amount > {}; + template< typename... Rules > struct seq : internal::seq< Rules... > {}; + template< typename... Rules > struct sor : internal::sor< Rules... > {}; + template< typename Rule, typename... Rules > struct star : internal::star< Rule, Rules... > {}; + template< typename Cond, typename... Rules > struct star_must : internal::star_must< Cond, Rules... > {}; + template< typename State, typename... Rules > struct state : internal::state< State, Rules... > {}; + struct success : internal::trivial< true > {}; + template< typename... Rules > struct try_catch : internal::seq< internal::try_catch_type< parse_error, Rules... > > {}; + template< typename Exception, typename... Rules > struct try_catch_type : internal::seq< internal::try_catch_type< Exception, Rules... > > {}; + template< typename Cond, typename... Rules > struct until : internal::until< Cond, Rules... > {}; + // clang-format on + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/string_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/string_input.hpp new file mode 100644 index 0000000..1c8bd5f --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/string_input.hpp @@ -0,0 +1,72 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_STRING_INPUT_HPP +#define TAO_PEGTL_STRING_INPUT_HPP + +#include +#include + +#include "config.hpp" +#include "eol.hpp" +#include "memory_input.hpp" +#include "tracking_mode.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace internal + { + struct string_holder + { + const std::string data; + + template< typename T > + explicit string_holder( T&& in_data ) + : data( std::forward< T >( in_data ) ) + { + } + + string_holder( const string_holder& ) = delete; + string_holder( string_holder&& ) = delete; + + ~string_holder() = default; + + void operator=( const string_holder& ) = delete; + void operator=( string_holder&& ) = delete; + }; + + } // namespace internal + + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf, typename Source = std::string > + struct string_input + : private internal::string_holder, + public memory_input< P, Eol, Source > + { + template< typename V, typename T, typename... Ts > + explicit string_input( V&& in_data, T&& in_source, Ts&&... ts ) + : internal::string_holder( std::forward< V >( in_data ) ), + memory_input< P, Eol, Source >( data.data(), data.size(), std::forward< T >( in_source ), std::forward< Ts >( ts )... ) + { + } + + string_input( const string_input& ) = delete; + string_input( string_input&& ) = delete; + + ~string_input() = default; + + void operator=( const string_input& ) = delete; + void operator=( string_input&& ) = delete; + }; + +#ifdef __cpp_deduction_guides + template< typename... Ts > + explicit string_input( Ts&&... )->string_input<>; +#endif + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/tracking_mode.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/tracking_mode.hpp new file mode 100644 index 0000000..9def6be --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/tracking_mode.hpp @@ -0,0 +1,27 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_TRACKING_MODE_HPP +#define TAO_PEGTL_TRACKING_MODE_HPP + +#include "config.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + enum class tracking_mode : bool + { + eager, + lazy, + + // Compatibility, remove with 3.0.0 + IMMEDIATE = eager, + LAZY = lazy + }; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint16.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint16.hpp new file mode 100644 index 0000000..0080df4 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint16.hpp @@ -0,0 +1,66 @@ +// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_UINT16_HPP +#define TAO_PEGTL_UINT16_HPP + +#include "config.hpp" + +#include "internal/peek_mask_uint.hpp" +#include "internal/peek_uint.hpp" +#include "internal/result_on_found.hpp" +#include "internal/rules.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace uint16_be + { + // clang-format off + struct any : internal::any< internal::peek_uint16_be > {}; + + template< std::uint16_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint16_be, Cs... > {}; + template< std::uint16_t Lo, std::uint16_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint16_be, Lo, Hi > {}; + template< std::uint16_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint16_be, Cs... > {}; + template< std::uint16_t Lo, std::uint16_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint16_be, Lo, Hi > {}; + template< std::uint16_t... Cs > struct ranges : internal::ranges< internal::peek_uint16_be, Cs... > {}; + template< std::uint16_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint16_be, Cs >... > {}; + + template< std::uint16_t M, std::uint16_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint16_be< M >, Cs... > {}; + template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint16_be< M >, Lo, Hi > {}; + template< std::uint16_t M, std::uint16_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint16_be< M >, Cs... > {}; + template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint16_be< M >, Lo, Hi > {}; + template< std::uint16_t M, std::uint16_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint16_be< M >, Cs... > {}; + template< std::uint16_t M, std::uint16_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint16_be< M >, Cs >... > {}; + // clang-format on + + } // namespace uint16_be + + namespace uint16_le + { + // clang-format off + struct any : internal::any< internal::peek_uint16_le > {}; + + template< std::uint16_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint16_le, Cs... > {}; + template< std::uint16_t Lo, std::uint16_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint16_le, Lo, Hi > {}; + template< std::uint16_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint16_le, Cs... > {}; + template< std::uint16_t Lo, std::uint16_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint16_le, Lo, Hi > {}; + template< std::uint16_t... Cs > struct ranges : internal::ranges< internal::peek_uint16_le, Cs... > {}; + template< std::uint16_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint16_le, Cs >... > {}; + + template< std::uint16_t M, std::uint16_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint16_le< M >, Cs... > {}; + template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint16_le< M >, Lo, Hi > {}; + template< std::uint16_t M, std::uint16_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint16_le< M >, Cs... > {}; + template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint16_le< M >, Lo, Hi > {}; + template< std::uint16_t M, std::uint16_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint16_le< M >, Cs... > {}; + template< std::uint16_t M, std::uint16_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint16_le< M >, Cs >... > {}; + // clang-format on + + } // namespace uint16_le + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint32.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint32.hpp new file mode 100644 index 0000000..af54cf3 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint32.hpp @@ -0,0 +1,66 @@ +// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_UINT32_HPP +#define TAO_PEGTL_UINT32_HPP + +#include "config.hpp" + +#include "internal/peek_mask_uint.hpp" +#include "internal/peek_uint.hpp" +#include "internal/result_on_found.hpp" +#include "internal/rules.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace uint32_be + { + // clang-format off + struct any : internal::any< internal::peek_uint32_be > {}; + + template< std::uint32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint32_be, Cs... > {}; + template< std::uint32_t Lo, std::uint32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint32_be, Lo, Hi > {}; + template< std::uint32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint32_be, Cs... > {}; + template< std::uint32_t Lo, std::uint32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint32_be, Lo, Hi > {}; + template< std::uint32_t... Cs > struct ranges : internal::ranges< internal::peek_uint32_be, Cs... > {}; + template< std::uint32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint32_be, Cs >... > {}; + + template< std::uint32_t M, std::uint32_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint32_be< M >, Cs... > {}; + template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint32_be< M >, Lo, Hi > {}; + template< std::uint32_t M, std::uint32_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint32_be< M >, Cs... > {}; + template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint32_be< M >, Lo, Hi > {}; + template< std::uint32_t M, std::uint32_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint32_be< M >, Cs... > {}; + template< std::uint32_t M, std::uint32_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint32_be< M >, Cs >... > {}; + // clang-format on + + } // namespace uint32_be + + namespace uint32_le + { + // clang-format off + struct any : internal::any< internal::peek_uint32_le > {}; + + template< std::uint32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint32_le, Cs... > {}; + template< std::uint32_t Lo, std::uint32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint32_le, Lo, Hi > {}; + template< std::uint32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint32_le, Cs... > {}; + template< std::uint32_t Lo, std::uint32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint32_le, Lo, Hi > {}; + template< std::uint32_t... Cs > struct ranges : internal::ranges< internal::peek_uint32_le, Cs... > {}; + template< std::uint32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint32_le, Cs >... > {}; + + template< std::uint32_t M, std::uint32_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint32_le< M >, Cs... > {}; + template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint32_le< M >, Lo, Hi > {}; + template< std::uint32_t M, std::uint32_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint32_le< M >, Cs... > {}; + template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint32_le< M >, Lo, Hi > {}; + template< std::uint32_t M, std::uint32_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint32_le< M >, Cs... > {}; + template< std::uint32_t M, std::uint32_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint32_le< M >, Cs >... > {}; + // clang-format on + + } // namespace uint32_le + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint64.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint64.hpp new file mode 100644 index 0000000..86074f8 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint64.hpp @@ -0,0 +1,67 @@ +// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_UINT64_HPP +#define TAO_PEGTL_UINT64_HPP + +#include "config.hpp" + +#include "internal/peek_mask_uint.hpp" +#include "internal/peek_uint.hpp" +#include "internal/result_on_found.hpp" +#include "internal/rules.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace uint64_be + { + // clang-format off + struct any : internal::any< internal::peek_uint64_be > {}; + + template< std::uint64_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint64_be, Cs... > {}; + template< std::uint64_t Lo, std::uint64_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint64_be, Lo, Hi > {}; + template< std::uint64_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint64_be, Cs... > {}; + template< std::uint64_t Lo, std::uint64_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint64_be, Lo, Hi > {}; + template< std::uint64_t... Cs > struct ranges : internal::ranges< internal::peek_uint64_be, Cs... > {}; + template< std::uint64_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint64_be, Cs >... > {}; + + + template< std::uint64_t M, std::uint64_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint64_be< M >, Cs... > {}; + template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint64_be< M >, Lo, Hi > {}; + template< std::uint64_t M, std::uint64_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint64_be< M >, Cs... > {}; + template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint64_be< M >, Lo, Hi > {}; + template< std::uint64_t M, std::uint64_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint64_be< M >, Cs... > {}; + template< std::uint64_t M, std::uint64_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint64_be< M >, Cs >... > {}; + // clang-format on + + } // namespace uint64_be + + namespace uint64_le + { + // clang-format off + struct any : internal::any< internal::peek_uint64_le > {}; + + template< std::uint64_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint64_le, Cs... > {}; + template< std::uint64_t Lo, std::uint64_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint64_le, Lo, Hi > {}; + template< std::uint64_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint64_le, Cs... > {}; + template< std::uint64_t Lo, std::uint64_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint64_le, Lo, Hi > {}; + template< std::uint64_t... Cs > struct ranges : internal::ranges< internal::peek_uint64_le, Cs... > {}; + template< std::uint64_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint64_le, Cs >... > {}; + + template< std::uint64_t M, std::uint64_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint64_le< M >, Cs... > {}; + template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint64_le< M >, Lo, Hi > {}; + template< std::uint64_t M, std::uint64_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint64_le< M >, Cs... > {}; + template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint64_le< M >, Lo, Hi > {}; + template< std::uint64_t M, std::uint64_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint64_le< M >, Cs... > {}; + template< std::uint64_t M, std::uint64_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint64_le< M >, Cs >... > {}; + // clang-format on + + } // namespace uint64_le + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint8.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint8.hpp new file mode 100644 index 0000000..fe2e11a --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint8.hpp @@ -0,0 +1,44 @@ +// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_UINT8_HPP +#define TAO_PEGTL_UINT8_HPP + +#include "config.hpp" + +#include "internal/peek_mask_uint8.hpp" +#include "internal/peek_uint8.hpp" +#include "internal/result_on_found.hpp" +#include "internal/rules.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace uint8 + { + // clang-format off + struct any : internal::any< internal::peek_uint8 > {}; + + template< std::uint8_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint8, Cs... > {}; + template< std::uint8_t Lo, std::uint8_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint8, Lo, Hi > {}; + template< std::uint8_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint8, Cs... > {}; + template< std::uint8_t Lo, std::uint8_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint8, Lo, Hi > {}; + template< std::uint8_t... Cs > struct ranges : internal::ranges< internal::peek_uint8, Cs... > {}; + template< std::uint8_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint8, Cs >... > {}; + + template< std::uint8_t M, std::uint8_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint8< M >, Cs... > {}; + template< std::uint8_t M, std::uint8_t Lo, std::uint8_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint8< M >, Lo, Hi > {}; + template< std::uint8_t M, std::uint8_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint8< M >, Cs... > {}; + template< std::uint8_t M, std::uint8_t Lo, std::uint8_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint8< M >, Lo, Hi > {}; + template< std::uint8_t M, std::uint8_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint8< M >, Cs... > {}; + template< std::uint8_t M, std::uint8_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint8< M >, Cs >... > {}; + // clang-format on + + } // namespace uint8 + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf16.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf16.hpp new file mode 100644 index 0000000..37f6190 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf16.hpp @@ -0,0 +1,53 @@ +// Copyright (c) 2015-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_UTF16_HPP +#define TAO_PEGTL_UTF16_HPP + +#include "config.hpp" + +#include "internal/peek_utf16.hpp" +#include "internal/result_on_found.hpp" +#include "internal/rules.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace utf16_be + { + // clang-format off + struct any : internal::any< internal::peek_utf16_be > {}; + struct bom : internal::one< internal::result_on_found::success, internal::peek_utf16_be, 0xfeff > {}; + template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf16_be, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf16_be, Lo, Hi > {}; + template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf16_be, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf16_be, Lo, Hi > {}; + template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf16_be, Cs... > {}; + template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf16_be, Cs >... > {}; + // clang-format on + + } // namespace utf16_be + + namespace utf16_le + { + // clang-format off + struct any : internal::any< internal::peek_utf16_le > {}; + struct bom : internal::one< internal::result_on_found::success, internal::peek_utf16_le, 0xfeff > {}; + template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf16_le, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf16_le, Lo, Hi > {}; + template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf16_le, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf16_le, Lo, Hi > {}; + template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf16_le, Cs... > {}; + template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf16_le, Cs >... > {}; + // clang-format on + + } // namespace utf16_le + + namespace utf16 = TAO_PEGTL_NATIVE_UTF16; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf32.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf32.hpp new file mode 100644 index 0000000..e9bafa0 --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf32.hpp @@ -0,0 +1,53 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_UTF32_HPP +#define TAO_PEGTL_UTF32_HPP + +#include "config.hpp" + +#include "internal/peek_utf32.hpp" +#include "internal/result_on_found.hpp" +#include "internal/rules.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace utf32_be + { + // clang-format off + struct any : internal::any< internal::peek_utf32_be > {}; + struct bom : internal::one< internal::result_on_found::success, internal::peek_utf32_be, 0xfeff > {}; + template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf32_be, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf32_be, Lo, Hi > {}; + template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf32_be, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf32_be, Lo, Hi > {}; + template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf32_be, Cs... > {}; + template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf32_be, Cs >... > {}; + // clang-format on + + } // namespace utf32_be + + namespace utf32_le + { + // clang-format off + struct any : internal::any< internal::peek_utf32_le > {}; + struct bom : internal::one< internal::result_on_found::success, internal::peek_utf32_le, 0xfeff > {}; + template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf32_le, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf32_le, Lo, Hi > {}; + template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf32_le, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf32_le, Lo, Hi > {}; + template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf32_le, Cs... > {}; + template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf32_le, Cs >... > {}; + // clang-format on + + } // namespace utf32_le + + namespace utf32 = TAO_PEGTL_NATIVE_UTF32; + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf8.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf8.hpp new file mode 100644 index 0000000..4f4befb --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf8.hpp @@ -0,0 +1,36 @@ +// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_UTF8_HPP +#define TAO_PEGTL_UTF8_HPP + +#include "config.hpp" + +#include "internal/peek_utf8.hpp" +#include "internal/result_on_found.hpp" +#include "internal/rules.hpp" + +namespace tao +{ + namespace TAO_PEGTL_NAMESPACE + { + namespace utf8 + { + // clang-format off + struct any : internal::any< internal::peek_utf8 > {}; + struct bom : internal::one< internal::result_on_found::success, internal::peek_utf8, 0xfeff > {}; + template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf8, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf8, Lo, Hi > {}; + template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf8, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf8, Lo, Hi > {}; + template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf8, Cs... > {}; + template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf8, Cs >... > {}; + // clang-format on + + } // namespace utf8 + + } // namespace TAO_PEGTL_NAMESPACE + +} // namespace tao + +#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/version.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/version.hpp new file mode 100644 index 0000000..4a5e8cf --- /dev/null +++ b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/version.hpp @@ -0,0 +1,19 @@ +// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_VERSION_HPP +#define TAO_PEGTL_VERSION_HPP + +#define TAO_PEGTL_VERSION "2.8.3" + +#define TAO_PEGTL_VERSION_MAJOR 2 +#define TAO_PEGTL_VERSION_MINOR 8 +#define TAO_PEGTL_VERSION_PATCH 3 + +// Compatibility, remove with 3.0.0 +#define TAOCPP_PEGTL_VERSION TAO_PEGTL_VERSION +#define TAOCPP_PEGTL_VERSION_MAJOR TAO_PEGTL_VERSION_MAJOR +#define TAOCPP_PEGTL_VERSION_MINOR TAO_PEGTL_VERSION_MINOR +#define TAOCPP_PEGTL_VERSION_PATCH TAO_PEGTL_VERSION_PATCH + +#endif From 54ee96e3bc0b59cc1e262dbd39767ddafa9994bd Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 28 Jun 2022 17:34:54 +0800 Subject: [PATCH 03/51] add ros2 message_type_support, not finished Signed-off-by: Chen Lihui --- .../src/DDSFilterExpression.cpp | 20 ++-- .../src/DDSFilterExpressionParser.cpp | 4 +- .../src/DDSFilterExpressionParser.hpp | 4 +- .../identifiers.hpp | 92 +++++++++---------- .../src/DDSFilterFactory.cpp | 15 ++- .../src/DDSFilterFactory.hpp | 4 +- common_content_filter/src/DDSFilterField.cpp | 24 ++--- .../src/IContentFilterFactory.hpp | 3 +- common_content_filter/src/test.cpp | 4 +- 9 files changed, 91 insertions(+), 79 deletions(-) diff --git a/common_content_filter/src/DDSFilterExpression.cpp b/common_content_filter/src/DDSFilterExpression.cpp index abbe703..7759ab4 100644 --- a/common_content_filter/src/DDSFilterExpression.cpp +++ b/common_content_filter/src/DDSFilterExpression.cpp @@ -62,16 +62,16 @@ bool DDSFilterExpression::evaluate( // return false; // } - // root->reset(); - // for (auto it = fields.begin(); - // it != fields.end() && DDSFilterConditionState::UNDECIDED == root->get_state(); - // ++it) - // { - // if (!it->second->set_value(*dyn_data_)) - // { - // return false; - // } - // } + root->reset(); + for (auto it = fields.begin(); + it != fields.end() && DDSFilterConditionState::UNDECIDED == root->get_state(); + ++it) + { + if (!it->second->set_value(payload)) + { + return false; + } + } return DDSFilterConditionState::RESULT_TRUE == root->get_state(); } diff --git a/common_content_filter/src/DDSFilterExpressionParser.cpp b/common_content_filter/src/DDSFilterExpressionParser.cpp index d2e0151..101a344 100644 --- a/common_content_filter/src/DDSFilterExpressionParser.cpp +++ b/common_content_filter/src/DDSFilterExpressionParser.cpp @@ -97,12 +97,12 @@ using selector = parse_tree::selector < std::unique_ptr parse_filter_expression( const char* expression, - const void* type_object) + const rosidl_message_type_support_t* type_support) { memory_input<> in(expression, ""); try { - CurrentIdentifierState identifier_state { type_object, nullptr, {} }; + CurrentIdentifierState identifier_state { type_support, nullptr, {} }; return parse_tree::parse< FilterExpressionGrammar, ParseNode, selector >(in, identifier_state); } catch (const parse_error& e) diff --git a/common_content_filter/src/DDSFilterExpressionParser.hpp b/common_content_filter/src/DDSFilterExpressionParser.hpp index 146d473..a520da9 100644 --- a/common_content_filter/src/DDSFilterExpressionParser.hpp +++ b/common_content_filter/src/DDSFilterExpressionParser.hpp @@ -25,6 +25,8 @@ #include "DDSFilterParseNode.hpp" +#include "rosidl_runtime_c/message_type_support_struct.h" + namespace eprosima_common { namespace fastdds { namespace dds { @@ -45,7 +47,7 @@ namespace parser { // const eprosima_common::fastrtps::types::TypeObject* type_object); std::unique_ptr parse_filter_expression( const char* expression, - const void* type_object); + const rosidl_message_type_support_t* type_support); /** * Performs parsing of a string containing a literal value. diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp index 4d0d74a..f58d8c3 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp @@ -24,7 +24,8 @@ struct CurrentIdentifierState { // TODO. const rosidl_message_type_support_t * type_support, - const void* type_object; + const rosidl_message_type_support_t * type_support; + // const void* type_object; // ? const void* current_type; @@ -87,19 +88,18 @@ struct identifier_processor // return false; // } - // static void add_member_access( - // std::unique_ptr< ParseNode >& n, - // CurrentIdentifierState& identifier_state, - // const CompleteTypeObject& complete) - // { + static void add_member_access( + std::unique_ptr< ParseNode >& n, + CurrentIdentifierState& identifier_state) + { // if (TK_STRUCTURE != complete._d()) // { // throw parse_error("trying to access field on a non-struct type", n->begin()); // } - // const ParseNode& name_node = n->left(); - // std::string name = name_node.content(); - // size_t member_index; + const ParseNode& name_node = n->left(); + std::string name = name_node.content(); + size_t member_index; // const CompleteStructMemberSeq& members = complete.struct_type().member_seq(); // for (member_index = 0; member_index < members.size(); ++member_index) // { @@ -117,7 +117,7 @@ struct identifier_processor // const TypeIdentifier& ti = members[member_index].common().member_type_id(); // bool has_index = n->children.size() > 1; // size_t max_size = 0; - // size_t array_index = std::numeric_limits::max(); + size_t array_index = std::numeric_limits::max(); // if (type_should_be_indexed(ti, identifier_state.current_type, max_size)) // { // if (!has_index) @@ -139,8 +139,8 @@ struct identifier_processor // } // } - // identifier_state.access_path.emplace_back(DDSFilterField::FieldAccessor{ member_index, array_index }); - // } + identifier_state.access_path.emplace_back(DDSFilterField::FieldAccessor{ member_index, array_index }); + } // static DDSFilterValue::ValueKind get_value_kind( // const TypeIdentifier& ti, @@ -199,41 +199,41 @@ struct identifier_processor States&&... /*st*/) { - // if (n->is()) - // { - // // Set data for fieldname node - // n->field_kind = get_value_kind(*state.current_type, n->end()); - // n->field_access_path = state.access_path; - // n->type_id = state.current_type; - - // // Reset parser state - // state.access_path.clear(); - // state.current_type = nullptr; - // } - // else - // { - // if (nullptr == state.current_type) - // { - // add_member_access(n, state, state.type_object->complete()); - // } - // else - // { - // if (EK_COMPLETE != state.current_type->_d()) - // { - // throw parse_error("trying to access field on a non-complete type", n->begin()); - // } - - // const TypeObject* type_object = TypeObjectFactory::get_instance()->get_type_object(state.current_type); - // if (nullptr == type_object) - // { - // throw parse_error("could not find type object definition", n->begin()); - // } - - // add_member_access(n, state, type_object->complete()); - // } - // } + if (n->is()) + { + // Set data for fieldname node + // n->field_kind = get_value_kind(*state.current_type, n->end()); + n->field_access_path = state.access_path; + n->type_id = state.current_type; + + // Reset parser state + state.access_path.clear(); + state.current_type = nullptr; + } + else + { + if (nullptr == state.current_type) + { + add_member_access(n, state); + } + else + { + // if (EK_COMPLETE != state.current_type->_d()) + // { + // throw parse_error("trying to access field on a non-complete type", n->begin()); + // } + + // const TypeObject* type_object = TypeObjectFactory::get_instance()->get_type_object(state.current_type); + // if (nullptr == type_object) + // { + // throw parse_error("could not find type object definition", n->begin()); + // } + + add_member_access(n, state); + } + } - // n->children.clear(); + n->children.clear(); } }; diff --git a/common_content_filter/src/DDSFilterFactory.cpp b/common_content_filter/src/DDSFilterFactory.cpp index d44ff4e..e6a0403 100644 --- a/common_content_filter/src/DDSFilterFactory.cpp +++ b/common_content_filter/src/DDSFilterFactory.cpp @@ -47,6 +47,8 @@ #include "DDSFilterPredicate.hpp" #include "DDSFilterValue.hpp" +#include "Log.hpp" + namespace eprosima_common { namespace fastdds { namespace dds { @@ -442,8 +444,15 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree(state, condition, node); } +DDSFilterFactory::DDSFilterFactory() +{ + logError(DDSSQLFILTER, "DDSFilterFactory::DDSFilterFactory " << this); +} + DDSFilterFactory::~DDSFilterFactory() { + logError(DDSSQLFILTER, "DDSFilterFactory::~DDSFilterFactory " << this); + auto& pool = expression_pool_.collection(); for (DDSFilterExpression* item : pool) { @@ -455,13 +464,13 @@ DDSFilterFactory::~DDSFilterFactory() IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( const char* filter_class_name, const char* type_name, - const void* data_type, + const rosidl_message_type_support_t* type_support, const char* filter_expression, const IContentFilterFactory::ParameterSeq& filter_parameters, IContentFilter*& filter_instance) { - static_cast(data_type); + // static_cast(type_support); ReturnCode_t ret = ReturnCode_t::RETCODE_UNSUPPORTED; @@ -527,7 +536,7 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( // } // else { - auto node = parser::parse_filter_expression(filter_expression, nullptr); + auto node = parser::parse_filter_expression(filter_expression, type_support); if (node) { // auto type_id = TypeObjectFactory::get_instance()->get_type_identifier(type_name, true); diff --git a/common_content_filter/src/DDSFilterFactory.hpp b/common_content_filter/src/DDSFilterFactory.hpp index dc3246a..f212f9c 100644 --- a/common_content_filter/src/DDSFilterFactory.hpp +++ b/common_content_filter/src/DDSFilterFactory.hpp @@ -46,13 +46,13 @@ class DDSFilterFactory final : public IContentFilterFactory { public: - + DDSFilterFactory(); ~DDSFilterFactory(); ReturnCode_t create_content_filter( const char* filter_class_name, const char* type_name, - const void* data_type, + const rosidl_message_type_support_t* data_type, const char* filter_expression, const ParameterSeq& filter_parameters, IContentFilter*& filter_instance) override; diff --git a/common_content_filter/src/DDSFilterField.cpp b/common_content_filter/src/DDSFilterField.cpp index ee70f83..2dc8fdb 100644 --- a/common_content_filter/src/DDSFilterField.cpp +++ b/common_content_filter/src/DDSFilterField.cpp @@ -43,7 +43,7 @@ bool DDSFilterField::set_value( // uint32_t index = static_cast(access_path_[n].member_index); // auto member_id = data.get_member_id_at_index(index); - // bool last_step = access_path_.size() - 1 == n; + bool last_step = access_path_.size() - 1 == n; bool ret = false; // if (access_path_[n].array_index < MEMBER_ID_INVALID) @@ -88,17 +88,17 @@ bool DDSFilterField::set_value( // } // } - // if (ret && last_step) - // { - // has_value_ = true; - // value_has_changed(); - - // // Inform parent predicates - // for (DDSFilterPredicate* parent : parents_) - // { - // parent->value_has_changed(); - // } - // } + if (ret && last_step) + { + has_value_ = true; + value_has_changed(); + + // Inform parent predicates + for (DDSFilterPredicate* parent : parents_) + { + parent->value_has_changed(); + } + } return ret; } diff --git a/common_content_filter/src/IContentFilterFactory.hpp b/common_content_filter/src/IContentFilterFactory.hpp index 1951bf2..503cbad 100644 --- a/common_content_filter/src/IContentFilterFactory.hpp +++ b/common_content_filter/src/IContentFilterFactory.hpp @@ -31,6 +31,7 @@ #include #include "IContentFilter.hpp" +#include "rosidl_runtime_c/message_type_support_struct.h" namespace eprosima_common { namespace fastdds { @@ -77,7 +78,7 @@ struct IContentFilterFactory virtual ReturnCode_t create_content_filter( const char* filter_class_name, const char* type_name, - const void* data_type, + const rosidl_message_type_support_t* data_type, const char* filter_expression, const ParameterSeq& filter_parameters, IContentFilter*& filter_instance) = 0; diff --git a/common_content_filter/src/test.cpp b/common_content_filter/src/test.cpp index f9d4097..d94c2ba 100644 --- a/common_content_filter/src/test.cpp +++ b/common_content_filter/src/test.cpp @@ -164,8 +164,8 @@ create_common_content_filter( } DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->create_content_filter( - "DDSSQL", - "type_name", + "DDSSQL", // deprecated + "type_name", // deprecated type_support, options->filter_expression, expression_parameters, From 8a85a6a97797b2792bdd13f88f1b2e3649e15d7e Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Wed, 29 Jun 2022 15:47:09 +0800 Subject: [PATCH 04/51] add the test access_path for content_filtering_subscriber Signed-off-by: Chen Lihui --- common_content_filter/CMakeLists.txt | 33 +- .../include/common_content_filter/test.h | 20 +- .../src/DDSFilterExpression.cpp | 5 + .../src/DDSFilterExpressionParser.cpp | 14 +- .../identifiers.hpp | 435 ++++++++++++++---- .../src/DDSFilterFactory.cpp | 8 +- common_content_filter/src/DDSFilterField.hpp | 6 +- .../src/DDSFilterParseNode.hpp | 5 +- common_content_filter/src/test.cpp | 15 +- 9 files changed, 410 insertions(+), 131 deletions(-) diff --git a/common_content_filter/CMakeLists.txt b/common_content_filter/CMakeLists.txt index 9ec4ca2..83a0552 100644 --- a/common_content_filter/CMakeLists.txt +++ b/common_content_filter/CMakeLists.txt @@ -15,12 +15,8 @@ find_package(ament_cmake REQUIRED) find_package(rcutils REQUIRED) find_package(rcpputils REQUIRED) find_package(rmw REQUIRED) -find_package(rosidl_runtime_cpp REQUIRED) - -ament_export_dependencies(ament_cmake_core) -ament_export_dependencies(rcpputils) -ament_export_dependencies(rcutils) -ament_export_dependencies(rmw) +find_package(rosidl_typesupport_introspection_c REQUIRED) +find_package(rosidl_typesupport_introspection_cpp REQUIRED) add_library(${PROJECT_NAME}_library SHARED src/DDSFilterCompoundCondition.cpp @@ -36,11 +32,12 @@ add_library(${PROJECT_NAME}_library SHARED set_target_properties(${PROJECT_NAME}_library PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) -target_link_libraries(${PROJECT_NAME}_library PUBLIC - rcutils::rcutils - rmw::rmw) -target_link_libraries(${PROJECT_NAME}_library PRIVATE - rcpputils::rcpputils) +# target_link_libraries(${PROJECT_NAME}_library PUBLIC +# rcutils::rcutils +# rmw::rmw +# ) +# target_link_libraries(${PROJECT_NAME}_library PRIVATE +# rcpputils::rcpputils) target_include_directories(${PROJECT_NAME}_library PUBLIC "$" @@ -49,6 +46,13 @@ target_include_directories(${PROJECT_NAME}_library ${PROJECT_SOURCE_DIR}/thirdparty/taocpp-pegtl ) +ament_target_dependencies(${PROJECT_NAME}_library + "rcpputils" + "rcutils" + "rmw" + "rosidl_typesupport_introspection_c" + "rosidl_typesupport_introspection_cpp" +) # # Wait for all rosidl generators to finish before building this library # add_dependencies(${PROJECT_NAME}_library # ${PROJECT_NAME}) @@ -77,6 +81,13 @@ ament_export_libraries(${PROJECT_NAME}_library) # Export modern CMake targets ament_export_targets(${PROJECT_NAME}_library) +ament_export_dependencies(ament_cmake_core) +ament_export_dependencies(rcpputils) +ament_export_dependencies(rcutils) +ament_export_dependencies(rmw) +ament_export_dependencies(rosidl_typesupport_introspection_c) +ament_export_dependencies(rosidl_typesupport_introspection_cpp) + install( DIRECTORY include/ DESTINATION include/${PROJECT_NAME}) diff --git a/common_content_filter/include/common_content_filter/test.h b/common_content_filter/include/common_content_filter/test.h index 3343212..6d5406e 100644 --- a/common_content_filter/include/common_content_filter/test.h +++ b/common_content_filter/include/common_content_filter/test.h @@ -30,17 +30,17 @@ COMMON_CONTENT_FILTER_PUBLIC void test_func_c(); -COMMON_CONTENT_FILTER_PUBLIC -void * -create_common_content_filter_factory(); +// COMMON_CONTENT_FILTER_PUBLIC +// void * +// create_common_content_filter_factory(); -COMMON_CONTENT_FILTER_PUBLIC -void -test_common_content_filter_factory(void *); +// COMMON_CONTENT_FILTER_PUBLIC +// void +// test_common_content_filter_factory(void *); -COMMON_CONTENT_FILTER_PUBLIC -void -destroy_common_content_filter_factory(void *); +// COMMON_CONTENT_FILTER_PUBLIC +// void +// destroy_common_content_filter_factory(void *); COMMON_CONTENT_FILTER_PUBLIC void * @@ -51,7 +51,7 @@ create_common_content_filter( COMMON_CONTENT_FILTER_PUBLIC bool -common_content_filter_evaluate(void * instance, void * ros_data); +common_content_filter_evaluate(void * instance, void * ros_data, bool serialized); COMMON_CONTENT_FILTER_PUBLIC void diff --git a/common_content_filter/src/DDSFilterExpression.cpp b/common_content_filter/src/DDSFilterExpression.cpp index 7759ab4..c19e042 100644 --- a/common_content_filter/src/DDSFilterExpression.cpp +++ b/common_content_filter/src/DDSFilterExpression.cpp @@ -35,6 +35,8 @@ #include "DDSFilterField.hpp" #include "DDSFilterParameter.hpp" +#include "Log.hpp" + namespace eprosima_common { namespace fastdds { namespace dds { @@ -62,6 +64,9 @@ bool DDSFilterExpression::evaluate( // return false; // } + + logInfo(DDSSQLFILTER, "DDSFilterExpression::evaluate"); + root->reset(); for (auto it = fields.begin(); it != fields.end() && DDSFilterConditionState::UNDECIDED == root->get_state(); diff --git a/common_content_filter/src/DDSFilterExpressionParser.cpp b/common_content_filter/src/DDSFilterExpressionParser.cpp index 101a344..2b232d0 100644 --- a/common_content_filter/src/DDSFilterExpressionParser.cpp +++ b/common_content_filter/src/DDSFilterExpressionParser.cpp @@ -26,6 +26,16 @@ // #include // #include + +// identifiers.hpp need this headers +#include "rmw/error_handling.h" +#include "rosidl_typesupport_introspection_c/identifier.h" +#include "rosidl_typesupport_introspection_cpp/identifier.hpp" +#include "rosidl_typesupport_introspection_c/message_introspection.h" +#include "rosidl_typesupport_introspection_cpp/message_introspection.hpp" +#include "rosidl_typesupport_introspection_cpp/field_types.hpp" + + #include "pegtl.hpp" #include "pegtl/contrib/parse_tree.hpp" @@ -102,7 +112,7 @@ std::unique_ptr parse_filter_expression( memory_input<> in(expression, ""); try { - CurrentIdentifierState identifier_state { type_support, nullptr, {} }; + CurrentIdentifierState identifier_state { type_support, nullptr, 0, {} }; return parse_tree::parse< FilterExpressionGrammar, ParseNode, selector >(in, identifier_state); } catch (const parse_error& e) @@ -126,7 +136,7 @@ std::unique_ptr parse_literal_value( memory_input<> in(expression, ""); try { - CurrentIdentifierState identifier_state{ nullptr, nullptr, {} }; + CurrentIdentifierState identifier_state{ nullptr, nullptr, 0, {} }; return parse_tree::parse< LiteralGrammar, ParseNode, selector >(in, identifier_state); } catch (const parse_error& e) diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp index f58d8c3..6238caf 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp @@ -20,18 +20,231 @@ */ - struct CurrentIdentifierState { // TODO. const rosidl_message_type_support_t * type_support, const rosidl_message_type_support_t * type_support; - // const void* type_object; - // ? - const void* current_type; + // ros2 primitive type + const rosidl_message_type_support_t * current_type_support; + uint8_t current_type; + std::vector access_path; }; + +const rosidl_message_type_support_t * +get_type_support_introspection( + const rosidl_message_type_support_t * type_supports) +{ + const rosidl_message_type_support_t * type_support = + get_message_typesupport_handle( + type_supports, rosidl_typesupport_introspection_c__identifier); + if (nullptr == type_support) { + rcutils_error_string_t prev_error_string = rcutils_get_error_string(); + rcutils_reset_error(); + + type_support = + get_message_typesupport_handle( + type_supports, + rosidl_typesupport_introspection_cpp::typesupport_identifier); + if (nullptr == type_support) { + rcutils_error_string_t error_string = rcutils_get_error_string(); + rcutils_reset_error(); + RMW_SET_ERROR_MSG_WITH_FORMAT_STRING( + "Type support not from this implementation. Got:\n" + " %s\n" + " %s\n" + "while fetching it", + prev_error_string.str, error_string.str); + return nullptr; + } + } + + return type_support; +} + + +template +void GetTypeIdentifier( + CurrentIdentifierState& identifier_state, + const std::string & parse_node_name, + const MembersType * members, uint32_t index) +{ + const auto member = members->members_ + index; + std::string name = member->name_; + + if (name == parse_node_name) { + logError(DDSSQLFILTER, "find the parse_node_name: " << parse_node_name + << " type_id:" << static_cast(member->type_id_) + << " member index:" << index + << " member member->is_array_:" << member->is_array_ + << " member member->array_size_:" << member->array_size_ + << " member member->is_upper_bound_:" << member->is_upper_bound_ + ); + // some important information should be saved in the identifier_state + identifier_state.current_type = member->type_id_; + + if (member->type_id_ == ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE) { + + // const rosidl_message_type_support_t * type_support_intro = + // get_type_support_introspection(member->members_); + // const MembersType * sub_members = + // static_cast(type_support_intro->data); + + identifier_state.current_type_support = member->members_; + } + + } + + std::string type_name; + switch (member->type_id_) { + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: + { + type_name = "float"; + break; + } + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_DOUBLE: + { + type_name = "double"; + break; + } + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_LONG_DOUBLE: + { + type_name = "longdouble"; + break; + } + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_CHAR: + { + type_name = "char"; + break; + } + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: + { + type_name = "wchar"; + break; + } + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: + { + type_name = "bool"; + break; + } + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_OCTET: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT8: + { + type_name = "uint8_t"; + break; + } + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT8: + { + type_name = "int8_t"; + break; + } + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT16: + { + type_name = "uint16_t"; + break; + } + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT16: + { + type_name = "int16_t"; + break; + } + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT32: + { + type_name = "uint32_t"; + break; + } + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT32: + { + type_name = "int32_t"; + break; + } + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT64: + { + type_name = "uint64_t"; + break; + } + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT64: + { + type_name = "int64_t"; + break; + } + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: + { + uint32_t bound = member->string_upper_bound_ ? + static_cast(member->string_upper_bound_) : 255; + bool wide = + (member->type_id_ == ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING) ? + false : true; + + break; + } + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE: + { + const rosidl_message_type_support_t * type_support_intro = + get_type_support_introspection(member->members_); + const MembersType * sub_members = + static_cast(type_support_intro->data); + + } + break; + default: + break; + } + + logError(DDSSQLFILTER, "GetTypeIdentifier name:" << name << " type_name:" << type_name); +} + +template +inline bool +add_type_object( + CurrentIdentifierState& identifier_state, + const std::string & parse_node_name, + const void * untype_members) +{ + const MembersType * members = static_cast(untype_members); + if (!members) { + return false; + } + + for (uint32_t i = 0; i < members->member_count_; ++i) { + GetTypeIdentifier(identifier_state, parse_node_name, members, i); + } + + return true; +} + +bool test_type_support( + CurrentIdentifierState& identifier_state, + const std::string & parse_node_name, + const rosidl_message_type_support_t * type_supports) +{ + const rosidl_message_type_support_t * type_support_intro = + get_type_support_introspection(type_supports); + if (!type_support_intro) { + return false; + } + + bool ret = false; + logError(DDSSQLFILTER, "test_type_support: " << type_support_intro->typesupport_identifier); + if (type_support_intro->typesupport_identifier == + rosidl_typesupport_introspection_c__identifier) + { + ret = add_type_object( + identifier_state, parse_node_name, type_support_intro->data); + } else { + ret = add_type_object( + identifier_state, parse_node_name, type_support_intro->data); + } + + return ret; +} + + + + struct identifier_processor : parse_tree::apply< identifier_processor > { @@ -55,51 +268,70 @@ struct identifier_processor } // static bool type_should_be_indexed( - // const TypeIdentifier& ti, + // CurrentIdentifierState& identifier_state, // const TypeIdentifier*& out_type, // size_t& max_size) // { - // max_size = 0; - - // switch (ti._d()) - // { - // case TI_PLAIN_ARRAY_SMALL: - // out_type = ti.array_sdefn().element_identifier(); - // max_size = process_bounds(ti.array_sdefn().array_bound_seq()); - // return true; - - // case TI_PLAIN_ARRAY_LARGE: - // out_type = ti.array_ldefn().element_identifier(); - // max_size = process_bounds(ti.array_ldefn().array_bound_seq()); - // return true; - - // case TI_PLAIN_SEQUENCE_SMALL: - // out_type = ti.seq_sdefn().element_identifier(); - // max_size = process_bound(ti.seq_sdefn().bound()); - // return true; - - // case TI_PLAIN_SEQUENCE_LARGE: - // out_type = ti.seq_ldefn().element_identifier(); - // max_size = process_bound(ti.seq_ldefn().bound()); - // return true; - // } - - // out_type = &ti; + // max_size = 0; + + // switch (identifier_state.current_type_support) + // { + // case TI_PLAIN_ARRAY_SMALL: + // out_type = ti.array_sdefn().element_identifier(); + // max_size = process_bounds(ti.array_sdefn().array_bound_seq()); + // return true; + + // case TI_PLAIN_ARRAY_LARGE: + // out_type = ti.array_ldefn().element_identifier(); + // max_size = process_bounds(ti.array_ldefn().array_bound_seq()); + // return true; + + // case TI_PLAIN_SEQUENCE_SMALL: + // out_type = ti.seq_sdefn().element_identifier(); + // max_size = process_bound(ti.seq_sdefn().bound()); + // return true; + + // case TI_PLAIN_SEQUENCE_LARGE: + // out_type = ti.seq_ldefn().element_identifier(); + // max_size = process_bound(ti.seq_ldefn().bound()); + // return true; + // } + + // out_type = &ti; // return false; // } static void add_member_access( std::unique_ptr< ParseNode >& n, - CurrentIdentifierState& identifier_state) + CurrentIdentifierState& identifier_state, + const rosidl_message_type_support_t * type_support) { // if (TK_STRUCTURE != complete._d()) // { // throw parse_error("trying to access field on a non-struct type", n->begin()); // } + /* + idl + msg1 + string data + + msg2 + string data + msg1 m1; + + msg2 topic message type, and use `m1.data = 'test'` + + */ + const ParseNode& name_node = n->left(); std::string name = name_node.content(); - size_t member_index; + + logError(DDSSQLFILTER, "identifiers add_member_access: " << name); + + test_type_support(identifier_state, name, identifier_state.type_support); + + size_t member_index = 0; // const CompleteStructMemberSeq& members = complete.struct_type().member_seq(); // for (member_index = 0; member_index < members.size(); ++member_index) // { @@ -115,22 +347,22 @@ struct identifier_processor // } // const TypeIdentifier& ti = members[member_index].common().member_type_id(); - // bool has_index = n->children.size() > 1; - // size_t max_size = 0; + bool has_index = n->children.size() > 1; + size_t max_size = 0; size_t array_index = std::numeric_limits::max(); - // if (type_should_be_indexed(ti, identifier_state.current_type, max_size)) - // { - // if (!has_index) - // { - // throw parse_error("field should have an index (i.e. [n])", n->left().end()); - // } - - // array_index = static_cast(std::stoul(n->right().left().content())); - // if (max_size <= array_index) - // { - // throw parse_error("index is greater than maximum size", n->right().end()); - // } - // } + // if (type_should_be_indexed(ti, identifier_state, max_size)) + { + // if (!has_index) + // { + // throw parse_error("field should have an index (i.e. [n])", n->left().end()); + // } + + // array_index = static_cast(std::stoul(n->right().left().content())); + // if (max_size <= array_index) + // { + // throw parse_error("index is greater than maximum size", n->right().end()); + // } + } // else // { // if (has_index) @@ -142,55 +374,53 @@ struct identifier_processor identifier_state.access_path.emplace_back(DDSFilterField::FieldAccessor{ member_index, array_index }); } - // static DDSFilterValue::ValueKind get_value_kind( - // const TypeIdentifier& ti, - // const position& pos) - // { - // switch (ti._d()) - // { - // case TK_BOOLEAN: - // return DDSFilterValue::ValueKind::BOOLEAN; - - // case TK_CHAR8: - // return DDSFilterValue::ValueKind::CHAR; - - // case TK_STRING8: - // case TI_STRING8_SMALL: - // case TI_STRING8_LARGE: - // return DDSFilterValue::ValueKind::STRING; - - // case TK_INT16: - // case TK_INT32: - // case TK_INT64: - // return DDSFilterValue::ValueKind::SIGNED_INTEGER; - - // case TK_BYTE: - // case TK_UINT16: - // case TK_UINT32: - // case TK_UINT64: - // return DDSFilterValue::ValueKind::UNSIGNED_INTEGER; - - // case TK_FLOAT32: - // return DDSFilterValue::ValueKind::FLOAT_FIELD; - - // case TK_FLOAT64: - // return DDSFilterValue::ValueKind::DOUBLE_FIELD; - - // case TK_FLOAT128: - // return DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD; - - // case EK_COMPLETE: - // const TypeObject* type_object = TypeObjectFactory::get_instance()->get_type_object(&ti); - // if (TK_ENUM == type_object->complete()._d()) - // { - // return DDSFilterValue::ValueKind::ENUM; - // } - // break; + static DDSFilterValue::ValueKind get_value_kind( + uint8_t type_id, + const position& pos) + { + logError(DDSSQLFILTER, "get_value_kind type_id:" << type_id); + switch (type_id) + { + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: + return DDSFilterValue::ValueKind::BOOLEAN; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_CHAR: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: + return DDSFilterValue::ValueKind::CHAR; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: + return DDSFilterValue::ValueKind::STRING; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT8: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT16: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT32: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT64: + return DDSFilterValue::ValueKind::SIGNED_INTEGER; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_OCTET: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT16: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT32: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT64: + return DDSFilterValue::ValueKind::UNSIGNED_INTEGER; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: + return DDSFilterValue::ValueKind::FLOAT_FIELD; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_DOUBLE: + return DDSFilterValue::ValueKind::DOUBLE_FIELD; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_LONG_DOUBLE: + return DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE: + break; + + } - // } // throw parse_error("type is not primitive", pos); - // } + } template< typename ... States > static void transform( @@ -198,26 +428,33 @@ struct identifier_processor CurrentIdentifierState& state, States&&... /*st*/) { + logError(DDSSQLFILTER, "identifiers transform name:" << n->content()); if (n->is()) { + logError(DDSSQLFILTER, "identifiers transform n->is()"); + // Set data for fieldname node - // n->field_kind = get_value_kind(*state.current_type, n->end()); + n->field_kind = get_value_kind(state.current_type, n->end()); n->field_access_path = state.access_path; n->type_id = state.current_type; // Reset parser state state.access_path.clear(); - state.current_type = nullptr; + state.current_type = 0; } else { - if (nullptr == state.current_type) + if (0 == state.current_type) { - add_member_access(n, state); + logError(DDSSQLFILTER, "identifiers transform 0 == state.current_type"); + + add_member_access(n, state, state.type_support); } else { + logError(DDSSQLFILTER, "identifiers transform 0 != state.current_type"); + // if (EK_COMPLETE != state.current_type->_d()) // { // throw parse_error("trying to access field on a non-complete type", n->begin()); @@ -229,7 +466,7 @@ struct identifier_processor // throw parse_error("could not find type object definition", n->begin()); // } - add_member_access(n, state); + add_member_access(n, state, state.current_type_support); } } diff --git a/common_content_filter/src/DDSFilterFactory.cpp b/common_content_filter/src/DDSFilterFactory.cpp index e6a0403..575e822 100644 --- a/common_content_filter/src/DDSFilterFactory.cpp +++ b/common_content_filter/src/DDSFilterFactory.cpp @@ -56,7 +56,7 @@ namespace DDSSQLFilter { static IContentFilterFactory::ReturnCode_t transform_enum( std::shared_ptr& value, - const void* type, + uint8_t type, const std::string& string_value) { // const char* str_value = string_value.c_str(); @@ -76,9 +76,9 @@ static IContentFilterFactory::ReturnCode_t transform_enum( static IContentFilterFactory::ReturnCode_t transform_enums( std::shared_ptr& left_value, - const void* left_type, + uint8_t left_type, std::shared_ptr& right_value, - const void* right_type) + uint8_t right_type) { if ((DDSFilterValue::ValueKind::ENUM == left_value->kind) && (DDSFilterValue::ValueKind::STRING == right_value->kind)) @@ -223,7 +223,7 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree(); value->copy_from(*node.value.get(), true); } - else if (nullptr != node.type_id) + else if (0 != node.type_id) { std::string field_name = node.content(); auto it = state.filter->fields.find(field_name); diff --git a/common_content_filter/src/DDSFilterField.hpp b/common_content_filter/src/DDSFilterField.hpp index de32625..901ab60 100644 --- a/common_content_filter/src/DDSFilterField.hpp +++ b/common_content_filter/src/DDSFilterField.hpp @@ -67,12 +67,12 @@ class DDSFilterField final : public DDSFilterValue * @param[in] data_kind Kind of data the field represents. */ DDSFilterField( - const void* type_id, + uint8_t type_id, const std::vector& access_path, ValueKind data_kind) : DDSFilterValue(data_kind) , access_path_(access_path) - // , type_id_(type_id) + , type_id_(type_id) { } @@ -143,7 +143,7 @@ class DDSFilterField final : public DDSFilterValue bool has_value_ = false; std::vector access_path_; - const void* type_id_ = nullptr; + uint8_t type_id_ = 0; std::unordered_set parents_; }; diff --git a/common_content_filter/src/DDSFilterParseNode.hpp b/common_content_filter/src/DDSFilterParseNode.hpp index be648b2..51168c8 100644 --- a/common_content_filter/src/DDSFilterParseNode.hpp +++ b/common_content_filter/src/DDSFilterParseNode.hpp @@ -44,8 +44,11 @@ struct ParseNode : parse_tree::basic_node< ParseNode > // When the node is a fieldname, it will hold the access path to the field, the data kind, and the type id std::vector field_access_path; + + // TODO. why need the following two members? DDSFilterValue::ValueKind field_kind = DDSFilterValue::ValueKind::STRING; - const void* type_id = nullptr; + // filed type in the ros2 primitive type + uint8_t type_id = 0; // When the node is a parameter, it will hold the parameter index int32_t parameter_index = 0; diff --git a/common_content_filter/src/test.cpp b/common_content_filter/src/test.cpp index d94c2ba..2bcadcb 100644 --- a/common_content_filter/src/test.cpp +++ b/common_content_filter/src/test.cpp @@ -27,6 +27,13 @@ #include "Log.hpp" +// #include "rosidl_typesupport_introspection_c/identifier.h" +// #include "rosidl_typesupport_introspection_cpp/identifier.hpp" +// #include "rosidl_typesupport_introspection_c/message_introspection.h" +// #include "rosidl_typesupport_introspection_cpp/message_introspection.hpp" +// #include "rosidl_typesupport_introspection_cpp/field_types.hpp" + + using namespace eprosima_common::fastdds::dds; using namespace eprosima_common::fastdds::dds::DDSSQLFilter; @@ -154,6 +161,9 @@ create_common_content_filter( return NULL; } + + + logInfo(DDSSQLFILTER, "create_common_content_filter options: " << options->filter_expression); IContentFilter * filter_instance; @@ -177,9 +187,12 @@ create_common_content_filter( } bool -common_content_filter_evaluate(void * instance, void * ros_data) { +common_content_filter_evaluate(void * instance, void * ros_data, bool serialized) { eprosima_common::fastdds::dds::IContentFilter * content_filter = static_cast(instance); + if (serialized) { + // TODO. deserialize the ros_data + } bool ret = content_filter->evaluate(ros_data); return ret; From ab7a0dd12f87e77d0d8b2450d5ce99d1e9c9b2f1 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Wed, 29 Jun 2022 16:02:02 +0800 Subject: [PATCH 05/51] test Signed-off-by: Chen Lihui --- common_content_filter/src/DDSFilterExpression.cpp | 2 +- common_content_filter/src/DDSFilterField.cpp | 15 ++++++++++++++- common_content_filter/src/DDSFilterField.hpp | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/common_content_filter/src/DDSFilterExpression.cpp b/common_content_filter/src/DDSFilterExpression.cpp index c19e042..68957c3 100644 --- a/common_content_filter/src/DDSFilterExpression.cpp +++ b/common_content_filter/src/DDSFilterExpression.cpp @@ -65,7 +65,7 @@ bool DDSFilterExpression::evaluate( // } - logInfo(DDSSQLFILTER, "DDSFilterExpression::evaluate"); + logInfo(DDSSQLFILTER, "DDSFilterExpression::evaluate fields size:" << fields.size()); root->reset(); for (auto it = fields.begin(); diff --git a/common_content_filter/src/DDSFilterField.cpp b/common_content_filter/src/DDSFilterField.cpp index 2dc8fdb..4267c70 100644 --- a/common_content_filter/src/DDSFilterField.cpp +++ b/common_content_filter/src/DDSFilterField.cpp @@ -30,6 +30,8 @@ #include "DDSFilterPredicate.hpp" #include "DDSFilterValue.hpp" +#include "Log.hpp" + namespace eprosima_common { namespace fastdds { namespace dds { @@ -44,6 +46,17 @@ bool DDSFilterField::set_value( // uint32_t index = static_cast(access_path_[n].member_index); // auto member_id = data.get_member_id_at_index(index); bool last_step = access_path_.size() - 1 == n; + + logError(DDSSQLFILTER, "DDSFilterField::set_value " + << "access_path_.size():" << access_path_.size() + ); + + for (auto & access_path : access_path_) { + logError(DDSSQLFILTER, "DDSFilterField::set_value " + << " access_path.member_index:" << access_path.member_index + << " access_path.array_index:" << access_path.array_index + ); + } bool ret = false; // if (access_path_[n].array_index < MEMBER_ID_INVALID) @@ -105,7 +118,7 @@ bool DDSFilterField::set_value( bool DDSFilterField::set_value( const void * data, - int member_id) + float member_id) { // using namespace eprosima_common::fastrtps::types; diff --git a/common_content_filter/src/DDSFilterField.hpp b/common_content_filter/src/DDSFilterField.hpp index 901ab60..d9e9166 100644 --- a/common_content_filter/src/DDSFilterField.hpp +++ b/common_content_filter/src/DDSFilterField.hpp @@ -109,7 +109,7 @@ class DDSFilterField final : public DDSFilterValue inline bool set_value( const void * data_value) { - return set_value(data_value, 0); + return set_value(data_value, (size_t)0); } /** @@ -139,7 +139,7 @@ class DDSFilterField final : public DDSFilterValue bool set_value( const void * data_value, - int member_id); + float member_id); bool has_value_ = false; std::vector access_path_; From ace4980699a5fe625585c77c2a39b230a2340ece Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Wed, 29 Jun 2022 17:07:44 +0800 Subject: [PATCH 06/51] hard code to make content_filter_subscriber run successfully Signed-off-by: Chen Lihui --- .../identifiers.hpp | 1 + common_content_filter/src/DDSFilterField.cpp | 62 +++++++------------ 2 files changed, 22 insertions(+), 41 deletions(-) diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp index 6238caf..944e886 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp @@ -78,6 +78,7 @@ void GetTypeIdentifier( logError(DDSSQLFILTER, "find the parse_node_name: " << parse_node_name << " type_id:" << static_cast(member->type_id_) << " member index:" << index + << " member member->offset_:" << member->offset_ << " member member->is_array_:" << member->is_array_ << " member member->array_size_:" << member->array_size_ << " member member->is_upper_bound_:" << member->is_upper_bound_ diff --git a/common_content_filter/src/DDSFilterField.cpp b/common_content_filter/src/DDSFilterField.cpp index 4267c70..bfae1aa 100644 --- a/common_content_filter/src/DDSFilterField.cpp +++ b/common_content_filter/src/DDSFilterField.cpp @@ -59,47 +59,23 @@ bool DDSFilterField::set_value( } bool ret = false; - // if (access_path_[n].array_index < MEMBER_ID_INVALID) - // { - // DynamicData* array_data = data.loan_value(member_id); - // if (nullptr != array_data) - // { - // member_id = static_cast(access_path_[n].array_index); - // if (array_data->get_item_count() > member_id) - // { - // if (last_step) - // { - // ret = set_value(array_data, member_id); - // } - // else - // { - // DynamicData* struct_data = array_data->loan_value(member_id); - // if (nullptr != struct_data) - // { - // ret = set_value(*struct_data, n + 1); - // array_data->return_loaned_value(struct_data); - // } - // } - // } - // data.return_loaned_value(array_data); - // } - // } - // else - // { - // if (last_step) - // { - // ret = set_value(&data, member_id); - // } - // else - // { - // DynamicData* struct_data = data.loan_value(member_id); - // if (nullptr != struct_data) - // { - // ret = set_value(*struct_data, n + 1); - // data.return_loaned_value(struct_data); - // } - // } - // } + if (access_path_[n].array_index < std::numeric_limits::max()) + { + size_t array_index = access_path_[n].array_index; + + } + else + { + if (last_step) + { + ret = set_value(data, .0f); + } + else + { + const void * addr = data; // need to calculate the addr + ret = set_value(addr, n + 1); + } + } if (ret && last_step) { @@ -123,6 +99,10 @@ bool DDSFilterField::set_value( // using namespace eprosima_common::fastrtps::types; bool ret = true; + + // just a test, content_filtering_subscriber use float msg + float_value = *(float*)data; + // try // { // switch (type_id_->_d()) From f9612d5da1054305fd4a302902223c62df3478d5 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Thu, 30 Jun 2022 17:17:55 +0800 Subject: [PATCH 07/51] parameter event subscriber with 'new_parameters[0].value.type = 4' Signed-off-by: Chen Lihui --- .../identifiers.hpp | 154 ++++++++--- .../src/DDSFilterFactory.cpp | 4 + common_content_filter/src/DDSFilterField.cpp | 242 +++++++++++------- common_content_filter/src/DDSFilterField.hpp | 21 +- .../src/DDSFilterParameter.cpp | 5 + common_content_filter/src/test.cpp | 22 +- 6 files changed, 313 insertions(+), 135 deletions(-) diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp index 944e886..39d6406 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp @@ -96,6 +96,8 @@ void GetTypeIdentifier( identifier_state.current_type_support = member->members_; } + identifier_state.current_type_support = member->members_; + } std::string type_name; @@ -202,27 +204,101 @@ template inline bool add_type_object( CurrentIdentifierState& identifier_state, - const std::string & parse_node_name, - const void * untype_members) + std::unique_ptr< ParseNode >& n, + const void * untype_members, + size_t & member_index, + size_t & array_index) { const MembersType * members = static_cast(untype_members); if (!members) { return false; } + const ParseNode& name_node = n->left(); + std::string parse_node_name = name_node.content(); + for (uint32_t i = 0; i < members->member_count_; ++i) { - GetTypeIdentifier(identifier_state, parse_node_name, members, i); + // GetTypeIdentifier(identifier_state, parse_node_name, members, i); + + const auto member = members->members_ + i; + std::string name = member->name_; + + if (name == parse_node_name) { + + member_index = i; + + logError(DDSSQLFILTER, "find the parse_node_name: " << parse_node_name + << " type_id:" << static_cast(member->type_id_) + << " member index:" << i + << " member member->offset_:" << member->offset_ + << " member member->is_array_:" << member->is_array_ + << " member member->array_size_:" << member->array_size_ + << " member member->is_upper_bound_:" << member->is_upper_bound_ + ); + + bool has_index = n->children.size() > 1; + if (member->is_array_) + { + if (!has_index) + { + throw parse_error("field should have an index (i.e. [n])", n->left().end()); + } + + array_index = static_cast(std::stoul(n->right().left().content())); + + + + if (member->array_size_ && !member->is_upper_bound_) { + if (member->array_size_ <= array_index) + { + throw parse_error("index is greater than maximum size", n->right().end()); + } + } + + + } + else + { + if (has_index) + { + throw parse_error("field is not an array or sequence", n->right().begin()); + } + } + + + // some important information should be saved in the identifier_state + identifier_state.current_type = member->type_id_; + + + if (member->type_id_ == ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE) { + + // const rosidl_message_type_support_t * type_support_intro = + // get_type_support_introspection(member->members_); + // const MembersType * sub_members = + // static_cast(type_support_intro->data); + + identifier_state.current_type_support = member->members_; + } + + + + return true; + } } + throw parse_error("field not found", name_node.begin()); - return true; + return false; } bool test_type_support( CurrentIdentifierState& identifier_state, - const std::string & parse_node_name, - const rosidl_message_type_support_t * type_supports) + std::unique_ptr< ParseNode >& n, + const rosidl_message_type_support_t * type_supports, + size_t & member_index, + size_t & array_index, + const rosidl_message_type_support_t *& type_support_intro) { - const rosidl_message_type_support_t * type_support_intro = + type_support_intro = get_type_support_introspection(type_supports); if (!type_support_intro) { return false; @@ -234,10 +310,12 @@ bool test_type_support( rosidl_typesupport_introspection_c__identifier) { ret = add_type_object( - identifier_state, parse_node_name, type_support_intro->data); + identifier_state, n, type_support_intro->data, + member_index, array_index); } else { ret = add_type_object( - identifier_state, parse_node_name, type_support_intro->data); + identifier_state, n, type_support_intro->data, + member_index, array_index); } return ret; @@ -325,12 +403,12 @@ struct identifier_processor */ - const ParseNode& name_node = n->left(); - std::string name = name_node.content(); + // const ParseNode& name_node = n->left(); + // std::string name = name_node.content(); + + // logError(DDSSQLFILTER, "identifiers add_member_access: " << name); - logError(DDSSQLFILTER, "identifiers add_member_access: " << name); - test_type_support(identifier_state, name, identifier_state.type_support); size_t member_index = 0; // const CompleteStructMemberSeq& members = complete.struct_type().member_seq(); @@ -348,22 +426,34 @@ struct identifier_processor // } // const TypeIdentifier& ti = members[member_index].common().member_type_id(); - bool has_index = n->children.size() > 1; + // bool has_index = n->children.size() > 1; size_t max_size = 0; size_t array_index = std::numeric_limits::max(); - // if (type_should_be_indexed(ti, identifier_state, max_size)) - { - // if (!has_index) - // { - // throw parse_error("field should have an index (i.e. [n])", n->left().end()); - // } - - // array_index = static_cast(std::stoul(n->right().left().content())); - // if (max_size <= array_index) - // { - // throw parse_error("index is greater than maximum size", n->right().end()); - // } - } + + bool is_array; + size_t array_size; + // try to get member_index, is_array, + // TODO. just return the members + + const rosidl_message_type_support_t * type_support_intro; + + + bool ret = test_type_support(identifier_state, n, type_support, + member_index, array_index, type_support_intro); + + // if (is_array) + // { + // if (!has_index) + // { + // throw parse_error("field should have an index (i.e. [n])", n->left().end()); + // } + + // array_index = static_cast(std::stoul(n->right().left().content())); + // if (array_size <= array_index) + // { + // throw parse_error("index is greater than maximum size", n->right().end()); + // } + // } // else // { // if (has_index) @@ -372,14 +462,17 @@ struct identifier_processor // } // } - identifier_state.access_path.emplace_back(DDSFilterField::FieldAccessor{ member_index, array_index }); + logError(DDSSQLFILTER, "DDSFilterField::FieldAccessor:" + << member_index << " " + << array_index << " "); + identifier_state.access_path.emplace_back(DDSFilterField::FieldAccessor{ member_index, array_index, type_support_intro }); } static DDSFilterValue::ValueKind get_value_kind( uint8_t type_id, const position& pos) { - logError(DDSSQLFILTER, "get_value_kind type_id:" << type_id); + logError(DDSSQLFILTER, "get_value_kind type_id:" << static_cast(type_id)); switch (type_id) { case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: @@ -400,6 +493,7 @@ struct identifier_processor return DDSFilterValue::ValueKind::SIGNED_INTEGER; case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_OCTET: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT8: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT16: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT32: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT64: @@ -443,6 +537,8 @@ struct identifier_processor // Reset parser state state.access_path.clear(); state.current_type = 0; + state.current_type_support = nullptr; + } else { diff --git a/common_content_filter/src/DDSFilterFactory.cpp b/common_content_filter/src/DDSFilterFactory.cpp index 575e822..6d513bf 100644 --- a/common_content_filter/src/DDSFilterFactory.cpp +++ b/common_content_filter/src/DDSFilterFactory.cpp @@ -151,6 +151,8 @@ static bool check_value_compatibility( } } + logError(DDSSQLFILTER, "check_value_compatibility return false ," + << static_cast(left) << " " << static_cast(right)); return false; } @@ -539,6 +541,7 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( auto node = parser::parse_filter_expression(filter_expression, type_support); if (node) { + logError(DDSSQLFILTER, "parser::parse_filter_expression success "); // auto type_id = TypeObjectFactory::get_instance()->get_type_identifier(type_name, true); // auto dyn_type = TypeObjectFactory::get_instance()->build_dynamic_type(type_name, type_id, type_object); DDSFilterExpression* expr = get_expression(); @@ -564,6 +567,7 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( } else { + logError(DDSSQLFILTER, "parser::parse_filter_expression failed "); ret = ReturnCode_t::RETCODE_BAD_PARAMETER; } } diff --git a/common_content_filter/src/DDSFilterField.cpp b/common_content_filter/src/DDSFilterField.cpp index bfae1aa..da886d5 100644 --- a/common_content_filter/src/DDSFilterField.cpp +++ b/common_content_filter/src/DDSFilterField.cpp @@ -27,6 +27,8 @@ // #include // #include +#include "rosidl_typesupport_introspection_cpp/field_types.hpp" + #include "DDSFilterPredicate.hpp" #include "DDSFilterValue.hpp" @@ -37,6 +39,45 @@ namespace fastdds { namespace dds { namespace DDSSQLFilter { + +template +bool +DDSFilterField::test_member( + const void * untype_members, + FieldAccessor& accessor, + const void *& data) +{ + const MembersType * members = static_cast(untype_members); + if (!members) { + return false; + } + + const auto member = members->members_ + accessor.member_index; + + logError(DDSSQLFILTER, "DDSFilterField::test_member " + << " accessor.member_index:" << accessor.member_index + << " accessor.array_index:" << accessor.array_index + + << " member member->name:" << member->name_ + << " member member->type_id_:" << static_cast(member->type_id_) + << " member member->offset_:" << member->offset_ + << " member member->is_array_:" << member->is_array_ + << " member member->array_size_:" << member->array_size_ + << " member member->is_upper_bound_:" << member->is_upper_bound_ + ); + + // data = data+member->offset_ + if (member->is_array_) { + data = member->get_function((void *)(data + member->offset_), accessor.array_index); + } else { + data = data + member->offset_; + } + + return true; +} + + + bool DDSFilterField::set_value( const void * data, size_t n) @@ -46,36 +87,49 @@ bool DDSFilterField::set_value( // uint32_t index = static_cast(access_path_[n].member_index); // auto member_id = data.get_member_id_at_index(index); bool last_step = access_path_.size() - 1 == n; + void * addr; logError(DDSSQLFILTER, "DDSFilterField::set_value " << "access_path_.size():" << access_path_.size() ); - for (auto & access_path : access_path_) { - logError(DDSSQLFILTER, "DDSFilterField::set_value " - << " access_path.member_index:" << access_path.member_index - << " access_path.array_index:" << access_path.array_index - ); - } + // for (auto & access_path : access_path_) { + // logError(DDSSQLFILTER, "DDSFilterField::set_value " + // << " access_path.member_index:" << access_path.member_index + // << " access_path.array_index:" << access_path.array_index + // ); + // } bool ret = false; - if (access_path_[n].array_index < std::numeric_limits::max()) + const void * data_updated = data; + const rosidl_message_type_support_t * type_support_intro = access_path_[n].type_support_intro; + if (type_support_intro->typesupport_identifier == + rosidl_typesupport_introspection_c__identifier) { - size_t array_index = access_path_[n].array_index; - + ret = test_member( + type_support_intro->data, access_path_[n], data_updated); + } else { + ret = test_member( + type_support_intro->data, access_path_[n], data_updated); } - else - { + + // if (access_path_[n].array_index < std::numeric_limits::max()) + // { + // size_t array_index = access_path_[n].array_index; + // // member + + // } + // else + // { if (last_step) { - ret = set_value(data, .0f); + ret = set_member(data_updated); } else { - const void * addr = data; // need to calculate the addr - ret = set_value(addr, n + 1); + ret = set_value(data_updated, n + 1); } - } + // } if (ret && last_step) { @@ -92,92 +146,92 @@ bool DDSFilterField::set_value( return ret; } -bool DDSFilterField::set_value( - const void * data, - float member_id) +bool DDSFilterField::set_member( + const void * data) { // using namespace eprosima_common::fastrtps::types; bool ret = true; // just a test, content_filtering_subscriber use float msg - float_value = *(float*)data; + // float_value = *(float*)data; - // try - // { - // switch (type_id_->_d()) - // { - // case TK_BOOLEAN: - // boolean_value = data->get_bool_value(member_id); - // break; - - // case TK_CHAR8: - // char_value = data->get_char8_value(member_id); - // break; - - // case TK_STRING8: - // case TI_STRING8_SMALL: - // case TI_STRING8_LARGE: - // string_value = data->get_string_value(member_id); - // break; - - // case TK_INT16: - // signed_integer_value = data->get_int16_value(member_id); - // break; - - // case TK_INT32: - // signed_integer_value = data->get_int32_value(member_id); - // break; - - // case TK_INT64: - // signed_integer_value = data->get_int64_value(member_id); - // break; - - // case TK_BYTE: - // unsigned_integer_value = data->get_uint8_value(member_id); - // break; - - // case TK_UINT16: - // unsigned_integer_value = data->get_uint16_value(member_id); - // break; - - // case TK_UINT32: - // unsigned_integer_value = data->get_uint32_value(member_id); - // break; - - // case TK_UINT64: - // unsigned_integer_value = data->get_uint64_value(member_id); - // break; - - // case TK_FLOAT32: - // float_value = data->get_float32_value(member_id); - // break; - - // case TK_FLOAT64: - // float_value = data->get_float64_value(member_id); - // break; - - // case TK_FLOAT128: - // float_value = data->get_float128_value(member_id); - // break; - - // case EK_COMPLETE: - // { - // uint32_t enum_value; - // ret = !!data->get_enum_value(enum_value, member_id); - // signed_integer_value = enum_value; - // break; - // } - - // default: - // ret = false; - // break; - // } - // } - // catch (...) - // { - // ret = false; - // } + logError(DDSSQLFILTER, "DDSFilterField::set_member " + << "type_id_:" << type_id_ + ); + + + try + { + switch (type_id_) + { + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: + // boolean_value = data->get_bool_value(member_id); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_CHAR: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: + // char_value = data->get_char8_value(member_id); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: + // string_value = data->get_string_value(member_id); + break; + + // case TK_INT16: + // signed_integer_value = data->get_int16_value(member_id); + // break; + + // case TK_INT32: + // signed_integer_value = data->get_int32_value(member_id); + // break; + + // case TK_INT64: + // signed_integer_value = data->get_int64_value(member_id); + // break; + + // case TK_BYTE: + // unsigned_integer_value = data->get_uint8_value(member_id); + // break; + + // case TK_UINT16: + // unsigned_integer_value = data->get_uint16_value(member_id); + // break; + + // case TK_UINT32: + // unsigned_integer_value = data->get_uint32_value(member_id); + // break; + + // case TK_UINT64: + // unsigned_integer_value = data->get_uint64_value(member_id); + // break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT8: + unsigned_integer_value = *(int8_t*)data; + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: + float_value = *(float*)data; + break; + + // case TK_FLOAT64: + // float_value = data->get_float64_value(member_id); + // break; + + // case TK_FLOAT128: + // float_value = data->get_float128_value(member_id); + // break; + + default: + ret = false; + break; + } + } + catch (...) + { + ret = false; + } return ret; } diff --git a/common_content_filter/src/DDSFilterField.hpp b/common_content_filter/src/DDSFilterField.hpp index d9e9166..2b24616 100644 --- a/common_content_filter/src/DDSFilterField.hpp +++ b/common_content_filter/src/DDSFilterField.hpp @@ -28,6 +28,12 @@ // #include // #include +#include "rosidl_typesupport_introspection_c/identifier.h" +#include "rosidl_typesupport_introspection_cpp/identifier.hpp" +#include "rosidl_typesupport_introspection_c/message_introspection.h" +#include "rosidl_typesupport_introspection_cpp/message_introspection.hpp" +#include "rosidl_typesupport_introspection_cpp/field_types.hpp" + #include "DDSFilterPredicate.hpp" #include "DDSFilterValue.hpp" @@ -57,6 +63,8 @@ class DDSFilterField final : public DDSFilterValue /// Element index for array / sequence members size_t array_index; + + const rosidl_message_type_support_t * type_support_intro; }; /** @@ -96,6 +104,14 @@ class DDSFilterField final : public DDSFilterValue has_value_ = false; } + + template + inline bool + test_member( + const void * untype_members, + FieldAccessor& accessor, + const void *& data); + /** * Perform the deserialization of the field represented by this DDSFilterField. * Will notify the predicates where this DDSFilterField is being used. @@ -137,9 +153,8 @@ class DDSFilterField final : public DDSFilterValue private: - bool set_value( - const void * data_value, - float member_id); + bool set_member( + const void * data_value); bool has_value_ = false; std::vector access_path_; diff --git a/common_content_filter/src/DDSFilterParameter.cpp b/common_content_filter/src/DDSFilterParameter.cpp index 3829721..715a4a1 100644 --- a/common_content_filter/src/DDSFilterParameter.cpp +++ b/common_content_filter/src/DDSFilterParameter.cpp @@ -20,6 +20,8 @@ #include "DDSFilterExpressionParser.hpp" +#include "Log.hpp" + namespace eprosima_common { namespace fastdds { namespace dds { @@ -29,8 +31,11 @@ bool DDSFilterParameter::set_value( const char* parameter) { auto node = parser::parse_literal_value(parameter); + if (!node) { + logError(DDSSQLFILTER, "PARSE ERROR: parser::parse_literal_value"); + return false; } diff --git a/common_content_filter/src/test.cpp b/common_content_filter/src/test.cpp index 2bcadcb..4002da4 100644 --- a/common_content_filter/src/test.cpp +++ b/common_content_filter/src/test.cpp @@ -166,22 +166,26 @@ create_common_content_filter( logInfo(DDSSQLFILTER, "create_common_content_filter options: " << options->filter_expression); - IContentFilter * filter_instance; + IContentFilter * filter_instance = nullptr; std::vector expression_parameters; for (size_t i = 0; i < options->expression_parameters.size; ++i) { expression_parameters.push_back(options->expression_parameters.data[i]); } - DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->create_content_filter( - "DDSSQL", // deprecated - "type_name", // deprecated - type_support, - options->filter_expression, - expression_parameters, - filter_instance); + try { + DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->create_content_filter( + "DDSSQL", // deprecated + "type_name", // deprecated + type_support, + options->filter_expression, + expression_parameters, + filter_instance); - logInfo(DDSSQLFILTER, "factory.create_content_filter ret: " << ret); + logInfo(DDSSQLFILTER, "factory.create_content_filter xx ret: " << ret); + } catch (const std::runtime_error& e) { + logInfo(DDSSQLFILTER, "failed to create_content_filter: " << e.what()); + } return filter_instance; } From 49e67481ef37385b12f7c98d180414bcc52e5095 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 4 Jul 2022 12:45:24 +0800 Subject: [PATCH 08/51] refactor Signed-off-by: Chen Lihui --- common_content_filter/CMakeLists.txt | 2 +- .../common_content_filter/{test.h => api.h} | 27 +- .../identifiers.hpp | 267 ++---------------- common_content_filter/src/Log.hpp | 1 + common_content_filter/src/api.cpp | 187 ++++++++++++ common_content_filter/src/test.cpp | 225 --------------- 6 files changed, 212 insertions(+), 497 deletions(-) rename common_content_filter/include/common_content_filter/{test.h => api.h} (66%) create mode 100644 common_content_filter/src/api.cpp delete mode 100644 common_content_filter/src/test.cpp diff --git a/common_content_filter/CMakeLists.txt b/common_content_filter/CMakeLists.txt index 83a0552..dacf35e 100644 --- a/common_content_filter/CMakeLists.txt +++ b/common_content_filter/CMakeLists.txt @@ -19,6 +19,7 @@ find_package(rosidl_typesupport_introspection_c REQUIRED) find_package(rosidl_typesupport_introspection_cpp REQUIRED) add_library(${PROJECT_NAME}_library SHARED + src/api.cpp src/DDSFilterCompoundCondition.cpp src/DDSFilterExpression.cpp src/DDSFilterExpressionParser.cpp @@ -27,7 +28,6 @@ add_library(${PROJECT_NAME}_library SHARED src/DDSFilterParameter.cpp src/DDSFilterPredicate.cpp src/DDSFilterValue.cpp - src/test.cpp ) set_target_properties(${PROJECT_NAME}_library diff --git a/common_content_filter/include/common_content_filter/test.h b/common_content_filter/include/common_content_filter/api.h similarity index 66% rename from common_content_filter/include/common_content_filter/test.h rename to common_content_filter/include/common_content_filter/api.h index 6d5406e..0b89cc8 100644 --- a/common_content_filter/include/common_content_filter/test.h +++ b/common_content_filter/include/common_content_filter/api.h @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef COMMON_CONTENT_FILTER__TEST_HPP_ -#define COMMON_CONTENT_FILTER__TEST_HPP_ +#ifndef COMMON_CONTENT_FILTER__API_HPP_ +#define COMMON_CONTENT_FILTER__API_HPP_ #include "common_content_filter/visibility_control.h" -#include "rosidl_runtime_c/message_type_support_struct.h" -#include "rmw/subscription_content_filter_options.h" +#include +#include #ifdef __cplusplus @@ -26,22 +26,6 @@ extern "C" { #endif -COMMON_CONTENT_FILTER_PUBLIC -void -test_func_c(); - -// COMMON_CONTENT_FILTER_PUBLIC -// void * -// create_common_content_filter_factory(); - -// COMMON_CONTENT_FILTER_PUBLIC -// void -// test_common_content_filter_factory(void *); - -// COMMON_CONTENT_FILTER_PUBLIC -// void -// destroy_common_content_filter_factory(void *); - COMMON_CONTENT_FILTER_PUBLIC void * create_common_content_filter( @@ -61,5 +45,4 @@ destroy_common_content_filter(void *); } #endif - -#endif // COMMON_CONTENT_FILTER__TEST_HPP_ +#endif // COMMON_CONTENT_FILTER__API_HPP_ diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp index 39d6406..5a2292f 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp @@ -65,140 +65,7 @@ get_type_support_introspection( } -template -void GetTypeIdentifier( - CurrentIdentifierState& identifier_state, - const std::string & parse_node_name, - const MembersType * members, uint32_t index) -{ - const auto member = members->members_ + index; - std::string name = member->name_; - - if (name == parse_node_name) { - logError(DDSSQLFILTER, "find the parse_node_name: " << parse_node_name - << " type_id:" << static_cast(member->type_id_) - << " member index:" << index - << " member member->offset_:" << member->offset_ - << " member member->is_array_:" << member->is_array_ - << " member member->array_size_:" << member->array_size_ - << " member member->is_upper_bound_:" << member->is_upper_bound_ - ); - // some important information should be saved in the identifier_state - identifier_state.current_type = member->type_id_; - - if (member->type_id_ == ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE) { - - // const rosidl_message_type_support_t * type_support_intro = - // get_type_support_introspection(member->members_); - // const MembersType * sub_members = - // static_cast(type_support_intro->data); - - identifier_state.current_type_support = member->members_; - } - - identifier_state.current_type_support = member->members_; - - } - - std::string type_name; - switch (member->type_id_) { - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: - { - type_name = "float"; - break; - } - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_DOUBLE: - { - type_name = "double"; - break; - } - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_LONG_DOUBLE: - { - type_name = "longdouble"; - break; - } - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_CHAR: - { - type_name = "char"; - break; - } - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: - { - type_name = "wchar"; - break; - } - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: - { - type_name = "bool"; - break; - } - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_OCTET: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT8: - { - type_name = "uint8_t"; - break; - } - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT8: - { - type_name = "int8_t"; - break; - } - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT16: - { - type_name = "uint16_t"; - break; - } - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT16: - { - type_name = "int16_t"; - break; - } - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT32: - { - type_name = "uint32_t"; - break; - } - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT32: - { - type_name = "int32_t"; - break; - } - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT64: - { - type_name = "uint64_t"; - break; - } - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT64: - { - type_name = "int64_t"; - break; - } - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: - { - uint32_t bound = member->string_upper_bound_ ? - static_cast(member->string_upper_bound_) : 255; - bool wide = - (member->type_id_ == ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING) ? - false : true; - - break; - } - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE: - { - const rosidl_message_type_support_t * type_support_intro = - get_type_support_introspection(member->members_); - const MembersType * sub_members = - static_cast(type_support_intro->data); - } - break; - default: - break; - } - - logError(DDSSQLFILTER, "GetTypeIdentifier name:" << name << " type_name:" << type_name); -} template inline bool @@ -272,10 +139,10 @@ add_type_object( if (member->type_id_ == ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE) { - // const rosidl_message_type_support_t * type_support_intro = + // const rosidl_message_type_support_t * type_support_introspection = // get_type_support_introspection(member->members_); // const MembersType * sub_members = - // static_cast(type_support_intro->data); + // static_cast(type_support_introspection->data); identifier_state.current_type_support = member->members_; } @@ -296,25 +163,25 @@ bool test_type_support( const rosidl_message_type_support_t * type_supports, size_t & member_index, size_t & array_index, - const rosidl_message_type_support_t *& type_support_intro) + const rosidl_message_type_support_t *& type_support_introspection) { - type_support_intro = + type_support_introspection = get_type_support_introspection(type_supports); - if (!type_support_intro) { + if (!type_support_introspection) { return false; } bool ret = false; - logError(DDSSQLFILTER, "test_type_support: " << type_support_intro->typesupport_identifier); - if (type_support_intro->typesupport_identifier == + logError(DDSSQLFILTER, "test_type_support: " << type_support_introspection->typesupport_identifier); + if (type_support_introspection->typesupport_identifier == rosidl_typesupport_introspection_c__identifier) { ret = add_type_object( - identifier_state, n, type_support_intro->data, + identifier_state, n, type_support_introspection->data, member_index, array_index); } else { ret = add_type_object( - identifier_state, n, type_support_intro->data, + identifier_state, n, type_support_introspection->data, member_index, array_index); } @@ -385,136 +252,56 @@ struct identifier_processor CurrentIdentifierState& identifier_state, const rosidl_message_type_support_t * type_support) { - // if (TK_STRUCTURE != complete._d()) - // { - // throw parse_error("trying to access field on a non-struct type", n->begin()); - // } - - /* - idl - msg1 - string data - - msg2 - string data - msg1 m1; - - msg2 topic message type, and use `m1.data = 'test'` - - */ - - // const ParseNode& name_node = n->left(); - // std::string name = name_node.content(); - - // logError(DDSSQLFILTER, "identifiers add_member_access: " << name); - - - size_t member_index = 0; - // const CompleteStructMemberSeq& members = complete.struct_type().member_seq(); - // for (member_index = 0; member_index < members.size(); ++member_index) - // { - // if (members[member_index].detail().name() == name) - // { - // break; - // } - // } - - // if (member_index == members.size()) - // { - // throw parse_error("field not found", name_node.begin()); - // } - - // const TypeIdentifier& ti = members[member_index].common().member_type_id(); - // bool has_index = n->children.size() > 1; size_t max_size = 0; size_t array_index = std::numeric_limits::max(); - bool is_array; size_t array_size; - // try to get member_index, is_array, - // TODO. just return the members - - const rosidl_message_type_support_t * type_support_intro; - + const rosidl_message_type_support_t * type_support_introspection; bool ret = test_type_support(identifier_state, n, type_support, - member_index, array_index, type_support_intro); - - // if (is_array) - // { - // if (!has_index) - // { - // throw parse_error("field should have an index (i.e. [n])", n->left().end()); - // } - - // array_index = static_cast(std::stoul(n->right().left().content())); - // if (array_size <= array_index) - // { - // throw parse_error("index is greater than maximum size", n->right().end()); - // } - // } - // else - // { - // if (has_index) - // { - // throw parse_error("field is not an array or sequence", n->right().begin()); - // } - // } - - logError(DDSSQLFILTER, "DDSFilterField::FieldAccessor:" - << member_index << " " - << array_index << " "); - identifier_state.access_path.emplace_back(DDSFilterField::FieldAccessor{ member_index, array_index, type_support_intro }); + member_index, array_index, type_support_introspection); + + identifier_state.access_path.emplace_back( + DDSFilterField::FieldAccessor{ member_index, array_index, type_support_introspection }); } static DDSFilterValue::ValueKind get_value_kind( uint8_t type_id, const position& pos) { - logError(DDSSQLFILTER, "get_value_kind type_id:" << static_cast(type_id)); switch (type_id) { case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: return DDSFilterValue::ValueKind::BOOLEAN; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_CHAR: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: return DDSFilterValue::ValueKind::CHAR; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: return DDSFilterValue::ValueKind::STRING; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT8: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT16: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT32: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT64: return DDSFilterValue::ValueKind::SIGNED_INTEGER; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_OCTET: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT8: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT16: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT32: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT64: return DDSFilterValue::ValueKind::UNSIGNED_INTEGER; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: return DDSFilterValue::ValueKind::FLOAT_FIELD; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_DOUBLE: return DDSFilterValue::ValueKind::DOUBLE_FIELD; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_LONG_DOUBLE: return DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: break; - } - - // throw parse_error("type is not primitive", pos); + throw parse_error("type is not primitive", pos); } template< typename ... States > @@ -523,12 +310,10 @@ struct identifier_processor CurrentIdentifierState& state, States&&... /*st*/) { - logError(DDSSQLFILTER, "identifiers transform name:" << n->content()); + // logDebug(DDSSQLFILTER, "identifiers transform node name:" << n->content()); if (n->is()) { - logError(DDSSQLFILTER, "identifiers transform n->is()"); - // Set data for fieldname node n->field_kind = get_value_kind(state.current_type, n->end()); n->field_access_path = state.access_path; @@ -538,31 +323,15 @@ struct identifier_processor state.access_path.clear(); state.current_type = 0; state.current_type_support = nullptr; - } else { if (0 == state.current_type) { - logError(DDSSQLFILTER, "identifiers transform 0 == state.current_type"); - add_member_access(n, state, state.type_support); } else { - logError(DDSSQLFILTER, "identifiers transform 0 != state.current_type"); - - // if (EK_COMPLETE != state.current_type->_d()) - // { - // throw parse_error("trying to access field on a non-complete type", n->begin()); - // } - - // const TypeObject* type_object = TypeObjectFactory::get_instance()->get_type_object(state.current_type); - // if (nullptr == type_object) - // { - // throw parse_error("could not find type object definition", n->begin()); - // } - add_member_access(n, state, state.current_type_support); } } diff --git a/common_content_filter/src/Log.hpp b/common_content_filter/src/Log.hpp index e0e8549..5503440 100644 --- a/common_content_filter/src/Log.hpp +++ b/common_content_filter/src/Log.hpp @@ -9,6 +9,7 @@ std::cout << "[" << #cat << "] " << log_ss_tmp__.str() << std::endl; \ } +#define logDebug common_content_filter_log_ #define logInfo common_content_filter_log_ #define logWarning common_content_filter_log_ #define logError common_content_filter_log_ diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp new file mode 100644 index 0000000..898325f --- /dev/null +++ b/common_content_filter/src/api.cpp @@ -0,0 +1,187 @@ +// Copyright 2022 Open Source Robotics Foundation, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "common_content_filter/api.h" + +#include +#include +#include + +#include "DDSFilterFactory.hpp" +#include "Log.hpp" + + +namespace common_content_filter { + +const int MAGIC = 0x333644; // 'C','F','T' +const char* FILTER_CLASS_NAME = "DDSSQL"; + +using DDSFilterFactory = eprosima_common::fastdds::dds::DDSSQLFilter::DDSFilterFactory; +using IContentFilter = eprosima_common::fastdds::dds::IContentFilter; + +DDSFilterFactory * +get_common_content_filter_factory() { + static DDSFilterFactory content_filter_factory; + return &content_filter_factory; +} + +class ContentFilterWrapper { +public: + ContentFilterWrapper( + const rosidl_message_type_support_t * type_support, + const std::string & filter_expression, + const std::vector & expression_parameters) + : type_support_(type_support), + filter_expression_(filter_expression), + expression_parameters_(expression_parameters) + { + logDebug(DDSSQLFILTER, "ContentFilterWrapper ctor : " << this); + + try { + std::lock_guard lock(mutex_); + DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->create_content_filter( + FILTER_CLASS_NAME, // deprecated + "", // deprecated + type_support_, + filter_expression_.c_str(), + expression_parameters_, + filter_instance_); + + logInfo(DDSSQLFILTER, "factory.create_content_filter xx ret: " << ret); + } catch (const std::runtime_error& e) { + logInfo(DDSSQLFILTER, "failed to create_content_filter: " << e.what()); + } + + } + + ~ContentFilterWrapper() { + std::lock_guard lock(mutex_); + DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->delete_content_filter( + FILTER_CLASS_NAME, + filter_instance_); + if (ret != DDSFilterFactory::RETCODE_OK) { + logError(DDSSQLFILTER, "Failed to delete content filter: " << ret); + } + + filter_instance_ = nullptr; + logDebug(DDSSQLFILTER, "ContentFilterWrapper dtor : " << this); + } + + bool evaluate(void * ros_data, bool serialized) { + std::lock_guard lock(mutex_); + if (serialized) { + // TODO. deserialize the ros_data + } + + bool ret = true; + if (filter_instance_) { + ret = filter_instance_->evaluate(ros_data); + } + logDebug(DDSSQLFILTER, "evaluate ret: " << ret); + return ret; + } + + bool set_filter_expression() { + + } + + bool get_filter_expression() { + + } + + IContentFilter * filter_instance() { + return filter_instance_; + } + + int magic() { + return magic_; + } + +private: + const int magic_ = MAGIC; + IContentFilter * filter_instance_ = nullptr; + const rosidl_message_type_support_t * type_support_; + std::string filter_expression_; + std::vector expression_parameters_; + std::mutex mutex_; +}; + +} // namespace common_content_filter + + +#ifdef __cplusplus +extern "C" +{ +#endif + +void * +create_common_content_filter( + const rosidl_message_type_support_t * type_support, + rmw_subscription_content_filter_options_t * options +) { + if (!type_support || !options) { + logError(DDSSQLFILTER, "Invalid arguments"); + return NULL; + } + + std::vector expression_parameters; + for (size_t i = 0; i < options->expression_parameters.size; ++i) { + expression_parameters.push_back(options->expression_parameters.data[i]); + } + + common_content_filter::ContentFilterWrapper * filter_instance_wrapper = nullptr; + try { + filter_instance_wrapper = + new common_content_filter::ContentFilterWrapper( + type_support, options->filter_expression, expression_parameters); + } catch (const std::runtime_error& e) { + logInfo(DDSSQLFILTER, "Failed to create content filter: " << e.what()); + } + + return filter_instance_wrapper; +} + +bool +common_content_filter_evaluate(void * instance, void * ros_data, bool serialized) { + + common_content_filter::ContentFilterWrapper * content_filter_wrapper = + static_cast(instance); + if (!content_filter_wrapper || content_filter_wrapper->magic() != common_content_filter::MAGIC ) { + logError(DDSSQLFILTER, "Invalid arguments"); + return false; + } + + bool ret = content_filter_wrapper->evaluate(ros_data, serialized); + return ret; +} + +// TODO +// set_content_filter +// get_content_filter + +void +destroy_common_content_filter(void * instance) { + common_content_filter::ContentFilterWrapper * content_filter_wrapper = + static_cast(instance); + if (!content_filter_wrapper || content_filter_wrapper->magic() != common_content_filter::MAGIC ) { + logError(DDSSQLFILTER, "Invalid arguments"); + return; + } + + delete content_filter_wrapper; +} + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/common_content_filter/src/test.cpp b/common_content_filter/src/test.cpp deleted file mode 100644 index 4002da4..0000000 --- a/common_content_filter/src/test.cpp +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright 2022 Open Source Robotics Foundation, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "common_content_filter/test.h" - -#include "rmw/subscription_content_filter_options.h" - -#include // for printf -#include // for abort - -#include - -#include "DDSFilterGrammar.hpp" -#include "DDSFilterExpressionParser.hpp" -#include "DDSFilterFactory.hpp" -#include "Log.hpp" - - -// #include "rosidl_typesupport_introspection_c/identifier.h" -// #include "rosidl_typesupport_introspection_cpp/identifier.hpp" -// #include "rosidl_typesupport_introspection_c/message_introspection.h" -// #include "rosidl_typesupport_introspection_cpp/message_introspection.hpp" -// #include "rosidl_typesupport_introspection_cpp/field_types.hpp" - - - -using namespace eprosima_common::fastdds::dds; -using namespace eprosima_common::fastdds::dds::DDSSQLFilter; -using namespace eprosima_common::fastdds::dds::DDSSQLFilter::parser; - - -namespace common_content_filter { - -const int MAGIC = 0x333644; // cft - -void -test_func_cpp() -{ - printf("test_func_cpp\n"); - - struct sign s; - printf("test_func_cpp, %p\n", (void*)&s); - logError(DDSSQLFILTER, "ERROR " << MAGIC); - - std::string filter_expression = "id > 0"; - // std::string filter_expression = "id > 0 or a.b = 'def' and name=%0"; - // std::string filter_expression = "id=%0"; - // std::string filter_expression = "name[0]=%0"; - - logInfo(DDSSQLFILTER, "filter_expression: " << filter_expression); - - // std::unique_ptr node = parse_filter_expression(filter_expression.c_str(), nullptr); - - DDSFilterFactory factory; - IContentFilter * filter_instance; - - DDSFilterFactory::ReturnCode_t ret = factory.create_content_filter( - "filter_class_name", - "type_name", - nullptr, - filter_expression.c_str(), - {"'test'"}, - filter_instance); - - logInfo(DDSSQLFILTER, "factory.create_content_filter ret: " << ret); - - - - ret = factory.delete_content_filter( - "filter_class_name", - filter_instance); - - logInfo(DDSSQLFILTER, "factory.delete_content_filter ret: " << ret); - -} - -// class ContentFilterFactory { -// public: -// ContentFilterFactory() -// : magic_(MAGIC) -// { -// printf("ContentFilterFactory ctor : %p\n", (void*)this); -// } -// ~ContentFilterFactory() { -// printf("ContentFilterFactory dtor : %p\n", (void*)this); -// } - -// int magic() { -// return magic_; -// } -// void test() { -// printf("to call test in ContentFilterFactory : %p\n", (void*)this); -// } - -// private: -// int magic_; -// }; - -class ContentFilter { -public: - ContentFilter() - : magic_(MAGIC) - { - printf("ContentFilter ctor : %p\n", (void*)this); - }; - ~ContentFilter() { - printf("ContentFilter dtor : %p\n", (void*)this); - }; - - int magic() { - return magic_; - } - void test() { - printf("to call test in ContentFilter : %p\n", (void*)this); - } - -private: - int magic_; -}; - -} // namespace common_content_filter - - -#ifdef __cplusplus -extern "C" -{ -#endif - -void -test_func_c() { - return common_content_filter::test_func_cpp(); -} - - -// TODO. deprecated, factory not exported outside. use a static instance in this library. -eprosima_common::fastdds::dds::DDSSQLFilter::DDSFilterFactory * -get_common_content_filter_factory() { - // TODO. only one factory or one context one factory - static eprosima_common::fastdds::dds::DDSSQLFilter::DDSFilterFactory content_filter_factory; - return &content_filter_factory; -} - -void * -create_common_content_filter( - const rosidl_message_type_support_t * type_support, - rmw_subscription_content_filter_options_t * options -) { - - if (!type_support || !options) { - return NULL; - } - - - - - logInfo(DDSSQLFILTER, "create_common_content_filter options: " << options->filter_expression); - - IContentFilter * filter_instance = nullptr; - - std::vector expression_parameters; - for (size_t i = 0; i < options->expression_parameters.size; ++i) { - expression_parameters.push_back(options->expression_parameters.data[i]); - } - - try { - DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->create_content_filter( - "DDSSQL", // deprecated - "type_name", // deprecated - type_support, - options->filter_expression, - expression_parameters, - filter_instance); - - logInfo(DDSSQLFILTER, "factory.create_content_filter xx ret: " << ret); - } catch (const std::runtime_error& e) { - logInfo(DDSSQLFILTER, "failed to create_content_filter: " << e.what()); - } - - return filter_instance; -} - -bool -common_content_filter_evaluate(void * instance, void * ros_data, bool serialized) { - eprosima_common::fastdds::dds::IContentFilter * content_filter = - static_cast(instance); - if (serialized) { - // TODO. deserialize the ros_data - } - - bool ret = content_filter->evaluate(ros_data); - return ret; -} - -void -destroy_common_content_filter(void * instance) { - eprosima_common::fastdds::dds::IContentFilter * content_filter = - static_cast(instance); - // if (!content_filter || content_filter->magic() != common_content_filter::MAGIC ) { - // printf("the instance is invalid\n"); - // return; - // } - // delete content_filter; - - DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->delete_content_filter( - "DDSSQL", - content_filter); - - logInfo(DDSSQLFILTER, "factory.delete_content_filter ret: " << ret); - -} - -#ifdef __cplusplus -} -#endif \ No newline at end of file From 58da6effe6b7c0789a5654eb851ba2bbb82bd974 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 4 Jul 2022 13:14:11 +0800 Subject: [PATCH 09/51] re 2 Signed-off-by: Chen Lihui --- .../identifiers.hpp | 170 ++++-------------- 1 file changed, 30 insertions(+), 140 deletions(-) diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp index 5a2292f..6389610 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp @@ -33,7 +33,7 @@ struct CurrentIdentifierState }; -const rosidl_message_type_support_t * +static const rosidl_message_type_support_t * get_type_support_introspection( const rosidl_message_type_support_t * type_supports) { @@ -68,41 +68,28 @@ get_type_support_introspection( template -inline bool -add_type_object( +inline void +add_access_path( CurrentIdentifierState& identifier_state, std::unique_ptr< ParseNode >& n, - const void * untype_members, - size_t & member_index, - size_t & array_index) + const rosidl_message_type_support_t * type_support_introspection) { - const MembersType * members = static_cast(untype_members); + const MembersType * members = static_cast(type_support_introspection->data); if (!members) { - return false; + throw std::runtime_error("The members in the type support introspection is invalid."); } + size_t member_index = 0; + size_t array_index = std::numeric_limits::max(); + const ParseNode& name_node = n->left(); std::string parse_node_name = name_node.content(); for (uint32_t i = 0; i < members->member_count_; ++i) { - // GetTypeIdentifier(identifier_state, parse_node_name, members, i); - const auto member = members->members_ + i; - std::string name = member->name_; - - if (name == parse_node_name) { - - member_index = i; - - logError(DDSSQLFILTER, "find the parse_node_name: " << parse_node_name - << " type_id:" << static_cast(member->type_id_) - << " member index:" << i - << " member member->offset_:" << member->offset_ - << " member member->is_array_:" << member->is_array_ - << " member member->array_size_:" << member->array_size_ - << " member member->is_upper_bound_:" << member->is_upper_bound_ - ); + if (member->name_ == parse_node_name) { + member_index = i; bool has_index = n->children.size() > 1; if (member->is_array_) { @@ -113,16 +100,12 @@ add_type_object( array_index = static_cast(std::stoul(n->right().left().content())); - - if (member->array_size_ && !member->is_upper_bound_) { if (member->array_size_ <= array_index) { throw parse_error("index is greater than maximum size", n->right().end()); } } - - } else { @@ -132,138 +115,45 @@ add_type_object( } } - - // some important information should be saved in the identifier_state identifier_state.current_type = member->type_id_; - if (member->type_id_ == ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE) { - - // const rosidl_message_type_support_t * type_support_introspection = - // get_type_support_introspection(member->members_); - // const MembersType * sub_members = - // static_cast(type_support_introspection->data); - identifier_state.current_type_support = member->members_; } + identifier_state.access_path.emplace_back( + DDSFilterField::FieldAccessor{ member_index, array_index, type_support_introspection }); - - return true; + return; } } throw parse_error("field not found", name_node.begin()); - - return false; -} - -bool test_type_support( - CurrentIdentifierState& identifier_state, - std::unique_ptr< ParseNode >& n, - const rosidl_message_type_support_t * type_supports, - size_t & member_index, - size_t & array_index, - const rosidl_message_type_support_t *& type_support_introspection) -{ - type_support_introspection = - get_type_support_introspection(type_supports); - if (!type_support_introspection) { - return false; - } - - bool ret = false; - logError(DDSSQLFILTER, "test_type_support: " << type_support_introspection->typesupport_identifier); - if (type_support_introspection->typesupport_identifier == - rosidl_typesupport_introspection_c__identifier) - { - ret = add_type_object( - identifier_state, n, type_support_introspection->data, - member_index, array_index); - } else { - ret = add_type_object( - identifier_state, n, type_support_introspection->data, - member_index, array_index); - } - - return ret; } - - - struct identifier_processor : parse_tree::apply< identifier_processor > { - template - static constexpr size_t process_bound( - _TSize bound) - { - return 0 == bound ? std::numeric_limits::max() : static_cast(bound); - } - - template - static size_t process_bounds( - const _BSeq& bound_seq) - { - if (1 != bound_seq.size()) - { - return 0; - } - - return process_bound(bound_seq[0]); - } - - // static bool type_should_be_indexed( - // CurrentIdentifierState& identifier_state, - // const TypeIdentifier*& out_type, - // size_t& max_size) - // { - // max_size = 0; - - // switch (identifier_state.current_type_support) - // { - // case TI_PLAIN_ARRAY_SMALL: - // out_type = ti.array_sdefn().element_identifier(); - // max_size = process_bounds(ti.array_sdefn().array_bound_seq()); - // return true; - - // case TI_PLAIN_ARRAY_LARGE: - // out_type = ti.array_ldefn().element_identifier(); - // max_size = process_bounds(ti.array_ldefn().array_bound_seq()); - // return true; - - // case TI_PLAIN_SEQUENCE_SMALL: - // out_type = ti.seq_sdefn().element_identifier(); - // max_size = process_bound(ti.seq_sdefn().bound()); - // return true; - - // case TI_PLAIN_SEQUENCE_LARGE: - // out_type = ti.seq_ldefn().element_identifier(); - // max_size = process_bound(ti.seq_ldefn().bound()); - // return true; - // } - - // out_type = &ti; - // return false; - // } static void add_member_access( std::unique_ptr< ParseNode >& n, CurrentIdentifierState& identifier_state, - const rosidl_message_type_support_t * type_support) + const rosidl_message_type_support_t * type_supports) { - size_t member_index = 0; - size_t max_size = 0; - size_t array_index = std::numeric_limits::max(); - bool is_array; - size_t array_size; - const rosidl_message_type_support_t * type_support_introspection; - - bool ret = test_type_support(identifier_state, n, type_support, - member_index, array_index, type_support_introspection); - - identifier_state.access_path.emplace_back( - DDSFilterField::FieldAccessor{ member_index, array_index, type_support_introspection }); + const rosidl_message_type_support_t * type_support_introspection = + get_type_support_introspection(type_supports); + if (!type_support_introspection) { + throw std::runtime_error("failed to get type support introspection"); + } + + if (type_support_introspection->typesupport_identifier == + rosidl_typesupport_introspection_c__identifier) + { + add_access_path( + identifier_state, n, type_support_introspection); + } else { + add_access_path( + identifier_state, n, type_support_introspection); + } } static DDSFilterValue::ValueKind get_value_kind( From 32be4b7173d39dbad7c7fd717af8a89c2b460f22 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 4 Jul 2022 15:19:25 +0800 Subject: [PATCH 10/51] refactor 3 Signed-off-by: Chen Lihui --- .../src/DDSFilterExpression.cpp | 34 +-- .../src/DDSFilterExpression.hpp | 4 +- .../identifiers.hpp | 7 +- .../literal_values.hpp | 13 +- .../src/DDSFilterFactory.cpp | 71 +++--- .../src/DDSFilterFactory.hpp | 2 +- common_content_filter/src/DDSFilterField.cpp | 217 +++++++++--------- common_content_filter/src/DDSFilterField.hpp | 17 +- .../src/DDSFilterParseNode.hpp | 2 +- common_content_filter/src/api.cpp | 47 ++-- 10 files changed, 182 insertions(+), 232 deletions(-) diff --git a/common_content_filter/src/DDSFilterExpression.cpp b/common_content_filter/src/DDSFilterExpression.cpp index 68957c3..4761dfe 100644 --- a/common_content_filter/src/DDSFilterExpression.cpp +++ b/common_content_filter/src/DDSFilterExpression.cpp @@ -45,27 +45,7 @@ namespace DDSSQLFilter { bool DDSFilterExpression::evaluate( const void * payload) const { - // static_cast(sample_info); - // static_cast(reader_guid); - - // using namespace eprosima_common::fastrtps::types; - // using namespace eprosima_common::fastcdr; - - // dyn_data_->clear_all_values(); - // try - // { - // FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); - // Cdr deser(fastbuffer, eprosima_common::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima_common::fastcdr::Cdr::DDS_CDR); - // deser.read_encapsulation(); - // dyn_data_->deserialize(deser); - // } - // catch (eprosima_common::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - // { - // return false; - // } - - - logInfo(DDSSQLFILTER, "DDSFilterExpression::evaluate fields size:" << fields.size()); + // logDebug(DDSSQLFILTER, "DDSFilterExpression::evaluate fields size:" << fields.size()); root->reset(); for (auto it = fields.begin(); @@ -90,12 +70,12 @@ void DDSFilterExpression::clear() root.reset(); } -void DDSFilterExpression::set_type( - const void * type) -{ - // dyn_type_ = type; - // dyn_data_.reset(eprosima_common::fastrtps::types::DynamicDataFactory::get_instance()->create_data(type)); -} +// void DDSFilterExpression::set_type( +// const void * type) +// { +// // dyn_type_ = type; +// // dyn_data_.reset(eprosima_common::fastrtps::types::DynamicDataFactory::get_instance()->create_data(type)); +// } } // namespace DDSSQLFilter } // namespace dds diff --git a/common_content_filter/src/DDSFilterExpression.hpp b/common_content_filter/src/DDSFilterExpression.hpp index 238b627..39169b0 100644 --- a/common_content_filter/src/DDSFilterExpression.hpp +++ b/common_content_filter/src/DDSFilterExpression.hpp @@ -61,8 +61,8 @@ class DDSFilterExpression final : public IContentFilter * * @param [in] type The DynamicType to assign. */ - void set_type( - const void * type); + // void set_type( + // const void * type); /// The root condition of the expression tree. std::unique_ptr root; diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp index 6389610..3a8ab66 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp @@ -22,11 +22,11 @@ struct CurrentIdentifierState { - // TODO. const rosidl_message_type_support_t * type_support, const rosidl_message_type_support_t * type_support; // ros2 primitive type const rosidl_message_type_support_t * current_type_support; + uint8_t current_type; std::vector access_path; @@ -64,9 +64,6 @@ get_type_support_introspection( return type_support; } - - - template inline void add_access_path( @@ -76,7 +73,7 @@ add_access_path( { const MembersType * members = static_cast(type_support_introspection->data); if (!members) { - throw std::runtime_error("The members in the type support introspection is invalid."); + throw std::runtime_error("The data in the type support introspection is invalid."); } size_t member_index = 0; diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/literal_values.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/literal_values.hpp index db1b3c1..cde58ee 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/literal_values.hpp +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/literal_values.hpp @@ -27,22 +27,18 @@ struct literal_value_processor std::unique_ptr< ParseNode >& n, States&&... /*st*/) { - logError(DDSSQLFILTER, "PARSE literal_value_processor begin"); - n->value.reset(new DDSFilterValue()); if (n->is()) { n->value->kind = DDSFilterValue::ValueKind::BOOLEAN; n->value->boolean_value = true; - logError(DDSSQLFILTER, "PARSE literal_value_processor true"); } else if (n->is()) { n->value->kind = DDSFilterValue::ValueKind::BOOLEAN; n->value->boolean_value = false; - logError(DDSSQLFILTER, "PARSE literal_value_processor false"); } else if (n->is() || n->is()) { @@ -51,13 +47,11 @@ struct literal_value_processor { n->value->kind = DDSFilterValue::ValueKind::SIGNED_INTEGER; n->value->signed_integer_value = std::stoll(n->content(), nullptr, 0); - logError(DDSSQLFILTER, "PARSE literal_value_processor integer " << n->value->signed_integer_value); } else { n->value->kind = DDSFilterValue::ValueKind::UNSIGNED_INTEGER; n->value->unsigned_integer_value = std::stoull(n->content(), nullptr, 0); - logError(DDSSQLFILTER, "PARSE literal_value_processor integer " << n->value->unsigned_integer_value); } } else if (n->is()) @@ -65,14 +59,12 @@ struct literal_value_processor n->value->kind = DDSFilterValue::ValueKind::FLOAT_CONST; n->value->float_value = std::stold(n->content()); - logError(DDSSQLFILTER, "PARSE literal_value_processor float " << n->value->float_value); } else if (n->is()) { n->value->kind = DDSFilterValue::ValueKind::CHAR; n->value->char_value = n->m_begin.data[1]; - logError(DDSSQLFILTER, "PARSE literal_value_processor char " << n->value->char_value); } else if (n->is()) { @@ -84,10 +76,7 @@ struct literal_value_processor throw parse_error("string constant has more than 255 characters", n->end()); } n->value->kind = DDSFilterValue::ValueKind::STRING; - memcpy(n->value->string_value, content_node.m_begin.data, str_len); - // n->value->string_value.assign(content_node.m_begin.data, str_len); - - logError(DDSSQLFILTER, "PARSE literal_value_processor string " << n->value->string_value); + strncpy(n->value->string_value, content_node.m_begin.data, str_len); } n->children.clear(); diff --git a/common_content_filter/src/DDSFilterFactory.cpp b/common_content_filter/src/DDSFilterFactory.cpp index 6d513bf..0a93294 100644 --- a/common_content_filter/src/DDSFilterFactory.cpp +++ b/common_content_filter/src/DDSFilterFactory.cpp @@ -59,6 +59,9 @@ static IContentFilterFactory::ReturnCode_t transform_enum( uint8_t type, const std::string& string_value) { + static_cast(value); + static_cast(type); + static_cast(string_value); // const char* str_value = string_value.c_str(); // auto type_obj = eprosima_common::fastrtps::types::TypeObjectFactory::get_instance()->get_type_object(type); // for (const auto& enum_value : type_obj->complete().enumerated_type().literal_seq()) @@ -446,15 +449,8 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree(state, condition, node); } -DDSFilterFactory::DDSFilterFactory() -{ - logError(DDSSQLFILTER, "DDSFilterFactory::DDSFilterFactory " << this); -} - DDSFilterFactory::~DDSFilterFactory() { - logError(DDSSQLFILTER, "DDSFilterFactory::~DDSFilterFactory " << this); - auto& pool = expression_pool_.collection(); for (DDSFilterExpression* item : pool) { @@ -472,7 +468,7 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( IContentFilter*& filter_instance) { - // static_cast(type_support); + static_cast(type_name); ReturnCode_t ret = ReturnCode_t::RETCODE_UNSUPPORTED; @@ -530,47 +526,38 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( } else { - // auto type_object = TypeObjectFactory::get_instance()->get_type_object(type_name, true); - // if (!type_object) - // { - // logError(DDSSQLFILTER, "No TypeObject found for type " << type_name); - // ret = ReturnCode_t::RETCODE_BAD_PARAMETER; - // } - // else + auto node = parser::parse_filter_expression(filter_expression, type_support); + if (node) { - auto node = parser::parse_filter_expression(filter_expression, type_support); - if (node) + // logDebug(DDSSQLFILTER, "parser::parse_filter_expression success "); + // auto type_id = TypeObjectFactory::get_instance()->get_type_identifier(type_name, true); + // auto dyn_type = TypeObjectFactory::get_instance()->build_dynamic_type(type_name, type_id, type_object); + DDSFilterExpression* expr = get_expression(); + // TODO. set `const rosidl_message_type_support_t * type_support` from subscription in the rcl. + // expr->set_type(dyn_type); + size_t n_params = filter_parameters.size(); + expr->parameters.reserve(n_params); + while (expr->parameters.size() < n_params) { - logError(DDSSQLFILTER, "parser::parse_filter_expression success "); - // auto type_id = TypeObjectFactory::get_instance()->get_type_identifier(type_name, true); - // auto dyn_type = TypeObjectFactory::get_instance()->build_dynamic_type(type_name, type_id, type_object); - DDSFilterExpression* expr = get_expression(); - // TODO. set `const rosidl_message_type_support_t * type_support` from subscription in the rcl. - // expr->set_type(dyn_type); - size_t n_params = filter_parameters.size(); - expr->parameters.reserve(n_params); - while (expr->parameters.size() < n_params) - { - expr->parameters.emplace_back(); - } - ExpressionParsingState state{ nullptr, filter_parameters, expr }; - ret = convert_tree(state, expr->root, *(node->children[0])); - if (ReturnCode_t::RETCODE_OK == ret) - { - delete_content_filter(filter_class_name, filter_instance); - filter_instance = expr; - } - else - { - delete_content_filter(filter_class_name, expr); - } + expr->parameters.emplace_back(); + } + ExpressionParsingState state{ nullptr, filter_parameters, expr }; + ret = convert_tree(state, expr->root, *(node->children[0])); + if (ReturnCode_t::RETCODE_OK == ret) + { + delete_content_filter(filter_class_name, filter_instance); + filter_instance = expr; } else { - logError(DDSSQLFILTER, "parser::parse_filter_expression failed "); - ret = ReturnCode_t::RETCODE_BAD_PARAMETER; + delete_content_filter(filter_class_name, expr); } } + else + { + logError(DDSSQLFILTER, "parser::parse_filter_expression failed "); + ret = ReturnCode_t::RETCODE_BAD_PARAMETER; + } } return ret; diff --git a/common_content_filter/src/DDSFilterFactory.hpp b/common_content_filter/src/DDSFilterFactory.hpp index f212f9c..73baf9d 100644 --- a/common_content_filter/src/DDSFilterFactory.hpp +++ b/common_content_filter/src/DDSFilterFactory.hpp @@ -46,7 +46,7 @@ class DDSFilterFactory final : public IContentFilterFactory { public: - DDSFilterFactory(); + ~DDSFilterFactory(); ReturnCode_t create_content_filter( diff --git a/common_content_filter/src/DDSFilterField.cpp b/common_content_filter/src/DDSFilterField.cpp index da886d5..3b63b12 100644 --- a/common_content_filter/src/DDSFilterField.cpp +++ b/common_content_filter/src/DDSFilterField.cpp @@ -34,6 +34,8 @@ #include "Log.hpp" + + namespace eprosima_common { namespace fastdds { namespace dds { @@ -41,95 +43,84 @@ namespace DDSSQLFilter { template -bool -DDSFilterField::test_member( +void +DDSFilterField::get_msg_data_address( const void * untype_members, FieldAccessor& accessor, const void *& data) { const MembersType * members = static_cast(untype_members); if (!members) { - return false; + throw std::runtime_error("The data in the type support introspection is invalid."); } const auto member = members->members_ + accessor.member_index; + // logDebug(DDSSQLFILTER, "DDSFilterField::get_msg_data_address " + // << " accessor.member_index:" << accessor.member_index + // << " accessor.array_index:" << accessor.array_index + // << " member member->name:" << member->name_ + // << " member member->type_id_:" << static_cast(member->type_id_) + // << " member member->offset_:" << member->offset_ + // << " member member->is_array_:" << member->is_array_ + // << " member member->array_size_:" << member->array_size_ + // << " member member->is_upper_bound_:" << member->is_upper_bound_ + // ); + + uint64_t addr = reinterpret_cast(data); + if (member->is_array_) { + size_t array_size = member->array_size_; + if (array_size == 0) { + array_size = member->size_function( + reinterpret_cast(addr + member->offset_)); + } - logError(DDSSQLFILTER, "DDSFilterField::test_member " - << " accessor.member_index:" << accessor.member_index - << " accessor.array_index:" << accessor.array_index - - << " member member->name:" << member->name_ - << " member member->type_id_:" << static_cast(member->type_id_) - << " member member->offset_:" << member->offset_ - << " member member->is_array_:" << member->is_array_ - << " member member->array_size_:" << member->array_size_ - << " member member->is_upper_bound_:" << member->is_upper_bound_ - ); + if (accessor.array_index >= array_size) { + throw std::runtime_error("The array index should be less than array size."); + } - // data = data+member->offset_ - if (member->is_array_) { - data = member->get_function((void *)(data + member->offset_), accessor.array_index); + data = member->get_function( + reinterpret_cast(addr + member->offset_), accessor.array_index); } else { - data = data + member->offset_; + data = reinterpret_cast(addr + member->offset_); } - - return true; } - - bool DDSFilterField::set_value( const void * data, size_t n) { - // using namespace eprosima_common::fastrtps::types; - - // uint32_t index = static_cast(access_path_[n].member_index); - // auto member_id = data.get_member_id_at_index(index); bool last_step = access_path_.size() - 1 == n; - void * addr; - - logError(DDSSQLFILTER, "DDSFilterField::set_value " - << "access_path_.size():" << access_path_.size() - ); - - // for (auto & access_path : access_path_) { - // logError(DDSSQLFILTER, "DDSFilterField::set_value " - // << " access_path.member_index:" << access_path.member_index - // << " access_path.array_index:" << access_path.array_index - // ); - // } bool ret = false; + const void * addr = data; + bool is_c_type_support; - const void * data_updated = data; - const rosidl_message_type_support_t * type_support_intro = access_path_[n].type_support_intro; - if (type_support_intro->typesupport_identifier == + // logDebug( + // DDSSQLFILTER, + // "DDSFilterField::set_value " << "access_path size:" << access_path_.size() + // ); + + const rosidl_message_type_support_t * type_support_introspection = access_path_[n].type_support_intro; + if (type_support_introspection->typesupport_identifier == rosidl_typesupport_introspection_c__identifier) { - ret = test_member( - type_support_intro->data, access_path_[n], data_updated); + is_c_type_support = true; + get_msg_data_address( + type_support_introspection->data, access_path_[n], addr); + } else { - ret = test_member( - type_support_intro->data, access_path_[n], data_updated); + is_c_type_support = false; + get_msg_data_address( + type_support_introspection->data, access_path_[n], addr); } - // if (access_path_[n].array_index < std::numeric_limits::max()) - // { - // size_t array_index = access_path_[n].array_index; - // // member - - // } - // else - // { - if (last_step) - { - ret = set_member(data_updated); - } - else - { - ret = set_value(data_updated, n + 1); - } - // } + if (last_step) + { + ret = set_member(addr, is_c_type_support); + } + else + { + ret = set_value(addr, n + 1); + } if (ret && last_step) { @@ -147,82 +138,84 @@ bool DDSFilterField::set_value( } bool DDSFilterField::set_member( - const void * data) + const void * data, + bool is_c_type_support) { - // using namespace eprosima_common::fastrtps::types; - bool ret = true; - - // just a test, content_filtering_subscriber use float msg - // float_value = *(float*)data; - - logError(DDSSQLFILTER, "DDSFilterField::set_member " - << "type_id_:" << type_id_ - ); - + // logDebug( + // DDSSQLFILTER, + // "DDSFilterField::set_member " << "type_id_:" << (uint32_t)type_id_; + // ); try { switch (type_id_) { - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: - // boolean_value = data->get_bool_value(member_id); + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: + float_value = *(float*)data; break; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_CHAR: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: - // char_value = data->get_char8_value(member_id); + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_DOUBLE: + float_value = *(double*)data; break; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: - // string_value = data->get_string_value(member_id); + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_LONG_DOUBLE: + float_value = *(long double*)data; break; - // case TK_INT16: - // signed_integer_value = data->get_int16_value(member_id); - // break; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_CHAR: + char_value = *(char*)data; + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: + boolean_value = *(bool*)data; + break; - // case TK_INT32: - // signed_integer_value = data->get_int32_value(member_id); - // break; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_OCTET: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT8: + unsigned_integer_value = *(uint8_t*)data; + break; - // case TK_INT64: - // signed_integer_value = data->get_int64_value(member_id); - // break; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT8: + signed_integer_value = *(int8_t*)data; + break; - // case TK_BYTE: - // unsigned_integer_value = data->get_uint8_value(member_id); - // break; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT16: + unsigned_integer_value = *(uint16_t*)data; + break; - // case TK_UINT16: - // unsigned_integer_value = data->get_uint16_value(member_id); - // break; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT16: + signed_integer_value = *(int16_t*)data; + break; - // case TK_UINT32: - // unsigned_integer_value = data->get_uint32_value(member_id); - // break; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT32: + unsigned_integer_value = *(uint32_t*)data; + break; - // case TK_UINT64: - // unsigned_integer_value = data->get_uint64_value(member_id); - // break; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT32: + signed_integer_value = *(int32_t*)data; + break; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT8: - unsigned_integer_value = *(int8_t*)data; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT64: + unsigned_integer_value = *(uint64_t*)data; break; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: - float_value = *(float*)data; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT64: + signed_integer_value = *(int64_t*)data; break; - // case TK_FLOAT64: - // float_value = data->get_float64_value(member_id); - // break; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: - // case TK_FLOAT128: - // float_value = data->get_float128_value(member_id); - // break; + if (is_c_type_support) { + strncpy(string_value, (char*)data, sizeof(string_value)); + } else { + auto string = reinterpret_cast(data); + strncpy(string_value, (char*)string->c_str(), sizeof(string_value)); + } + break; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: default: ret = false; break; diff --git a/common_content_filter/src/DDSFilterField.hpp b/common_content_filter/src/DDSFilterField.hpp index 2b24616..8f6d2b2 100644 --- a/common_content_filter/src/DDSFilterField.hpp +++ b/common_content_filter/src/DDSFilterField.hpp @@ -105,13 +105,6 @@ class DDSFilterField final : public DDSFilterValue } - template - inline bool - test_member( - const void * untype_members, - FieldAccessor& accessor, - const void *& data); - /** * Perform the deserialization of the field represented by this DDSFilterField. * Will notify the predicates where this DDSFilterField is being used. @@ -153,8 +146,16 @@ class DDSFilterField final : public DDSFilterValue private: + template + void + get_msg_data_address( + const void * untype_members, + FieldAccessor& accessor, + const void *& data); + bool set_member( - const void * data_value); + const void * data_value, + bool is_c_type_support); bool has_value_ = false; std::vector access_path_; diff --git a/common_content_filter/src/DDSFilterParseNode.hpp b/common_content_filter/src/DDSFilterParseNode.hpp index 51168c8..300c074 100644 --- a/common_content_filter/src/DDSFilterParseNode.hpp +++ b/common_content_filter/src/DDSFilterParseNode.hpp @@ -51,7 +51,7 @@ struct ParseNode : parse_tree::basic_node< ParseNode > uint8_t type_id = 0; // When the node is a parameter, it will hold the parameter index - int32_t parameter_index = 0; + size_t parameter_index = 0; const ParseNode& left() const { diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index 898325f..96f50b5 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -24,7 +24,7 @@ namespace common_content_filter { -const int MAGIC = 0x333644; // 'C','F','T' +const int MAGIC = 0x434654; // 'C','F','T' const char* FILTER_CLASS_NAME = "DDSSQL"; using DDSFilterFactory = eprosima_common::fastdds::dds::DDSSQLFilter::DDSFilterFactory; @@ -46,23 +46,20 @@ class ContentFilterWrapper { filter_expression_(filter_expression), expression_parameters_(expression_parameters) { - logDebug(DDSSQLFILTER, "ContentFilterWrapper ctor : " << this); - - try { - std::lock_guard lock(mutex_); - DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->create_content_filter( - FILTER_CLASS_NAME, // deprecated - "", // deprecated - type_support_, - filter_expression_.c_str(), - expression_parameters_, - filter_instance_); - - logInfo(DDSSQLFILTER, "factory.create_content_filter xx ret: " << ret); - } catch (const std::runtime_error& e) { - logInfo(DDSSQLFILTER, "failed to create_content_filter: " << e.what()); - } + // logDebug(DDSSQLFILTER, "ContentFilterWrapper ctor : " << this); + std::lock_guard lock(mutex_); + DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->create_content_filter( + FILTER_CLASS_NAME, // deprecated + "", // deprecated + type_support_, + filter_expression_.c_str(), + expression_parameters_, + filter_instance_); + if (ret != DDSFilterFactory::RETCODE_OK) { + logError(DDSSQLFILTER, "create_content_filter ret: " << ret); + throw std::runtime_error("Failed to create content filter instance."); + } } ~ContentFilterWrapper() { @@ -75,7 +72,7 @@ class ContentFilterWrapper { } filter_instance_ = nullptr; - logDebug(DDSSQLFILTER, "ContentFilterWrapper dtor : " << this); + // logDebug(DDSSQLFILTER, "ContentFilterWrapper dtor : " << this); } bool evaluate(void * ros_data, bool serialized) { @@ -88,16 +85,16 @@ class ContentFilterWrapper { if (filter_instance_) { ret = filter_instance_->evaluate(ros_data); } - logDebug(DDSSQLFILTER, "evaluate ret: " << ret); + // logDebug(DDSSQLFILTER, "evaluate ret: " << ret); return ret; } bool set_filter_expression() { - + return false; } bool get_filter_expression() { - + return false; } IContentFilter * filter_instance() { @@ -162,7 +159,13 @@ common_content_filter_evaluate(void * instance, void * ros_data, bool serialized return false; } - bool ret = content_filter_wrapper->evaluate(ros_data, serialized); + bool ret = false; + try { + ret = content_filter_wrapper->evaluate(ros_data, serialized); + } catch (const std::runtime_error& e) { + logError(DDSSQLFILTER, "Failed to evaluate: " << e.what()); + } + return ret; } From 0051c2b4f9d47c5768199eaea50be7399cca2bec Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 4 Jul 2022 15:30:06 +0800 Subject: [PATCH 11/51] use strncpy for string Signed-off-by: Chen Lihui --- common_content_filter/src/DDSFilterValue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common_content_filter/src/DDSFilterValue.cpp b/common_content_filter/src/DDSFilterValue.cpp index ca77b92..586557b 100644 --- a/common_content_filter/src/DDSFilterValue.cpp +++ b/common_content_filter/src/DDSFilterValue.cpp @@ -178,7 +178,7 @@ void DDSFilterValue::copy_from( break; case ValueKind::STRING: - memcpy(string_value, other.string_value, sizeof(string_value)); + strncpy(string_value, other.string_value, sizeof(string_value)); break; default: From 887d577df7af95f752175c0619181a2e7dd986e8 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 4 Jul 2022 16:11:33 +0800 Subject: [PATCH 12/51] r4 Signed-off-by: Chen Lihui --- common_content_filter/src/DDSFilterField.cpp | 179 +++++++++---------- common_content_filter/src/DDSFilterField.hpp | 2 +- 2 files changed, 87 insertions(+), 94 deletions(-) diff --git a/common_content_filter/src/DDSFilterField.cpp b/common_content_filter/src/DDSFilterField.cpp index 3b63b12..2c093d8 100644 --- a/common_content_filter/src/DDSFilterField.cpp +++ b/common_content_filter/src/DDSFilterField.cpp @@ -43,7 +43,7 @@ namespace DDSSQLFilter { template -void +bool DDSFilterField::get_msg_data_address( const void * untype_members, FieldAccessor& accessor, @@ -51,7 +51,7 @@ DDSFilterField::get_msg_data_address( { const MembersType * members = static_cast(untype_members); if (!members) { - throw std::runtime_error("The data in the type support introspection is invalid."); + return false; } const auto member = members->members_ + accessor.member_index; @@ -75,7 +75,7 @@ DDSFilterField::get_msg_data_address( } if (accessor.array_index >= array_size) { - throw std::runtime_error("The array index should be less than array size."); + return false; } data = member->get_function( @@ -83,6 +83,8 @@ DDSFilterField::get_msg_data_address( } else { data = reinterpret_cast(addr + member->offset_); } + + return true; } bool DDSFilterField::set_value( @@ -91,7 +93,6 @@ bool DDSFilterField::set_value( { bool last_step = access_path_.size() - 1 == n; bool ret = false; - const void * addr = data; bool is_c_type_support; // logDebug( @@ -104,26 +105,20 @@ bool DDSFilterField::set_value( rosidl_typesupport_introspection_c__identifier) { is_c_type_support = true; - get_msg_data_address( - type_support_introspection->data, access_path_[n], addr); + ret = get_msg_data_address( + type_support_introspection->data, access_path_[n], data); } else { is_c_type_support = false; - get_msg_data_address( - type_support_introspection->data, access_path_[n], addr); + ret = get_msg_data_address( + type_support_introspection->data, access_path_[n], data); } - if (last_step) - { - ret = set_member(addr, is_c_type_support); - } - else + if (ret) { - ret = set_value(addr, n + 1); - } + if (last_step) { + ret = set_member(data, is_c_type_support); - if (ret && last_step) - { has_value_ = true; value_has_changed(); @@ -132,6 +127,11 @@ bool DDSFilterField::set_value( { parent->value_has_changed(); } + } + else + { + ret = set_value(data, n + 1); + } } return ret; @@ -147,83 +147,76 @@ bool DDSFilterField::set_member( // "DDSFilterField::set_member " << "type_id_:" << (uint32_t)type_id_; // ); - try - { - switch (type_id_) - { - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: - float_value = *(float*)data; - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_DOUBLE: - float_value = *(double*)data; - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_LONG_DOUBLE: - float_value = *(long double*)data; - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_CHAR: - char_value = *(char*)data; - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: - boolean_value = *(bool*)data; - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_OCTET: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT8: - unsigned_integer_value = *(uint8_t*)data; - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT8: - signed_integer_value = *(int8_t*)data; - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT16: - unsigned_integer_value = *(uint16_t*)data; - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT16: - signed_integer_value = *(int16_t*)data; - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT32: - unsigned_integer_value = *(uint32_t*)data; - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT32: - signed_integer_value = *(int32_t*)data; - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT64: - unsigned_integer_value = *(uint64_t*)data; - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT64: - signed_integer_value = *(int64_t*)data; - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: - - if (is_c_type_support) { - strncpy(string_value, (char*)data, sizeof(string_value)); - } else { - auto string = reinterpret_cast(data); - strncpy(string_value, (char*)string->c_str(), sizeof(string_value)); - } - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: - default: - ret = false; - break; - } - } - catch (...) + switch (type_id_) { - ret = false; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: + float_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_DOUBLE: + float_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_LONG_DOUBLE: + float_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_CHAR: + char_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: + boolean_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_OCTET: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT8: + unsigned_integer_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT8: + signed_integer_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT16: + unsigned_integer_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT16: + signed_integer_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT32: + unsigned_integer_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT32: + signed_integer_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT64: + unsigned_integer_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT64: + signed_integer_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: + + if (is_c_type_support) { + strncpy(string_value, reinterpret_cast(data), sizeof(string_value)); + } else { + auto string = reinterpret_cast(data); + strncpy(string_value, (char*)string->c_str(), sizeof(string_value)); + } + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: + default: + ret = false; + break; } return ret; diff --git a/common_content_filter/src/DDSFilterField.hpp b/common_content_filter/src/DDSFilterField.hpp index 8f6d2b2..63411cb 100644 --- a/common_content_filter/src/DDSFilterField.hpp +++ b/common_content_filter/src/DDSFilterField.hpp @@ -147,7 +147,7 @@ class DDSFilterField final : public DDSFilterValue private: template - void + bool get_msg_data_address( const void * untype_members, FieldAccessor& accessor, From 8e386110c0c6f75078ac6f3706b5aa5cc514d5b1 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 4 Jul 2022 16:41:42 +0800 Subject: [PATCH 13/51] r5 Signed-off-by: Chen Lihui --- .../identifiers.hpp | 168 +++++++++--------- .../src/DDSFilterFactory.cpp | 19 +- .../src/DDSFilterFactory.hpp | 2 +- common_content_filter/src/IContentFilter.hpp | 25 +-- .../src/IContentFilterFactory.hpp | 15 +- 5 files changed, 95 insertions(+), 134 deletions(-) diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp index 3a8ab66..d11c4f9 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp @@ -24,7 +24,6 @@ struct CurrentIdentifierState { const rosidl_message_type_support_t * type_support; - // ros2 primitive type const rosidl_message_type_support_t * current_type_support; uint8_t current_type; @@ -32,112 +31,111 @@ struct CurrentIdentifierState std::vector access_path; }; - -static const rosidl_message_type_support_t * -get_type_support_introspection( - const rosidl_message_type_support_t * type_supports) +struct identifier_processor + : parse_tree::apply< identifier_processor > { - const rosidl_message_type_support_t * type_support = - get_message_typesupport_handle( - type_supports, rosidl_typesupport_introspection_c__identifier); - if (nullptr == type_support) { - rcutils_error_string_t prev_error_string = rcutils_get_error_string(); - rcutils_reset_error(); - - type_support = - get_message_typesupport_handle( - type_supports, - rosidl_typesupport_introspection_cpp::typesupport_identifier); - if (nullptr == type_support) { - rcutils_error_string_t error_string = rcutils_get_error_string(); - rcutils_reset_error(); - RMW_SET_ERROR_MSG_WITH_FORMAT_STRING( - "Type support not from this implementation. Got:\n" - " %s\n" - " %s\n" - "while fetching it", - prev_error_string.str, error_string.str); - return nullptr; - } - } - return type_support; -} - -template -inline void -add_access_path( - CurrentIdentifierState& identifier_state, - std::unique_ptr< ParseNode >& n, - const rosidl_message_type_support_t * type_support_introspection) -{ - const MembersType * members = static_cast(type_support_introspection->data); - if (!members) { - throw std::runtime_error("The data in the type support introspection is invalid."); - } + static const rosidl_message_type_support_t * + get_type_support_introspection( + const rosidl_message_type_support_t * type_support) + { + const rosidl_message_type_support_t * type_support_introspection = + get_message_typesupport_handle( + type_support, rosidl_typesupport_introspection_c__identifier); + if (nullptr == type_support_introspection) { + rcutils_error_string_t prev_error_string = rcutils_get_error_string(); + rcutils_reset_error(); + + type_support_introspection = + get_message_typesupport_handle( + type_support, + rosidl_typesupport_introspection_cpp::typesupport_identifier); + if (nullptr == type_support_introspection) { + rcutils_error_string_t error_string = rcutils_get_error_string(); + rcutils_reset_error(); + RMW_SET_ERROR_MSG_WITH_FORMAT_STRING( + "Type support not from this implementation. Got:\n" + " %s\n" + " %s\n" + "while fetching it", + prev_error_string.str, error_string.str); + return nullptr; + } + } - size_t member_index = 0; - size_t array_index = std::numeric_limits::max(); + return type_support_introspection; + } - const ParseNode& name_node = n->left(); - std::string parse_node_name = name_node.content(); + template + static void + add_access_path( + CurrentIdentifierState& identifier_state, + std::unique_ptr< ParseNode >& n, + const rosidl_message_type_support_t * type_support_introspection) + { + const MembersType * members = static_cast(type_support_introspection->data); + if (!members) { + throw std::runtime_error("The data in the type support introspection is invalid."); + } - for (uint32_t i = 0; i < members->member_count_; ++i) { - const auto member = members->members_ + i; + size_t member_index = 0; + size_t array_index = std::numeric_limits::max(); - if (member->name_ == parse_node_name) { - member_index = i; - bool has_index = n->children.size() > 1; - if (member->is_array_) - { - if (!has_index) - { - throw parse_error("field should have an index (i.e. [n])", n->left().end()); - } + const ParseNode& name_node = n->left(); + std::string parse_node_name = name_node.content(); - array_index = static_cast(std::stoul(n->right().left().content())); + for (uint32_t i = 0; i < members->member_count_; ++i) { + const auto member = members->members_ + i; - if (member->array_size_ && !member->is_upper_bound_) { - if (member->array_size_ <= array_index) - { - throw parse_error("index is greater than maximum size", n->right().end()); - } + if (member->name_ == parse_node_name) { + member_index = i; + bool has_index = n->children.size() > 1; + if (member->is_array_) + { + if (!has_index) + { + throw parse_error("field should have an index (i.e. [n])", n->left().end()); + } + + array_index = static_cast(std::stoul(n->right().left().content())); + + if (member->array_size_ && !member->is_upper_bound_) { + if (member->array_size_ <= array_index) + { + throw parse_error("index is greater than maximum size", n->right().end()); + } + } } - } - else - { - if (has_index) + else { - throw parse_error("field is not an array or sequence", n->right().begin()); + if (has_index) + { + throw parse_error("field is not an array or sequence", n->right().begin()); + } } - } - identifier_state.current_type = member->type_id_; + identifier_state.current_type = member->type_id_; - if (member->type_id_ == ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE) { - identifier_state.current_type_support = member->members_; - } + if (member->type_id_ == ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE) { + identifier_state.current_type_support = member->members_; + } - identifier_state.access_path.emplace_back( - DDSFilterField::FieldAccessor{ member_index, array_index, type_support_introspection }); + identifier_state.access_path.emplace_back( + DDSFilterField::FieldAccessor{ member_index, array_index, type_support_introspection }); - return; + return; + } + } + throw parse_error("field not found", name_node.begin()); } - } - throw parse_error("field not found", name_node.begin()); -} - -struct identifier_processor - : parse_tree::apply< identifier_processor > -{ static void add_member_access( std::unique_ptr< ParseNode >& n, CurrentIdentifierState& identifier_state, - const rosidl_message_type_support_t * type_supports) + const rosidl_message_type_support_t * type_support) { const rosidl_message_type_support_t * type_support_introspection = - get_type_support_introspection(type_supports); + get_type_support_introspection(type_support); if (!type_support_introspection) { throw std::runtime_error("failed to get type support introspection"); } diff --git a/common_content_filter/src/DDSFilterFactory.cpp b/common_content_filter/src/DDSFilterFactory.cpp index 0a93294..4165ba6 100644 --- a/common_content_filter/src/DDSFilterFactory.cpp +++ b/common_content_filter/src/DDSFilterFactory.cpp @@ -62,17 +62,7 @@ static IContentFilterFactory::ReturnCode_t transform_enum( static_cast(value); static_cast(type); static_cast(string_value); - // const char* str_value = string_value.c_str(); - // auto type_obj = eprosima_common::fastrtps::types::TypeObjectFactory::get_instance()->get_type_object(type); - // for (const auto& enum_value : type_obj->complete().enumerated_type().literal_seq()) - // { - // if (enum_value.detail().name() == str_value) - // { - // value->kind = DDSFilterValue::ValueKind::SIGNED_INTEGER; - // value->signed_integer_value = enum_value.common().value(); - // return IContentFilterFactory::ReturnCode_t::RETCODE_OK; - // } - // } + // TODO. after enum supported in the rosidl return IContentFilterFactory::ReturnCode_t::RETCODE_BAD_PARAMETER; } @@ -154,8 +144,6 @@ static bool check_value_compatibility( } } - logError(DDSSQLFILTER, "check_value_compatibility return false ," - << static_cast(left) << " " << static_cast(right)); return false; } @@ -530,11 +518,7 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( if (node) { // logDebug(DDSSQLFILTER, "parser::parse_filter_expression success "); - // auto type_id = TypeObjectFactory::get_instance()->get_type_identifier(type_name, true); - // auto dyn_type = TypeObjectFactory::get_instance()->build_dynamic_type(type_name, type_id, type_object); DDSFilterExpression* expr = get_expression(); - // TODO. set `const rosidl_message_type_support_t * type_support` from subscription in the rcl. - // expr->set_type(dyn_type); size_t n_params = filter_parameters.size(); expr->parameters.reserve(n_params); while (expr->parameters.size() < n_params) @@ -555,7 +539,6 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( } else { - logError(DDSSQLFILTER, "parser::parse_filter_expression failed "); ret = ReturnCode_t::RETCODE_BAD_PARAMETER; } } diff --git a/common_content_filter/src/DDSFilterFactory.hpp b/common_content_filter/src/DDSFilterFactory.hpp index 73baf9d..7ff93d3 100644 --- a/common_content_filter/src/DDSFilterFactory.hpp +++ b/common_content_filter/src/DDSFilterFactory.hpp @@ -52,7 +52,7 @@ class DDSFilterFactory final : public IContentFilterFactory ReturnCode_t create_content_filter( const char* filter_class_name, const char* type_name, - const rosidl_message_type_support_t* data_type, + const rosidl_message_type_support_t* type_support, const char* filter_expression, const ParameterSeq& filter_parameters, IContentFilter*& filter_instance) override; diff --git a/common_content_filter/src/IContentFilter.hpp b/common_content_filter/src/IContentFilter.hpp index f99c62d..855eccb 100644 --- a/common_content_filter/src/IContentFilter.hpp +++ b/common_content_filter/src/IContentFilter.hpp @@ -39,31 +39,12 @@ namespace dds { */ struct IContentFilter { - // using SerializedPayload = eprosima_common::fastrtps::rtps::SerializedPayload_t; - // using GUID_t = fastrtps::rtps::GUID_t; - - /** - * Selected information from the cache change that is passed to the content filter object on - * payload evaluation. - */ - // struct FilterSampleInfo - // { - // using SampleIdentity = eprosima_common::fastrtps::rtps::SampleIdentity; - - // /// Identity of the sample being filtered. - // SampleIdentity sample_identity; - // /// Identity of a sample related to the one being filtered. - // SampleIdentity related_sample_identity; - // }; - /** - * Evaluate if a serialized payload should be accepted by certain reader. + * Evaluate if a de-serialized payload should be accepted by certain reader. * - * @param [in] payload The serialized payload of the sample being evaluated. - * @param [in] sample_info The accompanying sample information. - * @param [in] reader_guid The GUID of the reader for which the filter is being evaluated. + * @param [in] payload The de-serialized payload of the sample being evaluated. * - * @return whether the sample should be accepted for the specified reader. + * @return whether the sample should be accepted. */ virtual bool evaluate( const void * payload) const = 0; diff --git a/common_content_filter/src/IContentFilterFactory.hpp b/common_content_filter/src/IContentFilterFactory.hpp index 503cbad..74121c6 100644 --- a/common_content_filter/src/IContentFilterFactory.hpp +++ b/common_content_filter/src/IContentFilterFactory.hpp @@ -42,14 +42,13 @@ namespace dds { */ struct IContentFilterFactory { - enum ReturnCode_t { - RETCODE_OK, - RETCODE_BAD_PARAMETER, - RETCODE_UNSUPPORTED, - }; + enum ReturnCode_t { + RETCODE_OK, + RETCODE_BAD_PARAMETER, + RETCODE_UNSUPPORTED, + }; using ParameterSeq = std::vector; - // using TypeDescriptor = eprosima_common::fastrtps::types::TypeDescriptor; /** * Create or update an IContentFilter instance. @@ -57,7 +56,7 @@ struct IContentFilterFactory * @param [in] filter_class_name Filter class name for which the factory is being called. * Allows using the same factory for different filter classes. * @param [in] type_name Type name of the topic being filtered. - * @param [in] data_type Type support object of the topic being filtered. + * @param [in] type_support Type support of the topic data being filtered. * @param [in] filter_expression Content filter expression. * May be nullptr when updating the parameters of a filter instance. * @param [in] filter_parameters Values to set for the filter parameters (%n on the filter expression). @@ -78,7 +77,7 @@ struct IContentFilterFactory virtual ReturnCode_t create_content_filter( const char* filter_class_name, const char* type_name, - const rosidl_message_type_support_t* data_type, + const rosidl_message_type_support_t* type_support, const char* filter_expression, const ParameterSeq& filter_parameters, IContentFilter*& filter_instance) = 0; From b868a03e776fe738f91a5ac9f99e076569b96c35 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 4 Jul 2022 17:07:14 +0800 Subject: [PATCH 14/51] update define macro Signed-off-by: Chen Lihui --- .../src/DDSFilterCondition.hpp | 6 +-- .../src/DDSFilterConditionState.hpp | 6 +-- .../src/DDSFilterEmptyExpression.hpp | 6 +-- .../src/DDSFilterExpression.cpp | 16 -------- .../src/DDSFilterExpression.hpp | 39 ++----------------- .../src/DDSFilterExpressionParser.cpp | 14 ++----- .../src/DDSFilterExpressionParser.hpp | 13 ++----- .../src/DDSFilterFactory.cpp | 9 +---- .../src/DDSFilterFactory.hpp | 13 ++----- common_content_filter/src/DDSFilterField.cpp | 12 +----- common_content_filter/src/DDSFilterField.hpp | 17 +++----- .../src/DDSFilterGrammar.hpp | 6 +-- .../src/DDSFilterParameter.hpp | 6 +-- .../src/DDSFilterParseNode.hpp | 12 ++---- .../src/DDSFilterPredicate.hpp | 6 +-- common_content_filter/src/DDSFilterValue.hpp | 8 ++-- common_content_filter/src/IContentFilter.hpp | 16 ++------ .../src/IContentFilterFactory.hpp | 6 +-- common_content_filter/src/Log.hpp | 6 +++ common_content_filter/src/ObjectPool.hpp | 6 +-- 20 files changed, 61 insertions(+), 162 deletions(-) diff --git a/common_content_filter/src/DDSFilterCondition.hpp b/common_content_filter/src/DDSFilterCondition.hpp index 13474bc..784755f 100644 --- a/common_content_filter/src/DDSFilterCondition.hpp +++ b/common_content_filter/src/DDSFilterCondition.hpp @@ -16,8 +16,8 @@ * @file DDSFilterCondition.hpp */ -#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCONDITION_HPP_ -#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCONDITION_HPP_ +#ifndef COMMON_CONTENT_FILTER__DDSFILTERCONDITION_HPP_ +#define COMMON_CONTENT_FILTER__DDSFILTERCONDITION_HPP_ #include "DDSFilterConditionState.hpp" @@ -132,4 +132,4 @@ class DDSFilterCondition } // namespace fastdds } // namespace eprosima_common -#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCONDITION_HPP_ +#endif // COMMON_CONTENT_FILTER__DDSFILTERCONDITION_HPP_ diff --git a/common_content_filter/src/DDSFilterConditionState.hpp b/common_content_filter/src/DDSFilterConditionState.hpp index 0ea3307..c48ba09 100644 --- a/common_content_filter/src/DDSFilterConditionState.hpp +++ b/common_content_filter/src/DDSFilterConditionState.hpp @@ -16,8 +16,8 @@ * @file DDSFilterConditionState.hpp */ -#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCONDITIONSTATE_HPP_ -#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCONDITIONSTATE_HPP_ +#ifndef COMMON_CONTENT_FILTER__DDSFILTERCONDITIONSTATE_HPP_ +#define COMMON_CONTENT_FILTER__DDSFILTERCONDITIONSTATE_HPP_ namespace eprosima_common { namespace fastdds { @@ -44,4 +44,4 @@ enum class DDSFilterConditionState : char } // namespace fastdds } // namespace eprosima_common -#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCONDITIONSTATE_HPP_ +#endif // COMMON_CONTENT_FILTER__DDSFILTERCONDITIONSTATE_HPP_ diff --git a/common_content_filter/src/DDSFilterEmptyExpression.hpp b/common_content_filter/src/DDSFilterEmptyExpression.hpp index ca6883d..d34c3df 100644 --- a/common_content_filter/src/DDSFilterEmptyExpression.hpp +++ b/common_content_filter/src/DDSFilterEmptyExpression.hpp @@ -16,8 +16,8 @@ * @file DDSFilterEmptyExpression.hpp */ -#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREMPTYEXPRESSION_HPP_ -#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREMPTYEXPRESSION_HPP_ +#ifndef COMMON_CONTENT_FILTER__DDSFILTEREMPTYEXPRESSION_HPP_ +#define COMMON_CONTENT_FILTER__DDSFILTEREMPTYEXPRESSION_HPP_ #include "IContentFilter.hpp" @@ -49,4 +49,4 @@ class DDSFilterEmptyExpression final : public IContentFilter } // namespace fastdds } // namespace eprosima_common -#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREMPTYEXPRESSION_HPP_ +#endif // COMMON_CONTENT_FILTER__DDSFILTEREMPTYEXPRESSION_HPP_ diff --git a/common_content_filter/src/DDSFilterExpression.cpp b/common_content_filter/src/DDSFilterExpression.cpp index 4761dfe..22d3326 100644 --- a/common_content_filter/src/DDSFilterExpression.cpp +++ b/common_content_filter/src/DDSFilterExpression.cpp @@ -23,15 +23,7 @@ #include #include -// #include -// #include -// #include -// #include -// #include -// #include - #include "DDSFilterCondition.hpp" - #include "DDSFilterField.hpp" #include "DDSFilterParameter.hpp" @@ -63,19 +55,11 @@ bool DDSFilterExpression::evaluate( void DDSFilterExpression::clear() { - // dyn_data_.reset(); - // dyn_type_.reset(); parameters.clear(); fields.clear(); root.reset(); } -// void DDSFilterExpression::set_type( -// const void * type) -// { -// // dyn_type_ = type; -// // dyn_data_.reset(eprosima_common::fastrtps::types::DynamicDataFactory::get_instance()->create_data(type)); -// } } // namespace DDSSQLFilter } // namespace dds diff --git a/common_content_filter/src/DDSFilterExpression.hpp b/common_content_filter/src/DDSFilterExpression.hpp index 39169b0..df692a2 100644 --- a/common_content_filter/src/DDSFilterExpression.hpp +++ b/common_content_filter/src/DDSFilterExpression.hpp @@ -16,19 +16,14 @@ * @file DDSFilterExpression.hpp */ -#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREXPRESSION_HPP_ -#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREXPRESSION_HPP_ +#ifndef COMMON_CONTENT_FILTER__DDSFILTEREXPRESSION_HPP_ +#define COMMON_CONTENT_FILTER__DDSFILTEREXPRESSION_HPP_ #include #include #include #include -// #include -// #include -// #include -// #include - #include "IContentFilter.hpp" #include "DDSFilterCondition.hpp" @@ -56,40 +51,12 @@ class DDSFilterExpression final : public IContentFilter */ void clear(); - /** - * Set the DynamicType to be used when evaluating this expression. - * - * @param [in] type The DynamicType to assign. - */ - // void set_type( - // const void * type); - /// The root condition of the expression tree. std::unique_ptr root; /// The fields referenced by this expression. std::map> fields; /// The parameters referenced by this expression. std::vector> parameters; - -private: - - // class DynDataDeleter - // { - - // public: - - // void operator ()( - // eprosima_common::fastrtps::types::DynamicData* ptr) - // { - // eprosima_common::fastrtps::types::DynamicDataFactory::get_instance()->delete_data(ptr); - // } - - // }; - - /// The Dynamic type used to deserialize the payloads - // eprosima_common::fastrtps::types::DynamicType_ptr dyn_type_; - /// The Dynamic data used to deserialize the payloads - // std::unique_ptr dyn_data_; }; } // namespace DDSSQLFilter @@ -97,4 +64,4 @@ class DDSFilterExpression final : public IContentFilter } // namespace fastdds } // namespace eprosima_common -#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREXPRESSION_HPP_ +#endif // COMMON_CONTENT_FILTER__DDSFILTEREXPRESSION_HPP_ diff --git a/common_content_filter/src/DDSFilterExpressionParser.cpp b/common_content_filter/src/DDSFilterExpressionParser.cpp index 2b232d0..0e199b3 100644 --- a/common_content_filter/src/DDSFilterExpressionParser.cpp +++ b/common_content_filter/src/DDSFilterExpressionParser.cpp @@ -20,14 +20,7 @@ #include -#include "Log.hpp" - -// #include -// #include -// #include - - -// identifiers.hpp need this headers +// header files needed by identifiers.hpp #include "rmw/error_handling.h" #include "rosidl_typesupport_introspection_c/identifier.h" #include "rosidl_typesupport_introspection_cpp/identifier.hpp" @@ -35,16 +28,16 @@ #include "rosidl_typesupport_introspection_cpp/message_introspection.hpp" #include "rosidl_typesupport_introspection_cpp/field_types.hpp" - #include "pegtl.hpp" #include "pegtl/contrib/parse_tree.hpp" #include "DDSFilterGrammar.hpp" #include "DDSFilterParseNode.hpp" - #include "DDSFilterValue.hpp" #include "DDSFilterField.hpp" +#include "Log.hpp" + namespace eprosima_common { namespace fastdds { namespace dds { @@ -52,7 +45,6 @@ namespace DDSSQLFilter { namespace parser { using namespace tao::TAO_PEGTL_NAMESPACE; -// using namespace eprosima_common::fastrtps::types; #include "DDSFilterExpressionParserImpl/rearrange.hpp" #include "DDSFilterExpressionParserImpl/literal_values.hpp" diff --git a/common_content_filter/src/DDSFilterExpressionParser.hpp b/common_content_filter/src/DDSFilterExpressionParser.hpp index a520da9..7f6fe81 100644 --- a/common_content_filter/src/DDSFilterExpressionParser.hpp +++ b/common_content_filter/src/DDSFilterExpressionParser.hpp @@ -16,13 +16,11 @@ * @file DDSFilterExpressionParser.hpp */ -#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREXPRESSIONPARSER_HPP_ -#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREXPRESSIONPARSER_HPP_ +#ifndef COMMON_CONTENT_FILTER__DDSFILTEREXPRESSIONPARSER_HPP_ +#define COMMON_CONTENT_FILTER__DDSFILTEREXPRESSIONPARSER_HPP_ #include -// #include - #include "DDSFilterParseNode.hpp" #include "rosidl_runtime_c/message_type_support_struct.h" @@ -37,14 +35,11 @@ namespace parser { * Performs parsing of a string containing a DDS-SQL filter expression. * * @param[in] expression The string to parse. - * @param[in] type_object The TypeObject representing the type of the topic being filtered. + * @param[in] type_support The type support representing the type of the data being filtered. * * @return nullptr when there is a parsing error. * @return A pointer to the root node of the AST tree for the expression. */ -// std::unique_ptr parse_filter_expression( -// const char* expression, -// const eprosima_common::fastrtps::types::TypeObject* type_object); std::unique_ptr parse_filter_expression( const char* expression, const rosidl_message_type_support_t* type_support); @@ -67,4 +62,4 @@ std::unique_ptr parse_literal_value( } // namespace fastdds } // namespace eprosima_common -#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTEREXPRESSIONPARSER_HPP_ +#endif // COMMON_CONTENT_FILTER__DDSFILTEREXPRESSIONPARSER_HPP_ diff --git a/common_content_filter/src/DDSFilterFactory.cpp b/common_content_filter/src/DDSFilterFactory.cpp index 4165ba6..d65757f 100644 --- a/common_content_filter/src/DDSFilterFactory.cpp +++ b/common_content_filter/src/DDSFilterFactory.cpp @@ -22,13 +22,6 @@ #include #include -// #include -// #include -// #include - -// #include -// #include - #include "IContentFilter.hpp" #include "IContentFilterFactory.hpp" @@ -62,7 +55,7 @@ static IContentFilterFactory::ReturnCode_t transform_enum( static_cast(value); static_cast(type); static_cast(string_value); - // TODO. after enum supported in the rosidl + // TODO. when enum supported in the rosidl return IContentFilterFactory::ReturnCode_t::RETCODE_BAD_PARAMETER; } diff --git a/common_content_filter/src/DDSFilterFactory.hpp b/common_content_filter/src/DDSFilterFactory.hpp index 7ff93d3..a82c9f2 100644 --- a/common_content_filter/src/DDSFilterFactory.hpp +++ b/common_content_filter/src/DDSFilterFactory.hpp @@ -16,13 +16,8 @@ * @file DDSFilterFactory.hpp */ -#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERFACTORY_HPP_ -#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERFACTORY_HPP_ - -// #include -// #include -// #include - +#ifndef COMMON_CONTENT_FILTER__DDSFILTERFACTORY_HPP_ +#define COMMON_CONTENT_FILTER__DDSFILTERFACTORY_HPP_ #include "IContentFilterFactory.hpp" @@ -37,8 +32,6 @@ namespace fastdds { namespace dds { namespace DDSSQLFilter { -// class IContentFilter; - /** * An IContentFilterFactory that processes DDS-SQL filter expressions. */ @@ -101,4 +94,4 @@ class DDSFilterFactory final : public IContentFilterFactory } // namespace fastdds } // namespace eprosima_common -#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERFACTORY_HPP_ +#endif // COMMON_CONTENT_FILTER__DDSFILTERFACTORY_HPP_ diff --git a/common_content_filter/src/DDSFilterField.cpp b/common_content_filter/src/DDSFilterField.cpp index 2c093d8..365fd3d 100644 --- a/common_content_filter/src/DDSFilterField.cpp +++ b/common_content_filter/src/DDSFilterField.cpp @@ -22,20 +22,11 @@ #include #include -// #include -// #include -// #include -// #include - -#include "rosidl_typesupport_introspection_cpp/field_types.hpp" - #include "DDSFilterPredicate.hpp" #include "DDSFilterValue.hpp" #include "Log.hpp" - - namespace eprosima_common { namespace fastdds { namespace dds { @@ -100,7 +91,8 @@ bool DDSFilterField::set_value( // "DDSFilterField::set_value " << "access_path size:" << access_path_.size() // ); - const rosidl_message_type_support_t * type_support_introspection = access_path_[n].type_support_intro; + const rosidl_message_type_support_t * type_support_introspection = + access_path_[n].type_support_introspection; if (type_support_introspection->typesupport_identifier == rosidl_typesupport_introspection_c__identifier) { diff --git a/common_content_filter/src/DDSFilterField.hpp b/common_content_filter/src/DDSFilterField.hpp index 63411cb..085a4bc 100644 --- a/common_content_filter/src/DDSFilterField.hpp +++ b/common_content_filter/src/DDSFilterField.hpp @@ -16,18 +16,13 @@ * @file DDSFilterField.hpp */ -#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERFIELD_HPP_ -#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERFIELD_HPP_ +#ifndef COMMON_CONTENT_FILTER__DDSFILTERFIELD_HPP_ +#define COMMON_CONTENT_FILTER__DDSFILTERFIELD_HPP_ #include #include #include -// #include -// #include -// #include -// #include - #include "rosidl_typesupport_introspection_c/identifier.h" #include "rosidl_typesupport_introspection_cpp/identifier.hpp" #include "rosidl_typesupport_introspection_c/message_introspection.h" @@ -55,16 +50,14 @@ class DDSFilterField final : public DDSFilterValue */ struct FieldAccessor final { - // TODO. use pos instead, the `array_index` might be used - - /// Index of the member to access size_t member_index; /// Element index for array / sequence members size_t array_index; - const rosidl_message_type_support_t * type_support_intro; + /// Type support introspection information for current field + const rosidl_message_type_support_t * type_support_introspection; }; /** @@ -168,4 +161,4 @@ class DDSFilterField final : public DDSFilterValue } // namespace fastdds } // namespace eprosima_common -#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERFIELD_HPP_ +#endif // COMMON_CONTENT_FILTER__DDSFILTERFIELD_HPP_ diff --git a/common_content_filter/src/DDSFilterGrammar.hpp b/common_content_filter/src/DDSFilterGrammar.hpp index d745313..fc7f2cf 100644 --- a/common_content_filter/src/DDSFilterGrammar.hpp +++ b/common_content_filter/src/DDSFilterGrammar.hpp @@ -16,8 +16,8 @@ * @file DDSFilterGrammar.hpp */ -#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERGRAMMAR_HPP_ -#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERGRAMMAR_HPP_ +#ifndef COMMON_CONTENT_FILTER__DDSFILTERGRAMMAR_HPP_ +#define COMMON_CONTENT_FILTER__DDSFILTERGRAMMAR_HPP_ #include "pegtl.hpp" @@ -119,4 +119,4 @@ struct LiteralGrammar : must< Literal, tao::TAO_PEGTL_NAMESPACE::eof > {}; } // namespace fastdds } // namespace eprosima_common -#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERGRAMMAR_HPP_ +#endif // COMMON_CONTENT_FILTER__DDSFILTERGRAMMAR_HPP_ diff --git a/common_content_filter/src/DDSFilterParameter.hpp b/common_content_filter/src/DDSFilterParameter.hpp index 8c4bf32..20e783a 100644 --- a/common_content_filter/src/DDSFilterParameter.hpp +++ b/common_content_filter/src/DDSFilterParameter.hpp @@ -16,8 +16,8 @@ * @file DDSFilterParameter.hpp */ -#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPARAMETER_HPP_ -#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPARAMETER_HPP_ +#ifndef COMMON_CONTENT_FILTER__DDSFILTERPARAMETER_HPP_ +#define COMMON_CONTENT_FILTER__DDSFILTERPARAMETER_HPP_ #include "DDSFilterValue.hpp" @@ -52,4 +52,4 @@ class DDSFilterParameter final : public DDSFilterValue } // namespace fastdds } // namespace eprosima_common -#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPARAMETER_HPP_ +#endif // COMMON_CONTENT_FILTER__DDSFILTERPARAMETER_HPP_ diff --git a/common_content_filter/src/DDSFilterParseNode.hpp b/common_content_filter/src/DDSFilterParseNode.hpp index 300c074..2f0455a 100644 --- a/common_content_filter/src/DDSFilterParseNode.hpp +++ b/common_content_filter/src/DDSFilterParseNode.hpp @@ -16,14 +16,12 @@ * @file DDSFilterParseNode.hpp */ -#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPARSENODE_HPP_ -#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPARSENODE_HPP_ +#ifndef COMMON_CONTENT_FILTER__DDSFILTERPARSENODE_HPP_ +#define COMMON_CONTENT_FILTER__DDSFILTERPARSENODE_HPP_ #include #include -// #include - #include "pegtl/contrib/parse_tree.hpp" #include "DDSFilterField.hpp" @@ -44,10 +42,8 @@ struct ParseNode : parse_tree::basic_node< ParseNode > // When the node is a fieldname, it will hold the access path to the field, the data kind, and the type id std::vector field_access_path; - - // TODO. why need the following two members? DDSFilterValue::ValueKind field_kind = DDSFilterValue::ValueKind::STRING; - // filed type in the ros2 primitive type + // ros2 primitive type id uint8_t type_id = 0; // When the node is a parameter, it will hold the parameter index @@ -71,4 +67,4 @@ struct ParseNode : parse_tree::basic_node< ParseNode > } // namespace fastdds } // namespace eprosima_common -#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPARSENODE_HPP_ +#endif // COMMON_CONTENT_FILTER__DDSFILTERPARSENODE_HPP_ diff --git a/common_content_filter/src/DDSFilterPredicate.hpp b/common_content_filter/src/DDSFilterPredicate.hpp index 52e483a..3d5188a 100644 --- a/common_content_filter/src/DDSFilterPredicate.hpp +++ b/common_content_filter/src/DDSFilterPredicate.hpp @@ -16,8 +16,8 @@ * @file DDSFilterPredicate.hpp */ -#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPREDICATE_HPP_ -#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPREDICATE_HPP_ +#ifndef COMMON_CONTENT_FILTER__DDSFILTERPREDICATE_HPP_ +#define COMMON_CONTENT_FILTER__DDSFILTERPREDICATE_HPP_ #include @@ -94,4 +94,4 @@ class DDSFilterPredicate final : public DDSFilterCondition } // namespace fastdds } // namespace eprosima_common -#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERPREDICATE_HPP_ +#endif // COMMON_CONTENT_FILTER__DDSFILTERPREDICATE_HPP_ diff --git a/common_content_filter/src/DDSFilterValue.hpp b/common_content_filter/src/DDSFilterValue.hpp index 584af10..3990d8d 100644 --- a/common_content_filter/src/DDSFilterValue.hpp +++ b/common_content_filter/src/DDSFilterValue.hpp @@ -16,14 +16,12 @@ * @file DDSFilterValue.hpp */ -#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERVALUE_HPP_ -#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERVALUE_HPP_ +#ifndef COMMON_CONTENT_FILTER__DDSFILTERVALUE_HPP_ +#define COMMON_CONTENT_FILTER__DDSFILTERVALUE_HPP_ #include #include -// #include - namespace eprosima_common { namespace fastdds { namespace dds { @@ -230,4 +228,4 @@ class DDSFilterValue } // namespace fastdds } // namespace eprosima_common -#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERVALUE_HPP_ +#endif // COMMON_CONTENT_FILTER__DDSFILTERVALUE_HPP_ diff --git a/common_content_filter/src/IContentFilter.hpp b/common_content_filter/src/IContentFilter.hpp index 855eccb..fe94ca4 100644 --- a/common_content_filter/src/IContentFilter.hpp +++ b/common_content_filter/src/IContentFilter.hpp @@ -16,19 +16,9 @@ * @file IContentFilter.hpp */ -#ifndef _FASTDDS_DDS_TOPIC_ICONTENTFILTER_HPP_ -#define _FASTDDS_DDS_TOPIC_ICONTENTFILTER_HPP_ +#ifndef COMMON_CONTENT_FILTER__ICONTENTFILTER_HPP_ +#define COMMON_CONTENT_FILTER__ICONTENTFILTER_HPP_ -// #include - -// #include - -// #include -// #include -// #include - -// #include -// #include namespace eprosima_common { namespace fastdds { @@ -54,4 +44,4 @@ struct IContentFilter } // namespace fastdds } // namespace eprosima_common -#endif // _FASTDDS_DDS_TOPIC_ICONTENTFILTER_HPP_ +#endif // COMMON_CONTENT_FILTER__ICONTENTFILTER_HPP_ diff --git a/common_content_filter/src/IContentFilterFactory.hpp b/common_content_filter/src/IContentFilterFactory.hpp index 74121c6..16647b9 100644 --- a/common_content_filter/src/IContentFilterFactory.hpp +++ b/common_content_filter/src/IContentFilterFactory.hpp @@ -16,8 +16,8 @@ * @file IContentFilter.hpp */ -#ifndef _FASTDDS_DDS_TOPIC_ICONTENTFILTERFACTORY_HPP_ -#define _FASTDDS_DDS_TOPIC_ICONTENTFILTERFACTORY_HPP_ +#ifndef COMMON_CONTENT_FILTER__ICONTENTFILTERFACTORY_HPP_ +#define COMMON_CONTENT_FILTER__ICONTENTFILTERFACTORY_HPP_ // #include @@ -103,4 +103,4 @@ struct IContentFilterFactory } // namespace fastdds } // namespace eprosima_common -#endif // _FASTDDS_DDS_TOPIC_ICONTENTFILTERFACTORY_HPP_ +#endif // COMMON_CONTENT_FILTER__ICONTENTFILTERFACTORY_HPP_ diff --git a/common_content_filter/src/Log.hpp b/common_content_filter/src/Log.hpp index 5503440..5bd6b6c 100644 --- a/common_content_filter/src/Log.hpp +++ b/common_content_filter/src/Log.hpp @@ -1,3 +1,7 @@ +// license + +#ifndef COMMON_CONTENT_FILTER__LOG_HPP_ +#define COMMON_CONTENT_FILTER__LOG_HPP_ // TODO. use rcutil log instead #include @@ -13,3 +17,5 @@ #define logInfo common_content_filter_log_ #define logWarning common_content_filter_log_ #define logError common_content_filter_log_ + +#endif // COMMON_CONTENT_FILTER__LOG_HPP_ \ No newline at end of file diff --git a/common_content_filter/src/ObjectPool.hpp b/common_content_filter/src/ObjectPool.hpp index 9ed47a3..da08d3e 100644 --- a/common_content_filter/src/ObjectPool.hpp +++ b/common_content_filter/src/ObjectPool.hpp @@ -17,8 +17,8 @@ * */ -#ifndef FASTRTPS_UTILS_COLLECTIONS_OBJECTPOOL_HPP_ -#define FASTRTPS_UTILS_COLLECTIONS_OBJECTPOOL_HPP_ +#ifndef COMMON_CONTENT_FILTER_OBJECTPOOL_HPP_ +#define COMMON_CONTENT_FILTER_OBJECTPOOL_HPP_ #include #include @@ -97,4 +97,4 @@ struct ObjectPool final } // namespace fastdds } // namespace eprosima_common -#endif /* FASTRTPS_UTILS_COLLECTIONS_OBJECTPOOL_HPP_ */ +#endif // COMMON_CONTENT_FILTER_OBJECTPOOL_HPP_ From 088d9dc82c52c92318a714aeefb8997eb16fc326 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 4 Jul 2022 17:09:39 +0800 Subject: [PATCH 15/51] update package description Signed-off-by: Chen Lihui --- common_content_filter/package.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common_content_filter/package.xml b/common_content_filter/package.xml index 5c1d7d4..257dc21 100644 --- a/common_content_filter/package.xml +++ b/common_content_filter/package.xml @@ -2,10 +2,10 @@ common_content_filter - 0.0.0 - TODO: Package description + 0.0.1 + To support content filter fallback used in rcl. chenlh - TODO: License declaration + Apache License 2.0 ament_cmake From 5ac257a9b7526d5c34dd60a4c18c5b6a9c0ff415 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 4 Jul 2022 17:25:26 +0800 Subject: [PATCH 16/51] r6 Signed-off-by: Chen Lihui --- .../include/common_content_filter/api.h | 21 +++++++++++++++++-- .../src/DDSFilterExpression.cpp | 1 - .../src/DDSFilterExpression.hpp | 1 - .../src/DDSFilterExpressionParser.cpp | 17 +++++++-------- .../src/DDSFilterExpressionParser.hpp | 3 +-- .../src/DDSFilterFactory.cpp | 3 --- .../src/DDSFilterFactory.hpp | 2 +- common_content_filter/src/DDSFilterField.cpp | 7 ++++++- common_content_filter/src/DDSFilterField.hpp | 6 +----- .../src/DDSFilterParameter.cpp | 1 - .../src/IContentFilterFactory.hpp | 10 ++------- 11 files changed, 38 insertions(+), 34 deletions(-) diff --git a/common_content_filter/include/common_content_filter/api.h b/common_content_filter/include/common_content_filter/api.h index 0b89cc8..97d8b37 100644 --- a/common_content_filter/include/common_content_filter/api.h +++ b/common_content_filter/include/common_content_filter/api.h @@ -26,6 +26,12 @@ extern "C" { #endif +/// Create a common content filter instance to filter data. +/** + * \param[in] type_support Type support of the topic data being filtered + * \param[in] options the filter options + * \return a valid address if success, or NULL on failure + */ COMMON_CONTENT_FILTER_PUBLIC void * create_common_content_filter( @@ -33,13 +39,24 @@ create_common_content_filter( rmw_subscription_content_filter_options_t * options ); +/// Use the content filter instance to evalute the data. +/** + * \param[in] instance The content filter instance + * \param[in] data The ros2 payload + * \param[in] serialized Indicate the ros2 payload is serialized or not + * \return true if evaluate successfully, or false + */ COMMON_CONTENT_FILTER_PUBLIC bool -common_content_filter_evaluate(void * instance, void * ros_data, bool serialized); +common_content_filter_evaluate(void * instance, void * data, bool serialized); +/// Destroy the content filter instance. +/** + * \param[in] instance The content filter instance + */ COMMON_CONTENT_FILTER_PUBLIC void -destroy_common_content_filter(void *); +destroy_common_content_filter(void * instance); #ifdef __cplusplus } diff --git a/common_content_filter/src/DDSFilterExpression.cpp b/common_content_filter/src/DDSFilterExpression.cpp index 22d3326..26ad66b 100644 --- a/common_content_filter/src/DDSFilterExpression.cpp +++ b/common_content_filter/src/DDSFilterExpression.cpp @@ -26,7 +26,6 @@ #include "DDSFilterCondition.hpp" #include "DDSFilterField.hpp" #include "DDSFilterParameter.hpp" - #include "Log.hpp" namespace eprosima_common { diff --git a/common_content_filter/src/DDSFilterExpression.hpp b/common_content_filter/src/DDSFilterExpression.hpp index df692a2..078250d 100644 --- a/common_content_filter/src/DDSFilterExpression.hpp +++ b/common_content_filter/src/DDSFilterExpression.hpp @@ -25,7 +25,6 @@ #include #include "IContentFilter.hpp" - #include "DDSFilterCondition.hpp" #include "DDSFilterField.hpp" #include "DDSFilterParameter.hpp" diff --git a/common_content_filter/src/DDSFilterExpressionParser.cpp b/common_content_filter/src/DDSFilterExpressionParser.cpp index 0e199b3..a2b2015 100644 --- a/common_content_filter/src/DDSFilterExpressionParser.cpp +++ b/common_content_filter/src/DDSFilterExpressionParser.cpp @@ -18,15 +18,15 @@ #include "DDSFilterExpressionParser.hpp" -#include - // header files needed by identifiers.hpp -#include "rmw/error_handling.h" -#include "rosidl_typesupport_introspection_c/identifier.h" -#include "rosidl_typesupport_introspection_cpp/identifier.hpp" -#include "rosidl_typesupport_introspection_c/message_introspection.h" -#include "rosidl_typesupport_introspection_cpp/message_introspection.hpp" -#include "rosidl_typesupport_introspection_cpp/field_types.hpp" +#include +#include +#include +#include +#include +#include + +#include #include "pegtl.hpp" #include "pegtl/contrib/parse_tree.hpp" @@ -35,7 +35,6 @@ #include "DDSFilterParseNode.hpp" #include "DDSFilterValue.hpp" #include "DDSFilterField.hpp" - #include "Log.hpp" namespace eprosima_common { diff --git a/common_content_filter/src/DDSFilterExpressionParser.hpp b/common_content_filter/src/DDSFilterExpressionParser.hpp index 7f6fe81..bfe4ee8 100644 --- a/common_content_filter/src/DDSFilterExpressionParser.hpp +++ b/common_content_filter/src/DDSFilterExpressionParser.hpp @@ -19,11 +19,10 @@ #ifndef COMMON_CONTENT_FILTER__DDSFILTEREXPRESSIONPARSER_HPP_ #define COMMON_CONTENT_FILTER__DDSFILTEREXPRESSIONPARSER_HPP_ +#include #include - #include "DDSFilterParseNode.hpp" -#include "rosidl_runtime_c/message_type_support_struct.h" namespace eprosima_common { namespace fastdds { diff --git a/common_content_filter/src/DDSFilterFactory.cpp b/common_content_filter/src/DDSFilterFactory.cpp index d65757f..4a644dc 100644 --- a/common_content_filter/src/DDSFilterFactory.cpp +++ b/common_content_filter/src/DDSFilterFactory.cpp @@ -24,11 +24,9 @@ #include "IContentFilter.hpp" #include "IContentFilterFactory.hpp" - #include "DDSFilterGrammar.hpp" #include "DDSFilterExpressionParser.hpp" #include "DDSFilterParseNode.hpp" - #include "DDSFilterExpression.hpp" #include "DDSFilterCompoundCondition.hpp" #include "DDSFilterCondition.hpp" @@ -39,7 +37,6 @@ #include "DDSFilterParameter.hpp" #include "DDSFilterPredicate.hpp" #include "DDSFilterValue.hpp" - #include "Log.hpp" namespace eprosima_common { diff --git a/common_content_filter/src/DDSFilterFactory.hpp b/common_content_filter/src/DDSFilterFactory.hpp index a82c9f2..d475aa7 100644 --- a/common_content_filter/src/DDSFilterFactory.hpp +++ b/common_content_filter/src/DDSFilterFactory.hpp @@ -23,9 +23,9 @@ #include "IContentFilter.hpp" -#include "ObjectPool.hpp" #include "DDSFilterEmptyExpression.hpp" #include "DDSFilterExpression.hpp" +#include "ObjectPool.hpp" namespace eprosima_common { namespace fastdds { diff --git a/common_content_filter/src/DDSFilterField.cpp b/common_content_filter/src/DDSFilterField.cpp index 365fd3d..84ba248 100644 --- a/common_content_filter/src/DDSFilterField.cpp +++ b/common_content_filter/src/DDSFilterField.cpp @@ -18,13 +18,18 @@ #include "DDSFilterField.hpp" +#include +#include +#include +#include +#include + #include #include #include #include "DDSFilterPredicate.hpp" #include "DDSFilterValue.hpp" - #include "Log.hpp" namespace eprosima_common { diff --git a/common_content_filter/src/DDSFilterField.hpp b/common_content_filter/src/DDSFilterField.hpp index 085a4bc..270ddc1 100644 --- a/common_content_filter/src/DDSFilterField.hpp +++ b/common_content_filter/src/DDSFilterField.hpp @@ -23,11 +23,7 @@ #include #include -#include "rosidl_typesupport_introspection_c/identifier.h" -#include "rosidl_typesupport_introspection_cpp/identifier.hpp" -#include "rosidl_typesupport_introspection_c/message_introspection.h" -#include "rosidl_typesupport_introspection_cpp/message_introspection.hpp" -#include "rosidl_typesupport_introspection_cpp/field_types.hpp" +#include #include "DDSFilterPredicate.hpp" #include "DDSFilterValue.hpp" diff --git a/common_content_filter/src/DDSFilterParameter.cpp b/common_content_filter/src/DDSFilterParameter.cpp index 715a4a1..96f1e9b 100644 --- a/common_content_filter/src/DDSFilterParameter.cpp +++ b/common_content_filter/src/DDSFilterParameter.cpp @@ -19,7 +19,6 @@ #include "DDSFilterParameter.hpp" #include "DDSFilterExpressionParser.hpp" - #include "Log.hpp" namespace eprosima_common { diff --git a/common_content_filter/src/IContentFilterFactory.hpp b/common_content_filter/src/IContentFilterFactory.hpp index 16647b9..6a5f733 100644 --- a/common_content_filter/src/IContentFilterFactory.hpp +++ b/common_content_filter/src/IContentFilterFactory.hpp @@ -19,19 +19,13 @@ #ifndef COMMON_CONTENT_FILTER__ICONTENTFILTERFACTORY_HPP_ #define COMMON_CONTENT_FILTER__ICONTENTFILTERFACTORY_HPP_ -// #include - -// #include -// #include -// #include - -// #include +#include #include #include #include "IContentFilter.hpp" -#include "rosidl_runtime_c/message_type_support_struct.h" + namespace eprosima_common { namespace fastdds { From c246a186a2d2fe5c9f925e5c4591799980c61b67 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 5 Jul 2022 10:55:12 +0800 Subject: [PATCH 17/51] add set/get_content_filter Signed-off-by: Chen Lihui --- .../include/common_content_filter/api.h | 47 +++- common_content_filter/src/api.cpp | 206 +++++++++++++----- 2 files changed, 197 insertions(+), 56 deletions(-) diff --git a/common_content_filter/include/common_content_filter/api.h b/common_content_filter/include/common_content_filter/api.h index 97d8b37..4581fc0 100644 --- a/common_content_filter/include/common_content_filter/api.h +++ b/common_content_filter/include/common_content_filter/api.h @@ -17,6 +17,7 @@ #include "common_content_filter/visibility_control.h" +#include #include #include @@ -34,10 +35,16 @@ extern "C" */ COMMON_CONTENT_FILTER_PUBLIC void * -create_common_content_filter( - const rosidl_message_type_support_t * type_support, - rmw_subscription_content_filter_options_t * options -); +create_common_content_filter(); + +/// Check if the content filter instance is enabled. +/** + * \param[in] instance The content filter instance + * \return true if enabled, or false + */ +COMMON_CONTENT_FILTER_PUBLIC +bool +is_common_content_filter_enabled(void * instance); /// Use the content filter instance to evalute the data. /** @@ -48,7 +55,37 @@ create_common_content_filter( */ COMMON_CONTENT_FILTER_PUBLIC bool -common_content_filter_evaluate(void * instance, void * data, bool serialized); +evaluate_common_content_filter(void * instance, void * data, bool serialized); + +/// Set a common content filter instance with an options. +/** + * \param[in] instance The content filter instance + * \param[in] type_support Type support of the topic data being filtered + * \param[in] options the filter options + * \return a valid address if success, or NULL on failure + */ +COMMON_CONTENT_FILTER_PUBLIC +bool +set_common_content_filter( + void * instance, + const rosidl_message_type_support_t * type_support, + const rmw_subscription_content_filter_options_t * options +); + +/// Get the options from a common content filter instance. +/** + * \param[in] instance The content filter instance + * \param[in] allocator Type support of the topic data being filtered + * \param[in] options the filter options + * \return a valid address if success, or NULL on failure + */ +COMMON_CONTENT_FILTER_PUBLIC +bool +get_common_content_filter( + void * instance, + rcutils_allocator_t * allocator, + rmw_subscription_content_filter_options_t * options +); /// Destroy the content filter instance. /** diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index 96f50b5..f551470 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -14,6 +14,10 @@ #include "common_content_filter/api.h" +#include "rmw/allocators.h" +#include "rmw/error_handling.h" +#include "rmw/rmw.h" + #include #include #include @@ -38,40 +42,24 @@ get_common_content_filter_factory() { class ContentFilterWrapper { public: - ContentFilterWrapper( - const rosidl_message_type_support_t * type_support, - const std::string & filter_expression, - const std::vector & expression_parameters) - : type_support_(type_support), - filter_expression_(filter_expression), - expression_parameters_(expression_parameters) + ContentFilterWrapper() { // logDebug(DDSSQLFILTER, "ContentFilterWrapper ctor : " << this); - - std::lock_guard lock(mutex_); - DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->create_content_filter( - FILTER_CLASS_NAME, // deprecated - "", // deprecated - type_support_, - filter_expression_.c_str(), - expression_parameters_, - filter_instance_); - if (ret != DDSFilterFactory::RETCODE_OK) { - logError(DDSSQLFILTER, "create_content_filter ret: " << ret); - throw std::runtime_error("Failed to create content filter instance."); - } } ~ContentFilterWrapper() { std::lock_guard lock(mutex_); - DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->delete_content_filter( - FILTER_CLASS_NAME, - filter_instance_); - if (ret != DDSFilterFactory::RETCODE_OK) { - logError(DDSSQLFILTER, "Failed to delete content filter: " << ret); + if (filter_instance_) { + DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->delete_content_filter( + FILTER_CLASS_NAME, + filter_instance_); + if (ret != DDSFilterFactory::RETCODE_OK) { + logError(DDSSQLFILTER, "Failed to delete content filter: " << ret); + } + + filter_instance_ = nullptr; } - filter_instance_ = nullptr; // logDebug(DDSSQLFILTER, "ContentFilterWrapper dtor : " << this); } @@ -89,18 +77,56 @@ class ContentFilterWrapper { return ret; } - bool set_filter_expression() { - return false; + bool set_filter_expression( + const rosidl_message_type_support_t * type_support, + const std::string & filter_expression, + const std::vector & expression_parameters) + { + std::lock_guard lock(mutex_); + static std::string tip = filter_instance_ ? "create" : "set"; + DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->create_content_filter( + FILTER_CLASS_NAME, // deprecated + "", // deprecated + type_support, + filter_expression.c_str(), + expression_parameters, + filter_instance_); + if (ret != DDSFilterFactory::RETCODE_OK) { + logError(DDSSQLFILTER, "failed to " << tip << " content filter, ret: " << ret); + return false; + } + + filter_expression_ = filter_expression; + expression_parameters_ = expression_parameters; + + return true; } - bool get_filter_expression() { - return false; + bool get_filter_expression( + std::string & filter_expression, + std::vector & expression_parameters) + { + std::lock_guard lock(mutex_); + + if (!filter_instance_) { + logError(DDSSQLFILTER, "content filter instance is not created"); + return false; + } + + filter_expression = filter_expression_; + expression_parameters = expression_parameters_; + + return true; } IContentFilter * filter_instance() { return filter_instance_; } + bool is_enabled() { + return filter_instance_ != nullptr; + } + int magic() { return magic_; } @@ -108,7 +134,6 @@ class ContentFilterWrapper { private: const int magic_ = MAGIC; IContentFilter * filter_instance_ = nullptr; - const rosidl_message_type_support_t * type_support_; std::string filter_expression_; std::vector expression_parameters_; std::mutex mutex_; @@ -123,25 +148,11 @@ extern "C" #endif void * -create_common_content_filter( - const rosidl_message_type_support_t * type_support, - rmw_subscription_content_filter_options_t * options -) { - if (!type_support || !options) { - logError(DDSSQLFILTER, "Invalid arguments"); - return NULL; - } - - std::vector expression_parameters; - for (size_t i = 0; i < options->expression_parameters.size; ++i) { - expression_parameters.push_back(options->expression_parameters.data[i]); - } - +create_common_content_filter() { common_content_filter::ContentFilterWrapper * filter_instance_wrapper = nullptr; try { filter_instance_wrapper = - new common_content_filter::ContentFilterWrapper( - type_support, options->filter_expression, expression_parameters); + new common_content_filter::ContentFilterWrapper(); } catch (const std::runtime_error& e) { logInfo(DDSSQLFILTER, "Failed to create content filter: " << e.what()); } @@ -150,7 +161,19 @@ create_common_content_filter( } bool -common_content_filter_evaluate(void * instance, void * ros_data, bool serialized) { +is_common_content_filter_enabled(void * instance) { + common_content_filter::ContentFilterWrapper * content_filter_wrapper = + static_cast(instance); + if (!content_filter_wrapper || content_filter_wrapper->magic() != common_content_filter::MAGIC ) { + logError(DDSSQLFILTER, "Invalid arguments"); + return false; + } + + return content_filter_wrapper->is_enabled(); +} + +bool +evaluate_common_content_filter(void * instance, void * ros_data, bool serialized) { common_content_filter::ContentFilterWrapper * content_filter_wrapper = static_cast(instance); @@ -169,9 +192,90 @@ common_content_filter_evaluate(void * instance, void * ros_data, bool serialized return ret; } -// TODO -// set_content_filter -// get_content_filter +bool +set_common_content_filter( + void * instance, + const rosidl_message_type_support_t * type_support, + const rmw_subscription_content_filter_options_t * options +) { + + common_content_filter::ContentFilterWrapper * content_filter_wrapper = + static_cast(instance); + if (!content_filter_wrapper || content_filter_wrapper->magic() != common_content_filter::MAGIC ) { + logError(DDSSQLFILTER, "Invalid arguments"); + return false; + } + + if (!type_support || !options) { + logError(DDSSQLFILTER, "Invalid arguments"); + return false; + } + + std::vector expression_parameters; + for (size_t i = 0; i < options->expression_parameters.size; ++i) { + expression_parameters.push_back(options->expression_parameters.data[i]); + } + + bool ret = false; + try { + ret = content_filter_wrapper->set_filter_expression( + type_support, options->filter_expression, expression_parameters + ); + } catch (const std::runtime_error& e) { + logInfo(DDSSQLFILTER, "Failed to create content filter: " << e.what()); + } + + return ret; +} + +bool +get_common_content_filter( + void * instance, + rcutils_allocator_t * allocator, + rmw_subscription_content_filter_options_t * options +) { + common_content_filter::ContentFilterWrapper * content_filter_wrapper = + static_cast(instance); + if (!content_filter_wrapper || content_filter_wrapper->magic() != common_content_filter::MAGIC ) { + logError(DDSSQLFILTER, "Invalid arguments"); + return false; + } + + if (!allocator || !options) { + logError(DDSSQLFILTER, "Invalid arguments"); + return false; + } + + std::string filter_expression; + std::vector expression_parameters; + bool ret = content_filter_wrapper->get_filter_expression( + filter_expression, + expression_parameters + ); + if (!ret) { + return false; + } + + std::vector string_array; + for (size_t i = 0; i < expression_parameters.size(); ++i) { + string_array.push_back(expression_parameters[i].c_str()); + } + + rmw_ret_t rmw_ret = rmw_subscription_content_filter_options_init( + filter_expression.c_str(), + string_array.size(), + string_array.data(), + allocator, + options + ); + + if (rmw_ret != RMW_RET_OK) { + logError(DDSSQLFILTER, rmw_get_error_string().str); + return false; + } + + return true; +} void destroy_common_content_filter(void * instance) { From 97512a4f8476e591e230dd034938ebbbea4db506 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 5 Jul 2022 11:31:26 +0800 Subject: [PATCH 18/51] r7 Signed-off-by: Chen Lihui --- common_content_filter/src/api.cpp | 51 ++++++++++++++++--------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index f551470..90a6f08 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -139,6 +139,17 @@ class ContentFilterWrapper { std::mutex mutex_; }; + +common_content_filter::ContentFilterWrapper * validate(void * instance) { + auto content_filter_wrapper = + static_cast(instance); + if (!content_filter_wrapper || content_filter_wrapper->magic() != common_content_filter::MAGIC ) { + logError(DDSSQLFILTER, "Invalid instance"); + return nullptr; + } + return content_filter_wrapper; +} + } // namespace common_content_filter @@ -149,23 +160,14 @@ extern "C" void * create_common_content_filter() { - common_content_filter::ContentFilterWrapper * filter_instance_wrapper = nullptr; - try { - filter_instance_wrapper = - new common_content_filter::ContentFilterWrapper(); - } catch (const std::runtime_error& e) { - logInfo(DDSSQLFILTER, "Failed to create content filter: " << e.what()); - } - - return filter_instance_wrapper; + return (new common_content_filter::ContentFilterWrapper); } bool is_common_content_filter_enabled(void * instance) { common_content_filter::ContentFilterWrapper * content_filter_wrapper = - static_cast(instance); - if (!content_filter_wrapper || content_filter_wrapper->magic() != common_content_filter::MAGIC ) { - logError(DDSSQLFILTER, "Invalid arguments"); + common_content_filter::validate(instance); + if (!content_filter_wrapper) { return false; } @@ -174,10 +176,13 @@ is_common_content_filter_enabled(void * instance) { bool evaluate_common_content_filter(void * instance, void * ros_data, bool serialized) { - common_content_filter::ContentFilterWrapper * content_filter_wrapper = - static_cast(instance); - if (!content_filter_wrapper || content_filter_wrapper->magic() != common_content_filter::MAGIC ) { + common_content_filter::validate(instance); + if (!content_filter_wrapper) { + return false; + } + + if (!ros_data) { logError(DDSSQLFILTER, "Invalid arguments"); return false; } @@ -198,11 +203,9 @@ set_common_content_filter( const rosidl_message_type_support_t * type_support, const rmw_subscription_content_filter_options_t * options ) { - common_content_filter::ContentFilterWrapper * content_filter_wrapper = - static_cast(instance); - if (!content_filter_wrapper || content_filter_wrapper->magic() != common_content_filter::MAGIC ) { - logError(DDSSQLFILTER, "Invalid arguments"); + common_content_filter::validate(instance); + if (!content_filter_wrapper) { return false; } @@ -235,9 +238,8 @@ get_common_content_filter( rmw_subscription_content_filter_options_t * options ) { common_content_filter::ContentFilterWrapper * content_filter_wrapper = - static_cast(instance); - if (!content_filter_wrapper || content_filter_wrapper->magic() != common_content_filter::MAGIC ) { - logError(DDSSQLFILTER, "Invalid arguments"); + common_content_filter::validate(instance); + if (!content_filter_wrapper) { return false; } @@ -280,9 +282,8 @@ get_common_content_filter( void destroy_common_content_filter(void * instance) { common_content_filter::ContentFilterWrapper * content_filter_wrapper = - static_cast(instance); - if (!content_filter_wrapper || content_filter_wrapper->magic() != common_content_filter::MAGIC ) { - logError(DDSSQLFILTER, "Invalid arguments"); + common_content_filter::validate(instance); + if (!content_filter_wrapper) { return; } From 96641331e19b15d6611cd422c4330bc3c6f8e5cc Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 5 Jul 2022 13:07:02 +0800 Subject: [PATCH 19/51] update Signed-off-by: Chen Lihui --- .../include/common_content_filter/api.h | 18 +++++++++--------- common_content_filter/src/api.cpp | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/common_content_filter/include/common_content_filter/api.h b/common_content_filter/include/common_content_filter/api.h index 4581fc0..ef92c7b 100644 --- a/common_content_filter/include/common_content_filter/api.h +++ b/common_content_filter/include/common_content_filter/api.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef COMMON_CONTENT_FILTER__API_HPP_ -#define COMMON_CONTENT_FILTER__API_HPP_ +#ifndef COMMON_CONTENT_FILTER__API_H_ +#define COMMON_CONTENT_FILTER__API_H_ #include "common_content_filter/visibility_control.h" @@ -35,7 +35,7 @@ extern "C" */ COMMON_CONTENT_FILTER_PUBLIC void * -create_common_content_filter(); +common_content_filter_create(); /// Check if the content filter instance is enabled. /** @@ -44,7 +44,7 @@ create_common_content_filter(); */ COMMON_CONTENT_FILTER_PUBLIC bool -is_common_content_filter_enabled(void * instance); +common_content_filter_is_enabled(void * instance); /// Use the content filter instance to evalute the data. /** @@ -55,7 +55,7 @@ is_common_content_filter_enabled(void * instance); */ COMMON_CONTENT_FILTER_PUBLIC bool -evaluate_common_content_filter(void * instance, void * data, bool serialized); +common_content_filter_evaluate(void * instance, void * data, bool serialized); /// Set a common content filter instance with an options. /** @@ -66,7 +66,7 @@ evaluate_common_content_filter(void * instance, void * data, bool serialized); */ COMMON_CONTENT_FILTER_PUBLIC bool -set_common_content_filter( +common_content_filter_set( void * instance, const rosidl_message_type_support_t * type_support, const rmw_subscription_content_filter_options_t * options @@ -81,7 +81,7 @@ set_common_content_filter( */ COMMON_CONTENT_FILTER_PUBLIC bool -get_common_content_filter( +common_content_filter_get( void * instance, rcutils_allocator_t * allocator, rmw_subscription_content_filter_options_t * options @@ -93,10 +93,10 @@ get_common_content_filter( */ COMMON_CONTENT_FILTER_PUBLIC void -destroy_common_content_filter(void * instance); +common_content_filter_destroy(void * instance); #ifdef __cplusplus } #endif -#endif // COMMON_CONTENT_FILTER__API_HPP_ +#endif // COMMON_CONTENT_FILTER__API_H_ diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index 90a6f08..f1d3ec1 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -159,12 +159,12 @@ extern "C" #endif void * -create_common_content_filter() { +common_content_filter_create() { return (new common_content_filter::ContentFilterWrapper); } bool -is_common_content_filter_enabled(void * instance) { +common_content_filter_is_enabled(void * instance) { common_content_filter::ContentFilterWrapper * content_filter_wrapper = common_content_filter::validate(instance); if (!content_filter_wrapper) { @@ -175,7 +175,7 @@ is_common_content_filter_enabled(void * instance) { } bool -evaluate_common_content_filter(void * instance, void * ros_data, bool serialized) { +common_content_filter_evaluate(void * instance, void * ros_data, bool serialized) { common_content_filter::ContentFilterWrapper * content_filter_wrapper = common_content_filter::validate(instance); if (!content_filter_wrapper) { @@ -198,7 +198,7 @@ evaluate_common_content_filter(void * instance, void * ros_data, bool serialized } bool -set_common_content_filter( +common_content_filter_set( void * instance, const rosidl_message_type_support_t * type_support, const rmw_subscription_content_filter_options_t * options @@ -232,7 +232,7 @@ set_common_content_filter( } bool -get_common_content_filter( +common_content_filter_get( void * instance, rcutils_allocator_t * allocator, rmw_subscription_content_filter_options_t * options @@ -280,7 +280,7 @@ get_common_content_filter( } void -destroy_common_content_filter(void * instance) { +common_content_filter_destroy(void * instance) { common_content_filter::ContentFilterWrapper * content_filter_wrapper = common_content_filter::validate(instance); if (!content_filter_wrapper) { From f727ad72306147156b4f4d640ac84d6c4fcecff1 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 5 Jul 2022 13:36:39 +0800 Subject: [PATCH 20/51] uncrustify and lint Signed-off-by: Chen Lihui --- common_content_filter/CMakeLists.txt | 21 +- common_content_filter/package.xml | 5 +- .../src/DDSFilterCompoundCondition.cpp | 126 ++- .../src/DDSFilterCompoundCondition.hpp | 75 +- .../src/DDSFilterCondition.hpp | 179 ++-- .../src/DDSFilterConditionState.hpp | 24 +- .../src/DDSFilterEmptyExpression.hpp | 25 +- .../src/DDSFilterExpression.cpp | 41 +- .../src/DDSFilterExpression.hpp | 37 +- .../src/DDSFilterExpressionParser.cpp | 173 ++-- .../src/DDSFilterExpressionParser.hpp | 21 +- .../identifiers.hpp | 326 ++++---- .../literal_values.hpp | 91 +-- .../parameters.hpp | 23 +- .../rearrange.hpp | 86 +- .../src/DDSFilterFactory.cpp | 773 ++++++++---------- .../src/DDSFilterFactory.hpp | 97 +-- common_content_filter/src/DDSFilterField.cpp | 251 +++--- common_content_filter/src/DDSFilterField.hpp | 221 ++--- .../src/DDSFilterGrammar.hpp | 12 +- .../src/DDSFilterParameter.cpp | 31 +- .../src/DDSFilterParameter.hpp | 35 +- .../src/DDSFilterParseNode.hpp | 51 +- .../src/DDSFilterPredicate.cpp | 119 ++- .../src/DDSFilterPredicate.hpp | 99 +-- common_content_filter/src/DDSFilterValue.cpp | 474 ++++++----- common_content_filter/src/DDSFilterValue.hpp | 356 ++++---- common_content_filter/src/IContentFilter.hpp | 27 +- .../src/IContentFilterFactory.hpp | 114 +-- common_content_filter/src/Log.hpp | 14 +- common_content_filter/src/ObjectPool.hpp | 94 +-- common_content_filter/src/api.cpp | 60 +- 32 files changed, 1999 insertions(+), 2082 deletions(-) diff --git a/common_content_filter/CMakeLists.txt b/common_content_filter/CMakeLists.txt index dacf35e..36d401d 100644 --- a/common_content_filter/CMakeLists.txt +++ b/common_content_filter/CMakeLists.txt @@ -27,24 +27,17 @@ add_library(${PROJECT_NAME}_library SHARED src/DDSFilterField.cpp src/DDSFilterParameter.cpp src/DDSFilterPredicate.cpp - src/DDSFilterValue.cpp - ) + src/DDSFilterValue.cpp) set_target_properties(${PROJECT_NAME}_library PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) -# target_link_libraries(${PROJECT_NAME}_library PUBLIC -# rcutils::rcutils -# rmw::rmw -# ) -# target_link_libraries(${PROJECT_NAME}_library PRIVATE -# rcpputils::rcpputils) + target_include_directories(${PROJECT_NAME}_library PUBLIC "$" "$" PRIVATE - ${PROJECT_SOURCE_DIR}/thirdparty/taocpp-pegtl - ) + ${PROJECT_SOURCE_DIR}/thirdparty/taocpp-pegtl) ament_target_dependencies(${PROJECT_NAME}_library "rcpputils" @@ -53,14 +46,6 @@ ament_target_dependencies(${PROJECT_NAME}_library "rosidl_typesupport_introspection_c" "rosidl_typesupport_introspection_cpp" ) -# # Wait for all rosidl generators to finish before building this library -# add_dependencies(${PROJECT_NAME}_library -# ${PROJECT_NAME}) - -# Depend on the generated C++ messages -# rosidl_get_typesupport_target(cpp_typesupport_target "${PROJECT_NAME}" "rosidl_typesupport_cpp") -# target_link_libraries(${PROJECT_NAME}_library PUBLIC -# ${cpp_typesupport_target}) # Causes the visibility macros to use dllexport rather than dllimport, # which is appropriate when building the dll but not consuming it. diff --git a/common_content_filter/package.xml b/common_content_filter/package.xml index 257dc21..ff8b2a5 100644 --- a/common_content_filter/package.xml +++ b/common_content_filter/package.xml @@ -3,7 +3,7 @@ common_content_filter 0.0.1 - To support content filter fallback used in rcl. + To support the common content filter (a CFT fallback on the DDS) used in rcl. chenlh Apache License 2.0 @@ -12,7 +12,8 @@ rcutils rcpputils rmw - rosidl_runtime_cpp + rosidl_typesupport_introspection_c + rosidl_typesupport_introspection_cpp ament_lint_auto ament_lint_common diff --git a/common_content_filter/src/DDSFilterCompoundCondition.cpp b/common_content_filter/src/DDSFilterCompoundCondition.cpp index 2c3ca96..5ec21bd 100644 --- a/common_content_filter/src/DDSFilterCompoundCondition.cpp +++ b/common_content_filter/src/DDSFilterCompoundCondition.cpp @@ -23,88 +23,80 @@ #include "DDSFilterCondition.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ DDSFilterCompoundCondition::DDSFilterCompoundCondition( - OperationKind op, - std::unique_ptr&& left, - std::unique_ptr&& right) - : op_(op) - , left_(std::move(left)) - , right_(std::move(right)) + OperationKind op, + std::unique_ptr && left, + std::unique_ptr && right) +: op_(op) + , left_(std::move(left)) + , right_(std::move(right)) { - assert(left_); - assert(right_ || OperationKind::NOT == op_); + assert(left_); + assert(right_ || OperationKind::NOT == op_); - left_->set_parent(this); - if (right_) - { - right_->set_parent(this); - } + left_->set_parent(this); + if (right_) { + right_->set_parent(this); + } } void DDSFilterCompoundCondition::propagate_reset() noexcept { - num_children_decided_ = 0; + num_children_decided_ = 0; - left_->reset(); - if (right_) - { - right_->reset(); - } + left_->reset(); + if (right_) { + right_->reset(); + } } void DDSFilterCompoundCondition::child_has_changed( - const DDSFilterCondition& child) noexcept + const DDSFilterCondition & child) noexcept { - DDSFilterConditionState child_state = child.get_state(); - assert(DDSFilterConditionState::UNDECIDED != child_state); - - ++num_children_decided_; - - if (DDSFilterConditionState::UNDECIDED == get_state()) - { - switch (op_) - { - case OperationKind::NOT: - set_result(DDSFilterConditionState::RESULT_FALSE == child_state); - break; - - case OperationKind::AND: - if (DDSFilterConditionState::RESULT_FALSE == child_state) - { - set_result(false); - } - else - { - if (2 == num_children_decided_) - { - set_result(true); - } - } - break; - - case OperationKind::OR: - if (DDSFilterConditionState::RESULT_TRUE == child_state) - { - set_result(true); - } - else - { - if (2 == num_children_decided_) - { - set_result(false); - } - } - break; - - default: - assert(false); + DDSFilterConditionState child_state = child.get_state(); + assert(DDSFilterConditionState::UNDECIDED != child_state); + + ++num_children_decided_; + + if (DDSFilterConditionState::UNDECIDED == get_state()) { + switch (op_) { + case OperationKind::NOT: + set_result(DDSFilterConditionState::RESULT_FALSE == child_state); + break; + + case OperationKind::AND: + if (DDSFilterConditionState::RESULT_FALSE == child_state) { + set_result(false); + } else { + if (2 == num_children_decided_) { + set_result(true); + } } + break; + + case OperationKind::OR: + if (DDSFilterConditionState::RESULT_TRUE == child_state) { + set_result(true); + } else { + if (2 == num_children_decided_) { + set_result(false); + } + } + break; + + default: + assert(false); } + } } } // namespace DDSSQLFilter diff --git a/common_content_filter/src/DDSFilterCompoundCondition.hpp b/common_content_filter/src/DDSFilterCompoundCondition.hpp index 585aaa5..6532ae9 100644 --- a/common_content_filter/src/DDSFilterCompoundCondition.hpp +++ b/common_content_filter/src/DDSFilterCompoundCondition.hpp @@ -23,10 +23,14 @@ #include "DDSFilterCondition.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ /** * A DDSFilterCondition that performs a logical operation over one or two DDSFilterCondition objects. @@ -35,44 +39,41 @@ class DDSFilterCompoundCondition final : public DDSFilterCondition { public: - - /** - * Possible kinds of logical operations - */ - enum class OperationKind : uint8_t - { - NOT, ///< NOT left - AND, ///< left AND right - OR ///< left OR right - }; - - /** - * Construct a DDSFilterCompoundCondition. - * - * @param[in] op Operation to perform. - * @param[in] left Left operand. - * @param[in] right Right operand. - */ - DDSFilterCompoundCondition( - OperationKind op, - std::unique_ptr&& left, - std::unique_ptr&& right); - - virtual ~DDSFilterCompoundCondition() = default; + /** + * Possible kinds of logical operations + */ + enum class OperationKind : uint8_t + { + NOT, ///< NOT left + AND, ///< left AND right + OR ///< left OR right + }; + + /** + * Construct a DDSFilterCompoundCondition. + * + * @param[in] op Operation to perform. + * @param[in] left Left operand. + * @param[in] right Right operand. + */ + DDSFilterCompoundCondition( + OperationKind op, + std::unique_ptr && left, + std::unique_ptr && right); + + virtual ~DDSFilterCompoundCondition() = default; protected: + void propagate_reset() noexcept final; - void propagate_reset() noexcept final; - - void child_has_changed( - const DDSFilterCondition& child) noexcept final; + void child_has_changed( + const DDSFilterCondition & child) noexcept final; private: - - OperationKind op_; - std::unique_ptr left_; - std::unique_ptr right_; - uint8_t num_children_decided_ = 0; + OperationKind op_; + std::unique_ptr left_; + std::unique_ptr right_; + uint8_t num_children_decided_ = 0; }; diff --git a/common_content_filter/src/DDSFilterCondition.hpp b/common_content_filter/src/DDSFilterCondition.hpp index 784755f..9410501 100644 --- a/common_content_filter/src/DDSFilterCondition.hpp +++ b/common_content_filter/src/DDSFilterCondition.hpp @@ -21,10 +21,14 @@ #include "DDSFilterConditionState.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ /** * Base class for conditions on a filter expression. @@ -33,97 +37,92 @@ class DDSFilterCondition { public: - - friend class DDSFilterCompoundCondition; - - virtual ~DDSFilterCondition() = default; - - /** - * @return the current state of this condition. - */ - inline DDSFilterConditionState get_state() const noexcept - { - return state_; - } - - /** - * Instruct this condition to reset. - * Will propagate the reset command down the expression tree. - * - * @post The state of this condition will be UNDECIDED. - */ - inline void reset() noexcept - { - state_ = DDSFilterConditionState::UNDECIDED; - propagate_reset(); - } + friend class DDSFilterCompoundCondition; + + virtual ~DDSFilterCondition() = default; + + /** + * @return the current state of this condition. + */ + inline DDSFilterConditionState get_state() const noexcept + { + return state_; + } + + /** + * Instruct this condition to reset. + * Will propagate the reset command down the expression tree. + * + * @post The state of this condition will be UNDECIDED. + */ + inline void reset() noexcept + { + state_ = DDSFilterConditionState::UNDECIDED; + propagate_reset(); + } protected: - - /** - * Set a new state for this condition. - * May propagate the change up the expression tree by calling - * @ref child_has_changed on the parent of this condition. - * - * @param[in] state New state for this condition. - * - * @post The state of this condition will be @c state. - */ - inline void set_state( - DDSFilterConditionState state) noexcept - { - if (state != state_) - { - state_ = state; - if (nullptr != parent_) - { - parent_->child_has_changed(*this); - } - } - } - - /** - * Set the result of this condition. - * - * @param[in] result The result to be set. - * - * @post The state of this condition will not be UNDECIDED. - */ - inline void set_result( - bool result) noexcept - { - set_state(result ? DDSFilterConditionState::RESULT_TRUE : DDSFilterConditionState::RESULT_FALSE); - } - - /** - * Set a new parent for this condition. - * - * @param parent New parent to set. - */ - inline void set_parent( - DDSFilterCondition* parent) noexcept - { - parent_ = parent; + /** + * Set a new state for this condition. + * May propagate the change up the expression tree by calling + * @ref child_has_changed on the parent of this condition. + * + * @param[in] state New state for this condition. + * + * @post The state of this condition will be @c state. + */ + inline void set_state( + DDSFilterConditionState state) noexcept + { + if (state != state_) { + state_ = state; + if (nullptr != parent_) { + parent_->child_has_changed(*this); + } } - - /** - * Propagates the reset command down the expression tree. - */ - virtual void propagate_reset() noexcept = 0; - - - /** - * A child condition will call this method whenever its state is changed. - * - * @param[in] child The child condition - */ - virtual void child_has_changed( - const DDSFilterCondition& child) noexcept = 0; + } + + /** + * Set the result of this condition. + * + * @param[in] result The result to be set. + * + * @post The state of this condition will not be UNDECIDED. + */ + inline void set_result( + bool result) noexcept + { + set_state(result ? DDSFilterConditionState::RESULT_TRUE : DDSFilterConditionState::RESULT_FALSE); + } + + /** + * Set a new parent for this condition. + * + * @param parent New parent to set. + */ + inline void set_parent( + DDSFilterCondition * parent) noexcept + { + parent_ = parent; + } + + /** + * Propagates the reset command down the expression tree. + */ + virtual void propagate_reset() noexcept = 0; + + + /** + * A child condition will call this method whenever its state is changed. + * + * @param[in] child The child condition + */ + virtual void child_has_changed( + const DDSFilterCondition & child) noexcept = 0; private: - - DDSFilterConditionState state_ = DDSFilterConditionState::UNDECIDED; - DDSFilterCondition* parent_ = nullptr; + DDSFilterConditionState state_ = DDSFilterConditionState::UNDECIDED; + DDSFilterCondition * parent_ = nullptr; }; diff --git a/common_content_filter/src/DDSFilterConditionState.hpp b/common_content_filter/src/DDSFilterConditionState.hpp index c48ba09..f149f0a 100644 --- a/common_content_filter/src/DDSFilterConditionState.hpp +++ b/common_content_filter/src/DDSFilterConditionState.hpp @@ -19,24 +19,28 @@ #ifndef COMMON_CONTENT_FILTER__DDSFILTERCONDITIONSTATE_HPP_ #define COMMON_CONTENT_FILTER__DDSFILTERCONDITIONSTATE_HPP_ -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ /** * Possible states of a DDSFilterCondition. */ enum class DDSFilterConditionState : char { - /// Initial state of the DDSFilterCondition, indicating there is no result. - UNDECIDED, + /// Initial state of the DDSFilterCondition, indicating there is no result. + UNDECIDED, - /// State indicating that the DDSFilterCondition evaluates to @c false. - RESULT_FALSE, + /// State indicating that the DDSFilterCondition evaluates to @c false. + RESULT_FALSE, - /// State indicating that the DDSFilterCondition evaluates to @c true. - RESULT_TRUE + /// State indicating that the DDSFilterCondition evaluates to @c true. + RESULT_TRUE }; } // namespace DDSSQLFilter diff --git a/common_content_filter/src/DDSFilterEmptyExpression.hpp b/common_content_filter/src/DDSFilterEmptyExpression.hpp index d34c3df..94b2121 100644 --- a/common_content_filter/src/DDSFilterEmptyExpression.hpp +++ b/common_content_filter/src/DDSFilterEmptyExpression.hpp @@ -21,10 +21,14 @@ #include "IContentFilter.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ /** * An IContentFilter for empty expressions that always evaluates to true. @@ -33,14 +37,13 @@ class DDSFilterEmptyExpression final : public IContentFilter { public: + bool evaluate( + const void * payload) const final + { + static_cast(payload); - bool evaluate( - const void * payload) const final - { - static_cast(payload); - - return true; - } + return true; + } }; diff --git a/common_content_filter/src/DDSFilterExpression.cpp b/common_content_filter/src/DDSFilterExpression.cpp index 26ad66b..2f5ffc0 100644 --- a/common_content_filter/src/DDSFilterExpression.cpp +++ b/common_content_filter/src/DDSFilterExpression.cpp @@ -28,35 +28,38 @@ #include "DDSFilterParameter.hpp" #include "Log.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ bool DDSFilterExpression::evaluate( - const void * payload) const + const void * payload) const { - // logDebug(DDSSQLFILTER, "DDSFilterExpression::evaluate fields size:" << fields.size()); + // logDebug(DDSSQLFILTER, "DDSFilterExpression::evaluate fields size:" << fields.size()); - root->reset(); - for (auto it = fields.begin(); - it != fields.end() && DDSFilterConditionState::UNDECIDED == root->get_state(); - ++it) - { - if (!it->second->set_value(payload)) - { - return false; - } + root->reset(); + for (auto it = fields.begin(); + it != fields.end() && DDSFilterConditionState::UNDECIDED == root->get_state(); + ++it) + { + if (!it->second->set_value(payload)) { + return false; } + } - return DDSFilterConditionState::RESULT_TRUE == root->get_state(); + return DDSFilterConditionState::RESULT_TRUE == root->get_state(); } void DDSFilterExpression::clear() { - parameters.clear(); - fields.clear(); - root.reset(); + parameters.clear(); + fields.clear(); + root.reset(); } diff --git a/common_content_filter/src/DDSFilterExpression.hpp b/common_content_filter/src/DDSFilterExpression.hpp index 078250d..f75d278 100644 --- a/common_content_filter/src/DDSFilterExpression.hpp +++ b/common_content_filter/src/DDSFilterExpression.hpp @@ -29,10 +29,14 @@ #include "DDSFilterField.hpp" #include "DDSFilterParameter.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ /** * An IContentFilter that evaluates DDS-SQL filter expressions @@ -41,21 +45,20 @@ class DDSFilterExpression final : public IContentFilter { public: + bool evaluate( + const void * payload) const final; - bool evaluate( - const void * payload) const final; - - /** - * Clear the information held by this object. - */ - void clear(); + /** + * Clear the information held by this object. + */ + void clear(); - /// The root condition of the expression tree. - std::unique_ptr root; - /// The fields referenced by this expression. - std::map> fields; - /// The parameters referenced by this expression. - std::vector> parameters; + /// The root condition of the expression tree. + std::unique_ptr root; + /// The fields referenced by this expression. + std::map> fields; + /// The parameters referenced by this expression. + std::vector> parameters; }; } // namespace DDSSQLFilter diff --git a/common_content_filter/src/DDSFilterExpressionParser.cpp b/common_content_filter/src/DDSFilterExpressionParser.cpp index a2b2015..6e8ef07 100644 --- a/common_content_filter/src/DDSFilterExpressionParser.cpp +++ b/common_content_filter/src/DDSFilterExpressionParser.cpp @@ -37,11 +37,16 @@ #include "DDSFilterField.hpp" #include "Log.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { -namespace parser { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ +namespace parser +{ using namespace tao::TAO_PEGTL_NAMESPACE; @@ -51,98 +56,90 @@ using namespace tao::TAO_PEGTL_NAMESPACE; #include "DDSFilterExpressionParserImpl/parameters.hpp" // select which rules in the grammar will produce parse tree nodes: -template< typename Rule > -using selector = parse_tree::selector < - Rule, - literal_value_processor::on< - true_value, - false_value, - hex_value, - integer_value, - float_value, - char_value, - string_value >, - parameter_processor::on< - parameter_value>, - parse_tree::store_content::on< - string_content, - integer, - index_part, - identifier >, - parse_tree::remove_content::on< - eq_op, - gt_op, - ge_op, - lt_op, - le_op, - ne_op, - like_op, - match_op, - and_op, - or_op, - not_op, - dot_op, - between_op, - not_between_op >, - rearrange::on< - boolean_value, - ComparisonPredicate, - BetweenPredicate, - Range, - Condition, - FilterExpression >, - identifier_processor::on< - fieldname_part, - fieldname > - >; +template +using selector = parse_tree::selector< + Rule, + literal_value_processor::on< + true_value, + false_value, + hex_value, + integer_value, + float_value, + char_value, + string_value>, + parameter_processor::on< + parameter_value>, + parse_tree::store_content::on< + string_content, + integer, + index_part, + identifier>, + parse_tree::remove_content::on< + eq_op, + gt_op, + ge_op, + lt_op, + le_op, + ne_op, + like_op, + match_op, + and_op, + or_op, + not_op, + dot_op, + between_op, + not_between_op>, + rearrange::on< + boolean_value, + ComparisonPredicate, + BetweenPredicate, + Range, + Condition, + FilterExpression>, + identifier_processor::on< + fieldname_part, + fieldname> +>; std::unique_ptr parse_filter_expression( - const char* expression, - const rosidl_message_type_support_t* type_support) + const char * expression, + const rosidl_message_type_support_t * type_support) { - memory_input<> in(expression, ""); - try - { - CurrentIdentifierState identifier_state { type_support, nullptr, 0, {} }; - return parse_tree::parse< FilterExpressionGrammar, ParseNode, selector >(in, identifier_state); - } - catch (const parse_error& e) - { - const auto p = e.positions.front(); - logError(DDSSQLFILTER, "PARSE ERROR: " << e.what() << std::endl - << in.line_at(p) << std::endl - << std::string(p.byte_in_line, ' ') << '^'); - } - catch (const std::exception& e) - { - logError(DDSSQLFILTER, "ERROR '" << e.what() << "' while parsing " << expression); - } + memory_input<> in(expression, ""); + try { + CurrentIdentifierState identifier_state {type_support, nullptr, 0, {}}; + return parse_tree::parse(in, identifier_state); + } catch (const parse_error & e) { + const auto p = e.positions.front(); + logError( + DDSSQLFILTER, "PARSE ERROR: " << e.what() << std::endl + << in.line_at(p) << std::endl + << std::string(p.byte_in_line, ' ') << '^'); + } catch (const std::exception & e) { + logError(DDSSQLFILTER, "ERROR '" << e.what() << "' while parsing " << expression); + } - return nullptr; + return nullptr; } std::unique_ptr parse_literal_value( - const char* expression) + const char * expression) { - memory_input<> in(expression, ""); - try - { - CurrentIdentifierState identifier_state{ nullptr, nullptr, 0, {} }; - return parse_tree::parse< LiteralGrammar, ParseNode, selector >(in, identifier_state); - } - catch (const parse_error& e) - { - const auto p = e.positions.front(); - logError(DDSSQLFILTER, "PARSE ERROR: " << e.what() << std::endl - << in.line_at(p) << std::endl - << std::string(p.byte_in_line, ' ') << '^'); - } - catch (const std::exception& e) - { - logError(DDSSQLFILTER, "ERROR '" << e.what() << "' while parsing " << expression); - } + memory_input<> in(expression, ""); + try { + CurrentIdentifierState identifier_state{nullptr, nullptr, 0, {}}; + return parse_tree::parse(in, identifier_state); + } catch (const parse_error & e) { + const auto p = e.positions.front(); + logError( + DDSSQLFILTER, "PARSE ERROR: " << e.what() << std::endl + << in.line_at(p) << std::endl + << std::string(p.byte_in_line, ' ') << '^'); + } catch (const std::exception & e) { + logError(DDSSQLFILTER, "ERROR '" << e.what() << "' while parsing " << expression); + } - return nullptr; + return nullptr; } } // namespace parser diff --git a/common_content_filter/src/DDSFilterExpressionParser.hpp b/common_content_filter/src/DDSFilterExpressionParser.hpp index bfe4ee8..54aa737 100644 --- a/common_content_filter/src/DDSFilterExpressionParser.hpp +++ b/common_content_filter/src/DDSFilterExpressionParser.hpp @@ -24,11 +24,16 @@ #include "DDSFilterParseNode.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { -namespace parser { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ +namespace parser +{ /** * Performs parsing of a string containing a DDS-SQL filter expression. @@ -40,8 +45,8 @@ namespace parser { * @return A pointer to the root node of the AST tree for the expression. */ std::unique_ptr parse_filter_expression( - const char* expression, - const rosidl_message_type_support_t* type_support); + const char * expression, + const rosidl_message_type_support_t * type_support); /** * Performs parsing of a string containing a literal value. @@ -53,7 +58,7 @@ std::unique_ptr parse_filter_expression( * @return A simple tree consisting of a root node, with a single child that contains the generated DDSFilterValue. */ std::unique_ptr parse_literal_value( - const char* value); + const char * value); } // namespace parser } // namespace DDSSQLFilter diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp index d11c4f9..a0853d2 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp @@ -22,206 +22,194 @@ struct CurrentIdentifierState { - const rosidl_message_type_support_t * type_support; + const rosidl_message_type_support_t * type_support; - const rosidl_message_type_support_t * current_type_support; + const rosidl_message_type_support_t * current_type_support; - uint8_t current_type; + uint8_t current_type; - std::vector access_path; + std::vector access_path; }; struct identifier_processor - : parse_tree::apply< identifier_processor > + : parse_tree::apply { - static const rosidl_message_type_support_t * - get_type_support_introspection( - const rosidl_message_type_support_t * type_support) - { - const rosidl_message_type_support_t * type_support_introspection = + static const rosidl_message_type_support_t * + get_type_support_introspection( + const rosidl_message_type_support_t * type_support) + { + const rosidl_message_type_support_t * type_support_introspection = + get_message_typesupport_handle( + type_support, rosidl_typesupport_introspection_c__identifier); + if (nullptr == type_support_introspection) { + rcutils_error_string_t prev_error_string = rcutils_get_error_string(); + rcutils_reset_error(); + + type_support_introspection = get_message_typesupport_handle( - type_support, rosidl_typesupport_introspection_c__identifier); + type_support, + rosidl_typesupport_introspection_cpp::typesupport_identifier); if (nullptr == type_support_introspection) { - rcutils_error_string_t prev_error_string = rcutils_get_error_string(); + rcutils_error_string_t error_string = rcutils_get_error_string(); rcutils_reset_error(); - - type_support_introspection = - get_message_typesupport_handle( - type_support, - rosidl_typesupport_introspection_cpp::typesupport_identifier); - if (nullptr == type_support_introspection) { - rcutils_error_string_t error_string = rcutils_get_error_string(); - rcutils_reset_error(); - RMW_SET_ERROR_MSG_WITH_FORMAT_STRING( - "Type support not from this implementation. Got:\n" - " %s\n" - " %s\n" - "while fetching it", - prev_error_string.str, error_string.str); - return nullptr; - } + RMW_SET_ERROR_MSG_WITH_FORMAT_STRING( + "Type support not from this implementation. Got:\n" + " %s\n" + " %s\n" + "while fetching it", + prev_error_string.str, error_string.str); + return nullptr; } + } - return type_support_introspection; + return type_support_introspection; + } + + template + static void + add_access_path( + CurrentIdentifierState & identifier_state, + std::unique_ptr & n, + const rosidl_message_type_support_t * type_support_introspection) + { + const MembersType * members = + static_cast(type_support_introspection->data); + if (!members) { + throw std::runtime_error("The data in the type support introspection is invalid."); } - template - static void - add_access_path( - CurrentIdentifierState& identifier_state, - std::unique_ptr< ParseNode >& n, - const rosidl_message_type_support_t * type_support_introspection) - { - const MembersType * members = static_cast(type_support_introspection->data); - if (!members) { - throw std::runtime_error("The data in the type support introspection is invalid."); - } + size_t member_index = 0; + size_t array_index = std::numeric_limits::max(); - size_t member_index = 0; - size_t array_index = std::numeric_limits::max(); - - const ParseNode& name_node = n->left(); - std::string parse_node_name = name_node.content(); - - for (uint32_t i = 0; i < members->member_count_; ++i) { - const auto member = members->members_ + i; - - if (member->name_ == parse_node_name) { - member_index = i; - bool has_index = n->children.size() > 1; - if (member->is_array_) - { - if (!has_index) - { - throw parse_error("field should have an index (i.e. [n])", n->left().end()); - } - - array_index = static_cast(std::stoul(n->right().left().content())); - - if (member->array_size_ && !member->is_upper_bound_) { - if (member->array_size_ <= array_index) - { - throw parse_error("index is greater than maximum size", n->right().end()); - } - } - } - else - { - if (has_index) - { - throw parse_error("field is not an array or sequence", n->right().begin()); - } - } + const ParseNode & name_node = n->left(); + std::string parse_node_name = name_node.content(); - identifier_state.current_type = member->type_id_; + for (uint32_t i = 0; i < members->member_count_; ++i) { + const auto member = members->members_ + i; - if (member->type_id_ == ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE) { - identifier_state.current_type_support = member->members_; + if (member->name_ == parse_node_name) { + member_index = i; + bool has_index = n->children.size() > 1; + if (member->is_array_) { + if (!has_index) { + throw parse_error("field should have an index (i.e. [n])", n->left().end()); } - identifier_state.access_path.emplace_back( - DDSFilterField::FieldAccessor{ member_index, array_index, type_support_introspection }); + array_index = static_cast(std::stoul(n->right().left().content())); - return; + if (member->array_size_ && !member->is_upper_bound_) { + if (member->array_size_ <= array_index) { + throw parse_error("index is greater than maximum size", n->right().end()); + } + } + } else { + if (has_index) { + throw parse_error("field is not an array or sequence", n->right().begin()); + } } - } - throw parse_error("field not found", name_node.begin()); - } - static void add_member_access( - std::unique_ptr< ParseNode >& n, - CurrentIdentifierState& identifier_state, - const rosidl_message_type_support_t * type_support) - { - const rosidl_message_type_support_t * type_support_introspection = - get_type_support_introspection(type_support); - if (!type_support_introspection) { - throw std::runtime_error("failed to get type support introspection"); - } + identifier_state.current_type = member->type_id_; - if (type_support_introspection->typesupport_identifier == - rosidl_typesupport_introspection_c__identifier) - { - add_access_path( - identifier_state, n, type_support_introspection); - } else { - add_access_path( - identifier_state, n, type_support_introspection); + if (member->type_id_ == ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE) { + identifier_state.current_type_support = member->members_; } - } - static DDSFilterValue::ValueKind get_value_kind( - uint8_t type_id, - const position& pos) - { - switch (type_id) - { - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: - return DDSFilterValue::ValueKind::BOOLEAN; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_CHAR: - return DDSFilterValue::ValueKind::CHAR; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: - return DDSFilterValue::ValueKind::STRING; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT8: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT16: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT32: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT64: - return DDSFilterValue::ValueKind::SIGNED_INTEGER; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_OCTET: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT8: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT16: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT32: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT64: - return DDSFilterValue::ValueKind::UNSIGNED_INTEGER; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: - return DDSFilterValue::ValueKind::FLOAT_FIELD; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_DOUBLE: - return DDSFilterValue::ValueKind::DOUBLE_FIELD; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_LONG_DOUBLE: - return DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: - break; - } + identifier_state.access_path.emplace_back( + DDSFilterField::FieldAccessor{member_index, array_index, type_support_introspection}); - throw parse_error("type is not primitive", pos); + return; + } + } + throw parse_error("field not found", name_node.begin()); + } + + static void add_member_access( + std::unique_ptr & n, + CurrentIdentifierState & identifier_state, + const rosidl_message_type_support_t * type_support) + { + const rosidl_message_type_support_t * type_support_introspection = + get_type_support_introspection(type_support); + if (!type_support_introspection) { + throw std::runtime_error("failed to get type support introspection"); } - template< typename ... States > - static void transform( - std::unique_ptr< ParseNode >& n, - CurrentIdentifierState& state, - States&&... /*st*/) + if (type_support_introspection->typesupport_identifier == + rosidl_typesupport_introspection_c__identifier) { - // logDebug(DDSSQLFILTER, "identifiers transform node name:" << n->content()); - - if (n->is()) - { - // Set data for fieldname node - n->field_kind = get_value_kind(state.current_type, n->end()); - n->field_access_path = state.access_path; - n->type_id = state.current_type; - - // Reset parser state - state.access_path.clear(); - state.current_type = 0; - state.current_type_support = nullptr; - } - else - { - if (0 == state.current_type) - { - add_member_access(n, state, state.type_support); - } - else - { - add_member_access(n, state, state.current_type_support); - } - } + add_access_path( + identifier_state, n, type_support_introspection); + } else { + add_access_path( + identifier_state, n, type_support_introspection); + } + } + + static DDSFilterValue::ValueKind get_value_kind( + uint8_t type_id, + const position & pos) + { + switch (type_id) { + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: + return DDSFilterValue::ValueKind::BOOLEAN; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_CHAR: + return DDSFilterValue::ValueKind::CHAR; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: + return DDSFilterValue::ValueKind::STRING; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT8: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT16: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT32: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT64: + return DDSFilterValue::ValueKind::SIGNED_INTEGER; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_OCTET: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT8: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT16: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT32: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT64: + return DDSFilterValue::ValueKind::UNSIGNED_INTEGER; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: + return DDSFilterValue::ValueKind::FLOAT_FIELD; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_DOUBLE: + return DDSFilterValue::ValueKind::DOUBLE_FIELD; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_LONG_DOUBLE: + return DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: + break; + } - n->children.clear(); + throw parse_error("type is not primitive", pos); + } + + template + static void transform( + std::unique_ptr & n, + CurrentIdentifierState & state, + States &&... /*st*/) + { + // logDebug(DDSSQLFILTER, "identifiers transform node name:" << n->content()); + + if (n->is()) { + // Set data for fieldname node + n->field_kind = get_value_kind(state.current_type, n->end()); + n->field_access_path = state.access_path; + n->type_id = state.current_type; + + // Reset parser state + state.access_path.clear(); + state.current_type = 0; + state.current_type_support = nullptr; + } else { + if (0 == state.current_type) { + add_member_access(n, state, state.type_support); + } else { + add_member_access(n, state, state.current_type_support); + } } + n->children.clear(); + } + }; diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/literal_values.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/literal_values.hpp index cde58ee..e97865a 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/literal_values.hpp +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/literal_values.hpp @@ -20,66 +20,51 @@ */ struct literal_value_processor - : parse_tree::apply< literal_value_processor > + : parse_tree::apply { - template< typename ... States > - static void transform( - std::unique_ptr< ParseNode >& n, - States&&... /*st*/) - { - n->value.reset(new DDSFilterValue()); - if (n->is()) - { + template + static void transform( + std::unique_ptr & n, + States &&... /*st*/) + { + n->value.reset(new DDSFilterValue()); + if (n->is()) { - n->value->kind = DDSFilterValue::ValueKind::BOOLEAN; - n->value->boolean_value = true; - } - else if (n->is()) - { + n->value->kind = DDSFilterValue::ValueKind::BOOLEAN; + n->value->boolean_value = true; + } else if (n->is()) { - n->value->kind = DDSFilterValue::ValueKind::BOOLEAN; - n->value->boolean_value = false; - } - else if (n->is() || n->is()) - { + n->value->kind = DDSFilterValue::ValueKind::BOOLEAN; + n->value->boolean_value = false; + } else if (n->is() || n->is()) { - if (n->m_begin.data[0] == '-') - { - n->value->kind = DDSFilterValue::ValueKind::SIGNED_INTEGER; - n->value->signed_integer_value = std::stoll(n->content(), nullptr, 0); - } - else - { - n->value->kind = DDSFilterValue::ValueKind::UNSIGNED_INTEGER; - n->value->unsigned_integer_value = std::stoull(n->content(), nullptr, 0); - } - } - else if (n->is()) - { + if (n->m_begin.data[0] == '-') { + n->value->kind = DDSFilterValue::ValueKind::SIGNED_INTEGER; + n->value->signed_integer_value = std::stoll(n->content(), nullptr, 0); + } else { + n->value->kind = DDSFilterValue::ValueKind::UNSIGNED_INTEGER; + n->value->unsigned_integer_value = std::stoull(n->content(), nullptr, 0); + } + } else if (n->is()) { - n->value->kind = DDSFilterValue::ValueKind::FLOAT_CONST; - n->value->float_value = std::stold(n->content()); - } - else if (n->is()) - { + n->value->kind = DDSFilterValue::ValueKind::FLOAT_CONST; + n->value->float_value = std::stold(n->content()); + } else if (n->is()) { - n->value->kind = DDSFilterValue::ValueKind::CHAR; - n->value->char_value = n->m_begin.data[1]; - } - else if (n->is()) - { + n->value->kind = DDSFilterValue::ValueKind::CHAR; + n->value->char_value = n->m_begin.data[1]; + } else if (n->is()) { - const ParseNode& content_node = n->left(); - size_t str_len = content_node.m_end.byte - content_node.m_begin.byte; - if (sizeof(n->value->string_value) < str_len) - { - throw parse_error("string constant has more than 255 characters", n->end()); - } - n->value->kind = DDSFilterValue::ValueKind::STRING; - strncpy(n->value->string_value, content_node.m_begin.data, str_len); - } - - n->children.clear(); + const ParseNode & content_node = n->left(); + size_t str_len = content_node.m_end.byte - content_node.m_begin.byte; + if (sizeof(n->value->string_value) < str_len) { + throw parse_error("string constant has more than 255 characters", n->end()); + } + n->value->kind = DDSFilterValue::ValueKind::STRING; + strncpy(n->value->string_value, content_node.m_begin.data, str_len); } + n->children.clear(); + } + }; diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/parameters.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/parameters.hpp index c3b94c5..3d7ba7f 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/parameters.hpp +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/parameters.hpp @@ -20,19 +20,18 @@ */ struct parameter_processor - : parse_tree::apply< parameter_processor > + : parse_tree::apply { - template< typename ... States > - static void transform( - std::unique_ptr< ParseNode >& n, - States&&... /*st*/) - { - n->parameter_index = static_cast(n->m_begin.data[1] - '0'); - if (n->m_end.byte - n->m_begin.byte == 3) - { - n->parameter_index *= 10; - n->parameter_index += static_cast(n->m_begin.data[2] - '0'); - } + template + static void transform( + std::unique_ptr & n, + States &&... /*st*/) + { + n->parameter_index = static_cast(n->m_begin.data[1] - '0'); + if (n->m_end.byte - n->m_begin.byte == 3) { + n->parameter_index *= 10; + n->parameter_index += static_cast(n->m_begin.data[2] - '0'); } + } }; diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/rearrange.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/rearrange.hpp index b1353ca..55ce6a8 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/rearrange.hpp +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/rearrange.hpp @@ -21,53 +21,47 @@ // after a node is stored successfully, you can add an optional transformer like this: struct rearrange - : parse_tree::apply< rearrange > // allows bulk selection, see selector<...> + : parse_tree::apply // allows bulk selection, see selector<...> { - // recursively rearrange nodes. the basic principle is: - // - // from: SEQ_BASED_RULE - // / | \ (LHS... may be one or more children, followed by OP,) - // LHS... OP RHS (which is one operator, and RHS, which is a single child) - // - // to: OP - // / \ (OP now has two children, the original PROD/EXPR and RHS) - // SEQ_BASED_RULE RHS (Note that PROD/EXPR has two fewer children now) - // | - // LHS... - // - // if only one child is left for LHS..., replace the SEQ_BASED_RULE with the child directly. - // otherwise, perform the above transformation, then apply it recursively until LHS... - // becomes a single child, which then replaces the parent node and the recursion ends. - template< typename ... States > - static void transform( - std::unique_ptr< ParseNode >& n, - States&&... st) - { - if (n->children.size() == 1) - { - n = std::move(n->children.back()); - } - else - { - n->remove_content(); - auto& c = n->children; - auto r = std::move(c.back()); - c.pop_back(); - auto o = std::move(c.back()); - c.pop_back(); - if (c.empty()) - { - o->children.emplace_back(std::move(r)); - n = std::move(o); - } - else - { - o->children.emplace_back(std::move(n)); - o->children.emplace_back(std::move(r)); - n = std::move(o); - transform(n->children.front(), st ...); - } - } + // recursively rearrange nodes. the basic principle is: + // + // from: SEQ_BASED_RULE + // / | \ (LHS... may be one or more children, followed by OP,) + // LHS... OP RHS (which is one operator, and RHS, which is a single child) + // + // to: OP + // / \ (OP now has two children, the original PROD/EXPR and RHS) + // SEQ_BASED_RULE RHS (Note that PROD/EXPR has two fewer children now) + // | + // LHS... + // + // if only one child is left for LHS..., replace the SEQ_BASED_RULE with the child directly. + // otherwise, perform the above transformation, then apply it recursively until LHS... + // becomes a single child, which then replaces the parent node and the recursion ends. + template + static void transform( + std::unique_ptr & n, + States &&... st) + { + if (n->children.size() == 1) { + n = std::move(n->children.back()); + } else { + n->remove_content(); + auto & c = n->children; + auto r = std::move(c.back()); + c.pop_back(); + auto o = std::move(c.back()); + c.pop_back(); + if (c.empty()) { + o->children.emplace_back(std::move(r)); + n = std::move(o); + } else { + o->children.emplace_back(std::move(n)); + o->children.emplace_back(std::move(r)); + n = std::move(o); + transform(n->children.front(), st ...); + } } + } }; diff --git a/common_content_filter/src/DDSFilterFactory.cpp b/common_content_filter/src/DDSFilterFactory.cpp index 4a644dc..1e1045d 100644 --- a/common_content_filter/src/DDSFilterFactory.cpp +++ b/common_content_filter/src/DDSFilterFactory.cpp @@ -39,521 +39,444 @@ #include "DDSFilterValue.hpp" #include "Log.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ static IContentFilterFactory::ReturnCode_t transform_enum( - std::shared_ptr& value, - uint8_t type, - const std::string& string_value) + std::shared_ptr & value, + uint8_t type, + const std::string & string_value) { - static_cast(value); - static_cast(type); - static_cast(string_value); - // TODO. when enum supported in the rosidl + static_cast(value); + static_cast(type); + static_cast(string_value); + // TODO. when enum supported in the rosidl - return IContentFilterFactory::ReturnCode_t::RETCODE_BAD_PARAMETER; + return IContentFilterFactory::ReturnCode_t::RETCODE_BAD_PARAMETER; } static IContentFilterFactory::ReturnCode_t transform_enums( - std::shared_ptr& left_value, - uint8_t left_type, - std::shared_ptr& right_value, - uint8_t right_type) + std::shared_ptr & left_value, + uint8_t left_type, + std::shared_ptr & right_value, + uint8_t right_type) { - if ((DDSFilterValue::ValueKind::ENUM == left_value->kind) && - (DDSFilterValue::ValueKind::STRING == right_value->kind)) - { - return transform_enum(right_value, left_type, right_value->string_value); - } - - if ((DDSFilterValue::ValueKind::ENUM == right_value->kind) && - (DDSFilterValue::ValueKind::STRING == left_value->kind)) - { - return transform_enum(left_value, right_type, left_value->string_value); - } - - return IContentFilterFactory::ReturnCode_t::RETCODE_OK; + if ((DDSFilterValue::ValueKind::ENUM == left_value->kind) && + (DDSFilterValue::ValueKind::STRING == right_value->kind)) + { + return transform_enum(right_value, left_type, right_value->string_value); + } + + if ((DDSFilterValue::ValueKind::ENUM == right_value->kind) && + (DDSFilterValue::ValueKind::STRING == left_value->kind)) + { + return transform_enum(left_value, right_type, left_value->string_value); + } + + return IContentFilterFactory::ReturnCode_t::RETCODE_OK; } static bool check_value_compatibility( - DDSFilterValue::ValueKind left, - DDSFilterValue::ValueKind right, - bool ignore_enum) + DDSFilterValue::ValueKind left, + DDSFilterValue::ValueKind right, + bool ignore_enum) { - if (!ignore_enum && DDSFilterValue::ValueKind::ENUM == right) - { - return DDSFilterValue::ValueKind::ENUM == left || - DDSFilterValue::ValueKind::SIGNED_INTEGER == left || - DDSFilterValue::ValueKind::UNSIGNED_INTEGER == left || - DDSFilterValue::ValueKind::STRING == left; - } - - switch (left) - { - case DDSFilterValue::ValueKind::BOOLEAN: - return DDSFilterValue::ValueKind::BOOLEAN == right || - DDSFilterValue::ValueKind::SIGNED_INTEGER == right || - DDSFilterValue::ValueKind::UNSIGNED_INTEGER == right; - - case DDSFilterValue::ValueKind::SIGNED_INTEGER: - case DDSFilterValue::ValueKind::UNSIGNED_INTEGER: - return DDSFilterValue::ValueKind::SIGNED_INTEGER == right || - DDSFilterValue::ValueKind::UNSIGNED_INTEGER == right || - DDSFilterValue::ValueKind::BOOLEAN == right || - DDSFilterValue::ValueKind::FLOAT_CONST == right || - DDSFilterValue::ValueKind::FLOAT_FIELD == right || - DDSFilterValue::ValueKind::DOUBLE_FIELD == right || - DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD == right; - - case DDSFilterValue::ValueKind::CHAR: - case DDSFilterValue::ValueKind::STRING: - return DDSFilterValue::ValueKind::CHAR == right || - DDSFilterValue::ValueKind::STRING == right; - - case DDSFilterValue::ValueKind::FLOAT_CONST: - case DDSFilterValue::ValueKind::FLOAT_FIELD: - case DDSFilterValue::ValueKind::DOUBLE_FIELD: - case DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD: - return DDSFilterValue::ValueKind::FLOAT_CONST == right || - DDSFilterValue::ValueKind::FLOAT_FIELD == right || - DDSFilterValue::ValueKind::DOUBLE_FIELD == right || - DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD == right || - DDSFilterValue::ValueKind::SIGNED_INTEGER == right || - DDSFilterValue::ValueKind::UNSIGNED_INTEGER == right; - - case DDSFilterValue::ValueKind::ENUM: - if (!ignore_enum) - { - return DDSFilterValue::ValueKind::ENUM == right || - DDSFilterValue::ValueKind::SIGNED_INTEGER == right || - DDSFilterValue::ValueKind::UNSIGNED_INTEGER == right || - DDSFilterValue::ValueKind::STRING == right; - } - } - - return false; + if (!ignore_enum && DDSFilterValue::ValueKind::ENUM == right) { + return DDSFilterValue::ValueKind::ENUM == left || + DDSFilterValue::ValueKind::SIGNED_INTEGER == left || + DDSFilterValue::ValueKind::UNSIGNED_INTEGER == left || + DDSFilterValue::ValueKind::STRING == left; + } + + switch (left) { + case DDSFilterValue::ValueKind::BOOLEAN: + return DDSFilterValue::ValueKind::BOOLEAN == right || + DDSFilterValue::ValueKind::SIGNED_INTEGER == right || + DDSFilterValue::ValueKind::UNSIGNED_INTEGER == right; + + case DDSFilterValue::ValueKind::SIGNED_INTEGER: + case DDSFilterValue::ValueKind::UNSIGNED_INTEGER: + return DDSFilterValue::ValueKind::SIGNED_INTEGER == right || + DDSFilterValue::ValueKind::UNSIGNED_INTEGER == right || + DDSFilterValue::ValueKind::BOOLEAN == right || + DDSFilterValue::ValueKind::FLOAT_CONST == right || + DDSFilterValue::ValueKind::FLOAT_FIELD == right || + DDSFilterValue::ValueKind::DOUBLE_FIELD == right || + DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD == right; + + case DDSFilterValue::ValueKind::CHAR: + case DDSFilterValue::ValueKind::STRING: + return DDSFilterValue::ValueKind::CHAR == right || + DDSFilterValue::ValueKind::STRING == right; + + case DDSFilterValue::ValueKind::FLOAT_CONST: + case DDSFilterValue::ValueKind::FLOAT_FIELD: + case DDSFilterValue::ValueKind::DOUBLE_FIELD: + case DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD: + return DDSFilterValue::ValueKind::FLOAT_CONST == right || + DDSFilterValue::ValueKind::FLOAT_FIELD == right || + DDSFilterValue::ValueKind::DOUBLE_FIELD == right || + DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD == right || + DDSFilterValue::ValueKind::SIGNED_INTEGER == right || + DDSFilterValue::ValueKind::UNSIGNED_INTEGER == right; + + case DDSFilterValue::ValueKind::ENUM: + if (!ignore_enum) { + return DDSFilterValue::ValueKind::ENUM == right || + DDSFilterValue::ValueKind::SIGNED_INTEGER == right || + DDSFilterValue::ValueKind::UNSIGNED_INTEGER == right || + DDSFilterValue::ValueKind::STRING == right; + } + } + + return false; } static DDSFilterPredicate::OperationKind get_predicate_op( - const parser::ParseNode& node) + const parser::ParseNode & node) { - DDSFilterPredicate::OperationKind ret_val = DDSFilterPredicate::OperationKind::EQUAL; - if (node.is()) - { - ret_val = DDSFilterPredicate::OperationKind::EQUAL; - } - else if (node.is()) - { - ret_val = DDSFilterPredicate::OperationKind::NOT_EQUAL; - } - else if (node.is()) - { - ret_val = DDSFilterPredicate::OperationKind::LESS_THAN; - } - else if (node.is()) - { - ret_val = DDSFilterPredicate::OperationKind::LESS_EQUAL; - } - else if (node.is()) - { - ret_val = DDSFilterPredicate::OperationKind::GREATER_THAN; - } - else if (node.is()) - { - ret_val = DDSFilterPredicate::OperationKind::GREATER_EQUAL; - } - else if (node.is()) - { - ret_val = DDSFilterPredicate::OperationKind::LIKE; - } - else if (node.is()) - { - ret_val = DDSFilterPredicate::OperationKind::MATCH; - } - else - { - assert(false); - } - - return ret_val; + DDSFilterPredicate::OperationKind ret_val = DDSFilterPredicate::OperationKind::EQUAL; + if (node.is()) { + ret_val = DDSFilterPredicate::OperationKind::EQUAL; + } else if (node.is()) { + ret_val = DDSFilterPredicate::OperationKind::NOT_EQUAL; + } else if (node.is()) { + ret_val = DDSFilterPredicate::OperationKind::LESS_THAN; + } else if (node.is()) { + ret_val = DDSFilterPredicate::OperationKind::LESS_EQUAL; + } else if (node.is()) { + ret_val = DDSFilterPredicate::OperationKind::GREATER_THAN; + } else if (node.is()) { + ret_val = DDSFilterPredicate::OperationKind::GREATER_EQUAL; + } else if (node.is()) { + ret_val = DDSFilterPredicate::OperationKind::LIKE; + } else if (node.is()) { + ret_val = DDSFilterPredicate::OperationKind::MATCH; + } else { + assert(false); + } + + return ret_val; } struct ExpressionParsingState { - const void* type_object; - const IContentFilterFactory::ParameterSeq& filter_parameters; - DDSFilterExpression* filter; + const void * type_object; + const IContentFilterFactory::ParameterSeq & filter_parameters; + DDSFilterExpression * filter; }; template<> IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( - ExpressionParsingState& state, - std::unique_ptr& condition, - const parser::ParseNode& node); + ExpressionParsingState & state, + std::unique_ptr & condition, + const parser::ParseNode & node); template<> IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( - ExpressionParsingState& state, - std::shared_ptr& value, - const parser::ParseNode& node) + ExpressionParsingState & state, + std::shared_ptr & value, + const parser::ParseNode & node) { - if (node.value) - { - value = std::make_shared(); - value->copy_from(*node.value.get(), true); + if (node.value) { + value = std::make_shared(); + value->copy_from(*node.value.get(), true); + } else if (0 != node.type_id) { + std::string field_name = node.content(); + auto it = state.filter->fields.find(field_name); + if (it == state.filter->fields.end()) { + value = state.filter->fields[field_name] = + std::make_shared(node.type_id, node.field_access_path, node.field_kind); + } else { + value = it->second; } - else if (0 != node.type_id) - { - std::string field_name = node.content(); - auto it = state.filter->fields.find(field_name); - if (it == state.filter->fields.end()) - { - value = state.filter->fields[field_name] = - std::make_shared(node.type_id, node.field_access_path, node.field_kind); - } - else - { - value = it->second; - } + } else { + // Check parameter index + if (node.parameter_index >= state.filter_parameters.size()) { + return ReturnCode_t::RETCODE_BAD_PARAMETER; } - else - { - // Check parameter index - if (node.parameter_index >= state.filter_parameters.size()) - { - return ReturnCode_t::RETCODE_BAD_PARAMETER; - } - if (state.filter->parameters[node.parameter_index]) - { - value = state.filter->parameters[node.parameter_index]; - } - else - { - auto param_value = std::make_shared(); - if (!param_value->set_value(state.filter_parameters[node.parameter_index].c_str())) - { - return ReturnCode_t::RETCODE_BAD_PARAMETER; - } - value = state.filter->parameters[node.parameter_index] = param_value; - } + if (state.filter->parameters[node.parameter_index]) { + value = state.filter->parameters[node.parameter_index]; + } else { + auto param_value = std::make_shared(); + if (!param_value->set_value(state.filter_parameters[node.parameter_index].c_str())) { + return ReturnCode_t::RETCODE_BAD_PARAMETER; + } + value = state.filter->parameters[node.parameter_index] = param_value; } + } - return ReturnCode_t::RETCODE_OK; + return ReturnCode_t::RETCODE_OK; } template<> IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( - ExpressionParsingState& state, - std::unique_ptr& condition, - const parser::ParseNode& node) + ExpressionParsingState & state, + std::unique_ptr & condition, + const parser::ParseNode & node) { - std::shared_ptr left; - std::shared_ptr right; - ReturnCode_t ret = convert_tree(state, left, node.left()); - if (ReturnCode_t::RETCODE_OK == ret) - { - ret = convert_tree(state, right, node.right()); - if (ReturnCode_t::RETCODE_OK == ret) + std::shared_ptr left; + std::shared_ptr right; + ReturnCode_t ret = convert_tree(state, left, node.left()); + if (ReturnCode_t::RETCODE_OK == ret) { + ret = convert_tree(state, right, node.right()); + if (ReturnCode_t::RETCODE_OK == ret) { + bool ignore_enum = false; + if (node.is() || node.is()) { + // At least one fieldname should be a string + if (!((node.left().is() && (DDSFilterValue::ValueKind::STRING == left->kind)) || + (node.right().is() && (DDSFilterValue::ValueKind::STRING == right->kind)))) { - bool ignore_enum = false; - if (node.is() || node.is()) - { - // At least one fieldname should be a string - if ( !((node.left().is() && (DDSFilterValue::ValueKind::STRING == left->kind)) || - (node.right().is() && (DDSFilterValue::ValueKind::STRING == right->kind)))) - { - return ReturnCode_t::RETCODE_BAD_PARAMETER; - } - - ignore_enum = true; - } + return ReturnCode_t::RETCODE_BAD_PARAMETER; + } - if ((DDSFilterValue::ValueKind::ENUM == left->kind) && (DDSFilterValue::ValueKind::ENUM == right->kind)) - { - if (node.left().type_id != node.right().type_id) - { - return ReturnCode_t::RETCODE_BAD_PARAMETER; - } - } - else if (!check_value_compatibility(left->kind, right->kind, ignore_enum)) - { - return ReturnCode_t::RETCODE_BAD_PARAMETER; - } + ignore_enum = true; + } - ret = transform_enums(left, node.left().type_id, right, node.right().type_id); - if (ReturnCode_t::RETCODE_OK == ret) - { - condition.reset(new DDSFilterPredicate(get_predicate_op(node), left, right)); - } + if ((DDSFilterValue::ValueKind::ENUM == left->kind) && + (DDSFilterValue::ValueKind::ENUM == right->kind)) + { + if (node.left().type_id != node.right().type_id) { + return ReturnCode_t::RETCODE_BAD_PARAMETER; } + } else if (!check_value_compatibility(left->kind, right->kind, ignore_enum)) { + return ReturnCode_t::RETCODE_BAD_PARAMETER; + } + + ret = transform_enums(left, node.left().type_id, right, node.right().type_id); + if (ReturnCode_t::RETCODE_OK == ret) { + condition.reset(new DDSFilterPredicate(get_predicate_op(node), left, right)); + } } + } - return ret; + return ret; } template<> IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( - ExpressionParsingState& state, - std::unique_ptr& condition, - const parser::ParseNode& node) + ExpressionParsingState & state, + std::unique_ptr & condition, + const parser::ParseNode & node) { - /* The nodes here will be in the following situation: - * - * between_op - * / \ - * fieldname and_op - * / \ - * op1 op2 - */ - - std::shared_ptr field; - ReturnCode_t ret = convert_tree(state, field, node.left()); - if (ReturnCode_t::RETCODE_OK == ret) - { - const parser::ParseNode& and_node = node.right(); - assert(and_node.is()); - - std::shared_ptr op1; - std::shared_ptr op2; - - ret = convert_tree(state, op1, and_node.left()); - if (ReturnCode_t::RETCODE_OK == ret) - { - ret = convert_tree(state, op2, and_node.right()); - } + /* The nodes here will be in the following situation: + * + * between_op + * / \ + * fieldname and_op + * / \ + * op1 op2 + */ + + std::shared_ptr field; + ReturnCode_t ret = convert_tree(state, field, node.left()); + if (ReturnCode_t::RETCODE_OK == ret) { + const parser::ParseNode & and_node = node.right(); + assert(and_node.is()); + + std::shared_ptr op1; + std::shared_ptr op2; + + ret = convert_tree(state, op1, and_node.left()); + if (ReturnCode_t::RETCODE_OK == ret) { + ret = convert_tree(state, op2, and_node.right()); + } - if (ReturnCode_t::RETCODE_OK == ret) - { - if (!check_value_compatibility(field->kind, op1->kind, false) || - !check_value_compatibility(field->kind, op2->kind, false) || - !check_value_compatibility(op1->kind, op2->kind, false)) - { - return ReturnCode_t::RETCODE_BAD_PARAMETER; - } + if (ReturnCode_t::RETCODE_OK == ret) { + if (!check_value_compatibility(field->kind, op1->kind, false) || + !check_value_compatibility(field->kind, op2->kind, false) || + !check_value_compatibility(op1->kind, op2->kind, false)) + { + return ReturnCode_t::RETCODE_BAD_PARAMETER; + } - ret = transform_enums(field, node.left().type_id, op1, and_node.left().type_id); - if (ReturnCode_t::RETCODE_OK == ret) - { - ret = transform_enums(field, node.left().type_id, op2, and_node.right().type_id); - } - } + ret = transform_enums(field, node.left().type_id, op1, and_node.left().type_id); + if (ReturnCode_t::RETCODE_OK == ret) { + ret = transform_enums(field, node.left().type_id, op2, and_node.right().type_id); + } + } - if (ReturnCode_t::RETCODE_OK == ret) - { - DDSFilterPredicate::OperationKind binary_op = node.is() ? - DDSFilterPredicate::OperationKind::LESS_EQUAL : - DDSFilterPredicate::OperationKind::GREATER_THAN; - DDSFilterCompoundCondition::OperationKind logical_op = node.is() ? - DDSFilterCompoundCondition::OperationKind::AND : - DDSFilterCompoundCondition::OperationKind::OR; - - std::unique_ptr left_cond(new DDSFilterPredicate(binary_op, op1, field)); - std::unique_ptr right_cond(new DDSFilterPredicate(binary_op, field, op2)); - auto cond = new DDSFilterCompoundCondition(logical_op, std::move(left_cond), std::move(right_cond)); - condition.reset(cond); - } + if (ReturnCode_t::RETCODE_OK == ret) { + DDSFilterPredicate::OperationKind binary_op = node.is() ? + DDSFilterPredicate::OperationKind::LESS_EQUAL : + DDSFilterPredicate::OperationKind::GREATER_THAN; + DDSFilterCompoundCondition::OperationKind logical_op = node.is() ? + DDSFilterCompoundCondition::OperationKind::AND : + DDSFilterCompoundCondition::OperationKind::OR; + + std::unique_ptr left_cond(new DDSFilterPredicate(binary_op, op1, field)); + std::unique_ptr right_cond(new DDSFilterPredicate(binary_op, field, op2)); + auto cond = + new DDSFilterCompoundCondition( + logical_op, std::move(left_cond), std::move( + right_cond)); + condition.reset(cond); } + } - return ret; + return ret; } template<> IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( - ExpressionParsingState& state, - std::unique_ptr& condition, - const parser::ParseNode& node) + ExpressionParsingState & state, + std::unique_ptr & condition, + const parser::ParseNode & node) { - ReturnCode_t ret = ReturnCode_t::RETCODE_UNSUPPORTED; - DDSFilterCompoundCondition::OperationKind op = DDSFilterCompoundCondition::OperationKind::NOT; - std::unique_ptr left; - std::unique_ptr right; - - if (node.is()) - { - op = DDSFilterCompoundCondition::OperationKind::NOT; - ret = convert_tree(state, left, node.left()); - } - else if (node.is()) - { - op = DDSFilterCompoundCondition::OperationKind::AND; - ret = convert_tree(state, left, node.left()); - if (ReturnCode_t::RETCODE_OK == ret) - { - ret = convert_tree(state, right, node.right()); - } + ReturnCode_t ret = ReturnCode_t::RETCODE_UNSUPPORTED; + DDSFilterCompoundCondition::OperationKind op = DDSFilterCompoundCondition::OperationKind::NOT; + std::unique_ptr left; + std::unique_ptr right; + + if (node.is()) { + op = DDSFilterCompoundCondition::OperationKind::NOT; + ret = convert_tree(state, left, node.left()); + } else if (node.is()) { + op = DDSFilterCompoundCondition::OperationKind::AND; + ret = convert_tree(state, left, node.left()); + if (ReturnCode_t::RETCODE_OK == ret) { + ret = convert_tree(state, right, node.right()); } - else if (node.is()) - { - op = DDSFilterCompoundCondition::OperationKind::OR; - ret = convert_tree(state, left, node.left()); - if (ReturnCode_t::RETCODE_OK == ret) - { - ret = convert_tree(state, right, node.right()); - } - } - else - { - assert(false); + } else if (node.is()) { + op = DDSFilterCompoundCondition::OperationKind::OR; + ret = convert_tree(state, left, node.left()); + if (ReturnCode_t::RETCODE_OK == ret) { + ret = convert_tree(state, right, node.right()); } + } else { + assert(false); + } - if (ReturnCode_t::RETCODE_OK == ret) - { - condition.reset(new DDSFilterCompoundCondition(op, std::move(left), std::move(right))); - } + if (ReturnCode_t::RETCODE_OK == ret) { + condition.reset(new DDSFilterCompoundCondition(op, std::move(left), std::move(right))); + } - return ret; + return ret; } template<> IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( - ExpressionParsingState& state, - std::unique_ptr& condition, - const parser::ParseNode& node) + ExpressionParsingState & state, + std::unique_ptr & condition, + const parser::ParseNode & node) { - if (node.is() || node.is() || node.is()) - { - return convert_tree(state, condition, node); - } - else if (node.is() || node.is()) - { - return convert_tree(state, condition, node); - } + if (node.is() || node.is() || node.is()) { + return convert_tree(state, condition, node); + } else if (node.is() || node.is()) { + return convert_tree(state, condition, node); + } - return convert_tree(state, condition, node); + return convert_tree(state, condition, node); } DDSFilterFactory::~DDSFilterFactory() { - auto& pool = expression_pool_.collection(); - for (DDSFilterExpression* item : pool) - { - delete item; - } - pool.clear(); + auto & pool = expression_pool_.collection(); + for (DDSFilterExpression * item : pool) { + delete item; + } + pool.clear(); } IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( - const char* filter_class_name, - const char* type_name, - const rosidl_message_type_support_t* type_support, - const char* filter_expression, - const IContentFilterFactory::ParameterSeq& filter_parameters, - IContentFilter*& filter_instance) + const char * filter_class_name, + const char * type_name, + const rosidl_message_type_support_t * type_support, + const char * filter_expression, + const IContentFilterFactory::ParameterSeq & filter_parameters, + IContentFilter * & filter_instance) { - static_cast(type_name); - - ReturnCode_t ret = ReturnCode_t::RETCODE_UNSUPPORTED; + static_cast(type_name); + + ReturnCode_t ret = ReturnCode_t::RETCODE_UNSUPPORTED; + + if (nullptr == filter_expression) { + if (nullptr == filter_instance) { + ret = ReturnCode_t::RETCODE_BAD_PARAMETER; + } else { + ret = ReturnCode_t::RETCODE_OK; + if (&empty_expression_ != filter_instance) { + auto expr = static_cast(filter_instance); + auto n_params = expr->parameters.size(); + if (filter_parameters.size() < n_params) { + ret = ReturnCode_t::RETCODE_BAD_PARAMETER; + } else { + std::vector old_values(n_params); + size_t n = n_params; + while ((n > 0) && (ReturnCode_t::RETCODE_OK == ret)) { + --n; + if (expr->parameters[n]) { + old_values[n].copy_from(*(expr->parameters[n]), true); + if (!expr->parameters[n]->set_value(filter_parameters[n].c_str())) { + ret = ReturnCode_t::RETCODE_BAD_PARAMETER; + } + } + } - if (nullptr == filter_expression) - { - if (nullptr == filter_instance) - { - ret = ReturnCode_t::RETCODE_BAD_PARAMETER; - } - else - { - ret = ReturnCode_t::RETCODE_OK; - if (&empty_expression_ != filter_instance) - { - auto expr = static_cast(filter_instance); - auto n_params = expr->parameters.size(); - if (filter_parameters.size() < n_params) - { - ret = ReturnCode_t::RETCODE_BAD_PARAMETER; - } - else - { - std::vector old_values(n_params); - size_t n = n_params; - while ((n > 0) && (ReturnCode_t::RETCODE_OK == ret)) - { - --n; - if (expr->parameters[n]) - { - old_values[n].copy_from(*(expr->parameters[n]), true); - if (!expr->parameters[n]->set_value(filter_parameters[n].c_str())) - { - ret = ReturnCode_t::RETCODE_BAD_PARAMETER; - } - } - } - - if (ReturnCode_t::RETCODE_OK != ret) - { - while (n < n_params) - { - expr->parameters[n]->copy_from(old_values[n], true); - ++n; - } - } - } + if (ReturnCode_t::RETCODE_OK != ret) { + while (n < n_params) { + expr->parameters[n]->copy_from(old_values[n], true); + ++n; } + } } + } } - else if (std::strlen(filter_expression) == 0) - { + } else if (std::strlen(filter_expression) == 0) { + delete_content_filter(filter_class_name, filter_instance); + filter_instance = &empty_expression_; + ret = ReturnCode_t::RETCODE_OK; + } else { + auto node = parser::parse_filter_expression(filter_expression, type_support); + if (node) { + // logDebug(DDSSQLFILTER, "parser::parse_filter_expression success "); + DDSFilterExpression * expr = get_expression(); + size_t n_params = filter_parameters.size(); + expr->parameters.reserve(n_params); + while (expr->parameters.size() < n_params) { + expr->parameters.emplace_back(); + } + ExpressionParsingState state{nullptr, filter_parameters, expr}; + ret = convert_tree(state, expr->root, *(node->children[0])); + if (ReturnCode_t::RETCODE_OK == ret) { delete_content_filter(filter_class_name, filter_instance); - filter_instance = &empty_expression_; - ret = ReturnCode_t::RETCODE_OK; - } - else - { - auto node = parser::parse_filter_expression(filter_expression, type_support); - if (node) - { - // logDebug(DDSSQLFILTER, "parser::parse_filter_expression success "); - DDSFilterExpression* expr = get_expression(); - size_t n_params = filter_parameters.size(); - expr->parameters.reserve(n_params); - while (expr->parameters.size() < n_params) - { - expr->parameters.emplace_back(); - } - ExpressionParsingState state{ nullptr, filter_parameters, expr }; - ret = convert_tree(state, expr->root, *(node->children[0])); - if (ReturnCode_t::RETCODE_OK == ret) - { - delete_content_filter(filter_class_name, filter_instance); - filter_instance = expr; - } - else - { - delete_content_filter(filter_class_name, expr); - } - } - else - { - ret = ReturnCode_t::RETCODE_BAD_PARAMETER; - } + filter_instance = expr; + } else { + delete_content_filter(filter_class_name, expr); + } + } else { + ret = ReturnCode_t::RETCODE_BAD_PARAMETER; } + } - return ret; + return ret; } IContentFilterFactory::ReturnCode_t DDSFilterFactory::delete_content_filter( - const char* filter_class_name, - IContentFilter* filter_instance) + const char * filter_class_name, + IContentFilter * filter_instance) { - static_cast(filter_class_name); - - if (nullptr == filter_instance) - { - return ReturnCode_t::RETCODE_BAD_PARAMETER; - } - - if (&empty_expression_ != filter_instance) - { - auto expr = static_cast(filter_instance); - expr->clear(); - expression_pool_.put(expr); - } - return ReturnCode_t::RETCODE_OK; + static_cast(filter_class_name); + + if (nullptr == filter_instance) { + return ReturnCode_t::RETCODE_BAD_PARAMETER; + } + + if (&empty_expression_ != filter_instance) { + auto expr = static_cast(filter_instance); + expr->clear(); + expression_pool_.put(expr); + } + return ReturnCode_t::RETCODE_OK; } } // namespace DDSSQLFilter diff --git a/common_content_filter/src/DDSFilterFactory.hpp b/common_content_filter/src/DDSFilterFactory.hpp index d475aa7..0584ab9 100644 --- a/common_content_filter/src/DDSFilterFactory.hpp +++ b/common_content_filter/src/DDSFilterFactory.hpp @@ -27,10 +27,14 @@ #include "DDSFilterExpression.hpp" #include "ObjectPool.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ /** * An IContentFilterFactory that processes DDS-SQL filter expressions. @@ -39,53 +43,52 @@ class DDSFilterFactory final : public IContentFilterFactory { public: + ~DDSFilterFactory(); - ~DDSFilterFactory(); - - ReturnCode_t create_content_filter( - const char* filter_class_name, - const char* type_name, - const rosidl_message_type_support_t* type_support, - const char* filter_expression, - const ParameterSeq& filter_parameters, - IContentFilter*& filter_instance) override; + ReturnCode_t create_content_filter( + const char * filter_class_name, + const char * type_name, + const rosidl_message_type_support_t * type_support, + const char * filter_expression, + const ParameterSeq & filter_parameters, + IContentFilter * & filter_instance) override; - ReturnCode_t delete_content_filter( - const char* filter_class_name, - IContentFilter* filter_instance) override; + ReturnCode_t delete_content_filter( + const char * filter_class_name, + IContentFilter * filter_instance) override; private: - - /** - * Retrieve a DDSFilterExpression from the pool. - * - * @return A pointer to an empty DDSFilterExpression. - */ - DDSFilterExpression* get_expression() - { - return expression_pool_.get([] - { - return new DDSFilterExpression(); - }); - } - - /** - * Generic method to perform processing of an AST node resulting from the parsing of a DDS-SQL filter expression. - * Provides a generic mechanism for methods that perform post-processing of the generated AST tree, so they could - * have access to the private fields of DDSFilterFactory. - * - * @return return code indicating the conversion result. - */ - template - ReturnCode_t convert_tree( - _State& state, - _Output& parse_output, - const _ParserNode& node); - - /// Empty expressions content filter - DDSFilterEmptyExpression empty_expression_; - /// Pool of DDSFilterExpression objects - ObjectPool expression_pool_; + /** + * Retrieve a DDSFilterExpression from the pool. + * + * @return A pointer to an empty DDSFilterExpression. + */ + DDSFilterExpression * get_expression() + { + return expression_pool_.get( + [] + { + return new DDSFilterExpression(); + }); + } + + /** + * Generic method to perform processing of an AST node resulting from the parsing of a DDS-SQL filter expression. + * Provides a generic mechanism for methods that perform post-processing of the generated AST tree, so they could + * have access to the private fields of DDSFilterFactory. + * + * @return return code indicating the conversion result. + */ + template + ReturnCode_t convert_tree( + _State & state, + _Output & parse_output, + const _ParserNode & node); + + /// Empty expressions content filter + DDSFilterEmptyExpression empty_expression_; + /// Pool of DDSFilterExpression objects + ObjectPool expression_pool_; }; diff --git a/common_content_filter/src/DDSFilterField.cpp b/common_content_filter/src/DDSFilterField.cpp index 84ba248..3615f9a 100644 --- a/common_content_filter/src/DDSFilterField.cpp +++ b/common_content_filter/src/DDSFilterField.cpp @@ -32,18 +32,22 @@ #include "DDSFilterValue.hpp" #include "Log.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ template bool DDSFilterField::get_msg_data_address( const void * untype_members, - FieldAccessor& accessor, - const void *& data) + FieldAccessor & accessor, + const void * & data) { const MembersType * members = static_cast(untype_members); if (!members) { @@ -84,139 +88,134 @@ DDSFilterField::get_msg_data_address( } bool DDSFilterField::set_value( - const void * data, - size_t n) + const void * data, + size_t n) { - bool last_step = access_path_.size() - 1 == n; - bool ret = false; - bool is_c_type_support; - - // logDebug( - // DDSSQLFILTER, - // "DDSFilterField::set_value " << "access_path size:" << access_path_.size() - // ); - - const rosidl_message_type_support_t * type_support_introspection = - access_path_[n].type_support_introspection; - if (type_support_introspection->typesupport_identifier == - rosidl_typesupport_introspection_c__identifier) - { - is_c_type_support = true; - ret = get_msg_data_address( - type_support_introspection->data, access_path_[n], data); + bool last_step = access_path_.size() - 1 == n; + bool ret = false; + bool is_c_type_support; + + // logDebug( + // DDSSQLFILTER, + // "DDSFilterField::set_value " << "access_path size:" << access_path_.size() + // ); + + const rosidl_message_type_support_t * type_support_introspection = + access_path_[n].type_support_introspection; + if (type_support_introspection->typesupport_identifier == + rosidl_typesupport_introspection_c__identifier) + { + is_c_type_support = true; + ret = get_msg_data_address( + type_support_introspection->data, access_path_[n], data); - } else { - is_c_type_support = false; - ret = get_msg_data_address( - type_support_introspection->data, access_path_[n], data); - } + } else { + is_c_type_support = false; + ret = get_msg_data_address( + type_support_introspection->data, access_path_[n], data); + } - if (ret) - { - if (last_step) { - ret = set_member(data, is_c_type_support); + if (ret) { + if (last_step) { + ret = set_member(data, is_c_type_support); - has_value_ = true; - value_has_changed(); + has_value_ = true; + value_has_changed(); - // Inform parent predicates - for (DDSFilterPredicate* parent : parents_) - { - parent->value_has_changed(); - } - } - else - { - ret = set_value(data, n + 1); + // Inform parent predicates + for (DDSFilterPredicate * parent : parents_) { + parent->value_has_changed(); } + } else { + ret = set_value(data, n + 1); } + } - return ret; + return ret; } bool DDSFilterField::set_member( - const void * data, - bool is_c_type_support) + const void * data, + bool is_c_type_support) { - bool ret = true; - // logDebug( - // DDSSQLFILTER, - // "DDSFilterField::set_member " << "type_id_:" << (uint32_t)type_id_; - // ); - - switch (type_id_) - { - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: - float_value = *reinterpret_cast(data); - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_DOUBLE: - float_value = *reinterpret_cast(data); - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_LONG_DOUBLE: - float_value = *reinterpret_cast(data); - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_CHAR: - char_value = *reinterpret_cast(data); - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: - boolean_value = *reinterpret_cast(data); - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_OCTET: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT8: - unsigned_integer_value = *reinterpret_cast(data); - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT8: - signed_integer_value = *reinterpret_cast(data); - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT16: - unsigned_integer_value = *reinterpret_cast(data); - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT16: - signed_integer_value = *reinterpret_cast(data); - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT32: - unsigned_integer_value = *reinterpret_cast(data); - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT32: - signed_integer_value = *reinterpret_cast(data); - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT64: - unsigned_integer_value = *reinterpret_cast(data); - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT64: - signed_integer_value = *reinterpret_cast(data); - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: - - if (is_c_type_support) { - strncpy(string_value, reinterpret_cast(data), sizeof(string_value)); - } else { - auto string = reinterpret_cast(data); - strncpy(string_value, (char*)string->c_str(), sizeof(string_value)); - } - break; - - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: - default: - ret = false; - break; - } + bool ret = true; + // logDebug( + // DDSSQLFILTER, + // "DDSFilterField::set_member " << "type_id_:" << (uint32_t)type_id_; + // ); + + switch (type_id_) { + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: + float_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_DOUBLE: + float_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_LONG_DOUBLE: + float_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_CHAR: + char_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: + boolean_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_OCTET: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT8: + unsigned_integer_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT8: + signed_integer_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT16: + unsigned_integer_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT16: + signed_integer_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT32: + unsigned_integer_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT32: + signed_integer_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT64: + unsigned_integer_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT64: + signed_integer_value = *reinterpret_cast(data); + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: + + if (is_c_type_support) { + strncpy(string_value, reinterpret_cast(data), sizeof(string_value)); + } else { + auto string = reinterpret_cast(data); + strncpy(string_value, (char *)string->c_str(), sizeof(string_value)); + } + break; + + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: + default: + ret = false; + break; + } - return ret; + return ret; } } // namespace DDSSQLFilter diff --git a/common_content_filter/src/DDSFilterField.hpp b/common_content_filter/src/DDSFilterField.hpp index 270ddc1..ed0be99 100644 --- a/common_content_filter/src/DDSFilterField.hpp +++ b/common_content_filter/src/DDSFilterField.hpp @@ -28,10 +28,14 @@ #include "DDSFilterPredicate.hpp" #include "DDSFilterValue.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ /** * A DDSFilterValue for fieldname-based expression values. @@ -40,116 +44,113 @@ class DDSFilterField final : public DDSFilterValue { public: - - /** - * An element on the access path to the final field. - */ - struct FieldAccessor final - { - /// Index of the member to access - size_t member_index; - - /// Element index for array / sequence members - size_t array_index; - - /// Type support introspection information for current field - const rosidl_message_type_support_t * type_support_introspection; - }; - - /** - * Construct a DDSFilterField. - * - * @param[in] type_id TypeIdentifier representing the primitive data type of the fieldname. - * @param[in] access_path Access path to the field. - * @param[in] data_kind Kind of data the field represents. - */ - DDSFilterField( - uint8_t type_id, - const std::vector& access_path, - ValueKind data_kind) - : DDSFilterValue(data_kind) - , access_path_(access_path) - , type_id_(type_id) - { - } - - virtual ~DDSFilterField() = default; - - /** - * This method is used by a DDSFilterPredicate to check if this DDSFilterField can be used. - * - * @return whether this DDSFilterField has a value that can be used on a predicate. - */ - inline bool has_value() const noexcept final - { - return has_value_; - } - - /** - * Instruct this value to reset. - */ - inline void reset() noexcept final - { - has_value_ = false; - } - - - /** - * Perform the deserialization of the field represented by this DDSFilterField. - * Will notify the predicates where this DDSFilterField is being used. - * - * @param[in] data The dynamic representation of the payload being filtered. - * - * @return Whether the deserialization process succeeded. - * - * @post Method @c has_value returns true. - */ - inline bool set_value( - const void * data_value) - { - return set_value(data_value, (size_t)0); - } - - /** - * Perform the deserialization of a specific step of the access path. - * - * @param[in] data The dynamic representation of the step being processed. - * @param[in] n The step on the access path being processed. - * - * @return Whether the deserialization process succeeded. - * - * @post Method @c has_value returns true. - */ - bool set_value( - const void * data_value, - size_t n); + /** + * An element on the access path to the final field. + */ + struct FieldAccessor final + { + /// Index of the member to access + size_t member_index; + + /// Element index for array / sequence members + size_t array_index; + + /// Type support introspection information for current field + const rosidl_message_type_support_t * type_support_introspection; + }; + + /** + * Construct a DDSFilterField. + * + * @param[in] type_id TypeIdentifier representing the primitive data type of the fieldname. + * @param[in] access_path Access path to the field. + * @param[in] data_kind Kind of data the field represents. + */ + DDSFilterField( + uint8_t type_id, + const std::vector & access_path, + ValueKind data_kind) + : DDSFilterValue(data_kind) + , access_path_(access_path) + , type_id_(type_id) + { + } + + virtual ~DDSFilterField() = default; + + /** + * This method is used by a DDSFilterPredicate to check if this DDSFilterField can be used. + * + * @return whether this DDSFilterField has a value that can be used on a predicate. + */ + inline bool has_value() const noexcept final + { + return has_value_; + } + + /** + * Instruct this value to reset. + */ + inline void reset() noexcept final + { + has_value_ = false; + } + + + /** + * Perform the deserialization of the field represented by this DDSFilterField. + * Will notify the predicates where this DDSFilterField is being used. + * + * @param[in] data The dynamic representation of the payload being filtered. + * + * @return Whether the deserialization process succeeded. + * + * @post Method @c has_value returns true. + */ + inline bool set_value( + const void * data_value) + { + return set_value(data_value, (size_t)0); + } + + /** + * Perform the deserialization of a specific step of the access path. + * + * @param[in] data The dynamic representation of the step being processed. + * @param[in] n The step on the access path being processed. + * + * @return Whether the deserialization process succeeded. + * + * @post Method @c has_value returns true. + */ + bool set_value( + const void * data_value, + size_t n); protected: - - inline void add_parent( - DDSFilterPredicate* parent) final - { - assert(nullptr != parent); - parents_.emplace(parent); - } + inline void add_parent( + DDSFilterPredicate * parent) final + { + assert(nullptr != parent); + parents_.emplace(parent); + } private: - - template - bool - get_msg_data_address( - const void * untype_members, - FieldAccessor& accessor, - const void *& data); - - bool set_member( - const void * data_value, - bool is_c_type_support); - - bool has_value_ = false; - std::vector access_path_; - uint8_t type_id_ = 0; - std::unordered_set parents_; + template + bool + get_msg_data_address( + const void * untype_members, + FieldAccessor & accessor, + const void * & data); + + bool set_member( + const void * data_value, + bool is_c_type_support); + + bool has_value_ = false; + std::vector access_path_; + uint8_t type_id_ = 0; + std::unordered_set parents_; }; } // namespace DDSSQLFilter diff --git a/common_content_filter/src/DDSFilterGrammar.hpp b/common_content_filter/src/DDSFilterGrammar.hpp index fc7f2cf..633de29 100644 --- a/common_content_filter/src/DDSFilterGrammar.hpp +++ b/common_content_filter/src/DDSFilterGrammar.hpp @@ -21,10 +21,14 @@ #include "pegtl.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ using namespace tao::TAO_PEGTL_NAMESPACE; diff --git a/common_content_filter/src/DDSFilterParameter.cpp b/common_content_filter/src/DDSFilterParameter.cpp index 96f1e9b..7627e42 100644 --- a/common_content_filter/src/DDSFilterParameter.cpp +++ b/common_content_filter/src/DDSFilterParameter.cpp @@ -21,27 +21,30 @@ #include "DDSFilterExpressionParser.hpp" #include "Log.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ bool DDSFilterParameter::set_value( - const char* parameter) + const char * parameter) { - auto node = parser::parse_literal_value(parameter); + auto node = parser::parse_literal_value(parameter); - if (!node) - { - logError(DDSSQLFILTER, "PARSE ERROR: parser::parse_literal_value"); + if (!node) { + logError(DDSSQLFILTER, "PARSE ERROR: parser::parse_literal_value"); - return false; - } + return false; + } - copy_from(*node->left().value, false); - value_has_changed(); + copy_from(*node->left().value, false); + value_has_changed(); - return true; + return true; } } // namespace DDSSQLFilter diff --git a/common_content_filter/src/DDSFilterParameter.hpp b/common_content_filter/src/DDSFilterParameter.hpp index 20e783a..4f674f8 100644 --- a/common_content_filter/src/DDSFilterParameter.hpp +++ b/common_content_filter/src/DDSFilterParameter.hpp @@ -21,10 +21,14 @@ #include "DDSFilterValue.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ /** * A DDSFilterValue for expression parameters (i.e. %nn). @@ -33,18 +37,17 @@ class DDSFilterParameter final : public DDSFilterValue { public: - - virtual ~DDSFilterParameter() = default; - - /** - * Sets the value of this DDSFilterParameter given from an input string. - * - * @param[in] parameter The string from which to set the value. - * - * @return whether the parsing of the string correspond to a valid literal value. - */ - bool set_value( - const char* parameter); + virtual ~DDSFilterParameter() = default; + + /** + * Sets the value of this DDSFilterParameter given from an input string. + * + * @param[in] parameter The string from which to set the value. + * + * @return whether the parsing of the string correspond to a valid literal value. + */ + bool set_value( + const char * parameter); }; } // namespace DDSSQLFilter diff --git a/common_content_filter/src/DDSFilterParseNode.hpp b/common_content_filter/src/DDSFilterParseNode.hpp index 2f0455a..4824d88 100644 --- a/common_content_filter/src/DDSFilterParseNode.hpp +++ b/common_content_filter/src/DDSFilterParseNode.hpp @@ -27,37 +27,42 @@ #include "DDSFilterField.hpp" #include "DDSFilterValue.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { -namespace parser { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ +namespace parser +{ using namespace tao::TAO_PEGTL_NAMESPACE; -struct ParseNode : parse_tree::basic_node< ParseNode > +struct ParseNode : parse_tree::basic_node { - // When the node is a literal value, it will hold a pointer to it - std::unique_ptr value; + // When the node is a literal value, it will hold a pointer to it + std::unique_ptr value; - // When the node is a fieldname, it will hold the access path to the field, the data kind, and the type id - std::vector field_access_path; - DDSFilterValue::ValueKind field_kind = DDSFilterValue::ValueKind::STRING; - // ros2 primitive type id - uint8_t type_id = 0; + // When the node is a fieldname, it will hold the access path to the field, the data kind, and the type id + std::vector field_access_path; + DDSFilterValue::ValueKind field_kind = DDSFilterValue::ValueKind::STRING; + // ros2 primitive type id + uint8_t type_id = 0; - // When the node is a parameter, it will hold the parameter index - size_t parameter_index = 0; + // When the node is a parameter, it will hold the parameter index + size_t parameter_index = 0; - const ParseNode& left() const - { - return *(children[0]); - } + const ParseNode & left() const + { + return *(children[0]); + } - const ParseNode& right() const - { - return *(children[1]); - } + const ParseNode & right() const + { + return *(children[1]); + } }; diff --git a/common_content_filter/src/DDSFilterPredicate.cpp b/common_content_filter/src/DDSFilterPredicate.cpp index 2eeadef..83b52d7 100644 --- a/common_content_filter/src/DDSFilterPredicate.cpp +++ b/common_content_filter/src/DDSFilterPredicate.cpp @@ -23,80 +23,79 @@ #include "DDSFilterValue.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ DDSFilterPredicate::DDSFilterPredicate( - OperationKind op, - const std::shared_ptr& left, - const std::shared_ptr& right) - : op_(op) - , left_(left) - , right_(right) + OperationKind op, + const std::shared_ptr & left, + const std::shared_ptr & right) +: op_(op) + , left_(left) + , right_(right) { - assert(left_); - assert(right_); + assert(left_); + assert(right_); - left_->add_parent(this); - right_->add_parent(this); + left_->add_parent(this); + right_->add_parent(this); - if (OperationKind::LIKE == op_) - { - right_->as_regular_expression(true); - } - else if (OperationKind::MATCH == op_) - { - right_->as_regular_expression(false); - } + if (OperationKind::LIKE == op_) { + right_->as_regular_expression(true); + } else if (OperationKind::MATCH == op_) { + right_->as_regular_expression(false); + } } void DDSFilterPredicate::value_has_changed() { - if (left_->has_value() && right_->has_value()) - { - switch (op_) - { - case OperationKind::EQUAL: - set_result(*left_ == *right_); - break; - - case OperationKind::NOT_EQUAL: - set_result(*left_ != *right_); - break; - - case OperationKind::LESS_THAN: - set_result(*left_ < *right_); - break; - - case OperationKind::LESS_EQUAL: - set_result(*left_ <= *right_); - break; - - case OperationKind::GREATER_THAN: - set_result(*left_ > *right_); - break; - - case OperationKind::GREATER_EQUAL: - set_result(*left_ >= *right_); - break; - - case OperationKind::LIKE: - case OperationKind::MATCH: - set_result(left_->is_like(*right_)); - break; - - default: - assert(false); - } + if (left_->has_value() && right_->has_value()) { + switch (op_) { + case OperationKind::EQUAL: + set_result(*left_ == *right_); + break; + + case OperationKind::NOT_EQUAL: + set_result(*left_ != *right_); + break; + + case OperationKind::LESS_THAN: + set_result(*left_ < *right_); + break; + + case OperationKind::LESS_EQUAL: + set_result(*left_ <= *right_); + break; + + case OperationKind::GREATER_THAN: + set_result(*left_ > *right_); + break; + + case OperationKind::GREATER_EQUAL: + set_result(*left_ >= *right_); + break; + + case OperationKind::LIKE: + case OperationKind::MATCH: + set_result(left_->is_like(*right_)); + break; + + default: + assert(false); } + } } void DDSFilterPredicate::propagate_reset() noexcept { - left_->reset(); - right_->reset(); + left_->reset(); + right_->reset(); } } // namespace DDSSQLFilter diff --git a/common_content_filter/src/DDSFilterPredicate.hpp b/common_content_filter/src/DDSFilterPredicate.hpp index 3d5188a..0fdfb9c 100644 --- a/common_content_filter/src/DDSFilterPredicate.hpp +++ b/common_content_filter/src/DDSFilterPredicate.hpp @@ -24,10 +24,14 @@ #include "DDSFilterCondition.hpp" #include "DDSFilterValue.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ /** * A DDSFilterCondition for binary predicates (i.e. ). @@ -36,56 +40,53 @@ class DDSFilterPredicate final : public DDSFilterCondition { public: - - /** - * Possible kinds of binary operations - */ - enum class OperationKind : uint8_t - { - EQUAL, ///< left = right - NOT_EQUAL, ///< left <> right - LESS_THAN, ///< left < right - LESS_EQUAL, ///< left <= right - GREATER_THAN, ///< left > right - GREATER_EQUAL, ///< left >= right - LIKE, ///< left LIKE right - MATCH ///< left MATCH right - }; - - /** - * Construct a DDSFilterPredicate. - * - * @param[in] op Operation to perform. - * @param[in] left Left operand. - * @param[in] right Right operand. - */ - DDSFilterPredicate( - OperationKind op, - const std::shared_ptr& left, - const std::shared_ptr& right); - - virtual ~DDSFilterPredicate() = default; - - /** - * Called when the value of an operand is changed. - */ - void value_has_changed(); + /** + * Possible kinds of binary operations + */ + enum class OperationKind : uint8_t + { + EQUAL, ///< left = right + NOT_EQUAL, ///< left <> right + LESS_THAN, ///< left < right + LESS_EQUAL, ///< left <= right + GREATER_THAN, ///< left > right + GREATER_EQUAL, ///< left >= right + LIKE, ///< left LIKE right + MATCH ///< left MATCH right + }; + + /** + * Construct a DDSFilterPredicate. + * + * @param[in] op Operation to perform. + * @param[in] left Left operand. + * @param[in] right Right operand. + */ + DDSFilterPredicate( + OperationKind op, + const std::shared_ptr & left, + const std::shared_ptr & right); + + virtual ~DDSFilterPredicate() = default; + + /** + * Called when the value of an operand is changed. + */ + void value_has_changed(); protected: + void propagate_reset() noexcept final; - void propagate_reset() noexcept final; - - void child_has_changed( - const DDSFilterCondition& child) noexcept final - { - static_cast(child); - } + void child_has_changed( + const DDSFilterCondition & child) noexcept final + { + static_cast(child); + } private: - - OperationKind op_; - std::shared_ptr left_; - std::shared_ptr right_; + OperationKind op_; + std::shared_ptr left_; + std::shared_ptr right_; }; diff --git a/common_content_filter/src/DDSFilterValue.cpp b/common_content_filter/src/DDSFilterValue.cpp index 586557b..bc342a2 100644 --- a/common_content_filter/src/DDSFilterValue.cpp +++ b/common_content_filter/src/DDSFilterValue.cpp @@ -23,18 +23,22 @@ #include #include -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ template int compare_values( - T lvalue, - T rvalue) + T lvalue, + T rvalue) { - return lvalue < rvalue ? -1 : - lvalue > rvalue ? 1 : 0; + return lvalue < rvalue ? -1 : + lvalue > rvalue ? 1 : 0; } /** @@ -42,322 +46,312 @@ int compare_values( * Only used during promotion to UNSIGNED_INTEGER. */ static bool is_negative( - const DDSFilterValue& value) + const DDSFilterValue & value) { - switch (value.kind) - { - case DDSFilterValue::ValueKind::BOOLEAN: - return false; + switch (value.kind) { + case DDSFilterValue::ValueKind::BOOLEAN: + return false; - case DDSFilterValue::ValueKind::ENUM: - case DDSFilterValue::ValueKind::SIGNED_INTEGER: - return value.signed_integer_value < 0; + case DDSFilterValue::ValueKind::ENUM: + case DDSFilterValue::ValueKind::SIGNED_INTEGER: + return value.signed_integer_value < 0; - // The rest of the types shall never be promoted to UNSIGNED_INTEGER - default: - assert(false); - } + // The rest of the types shall never be promoted to UNSIGNED_INTEGER + default: + assert(false); + } - return false; + return false; } /** * Performs promotion to SIGNED_INTEGER */ static int64_t to_signed_integer( - const DDSFilterValue& value) + const DDSFilterValue & value) { - switch (value.kind) - { - case DDSFilterValue::ValueKind::BOOLEAN: - return value.boolean_value ? 1 : 0; + switch (value.kind) { + case DDSFilterValue::ValueKind::BOOLEAN: + return value.boolean_value ? 1 : 0; - case DDSFilterValue::ValueKind::ENUM: - return value.signed_integer_value; + case DDSFilterValue::ValueKind::ENUM: + return value.signed_integer_value; - // The rest of the types shall never be promoted to SIGNED_INTEGER - default: - assert(false); - } + // The rest of the types shall never be promoted to SIGNED_INTEGER + default: + assert(false); + } - return 0; + return 0; } /** * Performs promotion to UNSIGNED_INTEGER */ static uint64_t to_unsigned_integer( - const DDSFilterValue& value) + const DDSFilterValue & value) { - switch (value.kind) - { - case DDSFilterValue::ValueKind::BOOLEAN: - return value.boolean_value ? 1 : 0; + switch (value.kind) { + case DDSFilterValue::ValueKind::BOOLEAN: + return value.boolean_value ? 1 : 0; - case DDSFilterValue::ValueKind::ENUM: - case DDSFilterValue::ValueKind::SIGNED_INTEGER: - return static_cast(value.signed_integer_value); + case DDSFilterValue::ValueKind::ENUM: + case DDSFilterValue::ValueKind::SIGNED_INTEGER: + return static_cast(value.signed_integer_value); - // The rest of the types shall never be promoted to UNSIGNED_INTEGER - default: - assert(false); - } + // The rest of the types shall never be promoted to UNSIGNED_INTEGER + default: + assert(false); + } - return 0; + return 0; } /** * Performs promotion to FLOAT */ static long double to_float( - const DDSFilterValue& value) + const DDSFilterValue & value) { - switch (value.kind) - { - case DDSFilterValue::ValueKind::ENUM: - case DDSFilterValue::ValueKind::SIGNED_INTEGER: - return static_cast(value.signed_integer_value); - - case DDSFilterValue::ValueKind::UNSIGNED_INTEGER: - return static_cast(value.unsigned_integer_value); - - case DDSFilterValue::ValueKind::FLOAT_CONST: - case DDSFilterValue::ValueKind::FLOAT_FIELD: - case DDSFilterValue::ValueKind::DOUBLE_FIELD: - case DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD: - return value.float_value; - - // The rest of the types shall never be promoted to FLOAT - default: - assert(false); - } - - return 0; + switch (value.kind) { + case DDSFilterValue::ValueKind::ENUM: + case DDSFilterValue::ValueKind::SIGNED_INTEGER: + return static_cast(value.signed_integer_value); + + case DDSFilterValue::ValueKind::UNSIGNED_INTEGER: + return static_cast(value.unsigned_integer_value); + + case DDSFilterValue::ValueKind::FLOAT_CONST: + case DDSFilterValue::ValueKind::FLOAT_FIELD: + case DDSFilterValue::ValueKind::DOUBLE_FIELD: + case DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD: + return value.float_value; + + // The rest of the types shall never be promoted to FLOAT + default: + assert(false); + } + + return 0; } /** * Performs promotion to STRING */ static void to_string_value( - const DDSFilterValue& in, - std::string& out) + const DDSFilterValue & in, + std::string & out) { - assert(DDSFilterValue::ValueKind::CHAR == in.kind); - out.assign(&in.char_value, 1); + assert(DDSFilterValue::ValueKind::CHAR == in.kind); + out.assign(&in.char_value, 1); } void DDSFilterValue::copy_from( - const DDSFilterValue& other, - bool copy_regular_expression) noexcept + const DDSFilterValue & other, + bool copy_regular_expression) noexcept { - kind = other.kind; - switch (kind) - { - case ValueKind::BOOLEAN: - boolean_value = other.boolean_value; - break; - - case ValueKind::CHAR: - char_value = other.char_value; - break; - - case ValueKind::ENUM: - case ValueKind::SIGNED_INTEGER: - signed_integer_value = other.signed_integer_value; - break; - - case ValueKind::UNSIGNED_INTEGER: - unsigned_integer_value = other.unsigned_integer_value; - break; - - case ValueKind::FLOAT_CONST: - case ValueKind::FLOAT_FIELD: - case ValueKind::DOUBLE_FIELD: - case ValueKind::LONG_DOUBLE_FIELD: - float_value = other.float_value; - break; - - case ValueKind::STRING: - strncpy(string_value, other.string_value, sizeof(string_value)); - break; - - default: - assert(false); - } - - if (copy_regular_expression) - { - regular_expr_kind_ = other.regular_expr_kind_; - if (has_value()) - { - value_has_changed(); - } + kind = other.kind; + switch (kind) { + case ValueKind::BOOLEAN: + boolean_value = other.boolean_value; + break; + + case ValueKind::CHAR: + char_value = other.char_value; + break; + + case ValueKind::ENUM: + case ValueKind::SIGNED_INTEGER: + signed_integer_value = other.signed_integer_value; + break; + + case ValueKind::UNSIGNED_INTEGER: + unsigned_integer_value = other.unsigned_integer_value; + break; + + case ValueKind::FLOAT_CONST: + case ValueKind::FLOAT_FIELD: + case ValueKind::DOUBLE_FIELD: + case ValueKind::LONG_DOUBLE_FIELD: + float_value = other.float_value; + break; + + case ValueKind::STRING: + strncpy(string_value, other.string_value, sizeof(string_value)); + break; + + default: + assert(false); + } + + if (copy_regular_expression) { + regular_expr_kind_ = other.regular_expr_kind_; + if (has_value()) { + value_has_changed(); } + } } int DDSFilterValue::compare( - const DDSFilterValue& lhs, - const DDSFilterValue& rhs) noexcept + const DDSFilterValue & lhs, + const DDSFilterValue & rhs) noexcept { - if (lhs.kind == rhs.kind) - { - switch (lhs.kind) - { - case ValueKind::BOOLEAN: - return lhs.boolean_value - rhs.boolean_value; + if (lhs.kind == rhs.kind) { + switch (lhs.kind) { + case ValueKind::BOOLEAN: + return lhs.boolean_value - rhs.boolean_value; - case ValueKind::CHAR: - return lhs.char_value - rhs.char_value; + case ValueKind::CHAR: + return lhs.char_value - rhs.char_value; - case ValueKind::SIGNED_INTEGER: - case ValueKind::ENUM: - return compare_values(lhs.signed_integer_value, rhs.signed_integer_value); + case ValueKind::SIGNED_INTEGER: + case ValueKind::ENUM: + return compare_values(lhs.signed_integer_value, rhs.signed_integer_value); - case ValueKind::UNSIGNED_INTEGER: - return compare_values(lhs.unsigned_integer_value, rhs.unsigned_integer_value); + case ValueKind::UNSIGNED_INTEGER: + return compare_values(lhs.unsigned_integer_value, rhs.unsigned_integer_value); - case ValueKind::FLOAT_FIELD: - return compare_values(static_cast(lhs.float_value), static_cast(rhs.float_value)); + case ValueKind::FLOAT_FIELD: + return compare_values( + static_cast(lhs.float_value), + static_cast(rhs.float_value)); - case ValueKind::DOUBLE_FIELD: - return compare_values(static_cast(lhs.float_value), static_cast(rhs.float_value)); + case ValueKind::DOUBLE_FIELD: + return compare_values( + static_cast(lhs.float_value), + static_cast(rhs.float_value)); - case ValueKind::LONG_DOUBLE_FIELD: - return compare_values(lhs.float_value, rhs.float_value); + case ValueKind::LONG_DOUBLE_FIELD: + return compare_values(lhs.float_value, rhs.float_value); - case ValueKind::STRING: - return std::strcmp(lhs.string_value, rhs.string_value); + case ValueKind::STRING: + return std::strcmp(lhs.string_value, rhs.string_value); - // As the grammar does not allow constant vs constant comparisons, FLOAT_CONST should never reach here - case ValueKind::FLOAT_CONST: - default: - assert(false); - } - } - else if (lhs.kind < rhs.kind) - { - // We want to always promote rhs - return -compare(rhs, lhs); + // As the grammar does not allow constant vs constant comparisons, FLOAT_CONST should never reach here + case ValueKind::FLOAT_CONST: + default: + assert(false); } - else - { - /* Type promotion rules are enforced during the construction of the expression tree on - * DDSFilterFactory. For the types on which promotion is supported, a corresponding to_xxx method exists - * that will assert if an invalid promotion is performed. - */ - switch (lhs.kind) + } else if (lhs.kind < rhs.kind) { + // We want to always promote rhs + return -compare(rhs, lhs); + } else { + /* Type promotion rules are enforced during the construction of the expression tree on + * DDSFilterFactory. For the types on which promotion is supported, a corresponding to_xxx method exists + * that will assert if an invalid promotion is performed. + */ + switch (lhs.kind) { + case ValueKind::ENUM: + case ValueKind::SIGNED_INTEGER: { - case ValueKind::ENUM: - case ValueKind::SIGNED_INTEGER: - { - return compare_values(lhs.signed_integer_value, to_signed_integer(rhs)); - } - - case ValueKind::UNSIGNED_INTEGER: - return is_negative(rhs) ? 1 : compare_values(lhs.unsigned_integer_value, to_unsigned_integer(rhs)); - - case ValueKind::FLOAT_CONST: - case ValueKind::FLOAT_FIELD: - return compare_values(static_cast(lhs.float_value), static_cast(to_float(rhs))); - - case ValueKind::DOUBLE_FIELD: - return compare_values(static_cast(lhs.float_value), static_cast(to_float(rhs))); - - case ValueKind::LONG_DOUBLE_FIELD: - return compare_values(lhs.float_value, to_float(rhs)); - - case ValueKind::STRING: - { - std::string rvalue; - to_string_value(rhs, rvalue); - return std::strcmp(lhs.string_value, rvalue.c_str()); - } - - // Promotion to boolean or char are not allowed. - case ValueKind::BOOLEAN: - case ValueKind::CHAR: - default: - assert(false); - break; + return compare_values(lhs.signed_integer_value, to_signed_integer(rhs)); } + + case ValueKind::UNSIGNED_INTEGER: + return is_negative(rhs) ? 1 : compare_values( + lhs.unsigned_integer_value, to_unsigned_integer( + rhs)); + + case ValueKind::FLOAT_CONST: + case ValueKind::FLOAT_FIELD: + return compare_values( + static_cast(lhs.float_value), + static_cast(to_float(rhs))); + + case ValueKind::DOUBLE_FIELD: + return compare_values( + static_cast(lhs.float_value), + static_cast(to_float(rhs))); + + case ValueKind::LONG_DOUBLE_FIELD: + return compare_values(lhs.float_value, to_float(rhs)); + + case ValueKind::STRING: + { + std::string rvalue; + to_string_value(rhs, rvalue); + return std::strcmp(lhs.string_value, rvalue.c_str()); + } + + // Promotion to boolean or char are not allowed. + case ValueKind::BOOLEAN: + case ValueKind::CHAR: + default: + assert(false); + break; } + } - return 0; + return 0; } void DDSFilterValue::as_regular_expression( - bool is_like_operand) + bool is_like_operand) { - regular_expr_kind_ = is_like_operand ? RegExpKind::LIKE : RegExpKind::MATCH; - if (has_value()) - { - value_has_changed(); - } + regular_expr_kind_ = is_like_operand ? RegExpKind::LIKE : RegExpKind::MATCH; + if (has_value()) { + value_has_changed(); + } } void DDSFilterValue::value_has_changed() { - if (RegExpKind::NONE != regular_expr_kind_) - { - std::string expr; + if (RegExpKind::NONE != regular_expr_kind_) { + std::string expr; - switch (kind) - { - case ValueKind::CHAR: - expr = char_value; - break; - - case ValueKind::STRING: - expr = string_value; - break; + switch (kind) { + case ValueKind::CHAR: + expr = char_value; + break; - default: - assert(false); - } + case ValueKind::STRING: + expr = string_value; + break; - if (RegExpKind::LIKE == regular_expr_kind_) - { - expr = std::regex_replace(expr, std::regex("\\*"), ".*"); - expr = std::regex_replace(expr, std::regex("\\?"), "."); - expr = std::regex_replace(expr, std::regex("%"), ".*"); - expr = std::regex_replace(expr, std::regex("_"), "."); - } + default: + assert(false); + } - regular_expr_.reset(new std::regex(expr)); + if (RegExpKind::LIKE == regular_expr_kind_) { + expr = std::regex_replace(expr, std::regex("\\*"), ".*"); + expr = std::regex_replace(expr, std::regex("\\?"), "."); + expr = std::regex_replace(expr, std::regex("%"), ".*"); + expr = std::regex_replace(expr, std::regex("_"), "."); } + + regular_expr_.reset(new std::regex(expr)); + } } bool DDSFilterValue::is_like( - const DDSFilterValue& other) const noexcept + const DDSFilterValue & other) const noexcept { - assert(other.regular_expr_); + assert(other.regular_expr_); - std::string char_string_value; + std::string char_string_value; - switch (kind) - { - case ValueKind::CHAR: - assert(ValueKind::STRING == other.kind); - to_string_value(*this, char_string_value); - return std::regex_match(char_string_value.c_str(), *other.regular_expr_); + switch (kind) { + case ValueKind::CHAR: + assert(ValueKind::STRING == other.kind); + to_string_value(*this, char_string_value); + return std::regex_match(char_string_value.c_str(), *other.regular_expr_); + case ValueKind::STRING: + switch (other.kind) { + case ValueKind::CHAR: case ValueKind::STRING: - switch (other.kind) - { - case ValueKind::CHAR: - case ValueKind::STRING: - return std::regex_match(string_value, *other.regular_expr_); - - default: - assert(false); - } - break; + return std::regex_match(string_value, *other.regular_expr_); default: - assert(false); - } + assert(false); + } + break; + + default: + assert(false); + } - return false; + return false; } } // namespace DDSSQLFilter diff --git a/common_content_filter/src/DDSFilterValue.hpp b/common_content_filter/src/DDSFilterValue.hpp index 3990d8d..5ab42ac 100644 --- a/common_content_filter/src/DDSFilterValue.hpp +++ b/common_content_filter/src/DDSFilterValue.hpp @@ -22,10 +22,14 @@ #include #include -namespace eprosima_common { -namespace fastdds { -namespace dds { -namespace DDSSQLFilter { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ +namespace DDSSQLFilter +{ class DDSFilterPredicate; @@ -36,190 +40,186 @@ class DDSFilterValue { public: - - // DDSFilterPredicate needs to call protected method add_parent - friend class DDSFilterPredicate; - - /** - * The high-level kind of a DDSFilterValue. - * Please note that the constants here should follow the promotion order. - */ - enum class ValueKind - { - BOOLEAN, ///< Value is a bool - ENUM, ///< Value is an int32_t with the value of an enumeration - SIGNED_INTEGER, ///< Value is a int16_t, int32_t, or int64_t - UNSIGNED_INTEGER, ///< Value is a uint8_t, uint16_t, uint32_t, or uint64_t - FLOAT_CONST, ///< Value is a long double constant - FLOAT_FIELD, ///< Value is a float field - DOUBLE_FIELD, ///< Value is a double field - LONG_DOUBLE_FIELD, ///< Value is a long double field - CHAR, ///< Value is a char - STRING ///< Value is a string - }; - - /// The kind of value held by this DDSFilterValue - ValueKind kind; - - union - { - bool boolean_value; ///< Value when kind == BOOL - char char_value; ///< Value when kind == CHAR - int64_t signed_integer_value; ///< Value when kind == SIGNED_INTEGER / ENUM - uint64_t unsigned_integer_value; ///< Value when kind == UNSIGNED_INTEGER - long double float_value; ///< Value when kind == FLOAT - char string_value[255]; ///< Value when kind == STRING - }; - - /** - * Default constructor. - * Constructs an empty string DDSFilterValue - */ - DDSFilterValue() noexcept - : kind(ValueKind::STRING) - , string_value() - { - } - - /** - * Explicit kind constructor. - * Constructs a zero-valued, specific kind DDSFilterValue. - * - * @param[in] kind The kind with which to construct the DDSFilterValue. - */ - explicit DDSFilterValue( - ValueKind data_kind) noexcept - : kind(data_kind) - , string_value() - { - } - - // *INDENT-OFF* + // DDSFilterPredicate needs to call protected method add_parent + friend class DDSFilterPredicate; + + /** + * The high-level kind of a DDSFilterValue. + * Please note that the constants here should follow the promotion order. + */ + enum class ValueKind + { + BOOLEAN, ///< Value is a bool + ENUM, ///< Value is an int32_t with the value of an enumeration + SIGNED_INTEGER, ///< Value is a int16_t, int32_t, or int64_t + UNSIGNED_INTEGER, ///< Value is a uint8_t, uint16_t, uint32_t, or uint64_t + FLOAT_CONST, ///< Value is a long double constant + FLOAT_FIELD, ///< Value is a float field + DOUBLE_FIELD, ///< Value is a double field + LONG_DOUBLE_FIELD, ///< Value is a long double field + CHAR, ///< Value is a char + STRING ///< Value is a string + }; + + /// The kind of value held by this DDSFilterValue + ValueKind kind; + + union { + bool boolean_value; ///< Value when kind == BOOL + char char_value; ///< Value when kind == CHAR + int64_t signed_integer_value; ///< Value when kind == SIGNED_INTEGER / ENUM + uint64_t unsigned_integer_value; ///< Value when kind == UNSIGNED_INTEGER + long double float_value; ///< Value when kind == FLOAT + char string_value[255]; ///< Value when kind == STRING + }; + + /** + * Default constructor. + * Constructs an empty string DDSFilterValue + */ + DDSFilterValue() noexcept + : kind(ValueKind::STRING) + , string_value() + { + } + + /** + * Explicit kind constructor. + * Constructs a zero-valued, specific kind DDSFilterValue. + * + * @param[in] kind The kind with which to construct the DDSFilterValue. + */ + explicit DDSFilterValue( + ValueKind data_kind) noexcept + : kind(data_kind) + , string_value() + { + } + + // *INDENT-OFF* DDSFilterValue(const DDSFilterValue&) = delete; DDSFilterValue& operator=(const DDSFilterValue&) = delete; DDSFilterValue(DDSFilterValue&&) = default; DDSFilterValue& operator=(DDSFilterValue&&) = default; - // *INDENT-ON* - - virtual ~DDSFilterValue() = default; - - /** - * Copy the state of this object from another one. - * - * @param [in] other The DDSFilterValue from where to copy the state. - * @param [in] copy_regular_expression Whether the regular expression state should be copied or not - */ - void copy_from( - const DDSFilterValue& other, - bool copy_regular_expression) noexcept; - - /** - * This method is used by a DDSFilterPredicate to check if this DDSFilterValue can be used. - * Constants and parameters will always have a value, but fieldname-based values can only be - * used after deserialization. - * - * @return whether this DDSFilterValue has a value that can be used on a predicate. - */ - virtual bool has_value() const noexcept - { - return true; - } - - /** - * Instruct this value to reset. - * Will only have effect on fieldname-based values. - */ - virtual void reset() noexcept - { - } - - /** - * Mark that this value should be handled as a regular expression. - * - * @param [in] is_like_operand Whether this value is used on a LIKE or MATCH operation. - */ - void as_regular_expression( - bool is_like_operand); - - /** - * @name Comparison operations - * Methods implementing the comparison operators of binary predicates. - * Should only be called against a DDSFilterValue of a compatible kind, - * according to the type promotion restrictions. - */ - ///@{ - inline bool operator ==( - const DDSFilterValue& other) const noexcept - { - return compare(*this, other) == 0; - } - - inline bool operator !=( - const DDSFilterValue& other) const noexcept - { - return compare(*this, other) != 0; - } - - inline bool operator <( - const DDSFilterValue& other) const noexcept - { - return compare(*this, other) < 0; - } - - inline bool operator <=( - const DDSFilterValue& other) const noexcept - { - return compare(*this, other) <= 0; - } - - inline bool operator >( - const DDSFilterValue& other) const noexcept - { - return compare(*this, other) > 0; - } - - inline bool operator >=( - const DDSFilterValue& other) const noexcept - { - return compare(*this, other) >= 0; - } - - bool is_like( - const DDSFilterValue& other) const noexcept; - ///@} + // *INDENT-ON* + + virtual ~DDSFilterValue() = default; + + /** + * Copy the state of this object from another one. + * + * @param [in] other The DDSFilterValue from where to copy the state. + * @param [in] copy_regular_expression Whether the regular expression state should be copied or not + */ + void copy_from( + const DDSFilterValue & other, + bool copy_regular_expression) noexcept; + + /** + * This method is used by a DDSFilterPredicate to check if this DDSFilterValue can be used. + * Constants and parameters will always have a value, but fieldname-based values can only be + * used after deserialization. + * + * @return whether this DDSFilterValue has a value that can be used on a predicate. + */ + virtual bool has_value() const noexcept + { + return true; + } + + /** + * Instruct this value to reset. + * Will only have effect on fieldname-based values. + */ + virtual void reset() noexcept + { + } + + /** + * Mark that this value should be handled as a regular expression. + * + * @param [in] is_like_operand Whether this value is used on a LIKE or MATCH operation. + */ + void as_regular_expression( + bool is_like_operand); + + /** + * @name Comparison operations + * Methods implementing the comparison operators of binary predicates. + * Should only be called against a DDSFilterValue of a compatible kind, + * according to the type promotion restrictions. + */ + ///@{ + inline bool operator==( + const DDSFilterValue & other) const noexcept + { + return compare(*this, other) == 0; + } + + inline bool operator!=( + const DDSFilterValue & other) const noexcept + { + return compare(*this, other) != 0; + } + + inline bool operator<( + const DDSFilterValue & other) const noexcept + { + return compare(*this, other) < 0; + } + + inline bool operator<=( + const DDSFilterValue & other) const noexcept + { + return compare(*this, other) <= 0; + } + + inline bool operator>( + const DDSFilterValue & other) const noexcept + { + return compare(*this, other) > 0; + } + + inline bool operator>=( + const DDSFilterValue & other) const noexcept + { + return compare(*this, other) >= 0; + } + + bool is_like( + const DDSFilterValue & other) const noexcept; + ///@} protected: - - /** - * Called when this DDSFilterValue is used on a DDSFilterPredicate. - * - * @param parent [in] The DDSFilterPredicate referencing this DDSFilterValue. - */ - virtual void add_parent( - DDSFilterPredicate* parent) - { - static_cast(parent); - } - - /** - * Called when the value of this DDSFilterValue has changed. - * Will regenerate the regular expression object if as_regular_expression was called. - */ - void value_has_changed(); + /** + * Called when this DDSFilterValue is used on a DDSFilterPredicate. + * + * @param parent [in] The DDSFilterPredicate referencing this DDSFilterValue. + */ + virtual void add_parent( + DDSFilterPredicate * parent) + { + static_cast(parent); + } + + /** + * Called when the value of this DDSFilterValue has changed. + * Will regenerate the regular expression object if as_regular_expression was called. + */ + void value_has_changed(); private: + enum class RegExpKind + { + NONE, LIKE, MATCH + }; - enum class RegExpKind - { - NONE, LIKE, MATCH - }; - - RegExpKind regular_expr_kind_ = RegExpKind::NONE; - std::unique_ptr regular_expr_; + RegExpKind regular_expr_kind_ = RegExpKind::NONE; + std::unique_ptr regular_expr_; - static int compare( - const DDSFilterValue& lhs, - const DDSFilterValue& rhs) noexcept; + static int compare( + const DDSFilterValue & lhs, + const DDSFilterValue & rhs) noexcept; }; diff --git a/common_content_filter/src/IContentFilter.hpp b/common_content_filter/src/IContentFilter.hpp index fe94ca4..3a7882c 100644 --- a/common_content_filter/src/IContentFilter.hpp +++ b/common_content_filter/src/IContentFilter.hpp @@ -20,24 +20,27 @@ #define COMMON_CONTENT_FILTER__ICONTENTFILTER_HPP_ -namespace eprosima_common { -namespace fastdds { -namespace dds { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ /** * The interface that content filter objects should implement. */ struct IContentFilter { - /** - * Evaluate if a de-serialized payload should be accepted by certain reader. - * - * @param [in] payload The de-serialized payload of the sample being evaluated. - * - * @return whether the sample should be accepted. - */ - virtual bool evaluate( - const void * payload) const = 0; + /** + * Evaluate if a de-serialized payload should be accepted by certain reader. + * + * @param [in] payload The de-serialized payload of the sample being evaluated. + * + * @return whether the sample should be accepted. + */ + virtual bool evaluate( + const void * payload) const = 0; }; } // namespace dds diff --git a/common_content_filter/src/IContentFilterFactory.hpp b/common_content_filter/src/IContentFilterFactory.hpp index 6a5f733..441bada 100644 --- a/common_content_filter/src/IContentFilterFactory.hpp +++ b/common_content_filter/src/IContentFilterFactory.hpp @@ -27,70 +27,74 @@ #include "IContentFilter.hpp" -namespace eprosima_common { -namespace fastdds { -namespace dds { +namespace eprosima_common +{ +namespace fastdds +{ +namespace dds +{ /** * The interface that a factory of IContentFilter objects should implement. */ struct IContentFilterFactory { - enum ReturnCode_t { - RETCODE_OK, - RETCODE_BAD_PARAMETER, - RETCODE_UNSUPPORTED, - }; + enum ReturnCode_t + { + RETCODE_OK, + RETCODE_BAD_PARAMETER, + RETCODE_UNSUPPORTED, + }; - using ParameterSeq = std::vector; + using ParameterSeq = std::vector; - /** - * Create or update an IContentFilter instance. - * - * @param [in] filter_class_name Filter class name for which the factory is being called. - * Allows using the same factory for different filter classes. - * @param [in] type_name Type name of the topic being filtered. - * @param [in] type_support Type support of the topic data being filtered. - * @param [in] filter_expression Content filter expression. - * May be nullptr when updating the parameters of a filter instance. - * @param [in] filter_parameters Values to set for the filter parameters (%n on the filter expression). - * @param [in, out] filter_instance When a filter is being created, it will be nullptr on input, - * and will have the pointer to the created filter instance on output. - * The caller takes ownership of the filter instance returned. - * When a filter is being updated, it will have a previously returned pointer - * on input. The method takes ownership of the filter instance during its - * execution, and can update the filter instance or even destroy it and - * create a new one. - * The caller takes ownership of the filter instance returned. - * It should always have a valid pointer upon return. - * The original state of the filter instance should be preserved when an - * error is returned. - * - * @return A return code indicating the result of the operation. - */ - virtual ReturnCode_t create_content_filter( - const char* filter_class_name, - const char* type_name, - const rosidl_message_type_support_t* type_support, - const char* filter_expression, - const ParameterSeq& filter_parameters, - IContentFilter*& filter_instance) = 0; + /** + * Create or update an IContentFilter instance. + * + * @param [in] filter_class_name Filter class name for which the factory is being called. + * Allows using the same factory for different filter classes. + * @param [in] type_name Type name of the topic being filtered. + * @param [in] type_support Type support of the topic data being filtered. + * @param [in] filter_expression Content filter expression. + * May be nullptr when updating the parameters of a filter instance. + * @param [in] filter_parameters Values to set for the filter parameters (%n on the filter expression). + * @param [in, out] filter_instance When a filter is being created, it will be nullptr on input, + * and will have the pointer to the created filter instance on output. + * The caller takes ownership of the filter instance returned. + * When a filter is being updated, it will have a previously returned pointer + * on input. The method takes ownership of the filter instance during its + * execution, and can update the filter instance or even destroy it and + * create a new one. + * The caller takes ownership of the filter instance returned. + * It should always have a valid pointer upon return. + * The original state of the filter instance should be preserved when an + * error is returned. + * + * @return A return code indicating the result of the operation. + */ + virtual ReturnCode_t create_content_filter( + const char * filter_class_name, + const char * type_name, + const rosidl_message_type_support_t * type_support, + const char * filter_expression, + const ParameterSeq & filter_parameters, + IContentFilter * & filter_instance) = 0; - /** - * Delete an IContentFilter instance. - * - * @param [in] filter_class_name Filter class name for which the factory is being called. - * Allows using the same factory for different filter classes. - * @param [in] filter_instance A pointer to a filter instance previously returned by create_content_filter. - * The factory takes ownership of the filter instance, and can decide to destroy - * it or keep it for future use. - * In case of deletion, note this pointer must be downcasted to the derived class. - * - * @return A return code indicating the result of the operation. - */ - virtual ReturnCode_t delete_content_filter( - const char* filter_class_name, - IContentFilter* filter_instance) = 0; + /** + * Delete an IContentFilter instance. + * + * @param [in] filter_class_name Filter class name for which the factory is being called. + * Allows using the same factory for different filter classes. + * @param [in] filter_instance A pointer to a filter instance previously returned by create_content_filter. + * The factory takes ownership of the filter instance, and can decide to destroy + * it or keep it for future use. + * In case of deletion, note this pointer must be downcasted to the derived class. + * + * @return A return code indicating the result of the operation. + */ + virtual ReturnCode_t delete_content_filter( + const char * filter_class_name, + IContentFilter * filter_instance) = 0; }; } // namespace dds diff --git a/common_content_filter/src/Log.hpp b/common_content_filter/src/Log.hpp index 5bd6b6c..dad31b0 100644 --- a/common_content_filter/src/Log.hpp +++ b/common_content_filter/src/Log.hpp @@ -6,16 +6,16 @@ // TODO. use rcutil log instead #include -#define common_content_filter_log_(cat, msg) \ - { \ - std::stringstream log_ss_tmp__; \ - log_ss_tmp__ << msg; \ - std::cout << "[" << #cat << "] " << log_ss_tmp__.str() << std::endl; \ - } +#define common_content_filter_log_(cat, msg) \ + { \ + std::stringstream log_ss_tmp__; \ + log_ss_tmp__ << msg; \ + std::cout << "[" << #cat << "] " << log_ss_tmp__.str() << std::endl; \ + } #define logDebug common_content_filter_log_ #define logInfo common_content_filter_log_ #define logWarning common_content_filter_log_ #define logError common_content_filter_log_ -#endif // COMMON_CONTENT_FILTER__LOG_HPP_ \ No newline at end of file +#endif // COMMON_CONTENT_FILTER__LOG_HPP_ diff --git a/common_content_filter/src/ObjectPool.hpp b/common_content_filter/src/ObjectPool.hpp index da08d3e..115621a 100644 --- a/common_content_filter/src/ObjectPool.hpp +++ b/common_content_filter/src/ObjectPool.hpp @@ -24,8 +24,10 @@ #include #include -namespace eprosima_common { -namespace fastdds { +namespace eprosima_common +{ +namespace fastdds +{ /** * A generic pool of objects. @@ -39,58 +41,56 @@ namespace fastdds { * * @ingroup UTILITIES_MODULE */ -template < - typename _Ty, - typename _Alloc = std::allocator<_Ty>, - typename _Collection = std::vector<_Ty, _Alloc>> +template< + typename _Ty, + typename _Alloc = std::allocator<_Ty>, + typename _Collection = std::vector<_Ty, _Alloc>> struct ObjectPool final { - using allocator_type = _Alloc; - using value_type = _Ty; - - /** - * Construct an ObjectPool. - */ - ObjectPool( - const allocator_type& alloc = allocator_type()) - : collection_(alloc) - { + using allocator_type = _Alloc; + using value_type = _Ty; + + /** + * Construct an ObjectPool. + */ + ObjectPool( + const allocator_type & alloc = allocator_type()) + : collection_(alloc) + { + } + + const _Collection & collection() const noexcept + { + return collection_; + } + + _Collection & collection() noexcept + { + return collection_; + } + + template + value_type get( + _DefaultGetter _Default) + { + if (collection_.empty()) { + return _Default(); } - const _Collection& collection() const noexcept - { - return collection_; - } - - _Collection& collection() noexcept - { - return collection_; - } + value_type ret = collection_.back(); + collection_.pop_back(); + return ret; + } - template - value_type get( - _DefaultGetter _Default) - { - if (collection_.empty()) - { - return _Default(); - } - - value_type ret = collection_.back(); - collection_.pop_back(); - return ret; - } - - template - void put( - _Valty&&... _Val) - { - collection_.emplace_back(std::forward<_Valty>(_Val)...); - } + template + void put( + _Valty &&... _Val) + { + collection_.emplace_back(std::forward<_Valty>(_Val)...); + } private: - - _Collection collection_; + _Collection collection_; }; diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index f1d3ec1..7b4f865 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -26,31 +26,36 @@ #include "Log.hpp" -namespace common_content_filter { +namespace common_content_filter +{ const int MAGIC = 0x434654; // 'C','F','T' -const char* FILTER_CLASS_NAME = "DDSSQL"; +const char * FILTER_CLASS_NAME = "DDSSQL"; using DDSFilterFactory = eprosima_common::fastdds::dds::DDSSQLFilter::DDSFilterFactory; using IContentFilter = eprosima_common::fastdds::dds::IContentFilter; DDSFilterFactory * -get_common_content_filter_factory() { +get_common_content_filter_factory() +{ static DDSFilterFactory content_filter_factory; return &content_filter_factory; } -class ContentFilterWrapper { +class ContentFilterWrapper +{ public: ContentFilterWrapper() { // logDebug(DDSSQLFILTER, "ContentFilterWrapper ctor : " << this); } - ~ContentFilterWrapper() { + ~ContentFilterWrapper() + { std::lock_guard lock(mutex_); if (filter_instance_) { - DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->delete_content_filter( + DDSFilterFactory::ReturnCode_t ret = + get_common_content_filter_factory()->delete_content_filter( FILTER_CLASS_NAME, filter_instance_); if (ret != DDSFilterFactory::RETCODE_OK) { @@ -63,7 +68,8 @@ class ContentFilterWrapper { // logDebug(DDSSQLFILTER, "ContentFilterWrapper dtor : " << this); } - bool evaluate(void * ros_data, bool serialized) { + bool evaluate(void * ros_data, bool serialized) + { std::lock_guard lock(mutex_); if (serialized) { // TODO. deserialize the ros_data @@ -119,15 +125,18 @@ class ContentFilterWrapper { return true; } - IContentFilter * filter_instance() { + IContentFilter * filter_instance() + { return filter_instance_; } - bool is_enabled() { + bool is_enabled() + { return filter_instance_ != nullptr; } - int magic() { + int magic() + { return magic_; } @@ -140,10 +149,11 @@ class ContentFilterWrapper { }; -common_content_filter::ContentFilterWrapper * validate(void * instance) { +common_content_filter::ContentFilterWrapper * validate(void * instance) +{ auto content_filter_wrapper = static_cast(instance); - if (!content_filter_wrapper || content_filter_wrapper->magic() != common_content_filter::MAGIC ) { + if (!content_filter_wrapper || content_filter_wrapper->magic() != common_content_filter::MAGIC) { logError(DDSSQLFILTER, "Invalid instance"); return nullptr; } @@ -159,12 +169,14 @@ extern "C" #endif void * -common_content_filter_create() { - return (new common_content_filter::ContentFilterWrapper); +common_content_filter_create() +{ + return new common_content_filter::ContentFilterWrapper; } bool -common_content_filter_is_enabled(void * instance) { +common_content_filter_is_enabled(void * instance) +{ common_content_filter::ContentFilterWrapper * content_filter_wrapper = common_content_filter::validate(instance); if (!content_filter_wrapper) { @@ -175,7 +187,8 @@ common_content_filter_is_enabled(void * instance) { } bool -common_content_filter_evaluate(void * instance, void * ros_data, bool serialized) { +common_content_filter_evaluate(void * instance, void * ros_data, bool serialized) +{ common_content_filter::ContentFilterWrapper * content_filter_wrapper = common_content_filter::validate(instance); if (!content_filter_wrapper) { @@ -190,7 +203,7 @@ common_content_filter_evaluate(void * instance, void * ros_data, bool serialized bool ret = false; try { ret = content_filter_wrapper->evaluate(ros_data, serialized); - } catch (const std::runtime_error& e) { + } catch (const std::runtime_error & e) { logError(DDSSQLFILTER, "Failed to evaluate: " << e.what()); } @@ -202,7 +215,8 @@ common_content_filter_set( void * instance, const rosidl_message_type_support_t * type_support, const rmw_subscription_content_filter_options_t * options -) { +) +{ common_content_filter::ContentFilterWrapper * content_filter_wrapper = common_content_filter::validate(instance); if (!content_filter_wrapper) { @@ -224,7 +238,7 @@ common_content_filter_set( ret = content_filter_wrapper->set_filter_expression( type_support, options->filter_expression, expression_parameters ); - } catch (const std::runtime_error& e) { + } catch (const std::runtime_error & e) { logInfo(DDSSQLFILTER, "Failed to create content filter: " << e.what()); } @@ -236,7 +250,8 @@ common_content_filter_get( void * instance, rcutils_allocator_t * allocator, rmw_subscription_content_filter_options_t * options -) { +) +{ common_content_filter::ContentFilterWrapper * content_filter_wrapper = common_content_filter::validate(instance); if (!content_filter_wrapper) { @@ -280,7 +295,8 @@ common_content_filter_get( } void -common_content_filter_destroy(void * instance) { +common_content_filter_destroy(void * instance) +{ common_content_filter::ContentFilterWrapper * content_filter_wrapper = common_content_filter::validate(instance); if (!content_filter_wrapper) { @@ -292,4 +308,4 @@ common_content_filter_destroy(void * instance) { #ifdef __cplusplus } -#endif \ No newline at end of file +#endif From 3b95aa3bab3847003ea492cca4410d0176193c02 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 5 Jul 2022 13:41:11 +0800 Subject: [PATCH 21/51] update Signed-off-by: Chen Lihui --- common_content_filter/src/api.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index 7b4f865..04fb8d2 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -14,9 +14,9 @@ #include "common_content_filter/api.h" -#include "rmw/allocators.h" -#include "rmw/error_handling.h" -#include "rmw/rmw.h" +#include +#include +#include #include #include From dffb8df81f961ce33a49c07c9cc375df2dd3b5b3 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 5 Jul 2022 15:49:19 +0800 Subject: [PATCH 22/51] use rosidl_runtime_c__String for string in c type_support Signed-off-by: Chen Lihui --- common_content_filter/src/DDSFilterFactory.cpp | 2 +- common_content_filter/src/DDSFilterField.cpp | 6 ++++-- common_content_filter/src/api.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/common_content_filter/src/DDSFilterFactory.cpp b/common_content_filter/src/DDSFilterFactory.cpp index 1e1045d..6a00c74 100644 --- a/common_content_filter/src/DDSFilterFactory.cpp +++ b/common_content_filter/src/DDSFilterFactory.cpp @@ -433,7 +433,7 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( } } else if (std::strlen(filter_expression) == 0) { delete_content_filter(filter_class_name, filter_instance); - filter_instance = &empty_expression_; + filter_instance = nullptr; ret = ReturnCode_t::RETCODE_OK; } else { auto node = parser::parse_filter_expression(filter_expression, type_support); diff --git a/common_content_filter/src/DDSFilterField.cpp b/common_content_filter/src/DDSFilterField.cpp index 3615f9a..4a52acd 100644 --- a/common_content_filter/src/DDSFilterField.cpp +++ b/common_content_filter/src/DDSFilterField.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -201,10 +202,11 @@ bool DDSFilterField::set_member( case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: if (is_c_type_support) { - strncpy(string_value, reinterpret_cast(data), sizeof(string_value)); + auto c_string = reinterpret_cast(data); + strncpy(string_value, c_string->data, sizeof(string_value)); } else { auto string = reinterpret_cast(data); - strncpy(string_value, (char *)string->c_str(), sizeof(string_value)); + strncpy(string_value, string->c_str(), sizeof(string_value)); } break; diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index 04fb8d2..6f86f26 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -278,7 +278,7 @@ common_content_filter_get( string_array.push_back(expression_parameters[i].c_str()); } - rmw_ret_t rmw_ret = rmw_subscription_content_filter_options_init( + rmw_ret_t rmw_ret = rmw_subscription_content_filter_options_set( filter_expression.c_str(), string_array.size(), string_array.data(), From dff09f0751c6d46ae9572f72c01148018456d604 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 5 Jul 2022 17:52:02 +0800 Subject: [PATCH 23/51] update Signed-off-by: Chen Lihui --- common_content_filter/src/api.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index 6f86f26..4ec5a94 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -89,7 +89,7 @@ class ContentFilterWrapper const std::vector & expression_parameters) { std::lock_guard lock(mutex_); - static std::string tip = filter_instance_ ? "create" : "set"; + const char * tip = filter_instance_ ? "create" : "set"; DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->create_content_filter( FILTER_CLASS_NAME, // deprecated "", // deprecated From 5c8c97013ce2ae13af5d9be9ac342daccb594ab1 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Wed, 6 Jul 2022 11:01:50 +0800 Subject: [PATCH 24/51] use rcutils log Signed-off-by: Chen Lihui --- .../include/common_content_filter/api.h | 2 -- common_content_filter/src/Log.hpp | 29 +++++++++++++------ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/common_content_filter/include/common_content_filter/api.h b/common_content_filter/include/common_content_filter/api.h index ef92c7b..3016cdc 100644 --- a/common_content_filter/include/common_content_filter/api.h +++ b/common_content_filter/include/common_content_filter/api.h @@ -29,8 +29,6 @@ extern "C" /// Create a common content filter instance to filter data. /** - * \param[in] type_support Type support of the topic data being filtered - * \param[in] options the filter options * \return a valid address if success, or NULL on failure */ COMMON_CONTENT_FILTER_PUBLIC diff --git a/common_content_filter/src/Log.hpp b/common_content_filter/src/Log.hpp index dad31b0..e8a8959 100644 --- a/common_content_filter/src/Log.hpp +++ b/common_content_filter/src/Log.hpp @@ -1,21 +1,32 @@ -// license +// Copyright 2022 Open Source Robotics Foundation, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #ifndef COMMON_CONTENT_FILTER__LOG_HPP_ #define COMMON_CONTENT_FILTER__LOG_HPP_ -// TODO. use rcutil log instead -#include +#include -#define common_content_filter_log_(cat, msg) \ +#define common_content_filter_log_(level, cat, msg) \ { \ std::stringstream log_ss_tmp__; \ log_ss_tmp__ << msg; \ - std::cout << "[" << #cat << "] " << log_ss_tmp__.str() << std::endl; \ + RCUTILS_LOG_ ## level ## _NAMED(#cat, "%s", log_ss_tmp__.str().c_str()); \ } -#define logDebug common_content_filter_log_ -#define logInfo common_content_filter_log_ -#define logWarning common_content_filter_log_ -#define logError common_content_filter_log_ +#define logDebug(cat, msg) common_content_filter_log_(DEBUG, cat, msg) +#define logInfo(cat, msg) common_content_filter_log_(INFO, cat, msg) +#define logWarning(cat, msg) common_content_filter_log_(WARN, cat, msg) +#define logError(cat, msg) common_content_filter_log_(ERROR, cat, msg) #endif // COMMON_CONTENT_FILTER__LOG_HPP_ From 46959026ac8dc39a98baa16d41b447d3573f3be5 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Wed, 6 Jul 2022 13:33:35 +0800 Subject: [PATCH 25/51] add test cases for the exported functions Signed-off-by: Chen Lihui --- common_content_filter/CMakeLists.txt | 10 ++ common_content_filter/package.xml | 3 + common_content_filter/test/test_api.cpp | 123 ++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 common_content_filter/test/test_api.cpp diff --git a/common_content_filter/CMakeLists.txt b/common_content_filter/CMakeLists.txt index 36d401d..0709d58 100644 --- a/common_content_filter/CMakeLists.txt +++ b/common_content_filter/CMakeLists.txt @@ -78,7 +78,11 @@ install( DESTINATION include/${PROJECT_NAME}) if(BUILD_TESTING) + find_package(ament_cmake_gtest REQUIRED) find_package(ament_lint_auto REQUIRED) + find_package(test_msgs REQUIRED) + find_package(osrf_testing_tools_cpp REQUIRED) + # the following line skips the linter which checks for copyrights # comment the line when a copyright and license is added to all source files set(ament_cmake_copyright_FOUND TRUE) @@ -86,7 +90,13 @@ if(BUILD_TESTING) # comment the line when this package is in a git repo and when # a copyright and license is added to all source files set(ament_cmake_cpplint_FOUND TRUE) + # the following line skips uncrustify (TODO. use pegtl as a new package(e.g. pegtl_vendor)) + set(ament_cmake_uncrustify_FOUND TRUE) ament_lint_auto_find_test_dependencies() + + ament_add_gtest(test_api test/test_api.cpp) + target_link_libraries(test_api ${PROJECT_NAME}_library) + ament_target_dependencies(test_api test_msgs osrf_testing_tools_cpp) endif() ament_package() diff --git a/common_content_filter/package.xml b/common_content_filter/package.xml index ff8b2a5..668922a 100644 --- a/common_content_filter/package.xml +++ b/common_content_filter/package.xml @@ -15,8 +15,11 @@ rosidl_typesupport_introspection_c rosidl_typesupport_introspection_cpp + ament_cmake_gtest ament_lint_auto ament_lint_common + test_msgs + osrf_testing_tools_cpp ament_cmake diff --git a/common_content_filter/test/test_api.cpp b/common_content_filter/test/test_api.cpp new file mode 100644 index 0000000..edffc0e --- /dev/null +++ b/common_content_filter/test/test_api.cpp @@ -0,0 +1,123 @@ +// Copyright 2022 Open Source Robotics Foundation, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include +#include + +#include "common_content_filter/api.h" + +class TestCommonContentFilterAPI : public ::testing::Test +{ +protected: + void SetUp() + { + instance = common_content_filter_create(); + EXPECT_NE(instance, nullptr); + type_support = ROSIDL_GET_MSG_TYPE_SUPPORT(test_msgs, msg, BasicTypes); + } + + void TearDown() + { + common_content_filter_destroy(instance); + } + +protected: + void set_options() { + rcutils_allocator_t allocator = rcutils_get_default_allocator(); + rmw_subscription_content_filter_options_t options = + rmw_get_zero_initialized_content_filter_options(); + EXPECT_EQ( + RMW_RET_OK, + rmw_subscription_content_filter_options_init( + filter_expression, + expression_parameter_argc, + expression_parameter_argv, + &allocator, + &options) + ); + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { + rmw_subscription_content_filter_options_fini(&options, &allocator); + }); + + EXPECT_TRUE(common_content_filter_set(instance, type_support, &options)); + } + + void * instance; + const rosidl_message_type_support_t * type_support; + const char * filter_expression = "int32_value = %0"; + size_t expression_parameter_argc = 1; + const char * expression_parameter_argv[1] = {"4"}; +}; + +TEST_F(TestCommonContentFilterAPI, is_enabled) { + EXPECT_FALSE(common_content_filter_is_enabled(nullptr)); + EXPECT_FALSE(common_content_filter_is_enabled(instance)); + set_options(); + EXPECT_TRUE(common_content_filter_is_enabled(instance)); +} + +TEST_F(TestCommonContentFilterAPI, evaluate) { + EXPECT_FALSE(common_content_filter_evaluate(nullptr, nullptr, false)); + EXPECT_FALSE(common_content_filter_evaluate(instance, nullptr, false)); + + test_msgs__msg__BasicTypes msg; + test_msgs__msg__BasicTypes__init(&msg); + msg.int32_value = 3; + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { + test_msgs__msg__BasicTypes__fini(&msg); + }); + + // no filter setting, expect true + EXPECT_TRUE(common_content_filter_evaluate(instance, &msg, false)); + // after setting filter with "int32_value = 4" + set_options(); + // expect msg(int32_value = 3) return false + EXPECT_FALSE(common_content_filter_evaluate(instance, &msg, false)); + // update msg with 4 + msg.int32_value = 4; + EXPECT_TRUE(common_content_filter_evaluate(instance, &msg, false)); +} + +TEST_F(TestCommonContentFilterAPI, set) { + EXPECT_FALSE(common_content_filter_set(nullptr, nullptr, nullptr)); + EXPECT_FALSE(common_content_filter_set(instance, nullptr, nullptr)); + EXPECT_FALSE(common_content_filter_set(instance, type_support, nullptr)); + set_options(); +} + +TEST_F(TestCommonContentFilterAPI, get) { + EXPECT_FALSE(common_content_filter_get(nullptr, nullptr, nullptr)); + EXPECT_FALSE(common_content_filter_get(instance, nullptr, nullptr)); + set_options(); + rcutils_allocator_t allocator = rcutils_get_default_allocator(); + EXPECT_FALSE(common_content_filter_get(instance, &allocator, nullptr)); + + rmw_subscription_content_filter_options_t options = + rmw_get_zero_initialized_content_filter_options(); + EXPECT_TRUE(common_content_filter_get(instance, &allocator, &options)); + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { + rmw_subscription_content_filter_options_fini(&options, &allocator); + }); + + EXPECT_STREQ(options.filter_expression, filter_expression); + ASSERT_EQ(expression_parameter_argc, options.expression_parameters.size); + for (size_t i = 0; i < expression_parameter_argc; ++i) { + EXPECT_STREQ(options.expression_parameters.data[i], expression_parameter_argv[i]); + } +} From 32f66cb8b4b5bddb29815695bb7fd75806cf5c2f Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Fri, 8 Jul 2022 10:39:17 +0800 Subject: [PATCH 26/51] to support serialized data Signed-off-by: Chen Lihui --- common_content_filter/CMakeLists.txt | 8 +- .../include/common_content_filter/api.h | 9 +- common_content_filter/package.xml | 1 + .../src/DDSFilterExpressionParser.cpp | 1 + .../identifiers.hpp | 31 ------- common_content_filter/src/Utilities.cpp | 53 ++++++++++++ common_content_filter/src/Utilities.hpp | 24 ++++++ common_content_filter/src/api.cpp | 85 ++++++++++++++++--- common_content_filter/test/test_api.cpp | 11 ++- 9 files changed, 169 insertions(+), 54 deletions(-) create mode 100644 common_content_filter/src/Utilities.cpp create mode 100644 common_content_filter/src/Utilities.hpp diff --git a/common_content_filter/CMakeLists.txt b/common_content_filter/CMakeLists.txt index 0709d58..0764711 100644 --- a/common_content_filter/CMakeLists.txt +++ b/common_content_filter/CMakeLists.txt @@ -15,6 +15,7 @@ find_package(ament_cmake REQUIRED) find_package(rcutils REQUIRED) find_package(rcpputils REQUIRED) find_package(rmw REQUIRED) +find_package(rmw_implementation REQUIRED) find_package(rosidl_typesupport_introspection_c REQUIRED) find_package(rosidl_typesupport_introspection_cpp REQUIRED) @@ -27,7 +28,8 @@ add_library(${PROJECT_NAME}_library SHARED src/DDSFilterField.cpp src/DDSFilterParameter.cpp src/DDSFilterPredicate.cpp - src/DDSFilterValue.cpp) + src/DDSFilterValue.cpp + src/Utilities.cpp) set_target_properties(${PROJECT_NAME}_library PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) @@ -43,6 +45,7 @@ ament_target_dependencies(${PROJECT_NAME}_library "rcpputils" "rcutils" "rmw" + "rmw_implementation" "rosidl_typesupport_introspection_c" "rosidl_typesupport_introspection_cpp" ) @@ -70,6 +73,7 @@ ament_export_dependencies(ament_cmake_core) ament_export_dependencies(rcpputils) ament_export_dependencies(rcutils) ament_export_dependencies(rmw) +ament_export_dependencies(rmw_implementation) ament_export_dependencies(rosidl_typesupport_introspection_c) ament_export_dependencies(rosidl_typesupport_introspection_cpp) @@ -96,7 +100,7 @@ if(BUILD_TESTING) ament_add_gtest(test_api test/test_api.cpp) target_link_libraries(test_api ${PROJECT_NAME}_library) - ament_target_dependencies(test_api test_msgs osrf_testing_tools_cpp) + ament_target_dependencies(test_api test_msgs osrf_testing_tools_cpp rmw) endif() ament_package() diff --git a/common_content_filter/include/common_content_filter/api.h b/common_content_filter/include/common_content_filter/api.h index 3016cdc..1c0c249 100644 --- a/common_content_filter/include/common_content_filter/api.h +++ b/common_content_filter/include/common_content_filter/api.h @@ -29,11 +29,12 @@ extern "C" /// Create a common content filter instance to filter data. /** + * \param[in] type_support Type support of the topic data being filtered * \return a valid address if success, or NULL on failure */ COMMON_CONTENT_FILTER_PUBLIC void * -common_content_filter_create(); +common_content_filter_create(const rosidl_message_type_support_t * type_support); /// Check if the content filter instance is enabled. /** @@ -58,15 +59,13 @@ common_content_filter_evaluate(void * instance, void * data, bool serialized); /// Set a common content filter instance with an options. /** * \param[in] instance The content filter instance - * \param[in] type_support Type support of the topic data being filtered * \param[in] options the filter options - * \return a valid address if success, or NULL on failure + * \return true if success, or false */ COMMON_CONTENT_FILTER_PUBLIC bool common_content_filter_set( void * instance, - const rosidl_message_type_support_t * type_support, const rmw_subscription_content_filter_options_t * options ); @@ -75,7 +74,7 @@ common_content_filter_set( * \param[in] instance The content filter instance * \param[in] allocator Type support of the topic data being filtered * \param[in] options the filter options - * \return a valid address if success, or NULL on failure + * \return true if success, or false */ COMMON_CONTENT_FILTER_PUBLIC bool diff --git a/common_content_filter/package.xml b/common_content_filter/package.xml index 668922a..a3a405e 100644 --- a/common_content_filter/package.xml +++ b/common_content_filter/package.xml @@ -12,6 +12,7 @@ rcutils rcpputils rmw + rmw_implementation rosidl_typesupport_introspection_c rosidl_typesupport_introspection_cpp diff --git a/common_content_filter/src/DDSFilterExpressionParser.cpp b/common_content_filter/src/DDSFilterExpressionParser.cpp index 6e8ef07..3874c04 100644 --- a/common_content_filter/src/DDSFilterExpressionParser.cpp +++ b/common_content_filter/src/DDSFilterExpressionParser.cpp @@ -36,6 +36,7 @@ #include "DDSFilterValue.hpp" #include "DDSFilterField.hpp" #include "Log.hpp" +#include "Utilities.hpp" namespace eprosima_common { diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp index a0853d2..5e5b5ec 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp @@ -35,37 +35,6 @@ struct identifier_processor : parse_tree::apply { - static const rosidl_message_type_support_t * - get_type_support_introspection( - const rosidl_message_type_support_t * type_support) - { - const rosidl_message_type_support_t * type_support_introspection = - get_message_typesupport_handle( - type_support, rosidl_typesupport_introspection_c__identifier); - if (nullptr == type_support_introspection) { - rcutils_error_string_t prev_error_string = rcutils_get_error_string(); - rcutils_reset_error(); - - type_support_introspection = - get_message_typesupport_handle( - type_support, - rosidl_typesupport_introspection_cpp::typesupport_identifier); - if (nullptr == type_support_introspection) { - rcutils_error_string_t error_string = rcutils_get_error_string(); - rcutils_reset_error(); - RMW_SET_ERROR_MSG_WITH_FORMAT_STRING( - "Type support not from this implementation. Got:\n" - " %s\n" - " %s\n" - "while fetching it", - prev_error_string.str, error_string.str); - return nullptr; - } - } - - return type_support_introspection; - } - template static void add_access_path( diff --git a/common_content_filter/src/Utilities.cpp b/common_content_filter/src/Utilities.cpp new file mode 100644 index 0000000..d1ab6ab --- /dev/null +++ b/common_content_filter/src/Utilities.cpp @@ -0,0 +1,53 @@ +// Copyright 2022 Open Source Robotics Foundation, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "Utilities.hpp" + +#include +#include +#include +#include +#include +#include + +const rosidl_message_type_support_t * +get_type_support_introspection( + const rosidl_message_type_support_t * type_support) +{ + const rosidl_message_type_support_t * type_support_introspection = + get_message_typesupport_handle( + type_support, rosidl_typesupport_introspection_c__identifier); + if (nullptr == type_support_introspection) { + rcutils_error_string_t prev_error_string = rcutils_get_error_string(); + rcutils_reset_error(); + + type_support_introspection = + get_message_typesupport_handle( + type_support, + rosidl_typesupport_introspection_cpp::typesupport_identifier); + if (nullptr == type_support_introspection) { + rcutils_error_string_t error_string = rcutils_get_error_string(); + rcutils_reset_error(); + RMW_SET_ERROR_MSG_WITH_FORMAT_STRING( + "Type support not from this implementation. Got:\n" + " %s\n" + " %s\n" + "while fetching it", + prev_error_string.str, error_string.str); + return nullptr; + } + } + + return type_support_introspection; +} diff --git a/common_content_filter/src/Utilities.hpp b/common_content_filter/src/Utilities.hpp new file mode 100644 index 0000000..fe0acad --- /dev/null +++ b/common_content_filter/src/Utilities.hpp @@ -0,0 +1,24 @@ +// Copyright 2022 Open Source Robotics Foundation, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef COMMON_CONTENT_FILTER__UTILITIES_HPP_ +#define COMMON_CONTENT_FILTER__UTILITIES_HPP_ + +#include + +const rosidl_message_type_support_t * +get_type_support_introspection( + const rosidl_message_type_support_t * type_support); + +#endif // COMMON_CONTENT_FILTER__UTILITIES_HPP_ diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index 4ec5a94..bdac7c4 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -19,11 +19,19 @@ #include #include + +#include +#include +#include +#include +#include + #include #include #include "DDSFilterFactory.hpp" #include "Log.hpp" +#include "Utilities.hpp" namespace common_content_filter @@ -45,7 +53,8 @@ get_common_content_filter_factory() class ContentFilterWrapper { public: - ContentFilterWrapper() + ContentFilterWrapper(const rosidl_message_type_support_t * type_support) + : type_support_(type_support) { // logDebug(DDSSQLFILTER, "ContentFilterWrapper ctor : " << this); } @@ -68,23 +77,79 @@ class ContentFilterWrapper // logDebug(DDSSQLFILTER, "ContentFilterWrapper dtor : " << this); } + template + auto + get_message( + const rosidl_message_type_support_t * type_support_introspection, + MessageInitialization message_initialization) + { + const MembersType * members = + static_cast(type_support_introspection->data); + if (!members) { + throw std::runtime_error("The data in the type support introspection is invalid."); + } + + auto msg = std::unique_ptr>( + malloc(members->size_of_), + [members](void * msg_ptr) { + members->fini_function(msg_ptr); + free(msg_ptr); + }); + if (msg) { + members->init_function(msg.get(), message_initialization); + } + + return msg; + } + + auto get_message_buffer() { + const rosidl_message_type_support_t * type_support_introspection = + get_type_support_introspection(type_support_); + if (!type_support_introspection) { + throw std::runtime_error("failed to get type support introspection"); + } + + if (type_support_introspection->typesupport_identifier == + rosidl_typesupport_introspection_c__identifier) + { + return get_message( + type_support_introspection, ROSIDL_RUNTIME_C_MSG_INIT_ZERO); + } else { + return get_message( + type_support_introspection, rosidl_runtime_cpp::MessageInitialization::ZERO); + } + } + bool evaluate(void * ros_data, bool serialized) { std::lock_guard lock(mutex_); + std::unique_ptr> deserialized_buffer = nullptr; + if (serialized) { - // TODO. deserialize the ros_data + deserialized_buffer = std::move(get_message_buffer()); + const rmw_serialized_message_t * serialized_message = + (const rmw_serialized_message_t *)ros_data; + rmw_ret_t rmw_ret = + rmw_deserialize(serialized_message, + type_support_, + deserialized_buffer.get()); + ros_data = deserialized_buffer.get(); + if (rmw_ret != RMW_RET_OK) { + logError(DDSSQLFILTER, "Failed to deserialize message"); + return false; + } } bool ret = true; if (filter_instance_) { ret = filter_instance_->evaluate(ros_data); } + // logDebug(DDSSQLFILTER, "evaluate ret: " << ret); return ret; } bool set_filter_expression( - const rosidl_message_type_support_t * type_support, const std::string & filter_expression, const std::vector & expression_parameters) { @@ -93,12 +158,12 @@ class ContentFilterWrapper DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->create_content_filter( FILTER_CLASS_NAME, // deprecated "", // deprecated - type_support, + type_support_, filter_expression.c_str(), expression_parameters, filter_instance_); if (ret != DDSFilterFactory::RETCODE_OK) { - logError(DDSSQLFILTER, "failed to " << tip << " content filter, ret: " << ret); + logError(DDSSQLFILTER, "failed to " << tip << " content filter, error code: " << ret); return false; } @@ -142,6 +207,7 @@ class ContentFilterWrapper private: const int magic_ = MAGIC; + const rosidl_message_type_support_t * type_support_; IContentFilter * filter_instance_ = nullptr; std::string filter_expression_; std::vector expression_parameters_; @@ -169,9 +235,9 @@ extern "C" #endif void * -common_content_filter_create() +common_content_filter_create(const rosidl_message_type_support_t * type_support) { - return new common_content_filter::ContentFilterWrapper; + return new common_content_filter::ContentFilterWrapper(type_support); } bool @@ -213,7 +279,6 @@ common_content_filter_evaluate(void * instance, void * ros_data, bool serialized bool common_content_filter_set( void * instance, - const rosidl_message_type_support_t * type_support, const rmw_subscription_content_filter_options_t * options ) { @@ -223,7 +288,7 @@ common_content_filter_set( return false; } - if (!type_support || !options) { + if (!options) { logError(DDSSQLFILTER, "Invalid arguments"); return false; } @@ -236,7 +301,7 @@ common_content_filter_set( bool ret = false; try { ret = content_filter_wrapper->set_filter_expression( - type_support, options->filter_expression, expression_parameters + options->filter_expression, expression_parameters ); } catch (const std::runtime_error & e) { logInfo(DDSSQLFILTER, "Failed to create content filter: " << e.what()); diff --git a/common_content_filter/test/test_api.cpp b/common_content_filter/test/test_api.cpp index edffc0e..e7faee2 100644 --- a/common_content_filter/test/test_api.cpp +++ b/common_content_filter/test/test_api.cpp @@ -24,9 +24,9 @@ class TestCommonContentFilterAPI : public ::testing::Test protected: void SetUp() { - instance = common_content_filter_create(); - EXPECT_NE(instance, nullptr); type_support = ROSIDL_GET_MSG_TYPE_SUPPORT(test_msgs, msg, BasicTypes); + instance = common_content_filter_create(type_support); + EXPECT_NE(instance, nullptr); } void TearDown() @@ -53,7 +53,7 @@ class TestCommonContentFilterAPI : public ::testing::Test rmw_subscription_content_filter_options_fini(&options, &allocator); }); - EXPECT_TRUE(common_content_filter_set(instance, type_support, &options)); + EXPECT_TRUE(common_content_filter_set(instance, &options)); } void * instance; @@ -94,9 +94,8 @@ TEST_F(TestCommonContentFilterAPI, evaluate) { } TEST_F(TestCommonContentFilterAPI, set) { - EXPECT_FALSE(common_content_filter_set(nullptr, nullptr, nullptr)); - EXPECT_FALSE(common_content_filter_set(instance, nullptr, nullptr)); - EXPECT_FALSE(common_content_filter_set(instance, type_support, nullptr)); + EXPECT_FALSE(common_content_filter_set(nullptr, nullptr)); + EXPECT_FALSE(common_content_filter_set(instance, nullptr)); set_options(); } From 4077f9ef82170830ecc294209a37663f60f4bc9d Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Fri, 8 Jul 2022 11:00:20 +0800 Subject: [PATCH 27/51] update test cases for serialized data Signed-off-by: Chen Lihui --- common_content_filter/test/test_api.cpp | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/common_content_filter/test/test_api.cpp b/common_content_filter/test/test_api.cpp index e7faee2..ecca879 100644 --- a/common_content_filter/test/test_api.cpp +++ b/common_content_filter/test/test_api.cpp @@ -16,6 +16,8 @@ #include #include +#include +#include #include "common_content_filter/api.h" @@ -73,6 +75,8 @@ TEST_F(TestCommonContentFilterAPI, is_enabled) { TEST_F(TestCommonContentFilterAPI, evaluate) { EXPECT_FALSE(common_content_filter_evaluate(nullptr, nullptr, false)); EXPECT_FALSE(common_content_filter_evaluate(instance, nullptr, false)); + EXPECT_FALSE(common_content_filter_evaluate(nullptr, nullptr, true)); + EXPECT_FALSE(common_content_filter_evaluate(instance, nullptr, true)); test_msgs__msg__BasicTypes msg; test_msgs__msg__BasicTypes__init(&msg); @@ -82,15 +86,41 @@ TEST_F(TestCommonContentFilterAPI, evaluate) { test_msgs__msg__BasicTypes__fini(&msg); }); + // test serialized message + rmw_serialized_message_t serialized_message = + rmw_get_zero_initialized_serialized_message(); + rcutils_allocator_t allocator = rcutils_get_default_allocator(); + EXPECT_EQ( + RMW_RET_OK, + rmw_serialized_message_init(&serialized_message, 1U, &allocator) + ); + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { + rmw_serialized_message_fini(&serialized_message); + }); + + EXPECT_EQ( + RMW_RET_OK, + rmw_serialize(&msg, type_support, &serialized_message) + ); + // no filter setting, expect true EXPECT_TRUE(common_content_filter_evaluate(instance, &msg, false)); + EXPECT_TRUE(common_content_filter_evaluate(instance, &serialized_message, true)); // after setting filter with "int32_value = 4" set_options(); // expect msg(int32_value = 3) return false EXPECT_FALSE(common_content_filter_evaluate(instance, &msg, false)); + EXPECT_FALSE(common_content_filter_evaluate(instance, &serialized_message, true)); // update msg with 4 msg.int32_value = 4; + EXPECT_EQ( + RMW_RET_OK, + rmw_serialize(&msg, type_support, &serialized_message) + ); + EXPECT_TRUE(common_content_filter_evaluate(instance, &msg, false)); + EXPECT_TRUE(common_content_filter_evaluate(instance, &serialized_message, true)); } TEST_F(TestCommonContentFilterAPI, set) { From e7957a0df6fee7c2baef732b3742da34b5e234f2 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Fri, 8 Jul 2022 12:55:47 +0800 Subject: [PATCH 28/51] r8 Signed-off-by: Chen Lihui --- common_content_filter/src/api.cpp | 101 ++++++++++++------------ common_content_filter/test/test_api.cpp | 3 +- 2 files changed, 53 insertions(+), 51 deletions(-) diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index bdac7c4..a06718a 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -50,11 +50,55 @@ get_common_content_filter_factory() return &content_filter_factory; } +template +auto +get_message( + const rosidl_message_type_support_t * type_support_introspection, + MessageInitialization message_initialization) +{ + const MembersType * members = + static_cast(type_support_introspection->data); + if (!members) { + throw std::runtime_error("The data in the type support introspection is invalid."); + } + + auto msg = std::unique_ptr>( + malloc(members->size_of_), + [members](void * msg_ptr) { + members->fini_function(msg_ptr); + free(msg_ptr); + }); + if (msg) { + members->init_function(msg.get(), message_initialization); + } + + return msg; +} + +auto get_message_buffer(const rosidl_message_type_support_t * type_support) +{ + const rosidl_message_type_support_t * type_support_introspection = + get_type_support_introspection(type_support); + if (!type_support_introspection) { + throw std::runtime_error("failed to get type support introspection"); + } + + if (type_support_introspection->typesupport_identifier == + rosidl_typesupport_introspection_c__identifier) + { + return get_message( + type_support_introspection, ROSIDL_RUNTIME_C_MSG_INIT_ZERO); + } else { + return get_message( + type_support_introspection, rosidl_runtime_cpp::MessageInitialization::ZERO); + } +} + class ContentFilterWrapper { public: ContentFilterWrapper(const rosidl_message_type_support_t * type_support) - : type_support_(type_support) + : type_support_(type_support) { // logDebug(DDSSQLFILTER, "ContentFilterWrapper ctor : " << this); } @@ -77,63 +121,19 @@ class ContentFilterWrapper // logDebug(DDSSQLFILTER, "ContentFilterWrapper dtor : " << this); } - template - auto - get_message( - const rosidl_message_type_support_t * type_support_introspection, - MessageInitialization message_initialization) - { - const MembersType * members = - static_cast(type_support_introspection->data); - if (!members) { - throw std::runtime_error("The data in the type support introspection is invalid."); - } - - auto msg = std::unique_ptr>( - malloc(members->size_of_), - [members](void * msg_ptr) { - members->fini_function(msg_ptr); - free(msg_ptr); - }); - if (msg) { - members->init_function(msg.get(), message_initialization); - } - - return msg; - } - - auto get_message_buffer() { - const rosidl_message_type_support_t * type_support_introspection = - get_type_support_introspection(type_support_); - if (!type_support_introspection) { - throw std::runtime_error("failed to get type support introspection"); - } - - if (type_support_introspection->typesupport_identifier == - rosidl_typesupport_introspection_c__identifier) - { - return get_message( - type_support_introspection, ROSIDL_RUNTIME_C_MSG_INIT_ZERO); - } else { - return get_message( - type_support_introspection, rosidl_runtime_cpp::MessageInitialization::ZERO); - } - } - bool evaluate(void * ros_data, bool serialized) { std::lock_guard lock(mutex_); - std::unique_ptr> deserialized_buffer = nullptr; if (serialized) { - deserialized_buffer = std::move(get_message_buffer()); const rmw_serialized_message_t * serialized_message = (const rmw_serialized_message_t *)ros_data; + if (!deserialized_buffer_) { + deserialized_buffer_ = std::move(get_message_buffer(type_support_)); + } rmw_ret_t rmw_ret = - rmw_deserialize(serialized_message, - type_support_, - deserialized_buffer.get()); - ros_data = deserialized_buffer.get(); + rmw_deserialize(serialized_message, type_support_, deserialized_buffer_.get()); + ros_data = deserialized_buffer_.get(); if (rmw_ret != RMW_RET_OK) { logError(DDSSQLFILTER, "Failed to deserialize message"); return false; @@ -208,6 +208,7 @@ class ContentFilterWrapper private: const int magic_ = MAGIC; const rosidl_message_type_support_t * type_support_; + std::unique_ptr> deserialized_buffer_ = nullptr; IContentFilter * filter_instance_ = nullptr; std::string filter_expression_; std::vector expression_parameters_; diff --git a/common_content_filter/test/test_api.cpp b/common_content_filter/test/test_api.cpp index ecca879..c49a63e 100644 --- a/common_content_filter/test/test_api.cpp +++ b/common_content_filter/test/test_api.cpp @@ -37,7 +37,8 @@ class TestCommonContentFilterAPI : public ::testing::Test } protected: - void set_options() { + void set_options() + { rcutils_allocator_t allocator = rcutils_get_default_allocator(); rmw_subscription_content_filter_options_t options = rmw_get_zero_initialized_content_filter_options(); From d237fc9052ecf97f324d6ab15698fb6b9032fd7c Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Fri, 8 Jul 2022 21:14:52 +0800 Subject: [PATCH 29/51] address partial review Signed-off-by: Chen Lihui --- .../src/DDSFilterExpression.cpp | 2 -- .../identifiers.hpp | 2 -- .../src/DDSFilterFactory.cpp | 13 +++------- .../src/DDSFilterFactory.hpp | 3 --- common_content_filter/src/DDSFilterField.cpp | 19 -------------- .../src/IContentFilterFactory.hpp | 8 ------ common_content_filter/src/api.cpp | 25 ++++++------------- 7 files changed, 10 insertions(+), 62 deletions(-) diff --git a/common_content_filter/src/DDSFilterExpression.cpp b/common_content_filter/src/DDSFilterExpression.cpp index 2f5ffc0..e37b25e 100644 --- a/common_content_filter/src/DDSFilterExpression.cpp +++ b/common_content_filter/src/DDSFilterExpression.cpp @@ -40,8 +40,6 @@ namespace DDSSQLFilter bool DDSFilterExpression::evaluate( const void * payload) const { - // logDebug(DDSSQLFILTER, "DDSFilterExpression::evaluate fields size:" << fields.size()); - root->reset(); for (auto it = fields.begin(); it != fields.end() && DDSFilterConditionState::UNDECIDED == root->get_state(); diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp index 5e5b5ec..de3cfa9 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp +++ b/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp @@ -158,8 +158,6 @@ struct identifier_processor CurrentIdentifierState & state, States &&... /*st*/) { - // logDebug(DDSSQLFILTER, "identifiers transform node name:" << n->content()); - if (n->is()) { // Set data for fieldname node n->field_kind = get_value_kind(state.current_type, n->end()); diff --git a/common_content_filter/src/DDSFilterFactory.cpp b/common_content_filter/src/DDSFilterFactory.cpp index 6a00c74..41c5a79 100644 --- a/common_content_filter/src/DDSFilterFactory.cpp +++ b/common_content_filter/src/DDSFilterFactory.cpp @@ -387,16 +387,12 @@ DDSFilterFactory::~DDSFilterFactory() } IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( - const char * filter_class_name, - const char * type_name, const rosidl_message_type_support_t * type_support, const char * filter_expression, const IContentFilterFactory::ParameterSeq & filter_parameters, IContentFilter * & filter_instance) { - static_cast(type_name); - ReturnCode_t ret = ReturnCode_t::RETCODE_UNSUPPORTED; if (nullptr == filter_expression) { @@ -432,7 +428,7 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( } } } else if (std::strlen(filter_expression) == 0) { - delete_content_filter(filter_class_name, filter_instance); + delete_content_filter(filter_instance); filter_instance = nullptr; ret = ReturnCode_t::RETCODE_OK; } else { @@ -448,10 +444,10 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( ExpressionParsingState state{nullptr, filter_parameters, expr}; ret = convert_tree(state, expr->root, *(node->children[0])); if (ReturnCode_t::RETCODE_OK == ret) { - delete_content_filter(filter_class_name, filter_instance); + delete_content_filter(filter_instance); filter_instance = expr; } else { - delete_content_filter(filter_class_name, expr); + delete_content_filter(expr); } } else { ret = ReturnCode_t::RETCODE_BAD_PARAMETER; @@ -462,11 +458,8 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( } IContentFilterFactory::ReturnCode_t DDSFilterFactory::delete_content_filter( - const char * filter_class_name, IContentFilter * filter_instance) { - static_cast(filter_class_name); - if (nullptr == filter_instance) { return ReturnCode_t::RETCODE_BAD_PARAMETER; } diff --git a/common_content_filter/src/DDSFilterFactory.hpp b/common_content_filter/src/DDSFilterFactory.hpp index 0584ab9..992aa46 100644 --- a/common_content_filter/src/DDSFilterFactory.hpp +++ b/common_content_filter/src/DDSFilterFactory.hpp @@ -46,15 +46,12 @@ class DDSFilterFactory final : public IContentFilterFactory ~DDSFilterFactory(); ReturnCode_t create_content_filter( - const char * filter_class_name, - const char * type_name, const rosidl_message_type_support_t * type_support, const char * filter_expression, const ParameterSeq & filter_parameters, IContentFilter * & filter_instance) override; ReturnCode_t delete_content_filter( - const char * filter_class_name, IContentFilter * filter_instance) override; private: diff --git a/common_content_filter/src/DDSFilterField.cpp b/common_content_filter/src/DDSFilterField.cpp index 4a52acd..dba8d17 100644 --- a/common_content_filter/src/DDSFilterField.cpp +++ b/common_content_filter/src/DDSFilterField.cpp @@ -56,16 +56,6 @@ DDSFilterField::get_msg_data_address( } const auto member = members->members_ + accessor.member_index; - // logDebug(DDSSQLFILTER, "DDSFilterField::get_msg_data_address " - // << " accessor.member_index:" << accessor.member_index - // << " accessor.array_index:" << accessor.array_index - // << " member member->name:" << member->name_ - // << " member member->type_id_:" << static_cast(member->type_id_) - // << " member member->offset_:" << member->offset_ - // << " member member->is_array_:" << member->is_array_ - // << " member member->array_size_:" << member->array_size_ - // << " member member->is_upper_bound_:" << member->is_upper_bound_ - // ); uint64_t addr = reinterpret_cast(data); if (member->is_array_) { @@ -96,11 +86,6 @@ bool DDSFilterField::set_value( bool ret = false; bool is_c_type_support; - // logDebug( - // DDSSQLFILTER, - // "DDSFilterField::set_value " << "access_path size:" << access_path_.size() - // ); - const rosidl_message_type_support_t * type_support_introspection = access_path_[n].type_support_introspection; if (type_support_introspection->typesupport_identifier == @@ -140,10 +125,6 @@ bool DDSFilterField::set_member( bool is_c_type_support) { bool ret = true; - // logDebug( - // DDSSQLFILTER, - // "DDSFilterField::set_member " << "type_id_:" << (uint32_t)type_id_; - // ); switch (type_id_) { case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: diff --git a/common_content_filter/src/IContentFilterFactory.hpp b/common_content_filter/src/IContentFilterFactory.hpp index 441bada..cece093 100644 --- a/common_content_filter/src/IContentFilterFactory.hpp +++ b/common_content_filter/src/IContentFilterFactory.hpp @@ -51,9 +51,6 @@ struct IContentFilterFactory /** * Create or update an IContentFilter instance. * - * @param [in] filter_class_name Filter class name for which the factory is being called. - * Allows using the same factory for different filter classes. - * @param [in] type_name Type name of the topic being filtered. * @param [in] type_support Type support of the topic data being filtered. * @param [in] filter_expression Content filter expression. * May be nullptr when updating the parameters of a filter instance. @@ -73,8 +70,6 @@ struct IContentFilterFactory * @return A return code indicating the result of the operation. */ virtual ReturnCode_t create_content_filter( - const char * filter_class_name, - const char * type_name, const rosidl_message_type_support_t * type_support, const char * filter_expression, const ParameterSeq & filter_parameters, @@ -83,8 +78,6 @@ struct IContentFilterFactory /** * Delete an IContentFilter instance. * - * @param [in] filter_class_name Filter class name for which the factory is being called. - * Allows using the same factory for different filter classes. * @param [in] filter_instance A pointer to a filter instance previously returned by create_content_filter. * The factory takes ownership of the filter instance, and can decide to destroy * it or keep it for future use. @@ -93,7 +86,6 @@ struct IContentFilterFactory * @return A return code indicating the result of the operation. */ virtual ReturnCode_t delete_content_filter( - const char * filter_class_name, IContentFilter * filter_instance) = 0; }; diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index a06718a..d52d127 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -38,7 +38,6 @@ namespace common_content_filter { const int MAGIC = 0x434654; // 'C','F','T' -const char * FILTER_CLASS_NAME = "DDSSQL"; using DDSFilterFactory = eprosima_common::fastdds::dds::DDSSQLFilter::DDSFilterFactory; using IContentFilter = eprosima_common::fastdds::dds::IContentFilter; @@ -99,31 +98,29 @@ class ContentFilterWrapper public: ContentFilterWrapper(const rosidl_message_type_support_t * type_support) : type_support_(type_support) - { - // logDebug(DDSSQLFILTER, "ContentFilterWrapper ctor : " << this); - } + { } ~ContentFilterWrapper() { std::lock_guard lock(mutex_); if (filter_instance_) { DDSFilterFactory::ReturnCode_t ret = - get_common_content_filter_factory()->delete_content_filter( - FILTER_CLASS_NAME, - filter_instance_); + get_common_content_filter_factory()->delete_content_filter(filter_instance_); if (ret != DDSFilterFactory::RETCODE_OK) { logError(DDSSQLFILTER, "Failed to delete content filter: " << ret); } filter_instance_ = nullptr; } - - // logDebug(DDSSQLFILTER, "ContentFilterWrapper dtor : " << this); } bool evaluate(void * ros_data, bool serialized) { std::lock_guard lock(mutex_); + if (!filter_instance_) { + logWarning(DDSSQLFILTER, "Common content filter is not set"); + return true; + } if (serialized) { const rmw_serialized_message_t * serialized_message = @@ -140,13 +137,7 @@ class ContentFilterWrapper } } - bool ret = true; - if (filter_instance_) { - ret = filter_instance_->evaluate(ros_data); - } - - // logDebug(DDSSQLFILTER, "evaluate ret: " << ret); - return ret; + return filter_instance_->evaluate(ros_data); } bool set_filter_expression( @@ -156,8 +147,6 @@ class ContentFilterWrapper std::lock_guard lock(mutex_); const char * tip = filter_instance_ ? "create" : "set"; DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->create_content_filter( - FILTER_CLASS_NAME, // deprecated - "", // deprecated type_support_, filter_expression.c_str(), expression_parameters, From 7aa2b9c2d88fb51749234969190f269dc0b35496 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Fri, 8 Jul 2022 23:47:09 +0800 Subject: [PATCH 30/51] add complex message and test Signed-off-by: Chen Lihui --- common_content_filter/CMakeLists.txt | 4 +- common_content_filter/package.xml | 1 + common_content_filter/src/api.cpp | 2 +- common_content_filter/test/test_api.cpp | 286 +++++++++++++++++- test_content_filter_msgs/CMakeLists.txt | 25 ++ test_content_filter_msgs/msg/Basic.msg | 2 + test_content_filter_msgs/msg/Complex.msg | 2 + test_content_filter_msgs/msg/Intermediate.msg | 2 + test_content_filter_msgs/package.xml | 22 ++ 9 files changed, 342 insertions(+), 4 deletions(-) create mode 100644 test_content_filter_msgs/CMakeLists.txt create mode 100644 test_content_filter_msgs/msg/Basic.msg create mode 100644 test_content_filter_msgs/msg/Complex.msg create mode 100644 test_content_filter_msgs/msg/Intermediate.msg create mode 100644 test_content_filter_msgs/package.xml diff --git a/common_content_filter/CMakeLists.txt b/common_content_filter/CMakeLists.txt index 0764711..fbe74e7 100644 --- a/common_content_filter/CMakeLists.txt +++ b/common_content_filter/CMakeLists.txt @@ -84,6 +84,7 @@ install( if(BUILD_TESTING) find_package(ament_cmake_gtest REQUIRED) find_package(ament_lint_auto REQUIRED) + find_package(test_content_filter_msgs REQUIRED) find_package(test_msgs REQUIRED) find_package(osrf_testing_tools_cpp REQUIRED) @@ -100,7 +101,8 @@ if(BUILD_TESTING) ament_add_gtest(test_api test/test_api.cpp) target_link_libraries(test_api ${PROJECT_NAME}_library) - ament_target_dependencies(test_api test_msgs osrf_testing_tools_cpp rmw) + ament_target_dependencies( + test_api test_content_filter_msgs test_msgs osrf_testing_tools_cpp) endif() ament_package() diff --git a/common_content_filter/package.xml b/common_content_filter/package.xml index a3a405e..a7e23ad 100644 --- a/common_content_filter/package.xml +++ b/common_content_filter/package.xml @@ -19,6 +19,7 @@ ament_cmake_gtest ament_lint_auto ament_lint_common + test_content_filter_msgs test_msgs osrf_testing_tools_cpp diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index d52d127..27bb3f8 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -98,7 +98,7 @@ class ContentFilterWrapper public: ContentFilterWrapper(const rosidl_message_type_support_t * type_support) : type_support_(type_support) - { } + {} ~ContentFilterWrapper() { diff --git a/common_content_filter/test/test_api.cpp b/common_content_filter/test/test_api.cpp index c49a63e..e56ba09 100644 --- a/common_content_filter/test/test_api.cpp +++ b/common_content_filter/test/test_api.cpp @@ -13,11 +13,16 @@ // limitations under the License. #include +#include +#include -#include -#include #include #include +#include + +#include +#include +#include #include "common_content_filter/api.h" @@ -151,3 +156,280 @@ TEST_F(TestCommonContentFilterAPI, get) { EXPECT_STREQ(options.expression_parameters.data[i], expression_parameter_argv[i]); } } + +class TestComplexMsgCommonContentFilterAPI : public ::testing::Test +{ +protected: + void SetUp() + { + type_support = + rosidl_typesupport_cpp::get_message_type_support_handle< + test_content_filter_msgs::msg::Complex>(); + + instance = common_content_filter_create(type_support); + EXPECT_NE(instance, nullptr); + } + + void TearDown() + { + common_content_filter_destroy(instance); + } + +protected: + void set_options( + const char * filter_expression, + size_t expression_parameter_argc, + const char * expression_parameter_argv[]) + { + rcutils_allocator_t allocator = rcutils_get_default_allocator(); + rmw_subscription_content_filter_options_t options = + rmw_get_zero_initialized_content_filter_options(); + EXPECT_EQ( + RMW_RET_OK, + rmw_subscription_content_filter_options_init( + filter_expression, + expression_parameter_argc, + expression_parameter_argv, + &allocator, + &options) + ); + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { + rmw_subscription_content_filter_options_fini(&options, &allocator); + }); + + EXPECT_TRUE(common_content_filter_set(instance, &options)); + } + + void * instance; + const rosidl_message_type_support_t * type_support; +}; + +TEST_F(TestComplexMsgCommonContentFilterAPI, get) { + // default is zero + test_msgs::msg::BasicTypes basic_types_data_zero; + + // set member data with one + test_msgs::msg::BasicTypes basic_types_data_one; + basic_types_data_one.bool_value = true; + basic_types_data_one.byte_value = 1; + basic_types_data_one.char_value = 1; + basic_types_data_one.float32_value = 1.0f; + basic_types_data_one.float64_value = 1.0; + basic_types_data_one.int8_value = 1; + basic_types_data_one.uint8_value = 1; + basic_types_data_one.int16_value = 1; + basic_types_data_one.uint16_value = 1; + basic_types_data_one.int32_value = 1l; + basic_types_data_one.uint32_value = 1ul; + basic_types_data_one.int64_value = 1ll; + basic_types_data_one.uint64_value = 1ull; + + test_content_filter_msgs::msg::Basic basic_zero_one; + basic_zero_one.names = { + "basic_zero_one_first_name", // data.basic_array[0].names[0] + "basic_zero_one_second_name" // data.basic_array[0].names[1] + }; + basic_zero_one.basic_types = { + basic_types_data_zero, // data.basic_array[0].basic_types[0] is 0 + basic_types_data_one // data.basic_array[0].basic_types[1] is 1 + }; + + test_content_filter_msgs::msg::Basic basic_one_zero; + basic_one_zero.names = { + "basic_one_zero_first_name", // data.basic_array[1].names[0] + "basic_one_zero_second_name" // data.basic_array[1].names[1] + }; + basic_one_zero.basic_types = { + basic_types_data_one, // data.basic_array[1].basic_types[0] is 1 + basic_types_data_zero // data.basic_array[1].basic_types[1] is 0 + }; + + test_content_filter_msgs::msg::Complex msg; + msg.data.basic_array = { + basic_zero_one, + basic_one_zero + }; + msg.data.names = { + "intermedia_first_name", // data.names[0] + "intermedia_second_name" // data.names[1] + }; + + msg.name = "complex_name"; // name + + EXPECT_TRUE(common_content_filter_evaluate(instance, &msg, false)); + + struct Info + { + const char * filter_expression; + std::vector expression_parameter; + bool expectation; + }; + + basic_types_data_one.bool_value = true; + basic_types_data_one.byte_value = 1; + basic_types_data_one.char_value = 1; + basic_types_data_one.float32_value = 1.0f; + basic_types_data_one.float64_value = 1.0; + basic_types_data_one.int8_value = 1; + basic_types_data_one.uint8_value = 1; + basic_types_data_one.int16_value = 1; + basic_types_data_one.uint16_value = 1; + basic_types_data_one.int32_value = 1l; + basic_types_data_one.uint32_value = 1ul; + basic_types_data_one.int64_value = 1ll; + basic_types_data_one.uint64_value = 1ull; + + + std::vector expectation = { + // name with string or string array + {"name=%0", {"'complex_name'"}, true}, + {"name=%0", {"'not_complex_name'"}, false}, + + {"data.names[0]=%0", {"'intermedia_first_name'"}, true}, + {"data.names[0]=%0", {"'intermedia_second_name'"}, false}, + {"data.names[1]=%0", {"'intermedia_first_name'"}, false}, + {"data.names[1]=%0", {"'intermedia_second_name'"}, true}, + + {"data.basic_array[0].names[0]=%0", {"'basic_zero_one_first_name'"}, true}, + {"data.basic_array[0].names[0]=%0", {"'basic_zero_one_second_name'"}, false}, + {"data.basic_array[0].names[1]=%0", {"'basic_zero_one_first_name'"}, false}, + {"data.basic_array[0].names[1]=%0", {"'basic_zero_one_second_name'"}, true}, + + {"data.basic_array[1].names[0]=%0", {"'basic_one_zero_first_name'"}, true}, + {"data.basic_array[1].names[0]=%0", {"'basic_one_zero_second_name'"}, false}, + {"data.basic_array[1].names[1]=%0", {"'basic_one_zero_first_name'"}, false}, + {"data.basic_array[1].names[1]=%0", {"'basic_one_zero_second_name'"}, true}, + + {"name=%0 and data.names[0]=%1", {"'complex_name'", "'intermedia_first_name'"}, true}, + {"name=%0 and data.names[0]=%1", {"'not_complex_name'", "'intermedia_first_name'"}, false}, + {"name=%0 or data.names[0]=%1", {"'complex_name'", "'intermedia_first_name'"}, true}, + {"name=%0 or data.names[0]=%1", {"'not_complex_name'", "'intermedia_first_name'"}, true}, + {"name=%0 or data.names[0]=%1", {"'complex_name'", "'intermedia_second_name'"}, true}, + + // basic types array + // 0 0 + {"data.basic_array[0].basic_types[0].bool_value=%0", {"false"}, true}, + {"data.basic_array[0].basic_types[0].byte_value=%0", {"0"}, true}, + {"data.basic_array[0].basic_types[0].char_value=%0", {"0"}, true}, + {"data.basic_array[0].basic_types[0].float32_value=%0", {"0"}, true}, + {"data.basic_array[0].basic_types[0].float64_value=%0", {"0"}, true}, + {"data.basic_array[0].basic_types[0].int8_value=%0", {"0"}, true}, + {"data.basic_array[0].basic_types[0].uint8_value=%0", {"0"}, true}, + {"data.basic_array[0].basic_types[0].int16_value=%0", {"0"}, true}, + {"data.basic_array[0].basic_types[0].uint16_value=%0", {"0"}, true}, + {"data.basic_array[0].basic_types[0].int32_value=%0", {"0"}, true}, + {"data.basic_array[0].basic_types[0].uint32_value=%0", {"0"}, true}, + {"data.basic_array[0].basic_types[0].int64_value=%0", {"0"}, true}, + {"data.basic_array[0].basic_types[0].uint64_value=%0", {"0"}, true}, + + {"data.basic_array[0].basic_types[0].bool_value=%0", {"true"}, false}, + {"data.basic_array[0].basic_types[0].byte_value=%0", {"1"}, false}, + {"data.basic_array[0].basic_types[0].char_value=%0", {"1"}, false}, + {"data.basic_array[0].basic_types[0].float32_value=%0", {"1"}, false}, + {"data.basic_array[0].basic_types[0].float64_value=%0", {"1"}, false}, + {"data.basic_array[0].basic_types[0].int8_value=%0", {"1"}, false}, + {"data.basic_array[0].basic_types[0].uint8_value=%0", {"1"}, false}, + {"data.basic_array[0].basic_types[0].int16_value=%0", {"1"}, false}, + {"data.basic_array[0].basic_types[0].uint16_value=%0", {"1"}, false}, + {"data.basic_array[0].basic_types[0].int32_value=%0", {"1"}, false}, + {"data.basic_array[0].basic_types[0].uint32_value=%0", {"1"}, false}, + {"data.basic_array[0].basic_types[0].int64_value=%0", {"1"}, false}, + {"data.basic_array[0].basic_types[0].uint64_value=%0", {"1"}, false}, + + // 0 1 + {"data.basic_array[0].basic_types[1].bool_value=%0", {"false"}, false}, + {"data.basic_array[0].basic_types[1].byte_value=%0", {"0"}, false}, + {"data.basic_array[0].basic_types[1].char_value=%0", {"0"}, false}, + {"data.basic_array[0].basic_types[1].float32_value=%0", {"0"}, false}, + {"data.basic_array[0].basic_types[1].float64_value=%0", {"0"}, false}, + {"data.basic_array[0].basic_types[1].int8_value=%0", {"0"}, false}, + {"data.basic_array[0].basic_types[1].uint8_value=%0", {"0"}, false}, + {"data.basic_array[0].basic_types[1].int16_value=%0", {"0"}, false}, + {"data.basic_array[0].basic_types[1].uint16_value=%0", {"0"}, false}, + {"data.basic_array[0].basic_types[1].int32_value=%0", {"0"}, false}, + {"data.basic_array[0].basic_types[1].uint32_value=%0", {"0"}, false}, + {"data.basic_array[0].basic_types[1].int64_value=%0", {"0"}, false}, + {"data.basic_array[0].basic_types[1].uint64_value=%0", {"0"}, false}, + + {"data.basic_array[0].basic_types[1].bool_value=%0", {"true"}, true}, + {"data.basic_array[0].basic_types[1].byte_value=%0", {"1"}, true}, + {"data.basic_array[0].basic_types[1].char_value=%0", {"1"}, true}, + {"data.basic_array[0].basic_types[1].float32_value=%0", {"1"}, true}, + {"data.basic_array[0].basic_types[1].float64_value=%0", {"1"}, true}, + {"data.basic_array[0].basic_types[1].int8_value=%0", {"1"}, true}, + {"data.basic_array[0].basic_types[1].uint8_value=%0", {"1"}, true}, + {"data.basic_array[0].basic_types[1].int16_value=%0", {"1"}, true}, + {"data.basic_array[0].basic_types[1].uint16_value=%0", {"1"}, true}, + {"data.basic_array[0].basic_types[1].int32_value=%0", {"1"}, true}, + {"data.basic_array[0].basic_types[1].uint32_value=%0", {"1"}, true}, + {"data.basic_array[0].basic_types[1].int64_value=%0", {"1"}, true}, + {"data.basic_array[0].basic_types[1].uint64_value=%0", {"1"}, true}, + + // [1][0] + {"data.basic_array[1].basic_types[0].bool_value=%0", {"false"}, false}, + {"data.basic_array[1].basic_types[0].byte_value=%0", {"0"}, false}, + {"data.basic_array[1].basic_types[0].char_value=%0", {"0"}, false}, + {"data.basic_array[1].basic_types[0].float32_value=%0", {"0"}, false}, + {"data.basic_array[1].basic_types[0].float64_value=%0", {"0"}, false}, + {"data.basic_array[1].basic_types[0].int8_value=%0", {"0"}, false}, + {"data.basic_array[1].basic_types[0].uint8_value=%0", {"0"}, false}, + {"data.basic_array[1].basic_types[0].int16_value=%0", {"0"}, false}, + {"data.basic_array[1].basic_types[0].uint16_value=%0", {"0"}, false}, + {"data.basic_array[1].basic_types[0].int32_value=%0", {"0"}, false}, + {"data.basic_array[1].basic_types[0].uint32_value=%0", {"0"}, false}, + {"data.basic_array[1].basic_types[0].int64_value=%0", {"0"}, false}, + {"data.basic_array[1].basic_types[0].uint64_value=%0", {"0"}, false}, + + {"data.basic_array[1].basic_types[0].bool_value=%0", {"true"}, true}, + {"data.basic_array[1].basic_types[0].byte_value=%0", {"1"}, true}, + {"data.basic_array[1].basic_types[0].char_value=%0", {"1"}, true}, + {"data.basic_array[1].basic_types[0].float32_value=%0", {"1"}, true}, + {"data.basic_array[1].basic_types[0].float64_value=%0", {"1"}, true}, + {"data.basic_array[1].basic_types[0].int8_value=%0", {"1"}, true}, + {"data.basic_array[1].basic_types[0].uint8_value=%0", {"1"}, true}, + {"data.basic_array[1].basic_types[0].int16_value=%0", {"1"}, true}, + {"data.basic_array[1].basic_types[0].uint16_value=%0", {"1"}, true}, + {"data.basic_array[1].basic_types[0].int32_value=%0", {"1"}, true}, + {"data.basic_array[1].basic_types[0].uint32_value=%0", {"1"}, true}, + {"data.basic_array[1].basic_types[0].int64_value=%0", {"1"}, true}, + {"data.basic_array[1].basic_types[0].uint64_value=%0", {"1"}, true}, + + // [1][1] + {"data.basic_array[1].basic_types[1].bool_value=%0", {"false"}, true}, + {"data.basic_array[1].basic_types[1].byte_value=%0", {"0"}, true}, + {"data.basic_array[1].basic_types[1].char_value=%0", {"0"}, true}, + {"data.basic_array[1].basic_types[1].float32_value=%0", {"0"}, true}, + {"data.basic_array[1].basic_types[1].float64_value=%0", {"0"}, true}, + {"data.basic_array[1].basic_types[1].int8_value=%0", {"0"}, true}, + {"data.basic_array[1].basic_types[1].uint8_value=%0", {"0"}, true}, + {"data.basic_array[1].basic_types[1].int16_value=%0", {"0"}, true}, + {"data.basic_array[1].basic_types[1].uint16_value=%0", {"0"}, true}, + {"data.basic_array[1].basic_types[1].int32_value=%0", {"0"}, true}, + {"data.basic_array[1].basic_types[1].uint32_value=%0", {"0"}, true}, + {"data.basic_array[1].basic_types[1].int64_value=%0", {"0"}, true}, + {"data.basic_array[1].basic_types[1].uint64_value=%0", {"0"}, true}, + + {"data.basic_array[1].basic_types[1].bool_value=%0", {"true"}, false}, + {"data.basic_array[1].basic_types[1].byte_value=%0", {"1"}, false}, + {"data.basic_array[1].basic_types[1].char_value=%0", {"1"}, false}, + {"data.basic_array[1].basic_types[1].float32_value=%0", {"1"}, false}, + {"data.basic_array[1].basic_types[1].float64_value=%0", {"1"}, false}, + {"data.basic_array[1].basic_types[1].int8_value=%0", {"1"}, false}, + {"data.basic_array[1].basic_types[1].uint8_value=%0", {"1"}, false}, + {"data.basic_array[1].basic_types[1].int16_value=%0", {"1"}, false}, + {"data.basic_array[1].basic_types[1].uint16_value=%0", {"1"}, false}, + {"data.basic_array[1].basic_types[1].int32_value=%0", {"1"}, false}, + {"data.basic_array[1].basic_types[1].uint32_value=%0", {"1"}, false}, + {"data.basic_array[1].basic_types[1].int64_value=%0", {"1"}, false}, + {"data.basic_array[1].basic_types[1].uint64_value=%0", {"1"}, false}, + }; + + for (auto & item : expectation) { + set_options( + item.filter_expression, + item.expression_parameter.size(), + item.expression_parameter.data()); + EXPECT_EQ(common_content_filter_evaluate(instance, &msg, false), item.expectation); + } +} diff --git a/test_content_filter_msgs/CMakeLists.txt b/test_content_filter_msgs/CMakeLists.txt new file mode 100644 index 0000000..4bbe6fc --- /dev/null +++ b/test_content_filter_msgs/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.5) + +project(test_content_filter_msgs) + +# Default to C++17 +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) +endif() + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +find_package(ament_cmake REQUIRED) +find_package(rosidl_default_generators REQUIRED) +find_package(test_msgs REQUIRED) + +rosidl_generate_interfaces(test_content_filter_msgs + "msg/Basic.msg" + "msg/Complex.msg" + "msg/Intermediate.msg" + DEPENDENCIES test_msgs +) + +ament_package() diff --git a/test_content_filter_msgs/msg/Basic.msg b/test_content_filter_msgs/msg/Basic.msg new file mode 100644 index 0000000..0722ae4 --- /dev/null +++ b/test_content_filter_msgs/msg/Basic.msg @@ -0,0 +1,2 @@ +string[] names +test_msgs/BasicTypes[] basic_types diff --git a/test_content_filter_msgs/msg/Complex.msg b/test_content_filter_msgs/msg/Complex.msg new file mode 100644 index 0000000..a07a86c --- /dev/null +++ b/test_content_filter_msgs/msg/Complex.msg @@ -0,0 +1,2 @@ +string name +Intermediate data diff --git a/test_content_filter_msgs/msg/Intermediate.msg b/test_content_filter_msgs/msg/Intermediate.msg new file mode 100644 index 0000000..2de8302 --- /dev/null +++ b/test_content_filter_msgs/msg/Intermediate.msg @@ -0,0 +1,2 @@ +Basic[] basic_array +string[] names \ No newline at end of file diff --git a/test_content_filter_msgs/package.xml b/test_content_filter_msgs/package.xml new file mode 100644 index 0000000..351d049 --- /dev/null +++ b/test_content_filter_msgs/package.xml @@ -0,0 +1,22 @@ + + + + test_content_filter_msgs + 0.0.1 + Complex messages for test common content filter api. + chenlh + Apache License 2.0 + + ament_cmake + + rosidl_default_generators + test_msgs + rosidl_default_runtime + test_msgs + + rosidl_interface_packages + + + ament_cmake + + From 547265d3be420c0b7924c499610e14669cfbc167 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Fri, 8 Jul 2022 23:55:33 +0800 Subject: [PATCH 31/51] remove unuseful code Signed-off-by: Chen Lihui --- common_content_filter/test/test_api.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/common_content_filter/test/test_api.cpp b/common_content_filter/test/test_api.cpp index e56ba09..09adf85 100644 --- a/common_content_filter/test/test_api.cpp +++ b/common_content_filter/test/test_api.cpp @@ -266,21 +266,6 @@ TEST_F(TestComplexMsgCommonContentFilterAPI, get) { bool expectation; }; - basic_types_data_one.bool_value = true; - basic_types_data_one.byte_value = 1; - basic_types_data_one.char_value = 1; - basic_types_data_one.float32_value = 1.0f; - basic_types_data_one.float64_value = 1.0; - basic_types_data_one.int8_value = 1; - basic_types_data_one.uint8_value = 1; - basic_types_data_one.int16_value = 1; - basic_types_data_one.uint16_value = 1; - basic_types_data_one.int32_value = 1l; - basic_types_data_one.uint32_value = 1ul; - basic_types_data_one.int64_value = 1ll; - basic_types_data_one.uint64_value = 1ull; - - std::vector expectation = { // name with string or string array {"name=%0", {"'complex_name'"}, true}, From 42a28a363c1f659a0483229c54bd56ff3a005b85 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Fri, 8 Jul 2022 23:58:52 +0800 Subject: [PATCH 32/51] add error message for test case Signed-off-by: Chen Lihui --- common_content_filter/test/test_api.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common_content_filter/test/test_api.cpp b/common_content_filter/test/test_api.cpp index 09adf85..5c5db5b 100644 --- a/common_content_filter/test/test_api.cpp +++ b/common_content_filter/test/test_api.cpp @@ -415,6 +415,7 @@ TEST_F(TestComplexMsgCommonContentFilterAPI, get) { item.filter_expression, item.expression_parameter.size(), item.expression_parameter.data()); - EXPECT_EQ(common_content_filter_evaluate(instance, &msg, false), item.expectation); + EXPECT_EQ(common_content_filter_evaluate(instance, &msg, false), item.expectation) + << "Error happened by the filter expression:" << item.filter_expression; } } From 345e88ee9ef03590f1efdcdf5d05d1160dcb87df Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Sat, 9 Jul 2022 00:46:52 +0800 Subject: [PATCH 33/51] add unbounded and bounded array type Signed-off-by: Chen Lihui --- common_content_filter/test/test_api.cpp | 20 ++++++++++++++++++++ test_content_filter_msgs/msg/Basic.msg | 2 ++ 2 files changed, 22 insertions(+) diff --git a/common_content_filter/test/test_api.cpp b/common_content_filter/test/test_api.cpp index 5c5db5b..3f0f757 100644 --- a/common_content_filter/test/test_api.cpp +++ b/common_content_filter/test/test_api.cpp @@ -234,6 +234,8 @@ TEST_F(TestComplexMsgCommonContentFilterAPI, get) { basic_types_data_zero, // data.basic_array[0].basic_types[0] is 0 basic_types_data_one // data.basic_array[0].basic_types[1] is 1 }; + basic_zero_one.unbounded_int32_data = {0, 1}; + basic_zero_one.bounded_float64_data = {0, 1}; test_content_filter_msgs::msg::Basic basic_one_zero; basic_one_zero.names = { @@ -244,6 +246,8 @@ TEST_F(TestComplexMsgCommonContentFilterAPI, get) { basic_types_data_one, // data.basic_array[1].basic_types[0] is 1 basic_types_data_zero // data.basic_array[1].basic_types[1] is 0 }; + basic_one_zero.unbounded_int32_data = {1, 0}; + basic_one_zero.bounded_float64_data = {1, 0}; test_content_filter_msgs::msg::Complex msg; msg.data.basic_array = { @@ -307,6 +311,8 @@ TEST_F(TestComplexMsgCommonContentFilterAPI, get) { {"data.basic_array[0].basic_types[0].uint32_value=%0", {"0"}, true}, {"data.basic_array[0].basic_types[0].int64_value=%0", {"0"}, true}, {"data.basic_array[0].basic_types[0].uint64_value=%0", {"0"}, true}, + {"data.basic_array[0].unbounded_int32_data[0]=%0", {"0"}, true}, + {"data.basic_array[0].bounded_float64_data[0]=%0", {"0"}, true}, {"data.basic_array[0].basic_types[0].bool_value=%0", {"true"}, false}, {"data.basic_array[0].basic_types[0].byte_value=%0", {"1"}, false}, @@ -321,6 +327,8 @@ TEST_F(TestComplexMsgCommonContentFilterAPI, get) { {"data.basic_array[0].basic_types[0].uint32_value=%0", {"1"}, false}, {"data.basic_array[0].basic_types[0].int64_value=%0", {"1"}, false}, {"data.basic_array[0].basic_types[0].uint64_value=%0", {"1"}, false}, + {"data.basic_array[0].unbounded_int32_data[0]=%0", {"1"}, false}, + {"data.basic_array[0].bounded_float64_data[0]=%0", {"1"}, false}, // 0 1 {"data.basic_array[0].basic_types[1].bool_value=%0", {"false"}, false}, @@ -336,6 +344,8 @@ TEST_F(TestComplexMsgCommonContentFilterAPI, get) { {"data.basic_array[0].basic_types[1].uint32_value=%0", {"0"}, false}, {"data.basic_array[0].basic_types[1].int64_value=%0", {"0"}, false}, {"data.basic_array[0].basic_types[1].uint64_value=%0", {"0"}, false}, + {"data.basic_array[0].unbounded_int32_data[1]=%0", {"0"}, false}, + {"data.basic_array[0].bounded_float64_data[1]=%0", {"0"}, false}, {"data.basic_array[0].basic_types[1].bool_value=%0", {"true"}, true}, {"data.basic_array[0].basic_types[1].byte_value=%0", {"1"}, true}, @@ -350,6 +360,8 @@ TEST_F(TestComplexMsgCommonContentFilterAPI, get) { {"data.basic_array[0].basic_types[1].uint32_value=%0", {"1"}, true}, {"data.basic_array[0].basic_types[1].int64_value=%0", {"1"}, true}, {"data.basic_array[0].basic_types[1].uint64_value=%0", {"1"}, true}, + {"data.basic_array[0].unbounded_int32_data[1]=%0", {"1"}, true}, + {"data.basic_array[0].bounded_float64_data[1]=%0", {"1"}, true}, // [1][0] {"data.basic_array[1].basic_types[0].bool_value=%0", {"false"}, false}, @@ -365,6 +377,8 @@ TEST_F(TestComplexMsgCommonContentFilterAPI, get) { {"data.basic_array[1].basic_types[0].uint32_value=%0", {"0"}, false}, {"data.basic_array[1].basic_types[0].int64_value=%0", {"0"}, false}, {"data.basic_array[1].basic_types[0].uint64_value=%0", {"0"}, false}, + {"data.basic_array[1].unbounded_int32_data[0]=%0", {"0"}, false}, + {"data.basic_array[1].bounded_float64_data[0]=%0", {"0"}, false}, {"data.basic_array[1].basic_types[0].bool_value=%0", {"true"}, true}, {"data.basic_array[1].basic_types[0].byte_value=%0", {"1"}, true}, @@ -379,6 +393,10 @@ TEST_F(TestComplexMsgCommonContentFilterAPI, get) { {"data.basic_array[1].basic_types[0].uint32_value=%0", {"1"}, true}, {"data.basic_array[1].basic_types[0].int64_value=%0", {"1"}, true}, {"data.basic_array[1].basic_types[0].uint64_value=%0", {"1"}, true}, + {"data.basic_array[1].unbounded_int32_data[0]=%0", {"1"}, true}, + {"data.basic_array[1].bounded_float64_data[0]=%0", {"1"}, true}, + {"data.basic_array[1].unbounded_int32_data[0]=%0", {"1"}, true}, + {"data.basic_array[1].bounded_float64_data[0]=%0", {"1"}, true}, // [1][1] {"data.basic_array[1].basic_types[1].bool_value=%0", {"false"}, true}, @@ -408,6 +426,8 @@ TEST_F(TestComplexMsgCommonContentFilterAPI, get) { {"data.basic_array[1].basic_types[1].uint32_value=%0", {"1"}, false}, {"data.basic_array[1].basic_types[1].int64_value=%0", {"1"}, false}, {"data.basic_array[1].basic_types[1].uint64_value=%0", {"1"}, false}, + {"data.basic_array[1].unbounded_int32_data[1]=%0", {"1"}, false}, + {"data.basic_array[1].bounded_float64_data[1]=%0", {"1"}, false}, }; for (auto & item : expectation) { diff --git a/test_content_filter_msgs/msg/Basic.msg b/test_content_filter_msgs/msg/Basic.msg index 0722ae4..523d0df 100644 --- a/test_content_filter_msgs/msg/Basic.msg +++ b/test_content_filter_msgs/msg/Basic.msg @@ -1,2 +1,4 @@ string[] names test_msgs/BasicTypes[] basic_types +int32[] unbounded_int32_data +float64[2] bounded_float64_data From 870d20731e81803b0dc3d0cf4be5950db9a03cd3 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Sat, 9 Jul 2022 01:24:01 +0800 Subject: [PATCH 34/51] update test and add the missing header file for windows platform Signed-off-by: Chen Lihui --- common_content_filter/src/api.cpp | 1 + common_content_filter/test/test_api.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index 27bb3f8..1a0e41e 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include diff --git a/common_content_filter/test/test_api.cpp b/common_content_filter/test/test_api.cpp index 3f0f757..19fc35d 100644 --- a/common_content_filter/test/test_api.cpp +++ b/common_content_filter/test/test_api.cpp @@ -395,8 +395,6 @@ TEST_F(TestComplexMsgCommonContentFilterAPI, get) { {"data.basic_array[1].basic_types[0].uint64_value=%0", {"1"}, true}, {"data.basic_array[1].unbounded_int32_data[0]=%0", {"1"}, true}, {"data.basic_array[1].bounded_float64_data[0]=%0", {"1"}, true}, - {"data.basic_array[1].unbounded_int32_data[0]=%0", {"1"}, true}, - {"data.basic_array[1].bounded_float64_data[0]=%0", {"1"}, true}, // [1][1] {"data.basic_array[1].basic_types[1].bool_value=%0", {"false"}, true}, @@ -412,6 +410,8 @@ TEST_F(TestComplexMsgCommonContentFilterAPI, get) { {"data.basic_array[1].basic_types[1].uint32_value=%0", {"0"}, true}, {"data.basic_array[1].basic_types[1].int64_value=%0", {"0"}, true}, {"data.basic_array[1].basic_types[1].uint64_value=%0", {"0"}, true}, + {"data.basic_array[1].unbounded_int32_data[1]=%0", {"0"}, true}, + {"data.basic_array[1].bounded_float64_data[1]=%0", {"0"}, true}, {"data.basic_array[1].basic_types[1].bool_value=%0", {"true"}, false}, {"data.basic_array[1].basic_types[1].byte_value=%0", {"1"}, false}, From 4e7dea63f7d3c0046a7e1345b4dd7123f59ab997 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 11 Jul 2022 11:18:00 +0800 Subject: [PATCH 35/51] use pegtl as a vendor package Signed-off-by: Chen Lihui --- common_content_filter/CMakeLists.txt | 8 +- common_content_filter/package.xml | 1 + .../src/DDSFilterExpressionParser.cpp | 4 +- .../src/DDSFilterGrammar.hpp | 2 +- .../src/DDSFilterParseNode.hpp | 2 +- common_content_filter/src/api.cpp | 2 +- .../thirdparty/taocpp-pegtl/pegtl.hpp | 46 -- .../pegtl/analysis/analyze_cycles.hpp | 135 ----- .../taocpp-pegtl/pegtl/analysis/counted.hpp | 31 -- .../taocpp-pegtl/pegtl/analysis/generic.hpp | 43 -- .../pegtl/analysis/grammar_info.hpp | 40 -- .../pegtl/analysis/insert_guard.hpp | 68 --- .../taocpp-pegtl/pegtl/analysis/rule_info.hpp | 37 -- .../taocpp-pegtl/pegtl/analysis/rule_type.hpp | 35 -- .../thirdparty/taocpp-pegtl/pegtl/analyze.hpp | 25 - .../taocpp-pegtl/pegtl/apply_mode.hpp | 27 - .../taocpp-pegtl/pegtl/argv_input.hpp | 57 -- .../thirdparty/taocpp-pegtl/pegtl/ascii.hpp | 71 --- .../taocpp-pegtl/pegtl/buffer_input.hpp | 222 -------- .../taocpp-pegtl/pegtl/change_action.hpp | 42 -- .../pegtl/change_action_and_state.hpp | 73 --- .../pegtl/change_action_and_states.hpp | 83 --- .../taocpp-pegtl/pegtl/change_control.hpp | 40 -- .../taocpp-pegtl/pegtl/change_state.hpp | 72 --- .../taocpp-pegtl/pegtl/change_states.hpp | 81 --- .../thirdparty/taocpp-pegtl/pegtl/config.hpp | 20 - .../taocpp-pegtl/pegtl/contrib/abnf.hpp | 43 -- .../taocpp-pegtl/pegtl/contrib/alphabet.hpp | 75 --- .../taocpp-pegtl/pegtl/contrib/changes.hpp | 90 --- .../taocpp-pegtl/pegtl/contrib/counter.hpp | 58 -- .../taocpp-pegtl/pegtl/contrib/http.hpp | 282 ---------- .../pegtl/contrib/icu/internal.hpp | 76 --- .../taocpp-pegtl/pegtl/contrib/icu/utf16.hpp | 212 ------- .../taocpp-pegtl/pegtl/contrib/icu/utf32.hpp | 212 ------- .../taocpp-pegtl/pegtl/contrib/icu/utf8.hpp | 117 ---- .../taocpp-pegtl/pegtl/contrib/if_then.hpp | 61 --- .../taocpp-pegtl/pegtl/contrib/integer.hpp | 108 ---- .../taocpp-pegtl/pegtl/contrib/json.hpp | 98 ---- .../pegtl/contrib/json_pointer.hpp | 41 -- .../taocpp-pegtl/pegtl/contrib/parse_tree.hpp | 517 ------------------ .../pegtl/contrib/parse_tree_to_dot.hpp | 116 ---- .../taocpp-pegtl/pegtl/contrib/raw_string.hpp | 234 -------- .../pegtl/contrib/remove_first_state.hpp | 62 --- .../pegtl/contrib/remove_last_states.hpp | 106 ---- .../pegtl/contrib/rep_one_min_max.hpp | 68 --- .../taocpp-pegtl/pegtl/contrib/rep_string.hpp | 47 -- .../pegtl/contrib/shuffle_states.hpp | 174 ------ .../taocpp-pegtl/pegtl/contrib/to_string.hpp | 42 -- .../taocpp-pegtl/pegtl/contrib/tracer.hpp | 253 --------- .../taocpp-pegtl/pegtl/contrib/unescape.hpp | 207 ------- .../taocpp-pegtl/pegtl/contrib/uri.hpp | 115 ---- .../taocpp-pegtl/pegtl/cstream_input.hpp | 39 -- .../taocpp-pegtl/pegtl/disable_action.hpp | 39 -- .../taocpp-pegtl/pegtl/discard_input.hpp | 41 -- .../pegtl/discard_input_on_failure.hpp | 43 -- .../pegtl/discard_input_on_success.hpp | 43 -- .../taocpp-pegtl/pegtl/enable_action.hpp | 39 -- .../thirdparty/taocpp-pegtl/pegtl/eol.hpp | 41 -- .../taocpp-pegtl/pegtl/eol_pair.hpp | 22 - .../taocpp-pegtl/pegtl/file_input.hpp | 50 -- .../taocpp-pegtl/pegtl/input_error.hpp | 51 -- .../taocpp-pegtl/pegtl/internal/action.hpp | 59 -- .../pegtl/internal/action_input.hpp | 120 ---- .../taocpp-pegtl/pegtl/internal/alnum.hpp | 26 - .../taocpp-pegtl/pegtl/internal/alpha.hpp | 26 - .../pegtl/internal/always_false.hpp | 29 - .../taocpp-pegtl/pegtl/internal/any.hpp | 66 --- .../taocpp-pegtl/pegtl/internal/apply.hpp | 94 ---- .../taocpp-pegtl/pegtl/internal/apply0.hpp | 92 ---- .../pegtl/internal/apply0_single.hpp | 42 -- .../pegtl/internal/apply_single.hpp | 42 -- .../taocpp-pegtl/pegtl/internal/at.hpp | 67 --- .../taocpp-pegtl/pegtl/internal/bof.hpp | 41 -- .../taocpp-pegtl/pegtl/internal/bol.hpp | 41 -- .../taocpp-pegtl/pegtl/internal/bump.hpp | 53 -- .../taocpp-pegtl/pegtl/internal/bump_help.hpp | 63 --- .../taocpp-pegtl/pegtl/internal/bytes.hpp | 46 -- .../taocpp-pegtl/pegtl/internal/control.hpp | 59 -- .../pegtl/internal/cr_crlf_eol.hpp | 40 -- .../taocpp-pegtl/pegtl/internal/cr_eol.hpp | 40 -- .../taocpp-pegtl/pegtl/internal/crlf_eol.hpp | 40 -- .../pegtl/internal/cstream_reader.hpp | 50 -- .../pegtl/internal/cstring_reader.hpp | 49 -- .../taocpp-pegtl/pegtl/internal/demangle.hpp | 85 --- .../pegtl/internal/demangle_cxxabi.hpp | 41 -- .../pegtl/internal/demangle_nop.hpp | 28 - .../pegtl/internal/demangle_sanitise.hpp | 48 -- .../taocpp-pegtl/pegtl/internal/disable.hpp | 59 -- .../taocpp-pegtl/pegtl/internal/discard.hpp | 43 -- .../pegtl/internal/dusel_mode.hpp | 31 -- .../pegtl/internal/duseltronik.hpp | 188 ------- .../taocpp-pegtl/pegtl/internal/enable.hpp | 59 -- .../taocpp-pegtl/pegtl/internal/endian.hpp | 70 --- .../pegtl/internal/endian_gcc.hpp | 214 -------- .../pegtl/internal/endian_win.hpp | 115 ---- .../taocpp-pegtl/pegtl/internal/eof.hpp | 41 -- .../taocpp-pegtl/pegtl/internal/eol.hpp | 41 -- .../taocpp-pegtl/pegtl/internal/eolf.hpp | 42 -- .../pegtl/internal/file_mapper_posix.hpp | 95 ---- .../pegtl/internal/file_mapper_win32.hpp | 226 -------- .../pegtl/internal/file_opener.hpp | 78 --- .../pegtl/internal/file_reader.hpp | 109 ---- .../taocpp-pegtl/pegtl/internal/has_apply.hpp | 33 -- .../pegtl/internal/has_apply0.hpp | 33 -- .../taocpp-pegtl/pegtl/internal/has_match.hpp | 53 -- .../pegtl/internal/identifier.hpp | 30 - .../taocpp-pegtl/pegtl/internal/if_apply.hpp | 118 ---- .../pegtl/internal/if_missing.hpp | 72 --- .../taocpp-pegtl/pegtl/internal/if_must.hpp | 58 -- .../pegtl/internal/if_must_else.hpp | 27 - .../pegtl/internal/if_then_else.hpp | 61 --- .../pegtl/internal/input_pair.hpp | 37 -- .../pegtl/internal/integer_sequence.hpp | 86 --- .../pegtl/internal/istream_reader.hpp | 47 -- .../taocpp-pegtl/pegtl/internal/istring.hpp | 107 ---- .../taocpp-pegtl/pegtl/internal/iterator.hpp | 60 -- .../pegtl/internal/lf_crlf_eol.hpp | 45 -- .../taocpp-pegtl/pegtl/internal/lf_eol.hpp | 40 -- .../taocpp-pegtl/pegtl/internal/list.hpp | 27 - .../taocpp-pegtl/pegtl/internal/list_must.hpp | 28 - .../taocpp-pegtl/pegtl/internal/list_tail.hpp | 28 - .../pegtl/internal/list_tail_pad.hpp | 30 - .../taocpp-pegtl/pegtl/internal/marker.hpp | 99 ---- .../taocpp-pegtl/pegtl/internal/mmap_file.hpp | 42 -- .../pegtl/internal/mmap_file_win32.hpp | 244 --------- .../taocpp-pegtl/pegtl/internal/must.hpp | 70 --- .../taocpp-pegtl/pegtl/internal/not_at.hpp | 67 --- .../taocpp-pegtl/pegtl/internal/one.hpp | 77 --- .../taocpp-pegtl/pegtl/internal/opt.hpp | 69 --- .../taocpp-pegtl/pegtl/internal/pad.hpp | 27 - .../taocpp-pegtl/pegtl/internal/pad_opt.hpp | 28 - .../taocpp-pegtl/pegtl/internal/peek_char.hpp | 40 -- .../pegtl/internal/peek_mask_uint.hpp | 62 --- .../pegtl/internal/peek_mask_uint8.hpp | 42 -- .../taocpp-pegtl/pegtl/internal/peek_uint.hpp | 53 -- .../pegtl/internal/peek_uint8.hpp | 41 -- .../pegtl/internal/peek_utf16.hpp | 62 --- .../pegtl/internal/peek_utf32.hpp | 51 -- .../taocpp-pegtl/pegtl/internal/peek_utf8.hpp | 97 ---- .../pegtl/internal/pegtl_string.hpp | 103 ---- .../taocpp-pegtl/pegtl/internal/plus.hpp | 68 --- .../taocpp-pegtl/pegtl/internal/raise.hpp | 63 --- .../taocpp-pegtl/pegtl/internal/range.hpp | 58 -- .../taocpp-pegtl/pegtl/internal/ranges.hpp | 100 ---- .../taocpp-pegtl/pegtl/internal/read_uint.hpp | 85 --- .../taocpp-pegtl/pegtl/internal/rematch.hpp | 86 --- .../taocpp-pegtl/pegtl/internal/rep.hpp | 80 --- .../taocpp-pegtl/pegtl/internal/rep_min.hpp | 28 - .../pegtl/internal/rep_min_max.hpp | 91 --- .../taocpp-pegtl/pegtl/internal/rep_opt.hpp | 61 --- .../taocpp-pegtl/pegtl/internal/require.hpp | 52 -- .../pegtl/internal/result_on_found.hpp | 27 - .../taocpp-pegtl/pegtl/internal/rules.hpp | 61 --- .../taocpp-pegtl/pegtl/internal/seq.hpp | 91 --- .../pegtl/internal/skip_control.hpp | 35 -- .../taocpp-pegtl/pegtl/internal/sor.hpp | 76 --- .../taocpp-pegtl/pegtl/internal/star.hpp | 62 --- .../taocpp-pegtl/pegtl/internal/star_must.hpp | 27 - .../taocpp-pegtl/pegtl/internal/state.hpp | 96 ---- .../taocpp-pegtl/pegtl/internal/string.hpp | 68 --- .../taocpp-pegtl/pegtl/internal/trivial.hpp | 42 -- .../pegtl/internal/try_catch_type.hpp | 76 --- .../taocpp-pegtl/pegtl/internal/until.hpp | 98 ---- .../taocpp-pegtl/pegtl/istream_input.hpp | 39 -- .../thirdparty/taocpp-pegtl/pegtl/match.hpp | 71 --- .../taocpp-pegtl/pegtl/memory_input.hpp | 378 ------------- .../taocpp-pegtl/pegtl/mmap_input.hpp | 85 --- .../thirdparty/taocpp-pegtl/pegtl/normal.hpp | 96 ---- .../thirdparty/taocpp-pegtl/pegtl/nothing.hpp | 24 - .../thirdparty/taocpp-pegtl/pegtl/parse.hpp | 57 -- .../taocpp-pegtl/pegtl/parse_error.hpp | 51 -- .../taocpp-pegtl/pegtl/position.hpp | 54 -- .../taocpp-pegtl/pegtl/read_input.hpp | 80 --- .../taocpp-pegtl/pegtl/require_apply.hpp | 20 - .../taocpp-pegtl/pegtl/require_apply0.hpp | 20 - .../taocpp-pegtl/pegtl/rewind_mode.hpp | 29 - .../thirdparty/taocpp-pegtl/pegtl/rules.hpp | 71 --- .../taocpp-pegtl/pegtl/string_input.hpp | 72 --- .../taocpp-pegtl/pegtl/tracking_mode.hpp | 27 - .../thirdparty/taocpp-pegtl/pegtl/uint16.hpp | 66 --- .../thirdparty/taocpp-pegtl/pegtl/uint32.hpp | 66 --- .../thirdparty/taocpp-pegtl/pegtl/uint64.hpp | 67 --- .../thirdparty/taocpp-pegtl/pegtl/uint8.hpp | 44 -- .../thirdparty/taocpp-pegtl/pegtl/utf16.hpp | 53 -- .../thirdparty/taocpp-pegtl/pegtl/utf32.hpp | 53 -- .../thirdparty/taocpp-pegtl/pegtl/utf8.hpp | 36 -- .../thirdparty/taocpp-pegtl/pegtl/version.hpp | 19 - tao_pegtl_vendor/CMakeLists.txt | 77 +++ tao_pegtl_vendor/CONTRIBUTING.md | 18 + tao_pegtl_vendor/LICENSE | 201 +++++++ tao_pegtl_vendor/README.md | 2 + tao_pegtl_vendor/package.xml | 24 + .../tao_pegtl_vendor-extras.cmake | 16 + 193 files changed, 347 insertions(+), 13281 deletions(-) delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/analyze_cycles.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/counted.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/generic.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/grammar_info.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/insert_guard.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/rule_info.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/rule_type.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/analyze.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/apply_mode.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/argv_input.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/ascii.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/buffer_input.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action_and_state.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action_and_states.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_control.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_state.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_states.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/config.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/abnf.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/alphabet.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/changes.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/counter.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/http.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/internal.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf16.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf32.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf8.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/if_then.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/integer.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/json.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/json_pointer.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/parse_tree.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/parse_tree_to_dot.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/raw_string.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/remove_first_state.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/remove_last_states.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/rep_one_min_max.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/rep_string.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/shuffle_states.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/to_string.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/tracer.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/unescape.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/uri.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/cstream_input.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/disable_action.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input_on_failure.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input_on_success.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/enable_action.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/eol.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/eol_pair.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/file_input.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/input_error.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/action.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/action_input.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/alnum.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/alpha.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/always_false.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/any.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply0.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply0_single.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply_single.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/at.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bof.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bol.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bump.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bump_help.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bytes.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/control.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cr_crlf_eol.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cr_eol.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/crlf_eol.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cstream_reader.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cstring_reader.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_cxxabi.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_nop.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_sanitise.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/disable.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/discard.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/dusel_mode.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/duseltronik.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/enable.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian_gcc.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian_win.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eof.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eol.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eolf.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_mapper_posix.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_mapper_win32.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_opener.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_reader.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_apply.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_apply0.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_match.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/identifier.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_apply.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_missing.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_must.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_must_else.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_then_else.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/input_pair.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/integer_sequence.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/istream_reader.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/istring.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/iterator.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/lf_crlf_eol.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/lf_eol.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_must.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_tail.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_tail_pad.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/marker.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/mmap_file.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/mmap_file_win32.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/must.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/not_at.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/one.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/opt.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pad.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pad_opt.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_char.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_mask_uint.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_mask_uint8.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_uint.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_uint8.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf16.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf32.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf8.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pegtl_string.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/plus.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/raise.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/range.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/ranges.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/read_uint.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rematch.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_min.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_min_max.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_opt.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/require.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/result_on_found.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rules.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/seq.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/skip_control.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/sor.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/star.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/star_must.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/state.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/string.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/trivial.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/try_catch_type.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/until.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/istream_input.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/match.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/memory_input.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/mmap_input.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/normal.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/nothing.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/parse.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/parse_error.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/position.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/read_input.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/require_apply.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/require_apply0.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/rewind_mode.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/rules.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/string_input.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/tracking_mode.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint16.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint32.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint64.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint8.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf16.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf32.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf8.hpp delete mode 100644 common_content_filter/thirdparty/taocpp-pegtl/pegtl/version.hpp create mode 100644 tao_pegtl_vendor/CMakeLists.txt create mode 100644 tao_pegtl_vendor/CONTRIBUTING.md create mode 100644 tao_pegtl_vendor/LICENSE create mode 100644 tao_pegtl_vendor/README.md create mode 100644 tao_pegtl_vendor/package.xml create mode 100644 tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake diff --git a/common_content_filter/CMakeLists.txt b/common_content_filter/CMakeLists.txt index fbe74e7..f2bb6bc 100644 --- a/common_content_filter/CMakeLists.txt +++ b/common_content_filter/CMakeLists.txt @@ -18,6 +18,7 @@ find_package(rmw REQUIRED) find_package(rmw_implementation REQUIRED) find_package(rosidl_typesupport_introspection_c REQUIRED) find_package(rosidl_typesupport_introspection_cpp REQUIRED) +find_package(tao_pegtl_vendor REQUIRED) add_library(${PROJECT_NAME}_library SHARED src/api.cpp @@ -37,9 +38,7 @@ set_target_properties(${PROJECT_NAME}_library target_include_directories(${PROJECT_NAME}_library PUBLIC "$" - "$" - PRIVATE - ${PROJECT_SOURCE_DIR}/thirdparty/taocpp-pegtl) + "$") ament_target_dependencies(${PROJECT_NAME}_library "rcpputils" @@ -48,6 +47,7 @@ ament_target_dependencies(${PROJECT_NAME}_library "rmw_implementation" "rosidl_typesupport_introspection_c" "rosidl_typesupport_introspection_cpp" + "tao_pegtl_vendor" ) # Causes the visibility macros to use dllexport rather than dllimport, @@ -95,8 +95,6 @@ if(BUILD_TESTING) # comment the line when this package is in a git repo and when # a copyright and license is added to all source files set(ament_cmake_cpplint_FOUND TRUE) - # the following line skips uncrustify (TODO. use pegtl as a new package(e.g. pegtl_vendor)) - set(ament_cmake_uncrustify_FOUND TRUE) ament_lint_auto_find_test_dependencies() ament_add_gtest(test_api test/test_api.cpp) diff --git a/common_content_filter/package.xml b/common_content_filter/package.xml index a7e23ad..494b45a 100644 --- a/common_content_filter/package.xml +++ b/common_content_filter/package.xml @@ -15,6 +15,7 @@ rmw_implementation rosidl_typesupport_introspection_c rosidl_typesupport_introspection_cpp + tao_pegtl_vendor ament_cmake_gtest ament_lint_auto diff --git a/common_content_filter/src/DDSFilterExpressionParser.cpp b/common_content_filter/src/DDSFilterExpressionParser.cpp index 3874c04..15a41ed 100644 --- a/common_content_filter/src/DDSFilterExpressionParser.cpp +++ b/common_content_filter/src/DDSFilterExpressionParser.cpp @@ -28,8 +28,8 @@ #include -#include "pegtl.hpp" -#include "pegtl/contrib/parse_tree.hpp" +#include +#include #include "DDSFilterGrammar.hpp" #include "DDSFilterParseNode.hpp" diff --git a/common_content_filter/src/DDSFilterGrammar.hpp b/common_content_filter/src/DDSFilterGrammar.hpp index 633de29..d929043 100644 --- a/common_content_filter/src/DDSFilterGrammar.hpp +++ b/common_content_filter/src/DDSFilterGrammar.hpp @@ -19,7 +19,7 @@ #ifndef COMMON_CONTENT_FILTER__DDSFILTERGRAMMAR_HPP_ #define COMMON_CONTENT_FILTER__DDSFILTERGRAMMAR_HPP_ -#include "pegtl.hpp" +#include namespace eprosima_common { diff --git a/common_content_filter/src/DDSFilterParseNode.hpp b/common_content_filter/src/DDSFilterParseNode.hpp index 4824d88..7f8ee59 100644 --- a/common_content_filter/src/DDSFilterParseNode.hpp +++ b/common_content_filter/src/DDSFilterParseNode.hpp @@ -22,7 +22,7 @@ #include #include -#include "pegtl/contrib/parse_tree.hpp" +#include #include "DDSFilterField.hpp" #include "DDSFilterValue.hpp" diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index 1a0e41e..50bbcce 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include #include "DDSFilterFactory.hpp" #include "Log.hpp" diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl.hpp deleted file mode 100644 index e2e5d9e..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) - -#ifndef TAO_PEGTL_HPP -#define TAO_PEGTL_HPP - -#include "pegtl/internal/demangle.hpp" -#include "pegtl/parse.hpp" -#include "pegtl/version.hpp" - -#include "pegtl/ascii.hpp" -#include "pegtl/rules.hpp" -#include "pegtl/utf8.hpp" - -#include "pegtl/argv_input.hpp" -#include "pegtl/buffer_input.hpp" -#include "pegtl/cstream_input.hpp" -#include "pegtl/istream_input.hpp" -#include "pegtl/memory_input.hpp" -#include "pegtl/read_input.hpp" -#include "pegtl/string_input.hpp" - -// This has to be included *after* the above inputs, -// otherwise the amalgamated header will not work! -#include "pegtl/file_input.hpp" - -#include "pegtl/change_action.hpp" -#include "pegtl/change_action_and_state.hpp" -#include "pegtl/change_action_and_states.hpp" -#include "pegtl/change_control.hpp" -#include "pegtl/change_state.hpp" -#include "pegtl/change_states.hpp" - -#include "pegtl/disable_action.hpp" -#include "pegtl/enable_action.hpp" - -#include "pegtl/discard_input.hpp" -#include "pegtl/discard_input_on_failure.hpp" -#include "pegtl/discard_input_on_success.hpp" - -#if defined( __cpp_exceptions ) -#include "pegtl/internal/if_must.hpp" -#endif - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/analyze_cycles.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/analyze_cycles.hpp deleted file mode 100644 index 6222b04..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/analyze_cycles.hpp +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_ANALYSIS_ANALYZE_CYCLES_HPP -#define TAO_PEGTL_ANALYSIS_ANALYZE_CYCLES_HPP - -#include - -#include -#include -#include - -#include -#include - -#include "../config.hpp" - -#include "grammar_info.hpp" -#include "insert_guard.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace analysis - { - class analyze_cycles_impl - { - protected: - explicit analyze_cycles_impl( const bool verbose ) noexcept - : m_verbose( verbose ), - m_problems( 0 ) - { - } - - const bool m_verbose; - unsigned m_problems; - grammar_info m_info; - std::set< std::string > m_stack; - std::map< std::string, bool > m_cache; - std::map< std::string, bool > m_results; - - std::map< std::string, rule_info >::const_iterator find( const std::string& name ) const noexcept - { - const auto iter = m_info.map.find( name ); - assert( iter != m_info.map.end() ); - return iter; - } - - bool work( const std::map< std::string, rule_info >::const_iterator& start, const bool accum ) - { - const auto j = m_cache.find( start->first ); - - if( j != m_cache.end() ) { - return j->second; - } - if( const auto g = make_insert_guard( m_stack, start->first ) ) { - switch( start->second.type ) { - case rule_type::any: { - bool a = false; - for( const auto& r : start->second.rules ) { - a = a || work( find( r ), accum || a ); - } - return m_cache[ start->first ] = true; - } - case rule_type::opt: { - bool a = false; - for( const auto& r : start->second.rules ) { - a = a || work( find( r ), accum || a ); - } - return m_cache[ start->first ] = false; - } - case rule_type::seq: { - bool a = false; - for( const auto& r : start->second.rules ) { - a = a || work( find( r ), accum || a ); - } - return m_cache[ start->first ] = a; - } - case rule_type::sor: { - bool a = true; - for( const auto& r : start->second.rules ) { - a = a && work( find( r ), accum ); - } - return m_cache[ start->first ] = a; - } - } - throw std::logic_error( "code should be unreachable: invalid rule_type value" ); // NOLINT, LCOV_EXCL_LINE - } - if( !accum ) { - ++m_problems; - if( m_verbose ) { - std::cout << "problem: cycle without progress detected at rule class " << start->first << std::endl; // LCOV_EXCL_LINE - } - } - return m_cache[ start->first ] = accum; - } - }; - - template< typename Grammar > - class analyze_cycles - : private analyze_cycles_impl - { - public: - explicit analyze_cycles( const bool verbose ) - : analyze_cycles_impl( verbose ) - { - Grammar::analyze_t::template insert< Grammar >( m_info ); - } - - std::size_t problems() - { - for( auto i = m_info.map.begin(); i != m_info.map.end(); ++i ) { - m_results[ i->first ] = work( i, false ); - m_cache.clear(); - } - return m_problems; - } - - template< typename Rule > - bool consumes() const noexcept - { - const auto i = m_results.find( internal::demangle< Rule >() ); - assert( i != m_results.end() ); - return i->second; - } - }; - - } // namespace analysis - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/counted.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/counted.hpp deleted file mode 100644 index 6428e18..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/counted.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_ANALYSIS_COUNTED_HPP -#define TAO_PEGTL_ANALYSIS_COUNTED_HPP - -#include "../config.hpp" - -#include - -#include "generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace analysis - { - template< rule_type Type, std::size_t Count, typename... Rules > - struct counted - : generic< ( Count != 0 ) ? Type : rule_type::opt, Rules... > - { - }; - - } // namespace analysis - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/generic.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/generic.hpp deleted file mode 100644 index dc38b9f..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/generic.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_ANALYSIS_GENERIC_HPP -#define TAO_PEGTL_ANALYSIS_GENERIC_HPP - -#include "../config.hpp" - -#include "grammar_info.hpp" -#include "rule_type.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace analysis - { - template< rule_type Type, typename... Rules > - struct generic - { - template< typename Name > - static std::string insert( grammar_info& g ) - { - const auto r = g.insert< Name >( Type ); - if( r.second ) { -#ifdef __cpp_fold_expressions - ( r.first->second.rules.push_back( Rules::analyze_t::template insert< Rules >( g ) ), ... ); -#else - using swallow = bool[]; - (void)swallow{ ( r.first->second.rules.push_back( Rules::analyze_t::template insert< Rules >( g ) ), true )..., true }; -#endif - } - return r.first->first; - } - }; - - } // namespace analysis - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/grammar_info.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/grammar_info.hpp deleted file mode 100644 index 8c183d9..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/grammar_info.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_ANALYSIS_GRAMMAR_INFO_HPP -#define TAO_PEGTL_ANALYSIS_GRAMMAR_INFO_HPP - -#include -#include -#include - -#include "../config.hpp" -#include "../internal/demangle.hpp" - -#include "rule_info.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace analysis - { - struct grammar_info - { - using map_t = std::map< std::string, rule_info >; - map_t map; - - template< typename Name > - std::pair< map_t::iterator, bool > insert( const rule_type type ) - { - return map.insert( map_t::value_type( internal::demangle< Name >(), rule_info( type ) ) ); - } - }; - - } // namespace analysis - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/insert_guard.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/insert_guard.hpp deleted file mode 100644 index b56daff..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/insert_guard.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_ANALYSIS_INSERT_GUARD_HPP -#define TAO_PEGTL_ANALYSIS_INSERT_GUARD_HPP - -#include - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace analysis - { - template< typename C > - class insert_guard - { - public: - insert_guard( C& container, const typename C::value_type& value ) - : m_i( container.insert( value ) ), - m_c( &container ) - { - } - - insert_guard( const insert_guard& ) = delete; - - insert_guard( insert_guard&& other ) noexcept - : m_i( other.m_i ), - m_c( other.m_c ) - { - other.m_c = nullptr; - } - - ~insert_guard() - { - if( m_c && m_i.second ) { - m_c->erase( m_i.first ); - } - } - - void operator=( const insert_guard& ) = delete; - void operator=( insert_guard&& ) = delete; - - explicit operator bool() const noexcept - { - return m_i.second; - } - - private: - const std::pair< typename C::iterator, bool > m_i; - C* m_c; - }; - - template< typename C > - insert_guard< C > make_insert_guard( C& container, const typename C::value_type& value ) - { - return insert_guard< C >( container, value ); - } - - } // namespace analysis - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/rule_info.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/rule_info.hpp deleted file mode 100644 index a222839..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/rule_info.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_ANALYSIS_RULE_INFO_HPP -#define TAO_PEGTL_ANALYSIS_RULE_INFO_HPP - -#include -#include - -#include "../config.hpp" - -#include "rule_type.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace analysis - { - struct rule_info - { - explicit rule_info( const rule_type in_type ) noexcept - : type( in_type ) - { - } - - rule_type type; - std::vector< std::string > rules; - }; - - } // namespace analysis - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/rule_type.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/rule_type.hpp deleted file mode 100644 index a0eff9a..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analysis/rule_type.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_ANALYSIS_RULE_TYPE_HPP -#define TAO_PEGTL_ANALYSIS_RULE_TYPE_HPP - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace analysis - { - enum class rule_type : char - { - any, // Consumption-on-success is always true; assumes bounded repetition of conjunction of sub-rules. - opt, // Consumption-on-success not necessarily true; assumes bounded repetition of conjunction of sub-rules. - seq, // Consumption-on-success depends on consumption of (non-zero bounded repetition of) conjunction of sub-rules. - sor, // Consumption-on-success depends on consumption of (non-zero bounded repetition of) disjunction of sub-rules. - - // Compatibility, remove with 3.0.0 - ANY = any, - OPT = opt, - SEQ = seq, - SOR = sor - }; - - } // namespace analysis - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analyze.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analyze.hpp deleted file mode 100644 index bf50dc5..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/analyze.hpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_ANALYZE_HPP -#define TAO_PEGTL_ANALYZE_HPP - -#include "config.hpp" - -#include "analysis/analyze_cycles.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - template< typename Rule > - std::size_t analyze( const bool verbose = true ) - { - return analysis::analyze_cycles< Rule >( verbose ).problems(); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/apply_mode.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/apply_mode.hpp deleted file mode 100644 index 92c1335..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/apply_mode.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_APPLY_MODE_HPP -#define TAO_PEGTL_APPLY_MODE_HPP - -#include "config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - enum class apply_mode : bool - { - action = true, - nothing = false, - - // Compatibility, remove with 3.0.0 - ACTION = action, - NOTHING = nothing - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/argv_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/argv_input.hpp deleted file mode 100644 index 75744a3..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/argv_input.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_ARGV_INPUT_HPP -#define TAO_PEGTL_ARGV_INPUT_HPP - -#include -#include -#include -#include - -#include "config.hpp" -#include "eol.hpp" -#include "memory_input.hpp" -#include "tracking_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - inline std::string make_argv_source( const std::size_t argn ) - { - std::ostringstream os; - os << "argv[" << argn << ']'; - return os.str(); - } - - } // namespace internal - - template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > - struct argv_input - : public memory_input< P, Eol > - { - template< typename T > - argv_input( char** argv, const std::size_t argn, T&& in_source ) - : memory_input< P, Eol >( static_cast< const char* >( argv[ argn ] ), std::forward< T >( in_source ) ) - { - } - - argv_input( char** argv, const std::size_t argn ) - : argv_input( argv, argn, internal::make_argv_source( argn ) ) - { - } - }; - -#ifdef __cpp_deduction_guides - template< typename... Ts > - argv_input( Ts&&... )->argv_input<>; -#endif - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/ascii.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/ascii.hpp deleted file mode 100644 index 51cb0e4..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/ascii.hpp +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_ASCII_HPP -#define TAO_PEGTL_ASCII_HPP - -#include "config.hpp" -#include "eol.hpp" - -#include "internal/always_false.hpp" -#include "internal/result_on_found.hpp" -#include "internal/rules.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - inline namespace ascii - { - // clang-format off - struct alnum : internal::alnum {}; - struct alpha : internal::alpha {}; - struct any : internal::any< internal::peek_char > {}; - struct blank : internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > {}; - struct digit : internal::range< internal::result_on_found::success, internal::peek_char, '0', '9' > {}; - struct ellipsis : internal::string< '.', '.', '.' > {}; - struct eolf : internal::eolf {}; - template< char... Cs > struct forty_two : internal::rep< 42, internal::one< internal::result_on_found::success, internal::peek_char, Cs... > > {}; - struct identifier_first : internal::identifier_first {}; - struct identifier_other : internal::identifier_other {}; - struct identifier : internal::identifier {}; - template< char... Cs > struct istring : internal::istring< Cs... > {}; - template< char... Cs > struct keyword : internal::seq< internal::string< Cs... >, internal::not_at< internal::identifier_other > > {}; - struct lower : internal::range< internal::result_on_found::success, internal::peek_char, 'a', 'z' > {}; - template< char... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_char, Cs... > {}; - template< char Lo, char Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_char, Lo, Hi > {}; - struct nul : internal::one< internal::result_on_found::success, internal::peek_char, char( 0 ) > {}; - template< char... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_char, Cs... > {}; - struct print : internal::range< internal::result_on_found::success, internal::peek_char, char( 32 ), char( 126 ) > {}; - template< char Lo, char Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_char, Lo, Hi > {}; - template< char... Cs > struct ranges : internal::ranges< internal::peek_char, Cs... > {}; - struct seven : internal::range< internal::result_on_found::success, internal::peek_char, char( 0 ), char( 127 ) > {}; - struct shebang : internal::if_must< false, internal::string< '#', '!' >, internal::until< internal::eolf > > {}; - struct space : internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\n', '\r', '\t', '\v', '\f' > {}; - template< char... Cs > struct string : internal::string< Cs... > {}; - template< char C > struct three : internal::string< C, C, C > {}; - template< char C > struct two : internal::string< C, C > {}; - struct upper : internal::range< internal::result_on_found::success, internal::peek_char, 'A', 'Z' > {}; - struct xdigit : internal::ranges< internal::peek_char, '0', '9', 'a', 'f', 'A', 'F' > {}; - // clang-format on - - template<> - struct keyword<> - { - template< typename Input > - static bool match( Input& /*unused*/ ) noexcept - { - static_assert( internal::always_false< Input >::value, "empty keywords not allowed" ); - return false; - } - }; - - } // namespace ascii - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#include "internal/pegtl_string.hpp" - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/buffer_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/buffer_input.hpp deleted file mode 100644 index f43513a..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/buffer_input.hpp +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_BUFFER_INPUT_HPP -#define TAO_PEGTL_BUFFER_INPUT_HPP - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "config.hpp" -#include "eol.hpp" -#include "memory_input.hpp" -#include "position.hpp" -#include "tracking_mode.hpp" - -#include "internal/action_input.hpp" -#include "internal/bump.hpp" -#include "internal/iterator.hpp" -#include "internal/marker.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - template< typename Reader, typename Eol = eol::lf_crlf, typename Source = std::string, std::size_t Chunk = 64 > - class buffer_input - { - public: - using reader_t = Reader; - - using eol_t = Eol; - using source_t = Source; - - using iterator_t = internal::iterator; - - using action_t = internal::action_input< buffer_input >; - - static constexpr std::size_t chunk_size = Chunk; - static constexpr tracking_mode tracking_mode_v = tracking_mode::eager; - - template< typename T, typename... As > - buffer_input( T&& in_source, const std::size_t maximum, As&&... as ) - : m_reader( std::forward< As >( as )... ), - m_maximum( maximum + Chunk ), - m_buffer( new char[ maximum + Chunk ] ), - m_current( m_buffer.get() ), - m_end( m_buffer.get() ), - m_source( std::forward< T >( in_source ) ) - { - static_assert( Chunk != 0, "zero chunk size not implemented" ); - assert( m_maximum > maximum ); // Catches overflow; change to >= when zero chunk size is implemented. - } - - buffer_input( const buffer_input& ) = delete; - buffer_input( buffer_input&& ) = delete; - - ~buffer_input() = default; - - void operator=( const buffer_input& ) = delete; - void operator=( buffer_input&& ) = delete; - - bool empty() - { - require( 1 ); - return m_current.data == m_end; - } - - std::size_t size( const std::size_t amount ) - { - require( amount ); - return buffer_occupied(); - } - - const char* current() const noexcept - { - return m_current.data; - } - - const char* end( const std::size_t amount ) - { - require( amount ); - return m_end; - } - - std::size_t byte() const noexcept - { - return m_current.byte; - } - - std::size_t line() const noexcept - { - return m_current.line; - } - - std::size_t byte_in_line() const noexcept - { - return m_current.byte_in_line; - } - - const Source& source() const noexcept - { - return m_source; - } - - char peek_char( const std::size_t offset = 0 ) const noexcept - { - return m_current.data[ offset ]; - } - - std::uint8_t peek_uint8( const std::size_t offset = 0 ) const noexcept - { - return static_cast< std::uint8_t >( peek_char( offset ) ); - } - - // Compatibility, remove with 3.0.0 - std::uint8_t peek_byte( const std::size_t offset = 0 ) const noexcept - { - return static_cast< std::uint8_t >( peek_char( offset ) ); - } - - void bump( const std::size_t in_count = 1 ) noexcept - { - internal::bump( m_current, in_count, Eol::ch ); - } - - void bump_in_this_line( const std::size_t in_count = 1 ) noexcept - { - internal::bump_in_this_line( m_current, in_count ); - } - - void bump_to_next_line( const std::size_t in_count = 1 ) noexcept - { - internal::bump_to_next_line( m_current, in_count ); - } - - void discard() noexcept - { - if( m_current.data > m_buffer.get() + Chunk ) { - const auto s = m_end - m_current.data; - std::memmove( m_buffer.get(), m_current.data, s ); - m_current.data = m_buffer.get(); - m_end = m_buffer.get() + s; - } - } - - void require( const std::size_t amount ) - { - if( m_current.data + amount <= m_end ) { - return; - } - if( m_current.data + amount > m_buffer.get() + m_maximum ) { - throw std::overflow_error( "require beyond end of buffer" ); - } - if( const auto r = m_reader( m_end, ( std::min )( buffer_free_after_end(), ( std::max )( amount - buffer_occupied(), Chunk ) ) ) ) { - m_end += r; - } - } - - template< rewind_mode M > - internal::marker< iterator_t, M > mark() noexcept - { - return internal::marker< iterator_t, M >( m_current ); - } - - TAO_PEGTL_NAMESPACE::position position( const iterator_t& it ) const - { - return TAO_PEGTL_NAMESPACE::position( it, m_source ); - } - - TAO_PEGTL_NAMESPACE::position position() const - { - return position( m_current ); - } - - const iterator_t& iterator() const noexcept - { - return m_current; - } - - std::size_t buffer_capacity() const noexcept - { - return m_maximum; - } - - std::size_t buffer_occupied() const noexcept - { - assert( m_end >= m_current.data ); - return std::size_t( m_end - m_current.data ); - } - - std::size_t buffer_free_before_current() const noexcept - { - assert( m_current.data >= m_buffer.get() ); - return std::size_t( m_current.data - m_buffer.get() ); - } - - std::size_t buffer_free_after_end() const noexcept - { - assert( m_buffer.get() + m_maximum >= m_end ); - return std::size_t( m_buffer.get() + m_maximum - m_end ); - } - - private: - Reader m_reader; - std::size_t m_maximum; - std::unique_ptr< char[] > m_buffer; // NOLINT - iterator_t m_current; - char* m_end; - const Source m_source; - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action.hpp deleted file mode 100644 index 1766e93..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CHANGE_ACTION_HPP -#define TAO_PEGTL_CHANGE_ACTION_HPP - -#include - -#include "apply_mode.hpp" -#include "config.hpp" -#include "nothing.hpp" -#include "rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - template< template< typename... > class NewAction > - struct change_action - : maybe_nothing - { - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - static_assert( !std::is_same< Action< void >, NewAction< void > >::value, "old and new action class templates are identical" ); - return Control< Rule >::template match< A, M, NewAction, Control >( in, st... ); - } - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action_and_state.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action_and_state.hpp deleted file mode 100644 index f76eb31..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action_and_state.hpp +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CHANGE_ACTION_AND_STATE_HPP -#define TAO_PEGTL_CHANGE_ACTION_AND_STATE_HPP - -#include - -#include "apply_mode.hpp" -#include "config.hpp" -#include "nothing.hpp" -#include "rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - template< template< typename... > class NewAction, typename NewState > - struct change_action_and_state - : maybe_nothing - { - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static auto match( Input& in, States&&... st ) - -> typename std::enable_if< ( A == apply_mode::action ), bool >::type - { - static_assert( !std::is_same< Action< void >, NewAction< void > >::value, "old and new action class templates are identical" ); - NewState s( static_cast< const Input& >( in ), st... ); - if( Control< Rule >::template match< A, M, NewAction, Control >( in, s ) ) { - Action< Rule >::success( static_cast< const Input& >( in ), s, st... ); - return true; - } - return false; - } - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States, - int = 1 > - static auto match( Input& in, States&&... st ) - -> typename std::enable_if< ( A == apply_mode::nothing ), bool >::type - { - static_assert( !std::is_same< Action< void >, NewAction< void > >::value, "old and new action class templates are identical" ); - NewState s( static_cast< const Input& >( in ), st... ); - return Control< Rule >::template match< A, M, NewAction, Control >( in, s ); - } - - template< typename Input, - typename... States > - static void success( const Input& in, NewState& s, States&&... st ) noexcept( noexcept( s.success( in, st... ) ) ) - { - s.success( in, st... ); - } - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action_and_states.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action_and_states.hpp deleted file mode 100644 index 42d51e9..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_action_and_states.hpp +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CHANGE_ACTION_AND_STATES_HPP -#define TAO_PEGTL_CHANGE_ACTION_AND_STATES_HPP - -#include -#include - -#include "apply_mode.hpp" -#include "config.hpp" -#include "nothing.hpp" -#include "rewind_mode.hpp" - -#include "internal/integer_sequence.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - template< template< typename... > class NewAction, typename... NewStates > - struct change_action_and_states - : maybe_nothing - { - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - std::size_t... Ns, - typename Input, - typename... States > - static bool match( TAO_PEGTL_NAMESPACE::internal::index_sequence< Ns... >, Input& in, States&&... st ) - { - auto t = std::tie( st... ); - if( Control< Rule >::template match< A, M, NewAction, Control >( in, std::get< Ns >( t )... ) ) { - Action< Rule >::success( static_cast< const Input& >( in ), st... ); - return true; - } - return false; - } - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static auto match( Input& in, States&&... st ) - -> typename std::enable_if< ( A == apply_mode::action ), bool >::type - { - static_assert( !std::is_same< Action< void >, NewAction< void > >::value, "old and new action class templates are identical" ); - return match< Rule, A, M, Action, Control >( TAO_PEGTL_NAMESPACE::internal::index_sequence_for< NewStates... >(), in, NewStates()..., st... ); - } - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States, - int = 1 > - static auto match( Input& in, States&&... /*unused*/ ) - -> typename std::enable_if< ( A == apply_mode::nothing ), bool >::type - { - static_assert( !std::is_same< Action< void >, NewAction< void > >::value, "old and new action class templates are identical" ); - return Control< Rule >::template match< A, M, NewAction, Control >( in, NewStates()... ); - } - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_control.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_control.hpp deleted file mode 100644 index ba9251f..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_control.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CHANGE_CONTROL_HPP -#define TAO_PEGTL_CHANGE_CONTROL_HPP - -#include "apply_mode.hpp" -#include "config.hpp" -#include "match.hpp" -#include "nothing.hpp" -#include "rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - template< template< typename... > class NewControl > - struct change_control - : maybe_nothing - { - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, NewControl >( in, st... ); - } - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_state.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_state.hpp deleted file mode 100644 index 3f8e4d5..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_state.hpp +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CHANGE_STATE_HPP -#define TAO_PEGTL_CHANGE_STATE_HPP - -#include - -#include "apply_mode.hpp" -#include "config.hpp" -#include "match.hpp" -#include "nothing.hpp" -#include "rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - template< typename NewState > - struct change_state - : maybe_nothing - { - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static auto match( Input& in, States&&... st ) - -> typename std::enable_if< ( A == apply_mode::action ), bool >::type - { - NewState s( static_cast< const Input& >( in ), st... ); - if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, s ) ) { - Action< Rule >::success( static_cast< const Input& >( in ), s, st... ); - return true; - } - return false; - } - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States, - int = 1 > - static auto match( Input& in, States&&... st ) - -> typename std::enable_if< ( A == apply_mode::nothing ), bool >::type - { - NewState s( static_cast< const Input& >( in ), st... ); - return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, s ); - } - - template< typename Input, - typename... States > - static void success( const Input& in, NewState& s, States&&... st ) noexcept( noexcept( s.success( in, st... ) ) ) - { - s.success( in, st... ); - } - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_states.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_states.hpp deleted file mode 100644 index 151f410..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/change_states.hpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CHANGE_STATES_HPP -#define TAO_PEGTL_CHANGE_STATES_HPP - -#include - -#include "apply_mode.hpp" -#include "config.hpp" -#include "match.hpp" -#include "nothing.hpp" -#include "rewind_mode.hpp" - -#include "internal/integer_sequence.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - template< typename... NewStates > - struct change_states - : maybe_nothing - { - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - std::size_t... Ns, - typename Input, - typename... States > - static bool match( TAO_PEGTL_NAMESPACE::internal::index_sequence< Ns... >, Input& in, States&&... st ) - { - auto t = std::tie( st... ); - if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, std::get< Ns >( t )... ) ) { - Action< Rule >::success( static_cast< const Input& >( in ), st... ); - return true; - } - return false; - } - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static auto match( Input& in, States&&... st ) - -> typename std::enable_if< ( A == apply_mode::action ), bool >::type - { - return match< Rule, A, M, Action, Control >( TAO_PEGTL_NAMESPACE::internal::index_sequence_for< NewStates... >(), in, NewStates()..., st... ); - } - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States, - int = 1 > - static auto match( Input& in, States&&... /*unused*/ ) - -> typename std::enable_if< ( A == apply_mode::nothing ), bool >::type - { - return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, NewStates()... ); - } - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/config.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/config.hpp deleted file mode 100644 index 4e47aba..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/config.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONFIG_HPP -#define TAO_PEGTL_CONFIG_HPP - -// Compatibility, remove with 3.0.0 -#ifdef TAOCPP_PEGTL_NAMESPACE -#define TAO_PEGTL_NAMESPACE TAOCPP_PEGTL_NAMESPACE -#endif - -#ifndef TAO_PEGTL_NAMESPACE -#define TAO_PEGTL_NAMESPACE pegtl -#endif - -// Enable some improvements to the readability of -// demangled type names under some circumstances. -// #define TAO_PEGTL_PRETTY_DEMANGLE - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/abnf.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/abnf.hpp deleted file mode 100644 index 5fcd0d2..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/abnf.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_ABNF_HPP -#define TAO_PEGTL_CONTRIB_ABNF_HPP - -#include "../config.hpp" -#include "../internal/rules.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace abnf - { - // Core ABNF rules according to RFC 5234, Appendix B - - // clang-format off - struct ALPHA : internal::ranges< internal::peek_char, 'a', 'z', 'A', 'Z' > {}; - struct BIT : internal::one< internal::result_on_found::success, internal::peek_char, '0', '1' > {}; - struct CHAR : internal::range< internal::result_on_found::success, internal::peek_char, char( 1 ), char( 127 ) > {}; - struct CR : internal::one< internal::result_on_found::success, internal::peek_char, '\r' > {}; - struct CRLF : internal::string< '\r', '\n' > {}; - struct CTL : internal::ranges< internal::peek_char, char( 0 ), char( 31 ), char( 127 ) > {}; - struct DIGIT : internal::range< internal::result_on_found::success, internal::peek_char, '0', '9' > {}; - struct DQUOTE : internal::one< internal::result_on_found::success, internal::peek_char, '"' > {}; - struct HEXDIG : internal::ranges< internal::peek_char, '0', '9', 'a', 'f', 'A', 'F' > {}; - struct HTAB : internal::one< internal::result_on_found::success, internal::peek_char, '\t' > {}; - struct LF : internal::one< internal::result_on_found::success, internal::peek_char, '\n' > {}; - struct LWSP : internal::star< internal::sor< internal::string< '\r', '\n' >, internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > >, internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > > {}; - struct OCTET : internal::any< internal::peek_char > {}; - struct SP : internal::one< internal::result_on_found::success, internal::peek_char, ' ' > {}; - struct VCHAR : internal::range< internal::result_on_found::success, internal::peek_char, char( 33 ), char( 126 ) > {}; - struct WSP : internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > {}; - // clang-format on - - } // namespace abnf - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/alphabet.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/alphabet.hpp deleted file mode 100644 index 35f6a7c..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/alphabet.hpp +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2015-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_ALPHABET_HPP -#define TAO_PEGTL_CONTRIB_ALPHABET_HPP - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace alphabet - { - static const int a = 'a'; // NOLINT - static const int b = 'b'; // NOLINT - static const int c = 'c'; // NOLINT - static const int d = 'd'; // NOLINT - static const int e = 'e'; // NOLINT - static const int f = 'f'; // NOLINT - static const int g = 'g'; // NOLINT - static const int h = 'h'; // NOLINT - static const int i = 'i'; // NOLINT - static const int j = 'j'; // NOLINT - static const int k = 'k'; // NOLINT - static const int l = 'l'; // NOLINT - static const int m = 'm'; // NOLINT - static const int n = 'n'; // NOLINT - static const int o = 'o'; // NOLINT - static const int p = 'p'; // NOLINT - static const int q = 'q'; // NOLINT - static const int r = 'r'; // NOLINT - static const int s = 's'; // NOLINT - static const int t = 't'; // NOLINT - static const int u = 'u'; // NOLINT - static const int v = 'v'; // NOLINT - static const int w = 'w'; // NOLINT - static const int x = 'x'; // NOLINT - static const int y = 'y'; // NOLINT - static const int z = 'z'; // NOLINT - - static const int A = 'A'; // NOLINT - static const int B = 'B'; // NOLINT - static const int C = 'C'; // NOLINT - static const int D = 'D'; // NOLINT - static const int E = 'E'; // NOLINT - static const int F = 'F'; // NOLINT - static const int G = 'G'; // NOLINT - static const int H = 'H'; // NOLINT - static const int I = 'I'; // NOLINT - static const int J = 'J'; // NOLINT - static const int K = 'K'; // NOLINT - static const int L = 'L'; // NOLINT - static const int M = 'M'; // NOLINT - static const int N = 'N'; // NOLINT - static const int O = 'O'; // NOLINT - static const int P = 'P'; // NOLINT - static const int Q = 'Q'; // NOLINT - static const int R = 'R'; // NOLINT - static const int S = 'S'; // NOLINT - static const int T = 'T'; // NOLINT - static const int U = 'U'; // NOLINT - static const int V = 'V'; // NOLINT - static const int W = 'W'; // NOLINT - static const int X = 'X'; // NOLINT - static const int Y = 'Y'; // NOLINT - static const int Z = 'Z'; // NOLINT - - } // namespace alphabet - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/changes.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/changes.hpp deleted file mode 100644 index 3da10ee..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/changes.hpp +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2015-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_CHANGES_HPP -#define TAO_PEGTL_CONTRIB_CHANGES_HPP - -#include - -#include "../config.hpp" -#include "../normal.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct dummy_disabled_state - { - template< typename... Ts > - void success( Ts&&... /*unused*/ ) const noexcept - { - } - }; - - template< apply_mode A, typename NewState > - using state_disable_helper = typename std::conditional< A == apply_mode::action, NewState, dummy_disabled_state >::type; - - } // namespace internal - - template< typename Rule, typename NewState, template< typename... > class Base = normal > - struct change_state - : public Base< Rule > - { - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - internal::state_disable_helper< A, NewState > s; - - if( Base< Rule >::template match< A, M, Action, Control >( in, s ) ) { - s.success( st... ); - return true; - } - return false; - } - }; - - template< typename Rule, template< typename... > class NewAction, template< typename... > class Base = normal > - struct change_action - : public Base< Rule > - { - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return Base< Rule >::template match< A, M, NewAction, Control >( in, st... ); - } - }; - - template< template< typename... > class NewAction, template< typename... > class Base > - struct change_both_helper - { - template< typename T > - using change_action = change_action< T, NewAction, Base >; - }; - - template< typename Rule, typename NewState, template< typename... > class NewAction, template< typename... > class Base = normal > - struct change_state_and_action - : public change_state< Rule, NewState, change_both_helper< NewAction, Base >::template change_action > - { - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/counter.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/counter.hpp deleted file mode 100644 index fc0c969..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/counter.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_COUNTER_HPP -#define TAO_PEGTL_CONTRIB_COUNTER_HPP - -#include -#include - -#include "../config.hpp" -#include "../normal.hpp" - -#include "../internal/demangle.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - struct counter_data - { - unsigned start = 0; - unsigned success = 0; - unsigned failure = 0; - }; - - struct counter_state - { - std::map< std::string, counter_data > counts; - }; - - template< typename Rule > - struct counter - : normal< Rule > - { - template< typename Input > - static void start( const Input& /*unused*/, counter_state& ts ) - { - ++ts.counts[ internal::demangle< Rule >() ].start; - } - - template< typename Input > - static void success( const Input& /*unused*/, counter_state& ts ) - { - ++ts.counts[ internal::demangle< Rule >() ].success; - } - - template< typename Input > - static void failure( const Input& /*unused*/, counter_state& ts ) - { - ++ts.counts[ internal::demangle< Rule >() ].failure; - } - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/http.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/http.hpp deleted file mode 100644 index 829b40c..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/http.hpp +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_HTTP_HPP -#define TAO_PEGTL_CONTRIB_HTTP_HPP - -#include "../ascii.hpp" -#include "../config.hpp" -#include "../nothing.hpp" -#include "../rules.hpp" -#include "../utf8.hpp" - -#include "abnf.hpp" -#include "remove_first_state.hpp" -#include "uri.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace http - { - // HTTP 1.1 grammar according to RFC 7230. - - // This grammar is a direct PEG translation of the original HTTP grammar. - // It should be considered experimental -- in case of any issues, in particular - // missing rules for attached actions, please contact the developers. - - using OWS = star< abnf::WSP >; // optional whitespace - using RWS = plus< abnf::WSP >; // required whitespace - using BWS = OWS; // "bad" whitespace - - using obs_text = not_range< 0x00, 0x7F >; - using obs_fold = seq< abnf::CRLF, plus< abnf::WSP > >; - - // clang-format off - struct tchar : sor< abnf::ALPHA, abnf::DIGIT, one< '!', '#', '$', '%', '&', '\'', '*', '+', '-', '.', '^', '_', '`', '|', '~' > > {}; - struct token : plus< tchar > {}; - - struct field_name : token {}; - - struct field_vchar : sor< abnf::VCHAR, obs_text > {}; - struct field_content : list< field_vchar, plus< abnf::WSP > > {}; - struct field_value : star< sor< field_content, obs_fold > > {}; - - struct header_field : seq< field_name, one< ':' >, OWS, field_value, OWS > {}; - - struct method : token {}; - - struct absolute_path : plus< one< '/' >, uri::segment > {}; - - struct origin_form : seq< absolute_path, uri::opt_query > {}; - struct absolute_form : uri::absolute_URI {}; - struct authority_form : uri::authority {}; - struct asterisk_form : one< '*' > {}; - - struct request_target : sor< origin_form, absolute_form, authority_form, asterisk_form > {}; - - struct status_code : rep< 3, abnf::DIGIT > {}; - struct reason_phrase : star< sor< abnf::VCHAR, obs_text, abnf::WSP > > {}; - - struct HTTP_version : if_must< string< 'H', 'T', 'T', 'P', '/' >, abnf::DIGIT, one< '.' >, abnf::DIGIT > {}; - - struct request_line : if_must< method, abnf::SP, request_target, abnf::SP, HTTP_version, abnf::CRLF > {}; - struct status_line : if_must< HTTP_version, abnf::SP, status_code, abnf::SP, reason_phrase, abnf::CRLF > {}; - struct start_line : sor< status_line, request_line > {}; - - struct message_body : star< abnf::OCTET > {}; - struct HTTP_message : seq< start_line, star< header_field, abnf::CRLF >, abnf::CRLF, opt< message_body > > {}; - - struct Content_Length : plus< abnf::DIGIT > {}; - - struct uri_host : uri::host {}; - struct port : uri::port {}; - - struct Host : seq< uri_host, opt< one< ':' >, port > > {}; - - // PEG are different from CFGs! (this replaces ctext and qdtext) - using text = sor< abnf::HTAB, range< 0x20, 0x7E >, obs_text >; - - struct quoted_pair : if_must< one< '\\' >, sor< abnf::VCHAR, obs_text, abnf::WSP > > {}; - struct quoted_string : if_must< abnf::DQUOTE, until< abnf::DQUOTE, sor< quoted_pair, text > > > {}; - - struct transfer_parameter : seq< token, BWS, one< '=' >, BWS, sor< token, quoted_string > > {}; - struct transfer_extension : seq< token, star< OWS, one< ';' >, OWS, transfer_parameter > > {}; - struct transfer_coding : sor< istring< 'c', 'h', 'u', 'n', 'k', 'e', 'd' >, - istring< 'c', 'o', 'm', 'p', 'r', 'e', 's', 's' >, - istring< 'd', 'e', 'f', 'l', 'a', 't', 'e' >, - istring< 'g', 'z', 'i', 'p' >, - transfer_extension > {}; - - struct rank : sor< seq< one< '0' >, opt< one< '.' >, rep_opt< 3, abnf::DIGIT > > >, - seq< one< '1' >, opt< one< '.' >, rep_opt< 3, one< '0' > > > > > {}; - - struct t_ranking : seq< OWS, one< ';' >, OWS, one< 'q', 'Q' >, one< '=' >, rank > {}; - struct t_codings : sor< istring< 't', 'r', 'a', 'i', 'l', 'e', 'r', 's' >, seq< transfer_coding, opt< t_ranking > > > {}; - - struct TE : opt< sor< one< ',' >, t_codings >, star< OWS, one< ',' >, opt< OWS, t_codings > > > {}; - - template< typename T > - using make_comma_list = seq< star< one< ',' >, OWS >, T, star< OWS, one< ',' >, opt< OWS, T > > >; - - struct connection_option : token {}; - struct Connection : make_comma_list< connection_option > {}; - - struct Trailer : make_comma_list< field_name > {}; - - struct Transfer_Encoding : make_comma_list< transfer_coding > {}; - - struct protocol_name : token {}; - struct protocol_version : token {}; - struct protocol : seq< protocol_name, opt< one< '/' >, protocol_version > > {}; - struct Upgrade : make_comma_list< protocol > {}; - - struct pseudonym : token {}; - - struct received_protocol : seq< opt< protocol_name, one< '/' > >, protocol_version > {}; - struct received_by : sor< seq< uri_host, opt< one< ':' >, port > >, pseudonym > {}; - - struct comment : if_must< one< '(' >, until< one< ')' >, sor< comment, quoted_pair, text > > > {}; - - struct Via : make_comma_list< seq< received_protocol, RWS, received_by, opt< RWS, comment > > > {}; - - struct http_URI : if_must< istring< 'h', 't', 't', 'p', ':', '/', '/' >, uri::authority, uri::path_abempty, uri::opt_query, uri::opt_fragment > {}; - struct https_URI : if_must< istring< 'h', 't', 't', 'p', 's', ':', '/', '/' >, uri::authority, uri::path_abempty, uri::opt_query, uri::opt_fragment > {}; - - struct partial_URI : seq< uri::relative_part, uri::opt_query > {}; - - // clang-format on - struct chunk_size - { - using analyze_t = plus< abnf::HEXDIG >::analyze_t; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, std::size_t& size, States&&... /*unused*/ ) - { - size = 0; - std::size_t i = 0; - while( in.size( i + 1 ) >= i + 1 ) { - const auto c = in.peek_char( i ); - if( ( '0' <= c ) && ( c <= '9' ) ) { - size <<= 4; - size |= std::size_t( c - '0' ); - ++i; - continue; - } - if( ( 'a' <= c ) && ( c <= 'f' ) ) { - size <<= 4; - size |= std::size_t( c - 'a' + 10 ); - ++i; - continue; - } - if( ( 'A' <= c ) && ( c <= 'F' ) ) { - size <<= 4; - size |= std::size_t( c - 'A' + 10 ); - ++i; - continue; - } - break; - } - in.bump_in_this_line( i ); - return i > 0; - } - }; - // clang-format off - - struct chunk_ext_name : token {}; - struct chunk_ext_val : sor< quoted_string, token > {}; - struct chunk_ext : star_must< one< ';' >, chunk_ext_name, if_must< one< '=' >, chunk_ext_val > > {}; - - // clang-format on - struct chunk_data - { - using analyze_t = star< abnf::OCTET >::analyze_t; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, const std::size_t size, States&&... /*unused*/ ) - { - if( in.size( size ) >= size ) { - in.bump( size ); - return true; - } - return false; - } - }; - - namespace internal - { - namespace chunk_helper - { - template< typename Base > - struct control; - - template< template< typename... > class Control, typename Rule > - struct control< Control< Rule > > - : Control< Rule > - { - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class, - typename Input, - typename State, - typename... States > - static bool match( Input& in, State&& /*unused*/, States&&... st ) - { - return Control< Rule >::template match< A, M, Action, Control >( in, st... ); - } - }; - - template< template< typename... > class Control > - struct control< Control< chunk_size > > - : remove_first_state< Control< chunk_size > > - {}; - - template< template< typename... > class Control > - struct control< Control< chunk_data > > - : remove_first_state< Control< chunk_data > > - {}; - - template< template< typename... > class Control > - struct bind - { - template< typename Rule > - using type = control< Control< Rule > >; - }; - - } // namespace chunk_helper - - } // namespace internal - - struct chunk - { - using impl = seq< chunk_size, chunk_ext, abnf::CRLF, chunk_data, abnf::CRLF >; - using analyze_t = impl::analyze_t; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - std::size_t size{}; - return impl::template match< A, M, Action, internal::chunk_helper::bind< Control >::template type >( in, size, st... ); - } - }; - - // clang-format off - struct last_chunk : seq< plus< one< '0' > >, not_at< digit >, chunk_ext, abnf::CRLF > {}; - - struct trailer_part : star< header_field, abnf::CRLF > {}; - - struct chunked_body : seq< until< last_chunk, chunk >, trailer_part, abnf::CRLF > {}; - // clang-format on - - } // namespace http - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/internal.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/internal.hpp deleted file mode 100644 index d5bc93c..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/internal.hpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_ICU_INTERNAL_HPP -#define TAO_PEGTL_CONTRIB_ICU_INTERNAL_HPP - -#include - -#include "../../config.hpp" - -#include "../../analysis/generic.hpp" -#include "../../internal/skip_control.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - namespace icu - { - template< typename Peek, UProperty P, bool V = true > - struct binary_property - { - using analyze_t = analysis::generic< analysis::rule_type::any >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) ) - { - if( const auto r = Peek::peek( in ) ) { - if( u_hasBinaryProperty( r.data, P ) == V ) { - in.bump( r.size ); - return true; - } - } - return false; - } - }; - - template< typename Peek, UProperty P, int V > - struct property_value - { - using analyze_t = analysis::generic< analysis::rule_type::any >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) ) - { - if( const auto r = Peek::peek( in ) ) { - if( u_getIntPropertyValue( r.data, P ) == V ) { - in.bump( r.size ); - return true; - } - } - return false; - } - }; - - } // namespace icu - - template< typename Peek, UProperty P, bool V > - struct skip_control< icu::binary_property< Peek, P, V > > : std::true_type - { - }; - - template< typename Peek, UProperty P, int V > - struct skip_control< icu::property_value< Peek, P, V > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf16.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf16.hpp deleted file mode 100644 index bf2540c..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf16.hpp +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_ICU_UTF16_HPP -#define TAO_PEGTL_CONTRIB_ICU_UTF16_HPP - -#include "internal.hpp" - -#include "../../config.hpp" -#include "../../utf16.hpp" - -#include "../../internal/peek_utf16.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace utf16_be - { - namespace icu - { - template< UProperty P, bool V = true > - struct binary_property - : internal::icu::binary_property< internal::peek_utf16_be, P, V > - { - }; - - template< UProperty P, int V > - struct property_value - : internal::icu::property_value< internal::peek_utf16_be, P, V > - { - }; - - // clang-format off - struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; - struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; - struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; - struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; - struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; - struct dash : binary_property< UCHAR_DASH > {}; - struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; - struct deprecated : binary_property< UCHAR_DEPRECATED > {}; - struct diacritic : binary_property< UCHAR_DIACRITIC > {}; - struct extender : binary_property< UCHAR_EXTENDER > {}; - struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; - struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; - struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; - struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; - struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; - struct hyphen : binary_property< UCHAR_HYPHEN > {}; - struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; - struct id_start : binary_property< UCHAR_ID_START > {}; - struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; - struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; - struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; - struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; - struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; - struct lowercase : binary_property< UCHAR_LOWERCASE > {}; - struct math : binary_property< UCHAR_MATH > {}; - struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; - struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; - struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; - struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; - struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; - struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; - struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; - struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; - struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; - struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; - struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; - struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; - struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; - struct radical : binary_property< UCHAR_RADICAL > {}; - struct s_term : binary_property< UCHAR_S_TERM > {}; - struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; - struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; - struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; - struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; - struct uppercase : binary_property< UCHAR_UPPERCASE > {}; - struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; - struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; - struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; - struct xid_start : binary_property< UCHAR_XID_START > {}; - - template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; - template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; - template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; - template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; - template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; - template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; - template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; - template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; - template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; - template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; - // UNormalizationCheckResult requires an additional header : - // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; - template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; - template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; - template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; - - template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; - // clang-format on - - } // namespace icu - - } // namespace utf16_be - - namespace utf16_le - { - namespace icu - { - template< UProperty P, bool V = true > - struct binary_property - : internal::icu::binary_property< internal::peek_utf16_le, P, V > - { - }; - - template< UProperty P, int V > - struct property_value - : internal::icu::property_value< internal::peek_utf16_le, P, V > - { - }; - - // clang-format off - struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; - struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; - struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; - struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; - struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; - struct dash : binary_property< UCHAR_DASH > {}; - struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; - struct deprecated : binary_property< UCHAR_DEPRECATED > {}; - struct diacritic : binary_property< UCHAR_DIACRITIC > {}; - struct extender : binary_property< UCHAR_EXTENDER > {}; - struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; - struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; - struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; - struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; - struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; - struct hyphen : binary_property< UCHAR_HYPHEN > {}; - struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; - struct id_start : binary_property< UCHAR_ID_START > {}; - struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; - struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; - struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; - struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; - struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; - struct lowercase : binary_property< UCHAR_LOWERCASE > {}; - struct math : binary_property< UCHAR_MATH > {}; - struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; - struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; - struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; - struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; - struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; - struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; - struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; - struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; - struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; - struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; - struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; - struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; - struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; - struct radical : binary_property< UCHAR_RADICAL > {}; - struct s_term : binary_property< UCHAR_S_TERM > {}; - struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; - struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; - struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; - struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; - struct uppercase : binary_property< UCHAR_UPPERCASE > {}; - struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; - struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; - struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; - struct xid_start : binary_property< UCHAR_XID_START > {}; - - template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; - template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; - template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; - template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; - template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; - template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; - template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; - template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; - template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; - template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; - // UNormalizationCheckResult requires an additional header : - // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; - template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; - template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; - template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; - - template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; - // clang-format on - - } // namespace icu - - } // namespace utf16_le - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf32.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf32.hpp deleted file mode 100644 index ca35819..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf32.hpp +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_ICU_UTF32_HPP -#define TAO_PEGTL_CONTRIB_ICU_UTF32_HPP - -#include "internal.hpp" - -#include "../../config.hpp" -#include "../../utf32.hpp" - -#include "../../internal/peek_utf32.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace utf32_be - { - namespace icu - { - template< UProperty P, bool V = true > - struct binary_property - : internal::icu::binary_property< internal::peek_utf32_be, P, V > - { - }; - - template< UProperty P, int V > - struct property_value - : internal::icu::property_value< internal::peek_utf32_be, P, V > - { - }; - - // clang-format off - struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; - struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; - struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; - struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; - struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; - struct dash : binary_property< UCHAR_DASH > {}; - struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; - struct deprecated : binary_property< UCHAR_DEPRECATED > {}; - struct diacritic : binary_property< UCHAR_DIACRITIC > {}; - struct extender : binary_property< UCHAR_EXTENDER > {}; - struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; - struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; - struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; - struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; - struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; - struct hyphen : binary_property< UCHAR_HYPHEN > {}; - struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; - struct id_start : binary_property< UCHAR_ID_START > {}; - struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; - struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; - struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; - struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; - struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; - struct lowercase : binary_property< UCHAR_LOWERCASE > {}; - struct math : binary_property< UCHAR_MATH > {}; - struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; - struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; - struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; - struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; - struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; - struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; - struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; - struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; - struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; - struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; - struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; - struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; - struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; - struct radical : binary_property< UCHAR_RADICAL > {}; - struct s_term : binary_property< UCHAR_S_TERM > {}; - struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; - struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; - struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; - struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; - struct uppercase : binary_property< UCHAR_UPPERCASE > {}; - struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; - struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; - struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; - struct xid_start : binary_property< UCHAR_XID_START > {}; - - template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; - template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; - template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; - template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; - template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; - template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; - template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; - template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; - template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; - template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; - // UNormalizationCheckResult requires an additional header : - // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; - template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; - template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; - template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; - - template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; - // clang-format on - - } // namespace icu - - } // namespace utf32_be - - namespace utf32_le - { - namespace icu - { - template< UProperty P, bool V = true > - struct binary_property - : internal::icu::binary_property< internal::peek_utf32_le, P, V > - { - }; - - template< UProperty P, int V > - struct property_value - : internal::icu::property_value< internal::peek_utf32_le, P, V > - { - }; - - // clang-format off - struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; - struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; - struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; - struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; - struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; - struct dash : binary_property< UCHAR_DASH > {}; - struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; - struct deprecated : binary_property< UCHAR_DEPRECATED > {}; - struct diacritic : binary_property< UCHAR_DIACRITIC > {}; - struct extender : binary_property< UCHAR_EXTENDER > {}; - struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; - struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; - struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; - struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; - struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; - struct hyphen : binary_property< UCHAR_HYPHEN > {}; - struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; - struct id_start : binary_property< UCHAR_ID_START > {}; - struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; - struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; - struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; - struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; - struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; - struct lowercase : binary_property< UCHAR_LOWERCASE > {}; - struct math : binary_property< UCHAR_MATH > {}; - struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; - struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; - struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; - struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; - struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; - struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; - struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; - struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; - struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; - struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; - struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; - struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; - struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; - struct radical : binary_property< UCHAR_RADICAL > {}; - struct s_term : binary_property< UCHAR_S_TERM > {}; - struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; - struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; - struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; - struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; - struct uppercase : binary_property< UCHAR_UPPERCASE > {}; - struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; - struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; - struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; - struct xid_start : binary_property< UCHAR_XID_START > {}; - - template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; - template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; - template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; - template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; - template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; - template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; - template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; - template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; - template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; - template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; - // UNormalizationCheckResult requires an additional header : - // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; - template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; - template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; - template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; - - template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; - // clang-format on - - } // namespace icu - - } // namespace utf32_le - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf8.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf8.hpp deleted file mode 100644 index 089130d..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/icu/utf8.hpp +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_ICU_UTF8_HPP -#define TAO_PEGTL_CONTRIB_ICU_UTF8_HPP - -#include "internal.hpp" - -#include "../../config.hpp" -#include "../../utf8.hpp" - -#include "../../internal/peek_utf8.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace utf8 - { - namespace icu - { - template< UProperty P, bool V = true > - struct binary_property - : internal::icu::binary_property< internal::peek_utf8, P, V > - { - }; - - template< UProperty P, int V > - struct property_value - : internal::icu::property_value< internal::peek_utf8, P, V > - { - }; - - // clang-format off - struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; - struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; - struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; - struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; - struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; - struct dash : binary_property< UCHAR_DASH > {}; - struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; - struct deprecated : binary_property< UCHAR_DEPRECATED > {}; - struct diacritic : binary_property< UCHAR_DIACRITIC > {}; - struct extender : binary_property< UCHAR_EXTENDER > {}; - struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; - struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; - struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; - struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; - struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; - struct hyphen : binary_property< UCHAR_HYPHEN > {}; - struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; - struct id_start : binary_property< UCHAR_ID_START > {}; - struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; - struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; - struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; - struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; - struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; - struct lowercase : binary_property< UCHAR_LOWERCASE > {}; - struct math : binary_property< UCHAR_MATH > {}; - struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; - struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; - struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; - struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; - struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; - struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; - struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; - struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; - struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; - struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; - struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; - struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; - struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; - struct radical : binary_property< UCHAR_RADICAL > {}; - struct s_term : binary_property< UCHAR_S_TERM > {}; - struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; - struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; - struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; - struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; - struct uppercase : binary_property< UCHAR_UPPERCASE > {}; - struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; - struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; - struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; - struct xid_start : binary_property< UCHAR_XID_START > {}; - - template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; - template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; - template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; - template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; - template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; - template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; - template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; - template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; - template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; - template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; - // UNormalizationCheckResult requires an additional header : - // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; - template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; - template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; - template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; - - template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; - // clang-format on - - } // namespace icu - - } // namespace utf8 - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/if_then.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/if_then.hpp deleted file mode 100644 index b861aa7..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/if_then.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_IF_THEN_HPP -#define TAO_PEGTL_CONTRIB_IF_THEN_HPP - -#include - -#include "../config.hpp" - -#include "../internal/if_then_else.hpp" -#include "../internal/seq.hpp" -#include "../internal/skip_control.hpp" -#include "../internal/trivial.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Cond, typename Then > - struct if_pair - { - }; - - template< typename... Pairs > - struct if_then; - - template< typename Cond, typename Then, typename... Pairs > - struct if_then< if_pair< Cond, Then >, Pairs... > - : if_then_else< Cond, Then, if_then< Pairs... > > - { - template< typename ElseCond, typename... Thens > - using else_if_then = if_then< if_pair< Cond, Then >, Pairs..., if_pair< ElseCond, seq< Thens... > > >; - - template< typename... Thens > - using else_then = if_then_else< Cond, Then, if_then< Pairs..., if_pair< trivial< true >, seq< Thens... > > > >; - }; - - template<> - struct if_then<> - : trivial< false > - { - }; - - template< typename... Pairs > - struct skip_control< if_then< Pairs... > > : std::true_type - { - }; - - } // namespace internal - - template< typename Cond, typename... Thens > - using if_then = internal::if_then< internal::if_pair< Cond, internal::seq< Thens... > > >; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/integer.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/integer.hpp deleted file mode 100644 index 5c83145..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/integer.hpp +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_INTEGER_HPP -#define TAO_PEGTL_CONTRIB_INTEGER_HPP - -#include -#include - -#include "../ascii.hpp" -#include "../parse_error.hpp" -#include "../rules.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace integer - { - namespace internal - { - template< typename I, I Limit, typename Input > - I actual_convert( const Input& in, std::size_t index ) - { - static constexpr I cutoff = Limit / 10; - static constexpr I cutlim = Limit % 10; - - I out = in.peek_char( index ) - '0'; - while( ++index < in.size() ) { - const I c = in.peek_char( index ) - '0'; - if( ( out > cutoff ) || ( ( out == cutoff ) && ( c > cutlim ) ) ) { - throw parse_error( "integer out of range", in ); - } - out *= 10; - out += c; - } - return out; - } - - template< typename I, typename Input > - I convert_positive( const Input& in, std::size_t index ) - { - static constexpr I limit = ( std::numeric_limits< I >::max )(); - return actual_convert< I, limit >( in, index ); - } - - template< typename I, typename Input > - I convert_negative( const Input& in, std::size_t index ) - { - using U = typename std::make_unsigned< I >::type; - static constexpr U limit = static_cast< U >( ( std::numeric_limits< I >::max )() ) + 1; - return static_cast< I >( ~actual_convert< U, limit >( in, index ) ) + 1; - } - - } // namespace internal - - struct unsigned_rule - : plus< digit > - { - }; - - struct unsigned_action - { - // Assumes that 'in' contains a non-empty sequence of ASCII digits. - - template< typename Input, typename State, typename... States > - static void apply( const Input& in, State& st, States&&... /*unused*/ ) - { - using T = typename std::decay< decltype( st.converted ) >::type; - static_assert( std::is_integral< T >::value, "need integral type" ); - static_assert( std::is_unsigned< T >::value, "need unsigned type" ); - st.converted = internal::convert_positive< T >( in, 0 ); - } - }; - - struct signed_rule - : seq< opt< one< '+', '-' > >, plus< digit > > - { - }; - - struct signed_action - { - // Assumes that 'in' contains a non-empty sequence of ASCII digits, - // with optional leading sign; with sign, in.size() must be >= 2. - - template< typename Input, typename State, typename... States > - static void apply( const Input& in, State& st, States&&... /*unused*/ ) - { - using T = typename std::decay< decltype( st.converted ) >::type; - static_assert( std::is_integral< T >::value, "need integral type" ); - static_assert( std::is_signed< T >::value, "need signed type" ); - const auto c = in.peek_char(); - if( c == '-' ) { - st.converted = internal::convert_negative< T >( in, 1 ); - } - else { - st.converted = internal::convert_positive< T >( in, std::size_t( c == '+' ) ); - } - } - }; - - } // namespace integer - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/json.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/json.hpp deleted file mode 100644 index cd71148..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/json.hpp +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_JSON_HPP -#define TAO_PEGTL_CONTRIB_JSON_HPP - -#include "../ascii.hpp" -#include "../config.hpp" -#include "../rules.hpp" -#include "../utf8.hpp" - -#include "abnf.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace json - { - // JSON grammar according to RFC 8259 - - // clang-format off - struct ws : one< ' ', '\t', '\n', '\r' > {}; - - template< typename R, typename P = ws > - struct padr : internal::seq< R, internal::star< P > > {}; - - struct begin_array : padr< one< '[' > > {}; - struct begin_object : padr< one< '{' > > {}; - struct end_array : one< ']' > {}; - struct end_object : one< '}' > {}; - struct name_separator : pad< one< ':' >, ws > {}; - struct value_separator : padr< one< ',' > > {}; - - struct false_ : string< 'f', 'a', 'l', 's', 'e' > {}; // NOLINT - struct null : string< 'n', 'u', 'l', 'l' > {}; - struct true_ : string< 't', 'r', 'u', 'e' > {}; // NOLINT - - struct digits : plus< abnf::DIGIT > {}; - struct exp : seq< one< 'e', 'E' >, opt< one< '-', '+'> >, must< digits > > {}; - struct frac : if_must< one< '.' >, digits > {}; - struct int_ : sor< one< '0' >, digits > {}; // NOLINT - struct number : seq< opt< one< '-' > >, int_, opt< frac >, opt< exp > > {}; - - struct xdigit : abnf::HEXDIG {}; - struct unicode : list< seq< one< 'u' >, rep< 4, must< xdigit > > >, one< '\\' > > {}; - struct escaped_char : one< '"', '\\', '/', 'b', 'f', 'n', 'r', 't' > {}; - struct escaped : sor< escaped_char, unicode > {}; - struct unescaped : utf8::range< 0x20, 0x10FFFF > {}; - struct char_ : if_then_else< one< '\\' >, must< escaped >, unescaped > {}; // NOLINT - - struct string_content : until< at< one< '"' > >, must< char_ > > {}; - struct string : seq< one< '"' >, must< string_content >, any > - { - using content = string_content; - }; - - struct key_content : until< at< one< '"' > >, must< char_ > > {}; - struct key : seq< one< '"' >, must< key_content >, any > - { - using content = key_content; - }; - - struct value; - - struct array_element; - struct array_content : opt< list_must< array_element, value_separator > > {}; - struct array : seq< begin_array, array_content, must< end_array > > - { - using begin = begin_array; - using end = end_array; - using element = array_element; - using content = array_content; - }; - - struct member : if_must< key, name_separator, value > {}; - struct object_content : opt< list_must< member, value_separator > > {}; - struct object : seq< begin_object, object_content, must< end_object > > - { - using begin = begin_object; - using end = end_object; - using element = member; - using content = object_content; - }; - - struct value : padr< sor< string, number, object, array, false_, true_, null > > {}; - struct array_element : seq< value > {}; - - struct text : seq< star< ws >, value > {}; - // clang-format on - - } // namespace json - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/json_pointer.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/json_pointer.hpp deleted file mode 100644 index 1e4307c..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/json_pointer.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_JSON_POINTER_HPP -#define TAO_PEGTL_CONTRIB_JSON_POINTER_HPP - -#include "../ascii.hpp" -#include "../config.hpp" -#include "../rules.hpp" -#include "../utf8.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace json_pointer - { - // JSON pointer grammar according to RFC 6901 - - // clang-format off - struct unescaped : utf8::ranges< 0x0, 0x2E, 0x30, 0x7D, 0x7F, 0x10FFFF > {}; - struct escaped : seq< one< '~' >, one< '0', '1' > > {}; - - struct reference_token : star< sor< unescaped, escaped > > {}; - struct json_pointer : star< one< '/' >, reference_token > {}; - // clang-format on - - // relative JSON pointer, see ... - - // clang-format off - struct non_negative_integer : sor< one< '0' >, plus< digit > > {}; - struct relative_json_pointer : seq< non_negative_integer, sor< one< '#' >, json_pointer > > {}; - // clang-format on - - } // namespace json_pointer - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/parse_tree.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/parse_tree.hpp deleted file mode 100644 index 4abe7eb..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/parse_tree.hpp +++ /dev/null @@ -1,517 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_PARSE_TREE_HPP -#define TAO_PEGTL_CONTRIB_PARSE_TREE_HPP - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "remove_first_state.hpp" -#include "shuffle_states.hpp" - -#include "../apply_mode.hpp" -#include "../config.hpp" -#include "../memory_input.hpp" -#include "../normal.hpp" -#include "../nothing.hpp" -#include "../parse.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/counted.hpp" -#include "../analysis/generic.hpp" -#include "../internal/demangle.hpp" -#include "../internal/integer_sequence.hpp" -#include "../internal/iterator.hpp" -#include "../internal/skip_control.hpp" -#include "../internal/try_catch_type.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace parse_tree - { - template< typename T > - struct basic_node - { - using node_t = T; - using children_t = std::vector< std::unique_ptr< node_t > >; - children_t children; - - std::type_index id = std::type_index( typeid( void ) ); - std::string source; - - TAO_PEGTL_NAMESPACE::internal::iterator m_begin; - TAO_PEGTL_NAMESPACE::internal::iterator m_end; - - // each node will be default constructed - basic_node() = default; - - // no copy/move is necessary - // (nodes are always owned/handled by a std::unique_ptr) - basic_node( const basic_node& ) = delete; - basic_node( basic_node&& ) = delete; - - ~basic_node() = default; - - // no assignment either - basic_node& operator=( const basic_node& ) = delete; - basic_node& operator=( basic_node&& ) = delete; - - bool is_root() const noexcept - { - return id == typeid( void ); - } - - template< typename U > - bool is() const noexcept - { - return id == typeid( U ); - } - - std::string name() const - { - assert( !is_root() ); - return TAO_PEGTL_NAMESPACE::internal::demangle( id.name() ); - } - - position begin() const - { - return position( m_begin, source ); - } - - position end() const - { - return position( m_end, source ); - } - - bool has_content() const noexcept - { - return m_end.data != nullptr; - } - - std::string string() const - { - assert( has_content() ); - return std::string( m_begin.data, m_end.data ); - } - - // Compatibility, remove with 3.0.0 - std::string content() const - { - return string(); - } - - template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > - memory_input< P, Eol > as_memory_input() const - { - assert( has_content() ); - return { m_begin.data, m_end.data, source, m_begin.byte, m_begin.line, m_begin.byte_in_line }; - } - - template< typename... States > - void remove_content( States&&... /*unused*/ ) noexcept - { - m_end.reset(); - } - - // all non-root nodes are initialized by calling this method - template< typename Rule, typename Input, typename... States > - void start( const Input& in, States&&... /*unused*/ ) - { - id = typeid( Rule ); - source = in.source(); - m_begin = TAO_PEGTL_NAMESPACE::internal::iterator( in.iterator() ); - } - - // if parsing of the rule succeeded, this method is called - template< typename Rule, typename Input, typename... States > - void success( const Input& in, States&&... /*unused*/ ) noexcept - { - m_end = TAO_PEGTL_NAMESPACE::internal::iterator( in.iterator() ); - } - - // if parsing of the rule failed, this method is called - template< typename Rule, typename Input, typename... States > - void failure( const Input& /*unused*/, States&&... /*unused*/ ) noexcept - { - } - - // if parsing succeeded and the (optional) transform call - // did not discard the node, it is appended to its parent. - // note that "child" is the node whose Rule just succeeded - // and "*this" is the parent where the node should be appended. - template< typename... States > - void emplace_back( std::unique_ptr< node_t >&& child, States&&... /*unused*/ ) - { - assert( child ); - children.emplace_back( std::move( child ) ); - } - }; - - struct node - : basic_node< node > - { - }; - - namespace internal - { - template< typename > - struct is_try_catch_type - : std::false_type - { - }; - - template< typename Exception, typename... Rules > - struct is_try_catch_type< TAO_PEGTL_NAMESPACE::internal::try_catch_type< Exception, Rules... > > - : std::true_type - { - }; - - template< typename Node > - struct state - { - std::vector< std::unique_ptr< Node > > stack; - - state() - { - emplace_back(); - } - - void emplace_back() - { - stack.emplace_back( std::unique_ptr< Node >( new Node ) ); - } - - std::unique_ptr< Node >& back() noexcept - { - assert( !stack.empty() ); - return stack.back(); - } - - void pop_back() noexcept - { - assert( !stack.empty() ); - return stack.pop_back(); - } - }; - - template< typename Selector, typename... Parameters > - void transform( Parameters&&... /*unused*/ ) noexcept - { - } - - template< typename Selector, typename Input, typename Node, typename... States > - auto transform( const Input& in, std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( Selector::transform( in, n, st... ) ) ) - -> decltype( Selector::transform( in, n, st... ), void() ) - { - Selector::transform( in, n, st... ); - } - - template< typename Selector, typename Input, typename Node, typename... States > - auto transform( const Input& /*unused*/, std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( Selector::transform( n, st... ) ) ) - -> decltype( Selector::transform( n, st... ), void() ) - { - Selector::transform( n, st... ); - } - - template< typename Rule, template< typename... > class Selector > - struct is_selected_node - : std::integral_constant< bool, !TAO_PEGTL_NAMESPACE::internal::skip_control< Rule >::value && Selector< Rule >::value > - { - }; - - template< unsigned Level, typename Analyse, template< typename... > class Selector > - struct is_leaf - : std::false_type - { - }; - - template< analysis::rule_type Type, template< typename... > class Selector > - struct is_leaf< 0, analysis::generic< Type >, Selector > - : std::true_type - { - }; - - template< analysis::rule_type Type, std::size_t Count, template< typename... > class Selector > - struct is_leaf< 0, analysis::counted< Type, Count >, Selector > - : std::true_type - { - }; - - template< analysis::rule_type Type, typename... Rules, template< typename... > class Selector > - struct is_leaf< 0, analysis::generic< Type, Rules... >, Selector > - : std::false_type - { - }; - - template< analysis::rule_type Type, std::size_t Count, typename... Rules, template< typename... > class Selector > - struct is_leaf< 0, analysis::counted< Type, Count, Rules... >, Selector > - : std::false_type - { - }; - - template< bool... > - struct bool_sequence; - - template< bool... Bs > - struct is_all - : std::is_same< bool_sequence< Bs..., true >, bool_sequence< true, Bs... > > - { - }; - - template< bool... Bs > - struct is_none - : std::integral_constant< bool, !is_all< !Bs... >::value > - { - }; - - template< unsigned Level, typename Rule, template< typename... > class Selector > - using is_unselected_leaf = std::integral_constant< bool, !is_selected_node< Rule, Selector >::value && is_leaf< Level, typename Rule::analyze_t, Selector >::value >; - - template< unsigned Level, analysis::rule_type Type, typename... Rules, template< typename... > class Selector > - struct is_leaf< Level, analysis::generic< Type, Rules... >, Selector > - : is_all< is_unselected_leaf< Level - 1, Rules, Selector >::value... > - { - }; - - template< unsigned Level, analysis::rule_type Type, std::size_t Count, typename... Rules, template< typename... > class Selector > - struct is_leaf< Level, analysis::counted< Type, Count, Rules... >, Selector > - : is_all< is_unselected_leaf< Level - 1, Rules, Selector >::value... > - { - }; - - template< typename Node, template< typename... > class Selector, template< typename... > class Control > - struct make_control - { - template< typename Rule, bool, bool > - struct state_handler; - - template< typename Rule > - using type = rotate_states_right< state_handler< Rule, is_selected_node< Rule, Selector >::value, is_leaf< 8, typename Rule::analyze_t, Selector >::value > >; - }; - - template< typename Node, template< typename... > class Selector, template< typename... > class Control > - template< typename Rule > - struct make_control< Node, Selector, Control >::state_handler< Rule, false, true > - : remove_first_state< Control< Rule > > - { - }; - - template< typename Node, template< typename... > class Selector, template< typename... > class Control > - template< typename Rule > - struct make_control< Node, Selector, Control >::state_handler< Rule, false, false > - : remove_first_state< Control< Rule > > - { - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control2, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto& state = std::get< sizeof...( st ) - 1 >( std::tie( st... ) ); - if( is_try_catch_type< Rule >::value ) { - internal::state< Node > tmp; - tmp.emplace_back(); - tmp.stack.swap( state.stack ); - const bool result = Control< Rule >::template match< A, M, Action, Control2 >( in, st... ); - tmp.stack.swap( state.stack ); - if( result ) { - for( auto& c : tmp.back()->children ) { - state.back()->children.emplace_back( std::move( c ) ); - } - } - return result; - } - state.emplace_back(); - const bool result = Control< Rule >::template match< A, M, Action, Control2 >( in, st... ); - if( result ) { - auto n = std::move( state.back() ); - state.pop_back(); - for( auto& c : n->children ) { - state.back()->children.emplace_back( std::move( c ) ); - } - } - else { - state.pop_back(); - } - return result; - } - }; - - template< typename Node, template< typename... > class Selector, template< typename... > class Control > - template< typename Rule, bool B > - struct make_control< Node, Selector, Control >::state_handler< Rule, true, B > - : remove_first_state< Control< Rule > > - { - template< typename Input, typename... States > - static void start( const Input& in, state< Node >& state, States&&... st ) - { - Control< Rule >::start( in, st... ); - state.emplace_back(); - state.back()->template start< Rule >( in, st... ); - } - - template< typename Input, typename... States > - static void success( const Input& in, state< Node >& state, States&&... st ) - { - Control< Rule >::success( in, st... ); - auto n = std::move( state.back() ); - state.pop_back(); - n->template success< Rule >( in, st... ); - transform< Selector< Rule > >( in, n, st... ); - if( n ) { - state.back()->emplace_back( std::move( n ), st... ); - } - } - - template< typename Input, typename... States > - static void failure( const Input& in, state< Node >& state, States&&... st ) noexcept( noexcept( Control< Rule >::failure( in, st... ) ) && noexcept( std::declval< Node& >().template failure< Rule >( in, st... ) ) ) - { - Control< Rule >::failure( in, st... ); - state.back()->template failure< Rule >( in, st... ); - state.pop_back(); - } - }; - - template< typename > - using store_all = std::true_type; - - template< typename > - struct selector; - - template<> - struct selector< std::tuple<> > - { - using type = std::false_type; - }; - - template< typename T > - struct selector< std::tuple< T > > - { - using type = typename T::type; - }; - - template< typename... Ts > - struct selector< std::tuple< Ts... > > - { - static_assert( sizeof...( Ts ) == 0, "multiple matches found" ); - }; - - template< typename Rule, typename Collection > - using select_tuple = typename std::conditional< Collection::template contains< Rule >::value, std::tuple< Collection >, std::tuple<> >::type; - - } // namespace internal - - template< typename Rule, typename... Collections > - struct selector - : internal::selector< decltype( std::tuple_cat( std::declval< internal::select_tuple< Rule, Collections > >()... ) ) >::type - {}; - - template< typename Base > - struct apply - : std::true_type - { - template< typename... Rules > - struct on - { - using type = Base; - - template< typename Rule > - using contains = internal::is_none< std::is_same< Rule, Rules >::value... >; - }; - }; - - struct store_content - : apply< store_content > - {}; - - // some nodes don't need to store their content - struct remove_content - : apply< remove_content > - { - template< typename Node, typename... States > - static void transform( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( n->Node::remove_content( st... ) ) ) - { - n->remove_content( st... ); - } - }; - - // if a node has only one child, replace the node with its child, otherwise remove content - struct fold_one - : apply< fold_one > - { - template< typename Node, typename... States > - static void transform( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( n->children.size(), n->Node::remove_content( st... ) ) ) - { - if( n->children.size() == 1 ) { - n = std::move( n->children.front() ); - } - else { - n->remove_content( st... ); - } - } - }; - - // if a node has no children, discard the node, otherwise remove content - struct discard_empty - : apply< discard_empty > - { - template< typename Node, typename... States > - static void transform( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( n->children.empty(), n->Node::remove_content( st... ) ) ) - { - if( n->children.empty() ) { - n.reset(); - } - else { - n->remove_content( st... ); - } - } - }; - - template< typename Rule, - typename Node, - template< typename... > class Selector = internal::store_all, - template< typename... > class Action = nothing, - template< typename... > class Control = normal, - typename Input, - typename... States > - std::unique_ptr< Node > parse( Input&& in, States&&... st ) - { - internal::state< Node > state; - if( !TAO_PEGTL_NAMESPACE::parse< Rule, Action, internal::make_control< Node, Selector, Control >::template type >( in, st..., state ) ) { - return nullptr; - } - assert( state.stack.size() == 1 ); - return std::move( state.back() ); - } - - template< typename Rule, - template< typename... > class Selector = internal::store_all, - template< typename... > class Action = nothing, - template< typename... > class Control = normal, - typename Input, - typename... States > - std::unique_ptr< node > parse( Input&& in, States&&... st ) - { - return parse< Rule, node, Selector, Action, Control >( in, st... ); - } - - } // namespace parse_tree - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/parse_tree_to_dot.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/parse_tree_to_dot.hpp deleted file mode 100644 index cb6a6e0..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/parse_tree_to_dot.hpp +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_PARSE_TREE_TO_DOT_HPP -#define TAO_PEGTL_CONTRIB_PARSE_TREE_TO_DOT_HPP - -#include -#include -#include - -#include "parse_tree.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace parse_tree - { - namespace internal - { - inline void escape( std::ostream& os, const char* p, const std::size_t s ) - { - static const char* h = "0123456789abcdef"; - - const char* l = p; - const char* const e = p + s; - while( p != e ) { - const unsigned char c = *p; - if( c == '\\' ) { - os.write( l, p - l ); - l = ++p; - os << "\\\\"; - } - else if( c == '"' ) { - os.write( l, p - l ); - l = ++p; - os << "\\\""; - } - else if( c < 32 ) { - os.write( l, p - l ); - l = ++p; - switch( c ) { - case '\b': - os << "\\b"; - break; - case '\f': - os << "\\f"; - break; - case '\n': - os << "\\n"; - break; - case '\r': - os << "\\r"; - break; - case '\t': - os << "\\t"; - break; - default: - os << "\\u00" << h[ ( c & 0xf0 ) >> 4 ] << h[ c & 0x0f ]; - } - } - else if( c == 127 ) { - os.write( l, p - l ); - l = ++p; - os << "\\u007f"; - } - else { - ++p; - } - } - os.write( l, p - l ); - } - - inline void escape( std::ostream& os, const std::string& s ) - { - escape( os, s.data(), s.size() ); - } - - template< typename Node > - void print_dot_node( std::ostream& os, const Node& n, const std::string& s ) - { - os << " x" << &n << " [ label=\""; - escape( os, s ); - if( n.has_content() ) { - os << "\\n"; - escape( os, n.m_begin.data, n.m_end.data - n.m_begin.data ); - } - os << "\" ]\n"; - if( !n.children.empty() ) { - os << " x" << &n << " -> { "; - for( auto& up : n.children ) { - os << "x" << up.get() << ( ( up == n.children.back() ) ? " }\n" : ", " ); - } - for( auto& up : n.children ) { - print_dot_node( os, *up, up->name() ); - } - } - } - - } // namespace internal - - template< typename Node > - void print_dot( std::ostream& os, const Node& n ) - { - os << "digraph parse_tree\n{\n"; - internal::print_dot_node( os, n, n.is_root() ? "ROOT" : n.name() ); - os << "}\n"; - } - - } // namespace parse_tree - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/raw_string.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/raw_string.hpp deleted file mode 100644 index 1e66e3b..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/raw_string.hpp +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_RAW_STRING_HPP -#define TAO_PEGTL_CONTRIB_RAW_STRING_HPP - -#include -#include - -#include "../apply_mode.hpp" -#include "../config.hpp" -#include "../rewind_mode.hpp" - -#include "../internal/bytes.hpp" -#include "../internal/eof.hpp" -#include "../internal/eol.hpp" -#include "../internal/must.hpp" -#include "../internal/not_at.hpp" -#include "../internal/seq.hpp" -#include "../internal/skip_control.hpp" -#include "../internal/star.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< char Open, char Marker > - struct raw_string_open - { - using analyze_t = analysis::generic< analysis::rule_type::any >; - - template< apply_mode A, - rewind_mode, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, std::size_t& marker_size, States&&... /*unused*/ ) noexcept( noexcept( in.size( 0 ) ) ) - { - if( in.empty() || ( in.peek_char( 0 ) != Open ) ) { - return false; - } - for( std::size_t i = 1; i < in.size( i + 1 ); ++i ) { - switch( const auto c = in.peek_char( i ) ) { - case Open: - marker_size = i + 1; - in.bump_in_this_line( marker_size ); - eol::match( in ); - return true; - case Marker: - break; - default: - return false; - } - } - return false; - } - }; - - template< char Open, char Marker > - struct skip_control< raw_string_open< Open, Marker > > : std::true_type - { - }; - - template< char Marker, char Close > - struct at_raw_string_close - { - using analyze_t = analysis::generic< analysis::rule_type::opt >; - - template< apply_mode A, - rewind_mode, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, const std::size_t& marker_size, States&&... /*unused*/ ) noexcept( noexcept( in.size( 0 ) ) ) - { - if( in.size( marker_size ) < marker_size ) { - return false; - } - if( in.peek_char( 0 ) != Close ) { - return false; - } - if( in.peek_char( marker_size - 1 ) != Close ) { - return false; - } - for( std::size_t i = 0; i < ( marker_size - 2 ); ++i ) { - if( in.peek_char( i + 1 ) != Marker ) { - return false; - } - } - return true; - } - }; - - template< char Marker, char Close > - struct skip_control< at_raw_string_close< Marker, Close > > : std::true_type - { - }; - - template< typename Cond, typename... Rules > - struct raw_string_until; - - template< typename Cond > - struct raw_string_until< Cond > - { - using analyze_t = analysis::generic< analysis::rule_type::seq, star< not_at< Cond >, not_at< eof >, bytes< 1 > >, Cond >; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, const std::size_t& marker_size, States&&... st ) - { - auto m = in.template mark< M >(); - - while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, marker_size, st... ) ) { - if( in.empty() ) { - return false; - } - in.bump(); - } - return m( true ); - } - }; - - template< typename Cond, typename... Rules > - struct raw_string_until - { - using analyze_t = analysis::generic< analysis::rule_type::seq, star< not_at< Cond >, not_at< eof >, Rules... >, Cond >; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, const std::size_t& marker_size, States&&... st ) - { - auto m = in.template mark< M >(); - using m_t = decltype( m ); - - while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, marker_size, st... ) ) { - if( in.empty() || ( !Control< seq< Rules... > >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) ) { - return false; - } - } - return m( true ); - } - }; - - template< typename Cond, typename... Rules > - struct skip_control< raw_string_until< Cond, Rules... > > : std::true_type - { - }; - - } // namespace internal - - // raw_string matches Lua-style long literals. - // - // The following description was taken from the Lua documentation - // (see http://www.lua.org/docs.html): - // - // - An "opening long bracket of level n" is defined as an opening square - // bracket followed by n equal signs followed by another opening square - // bracket. So, an opening long bracket of level 0 is written as `[[`, - // an opening long bracket of level 1 is written as `[=[`, and so on. - // - A "closing long bracket" is defined similarly; for instance, a closing - // long bracket of level 4 is written as `]====]`. - // - A "long literal" starts with an opening long bracket of any level and - // ends at the first closing long bracket of the same level. It can - // contain any text except a closing bracket of the same level. - // - Literals in this bracketed form can run for several lines, do not - // interpret any escape sequences, and ignore long brackets of any other - // level. - // - For convenience, when the opening long bracket is immediately followed - // by a newline, the newline is not included in the string. - // - // Note that unlike Lua's long literal, a raw_string is customizable to use - // other characters than `[`, `=` and `]` for matching. Also note that Lua - // introduced newline-specific replacements in Lua 5.2, which we do not - // support on the grammar level. - - template< char Open, char Marker, char Close, typename... Contents > - struct raw_string - { - // This is used for binding the apply()-method and for error-reporting - // when a raw string is not closed properly or has invalid content. - struct content - : internal::raw_string_until< internal::at_raw_string_close< Marker, Close >, Contents... > - { - }; - - using analyze_t = typename internal::seq< internal::bytes< 1 >, content, internal::bytes< 1 > >::analyze_t; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - std::size_t marker_size; - if( internal::raw_string_open< Open, Marker >::template match< A, M, Action, Control >( in, marker_size, st... ) ) { - internal::must< content >::template match< A, M, Action, Control >( in, marker_size, st... ); - in.bump_in_this_line( marker_size ); - return true; - } - return false; - } - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/remove_first_state.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/remove_first_state.hpp deleted file mode 100644 index bbd671b..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/remove_first_state.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_REMOVE_FIRST_STATE_HPP -#define TAO_PEGTL_CONTRIB_REMOVE_FIRST_STATE_HPP - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - // Applies to start(), success(), failure(), raise(), apply(), and apply0(): - // The first state is removed when the call is forwarded to Base. - template< typename Base > - struct remove_first_state - : Base - { - template< typename Input, typename State, typename... States > - static void start( const Input& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::start( in, st... ) ) ) - { - Base::start( in, st... ); - } - - template< typename Input, typename State, typename... States > - static void success( const Input& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::success( in, st... ) ) ) - { - Base::success( in, st... ); - } - - template< typename Input, typename State, typename... States > - static void failure( const Input& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::failure( in, st... ) ) ) - { - Base::failure( in, st... ); - } - - template< typename Input, typename State, typename... States > - static void raise( const Input& in, State&& /*unused*/, States&&... st ) - { - Base::raise( in, st... ); - } - - template< template< typename... > class Action, typename Iterator, typename Input, typename State, typename... States > - static auto apply( const Iterator& begin, const Input& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::template apply< Action >( begin, in, st... ) ) ) - -> decltype( Base::template apply< Action >( begin, in, st... ) ) - { - return Base::template apply< Action >( begin, in, st... ); - } - - template< template< typename... > class Action, typename Input, typename State, typename... States > - static auto apply0( const Input& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::template apply0< Action >( in, st... ) ) ) - -> decltype( Base::template apply0< Action >( in, st... ) ) - { - return Base::template apply0< Action >( in, st... ); - } - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/remove_last_states.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/remove_last_states.hpp deleted file mode 100644 index c65cdc0..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/remove_last_states.hpp +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (c) 2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_REMOVE_LAST_STATES_HPP -#define TAO_PEGTL_CONTRIB_REMOVE_LAST_STATES_HPP - -#include -#include - -#include "../config.hpp" -#include "../internal/integer_sequence.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - // Remove the last N states of start(), success(), failure(), raise(), apply(), and apply0() - template< typename Base, std::size_t N > - struct remove_last_states - : Base - { - template< typename Input, typename Tuple, std::size_t... Is > - static void start_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::start( in, std::get< Is >( t )... ) ) ) - { - Base::start( in, std::get< Is >( t )... ); - } - - template< typename Input, typename... States > - static void start( const Input& in, States&&... st ) noexcept( noexcept( start_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ) ) ) - { - start_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ); - } - - template< typename Input, typename Tuple, std::size_t... Is > - static void success_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::success( in, std::get< Is >( t )... ) ) ) - { - Base::success( in, std::get< Is >( t )... ); - } - - template< typename Input, typename... States > - static void success( const Input& in, States&&... st ) noexcept( noexcept( success_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ) ) ) - { - success_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ); - } - - template< typename Input, typename Tuple, std::size_t... Is > - static void failure_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::failure( in, std::get< Is >( t )... ) ) ) - { - Base::failure( in, std::get< Is >( t )... ); - } - - template< typename Input, typename... States > - static void failure( const Input& in, States&&... st ) noexcept( noexcept( failure_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ) ) ) - { - failure_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ); - } - - template< typename Input, typename Tuple, std::size_t... Is > - static void raise_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) - { - Base::raise( in, std::get< Is >( t )... ); - } - - template< typename Input, typename... States > - static void raise( const Input& in, States&&... st ) - { - raise_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ); - } - - template< template< typename... > class Action, typename Iterator, typename Input, typename Tuple, std::size_t... Is > - static auto apply_impl( const Iterator& begin, const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::template apply< Action >( begin, in, std::get< Is >( t )... ) ) ) - -> decltype( Base::template apply< Action >( begin, in, std::get< Is >( t )... ) ) - { - return Base::template apply< Action >( begin, in, std::get< Is >( t )... ); - } - - template< template< typename... > class Action, typename Iterator, typename Input, typename... States > - static auto apply( const Iterator& begin, const Input& in, States&&... st ) noexcept( noexcept( apply_impl< Action >( begin, in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ) ) ) - -> decltype( apply_impl< Action >( begin, in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ) ) - { - return apply_impl< Action >( begin, in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ); - } - - template< template< typename... > class Action, typename Input, typename Tuple, std::size_t... Is > - static auto apply0_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::template apply0< Action >( in, std::get< Is >( t )... ) ) ) - -> decltype( Base::template apply0< Action >( in, std::get< Is >( t )... ) ) - { - return Base::template apply0< Action >( in, std::get< Is >( t )... ); - } - - template< template< typename... > class Action, typename Input, typename... States > - static auto apply0( const Input& in, States&&... st ) noexcept( noexcept( apply0_impl< Action >( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ) ) ) - -> decltype( apply0_impl< Action >( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ) ) - { - return apply0_impl< Action >( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) - N >() ); - } - }; - - template< typename Base > - using remove_last_state = remove_last_states< Base, 1 >; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/rep_one_min_max.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/rep_one_min_max.hpp deleted file mode 100644 index 9173ad4..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/rep_one_min_max.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_REP_ONE_MIN_MAX_HPP -#define TAO_PEGTL_CONTRIB_REP_ONE_MIN_MAX_HPP - -#include - -#include "../config.hpp" - -#include "../analysis/counted.hpp" - -#include "../internal/bump_help.hpp" -#include "../internal/skip_control.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< unsigned Min, unsigned Max, char C > - struct rep_one_min_max - { - using analyze_t = analysis::counted< analysis::rule_type::any, Min >; - - static_assert( Min <= Max, "invalid rep_one_min_max rule (maximum number of repetitions smaller than minimum)" ); - - template< typename Input > - static bool match( Input& in ) - { - const auto size = in.size( Max + 1 ); - if( size < Min ) { - return false; - } - std::size_t i = 0; - while( ( i < size ) && ( in.peek_char( i ) == C ) ) { - ++i; - } - if( ( Min <= i ) && ( i <= Max ) ) { - bump_help< result_on_found::success, Input, char, C >( in, i ); - return true; - } - return false; - } - }; - - template< unsigned Min, unsigned Max, char C > - struct skip_control< rep_one_min_max< Min, Max, C > > : std::true_type - { - }; - - } // namespace internal - - inline namespace ascii - { - template< unsigned Min, unsigned Max, char C > - struct rep_one_min_max : internal::rep_one_min_max< Min, Max, C > - { - }; - - } // namespace ascii - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/rep_string.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/rep_string.hpp deleted file mode 100644 index 41fc369..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/rep_string.hpp +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_REP_STRING_HPP -#define TAO_PEGTL_CONTRIB_REP_STRING_HPP - -#include - -#include "../config.hpp" -#include "../internal/string.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< std::size_t, typename, char... > - struct make_rep_string; - - template< char... Ss, char... Cs > - struct make_rep_string< 0, string< Ss... >, Cs... > - { - using type = string< Ss... >; - }; - - template< std::size_t N, char... Ss, char... Cs > - struct make_rep_string< N, string< Ss... >, Cs... > - : make_rep_string< N - 1, string< Ss..., Cs... >, Cs... > - {}; - - } // namespace internal - - inline namespace ascii - { - template< std::size_t N, char... Cs > - struct rep_string - : internal::make_rep_string< N, internal::string<>, Cs... >::type - {}; - - } // namespace ascii - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/shuffle_states.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/shuffle_states.hpp deleted file mode 100644 index 57caee3..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/shuffle_states.hpp +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright (c) 2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_SHUFFLE_STATES_HPP -#define TAO_PEGTL_CONTRIB_SHUFFLE_STATES_HPP - -#include -#include - -#include "../config.hpp" -#include "../internal/integer_sequence.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< std::size_t N > - struct rotate_left - { - template< std::size_t I, std::size_t S > - using type = std::integral_constant< std::size_t, ( I + N ) % S >; - }; - - template< std::size_t N > - struct rotate_right - { - template< std::size_t I, std::size_t S > - using type = std::integral_constant< std::size_t, ( I + S - N ) % S >; - }; - - struct reverse - { - template< std::size_t I, std::size_t S > - using type = std::integral_constant< std::size_t, ( S - 1 ) - I >; - }; - - } // namespace internal - - // Applies 'Shuffle' to the states of start(), success(), failure(), raise(), apply(), and apply0() - template< typename Base, typename Shuffle > - struct shuffle_states - : Base - { - template< typename Input, typename Tuple, std::size_t... Is > - static void start_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::start( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ) ) ) - { - Base::start( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ); - } - - template< typename Input, typename... States > - static void start( const Input& in, States&&... st ) noexcept( noexcept( start_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ) ) ) - { - start_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ); - } - - template< typename Input, typename State > - static void start( const Input& in, State&& st ) noexcept( noexcept( Base::start( in, st ) ) ) - { - Base::start( in, st ); - } - - template< typename Input, typename Tuple, std::size_t... Is > - static void success_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::success( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ) ) ) - { - Base::success( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ); - } - - template< typename Input, typename... States > - static void success( const Input& in, States&&... st ) noexcept( noexcept( success_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ) ) ) - { - success_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ); - } - - template< typename Input, typename State > - static void success( const Input& in, State&& st ) noexcept( noexcept( Base::success( in, st ) ) ) - { - Base::success( in, st ); - } - - template< typename Input, typename Tuple, std::size_t... Is > - static void failure_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::failure( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ) ) ) - { - Base::failure( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ); - } - - template< typename Input, typename... States > - static void failure( const Input& in, States&&... st ) noexcept( noexcept( failure_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ) ) ) - { - failure_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ); - } - - template< typename Input, typename State > - static void failure( const Input& in, State&& st ) noexcept( noexcept( Base::failure( in, st ) ) ) - { - Base::failure( in, st ); - } - - template< typename Input, typename Tuple, std::size_t... Is > - static void raise_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) - { - Base::raise( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ); - } - - template< typename Input, typename... States > - static void raise( const Input& in, States&&... st ) - { - raise_impl( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ); - } - - template< typename Input, typename State > - static void raise( const Input& in, State&& st ) - { - Base::raise( in, st ); - } - - template< template< typename... > class Action, typename Iterator, typename Input, typename Tuple, std::size_t... Is > - static auto apply_impl( const Iterator& begin, const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::template apply< Action >( begin, in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ) ) ) - -> decltype( Base::template apply< Action >( begin, in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ) ) - { - return Base::template apply< Action >( begin, in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ); - } - - template< template< typename... > class Action, typename Iterator, typename Input, typename... States > - static auto apply( const Iterator& begin, const Input& in, States&&... st ) noexcept( noexcept( apply_impl< Action >( begin, in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ) ) ) - -> decltype( apply_impl< Action >( begin, in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ) ) - { - return apply_impl< Action >( begin, in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ); - } - - template< template< typename... > class Action, typename Iterator, typename Input, typename State > - static auto apply( const Iterator& begin, const Input& in, State&& st ) noexcept( noexcept( Base::template apply< Action >( begin, in, st ) ) ) - -> decltype( Base::template apply< Action >( begin, in, st ) ) - { - return Base::template apply< Action >( begin, in, st ); - } - - template< template< typename... > class Action, typename Input, typename Tuple, std::size_t... Is > - static auto apply0_impl( const Input& in, const Tuple& t, internal::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::template apply0< Action >( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ) ) ) - -> decltype( Base::template apply0< Action >( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ) ) - { - return Base::template apply0< Action >( in, std::get< Shuffle::template type< Is, sizeof...( Is ) >::value >( t )... ); - } - - template< template< typename... > class Action, typename Input, typename... States > - static auto apply0( const Input& in, States&&... st ) noexcept( noexcept( apply0_impl< Action >( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ) ) ) - -> decltype( apply0_impl< Action >( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ) ) - { - return apply0_impl< Action >( in, std::tie( st... ), internal::make_index_sequence< sizeof...( st ) >() ); - } - - template< template< typename... > class Action, typename Input, typename State > - static auto apply0( const Input& in, State&& st ) noexcept( noexcept( Base::template apply0< Action >( in, st ) ) ) - -> decltype( Base::template apply0< Action >( in, st ) ) - { - return Base::template apply0< Action >( in, st ); - } - }; - - template< typename Base, std::size_t N = 1 > - using rotate_states_left = shuffle_states< Base, internal::rotate_left< N > >; - - template< typename Base, std::size_t N = 1 > - using rotate_states_right = shuffle_states< Base, internal::rotate_right< N > >; - - template< typename Base > - using reverse_states = shuffle_states< Base, internal::reverse >; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/to_string.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/to_string.hpp deleted file mode 100644 index 4d74384..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/to_string.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_TO_STRING_HPP -#define TAO_PEGTL_CONTRIB_TO_STRING_HPP - -#include - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename > - struct to_string; - - template< template< char... > class X, char... Cs > - struct to_string< X< Cs... > > - { - static std::string get() - { - const char s[] = { Cs..., 0 }; - return std::string( s, sizeof...( Cs ) ); - } - }; - - } // namespace internal - - template< typename T > - std::string to_string() - { - return internal::to_string< T >::get(); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/tracer.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/tracer.hpp deleted file mode 100644 index 4174e91..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/tracer.hpp +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_TRACER_HPP -#define TAO_PEGTL_CONTRIB_TRACER_HPP - -#include -#include -#include -#include -#include - -#include "../config.hpp" -#include "../normal.hpp" - -#include "../internal/demangle.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Input > - void print_current( const Input& in ) - { - if( in.empty() ) { - std::cerr << ""; - } - else { - const auto c = in.peek_uint8(); - switch( c ) { - case 0: - std::cerr << " = "; - break; - case 9: - std::cerr << " = "; - break; - case 10: - std::cerr << " = "; - break; - case 13: - std::cerr << " = "; - break; - default: - if( isprint( c ) ) { - std::cerr << '\'' << c << "' = "; - } - } - std::cerr << "(char)" << unsigned( c ); - } - } - - } // namespace internal - - struct trace_state - { - unsigned rule = 0; - unsigned line = 0; - std::vector< unsigned > stack; - }; - -#if defined( _MSC_VER ) && ( _MSC_VER < 1910 ) - - template< typename Rule > - struct tracer - : normal< Rule > - { - template< typename Input, typename... States > - static void start( const Input& in, States&&... /*unused*/ ) - { - std::cerr << in.position() << " start " << internal::demangle< Rule >() << "; current "; - print_current( in ); - std::cerr << std::endl; - } - - template< typename Input, typename... States > - static void start( const Input& in, trace_state& ts, States&&... st ) - { - std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ++ts.rule << " "; - start( in, st... ); - ts.stack.push_back( ts.rule ); - } - - template< typename Input, typename... States > - static void success( const Input& in, States&&... /*unused*/ ) - { - std::cerr << in.position() << " success " << internal::demangle< Rule >() << "; next "; - print_current( in ); - std::cerr << std::endl; - } - - template< typename Input, typename... States > - static void success( const Input& in, trace_state& ts, States&&... st ) - { - assert( !ts.stack.empty() ); - std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ts.stack.back() << " "; - success( in, st... ); - ts.stack.pop_back(); - } - - template< typename Input, typename... States > - static void failure( const Input& in, States&&... /*unused*/ ) - { - std::cerr << in.position() << " failure " << internal::demangle< Rule >() << std::endl; - } - - template< typename Input, typename... States > - static void failure( const Input& in, trace_state& ts, States&&... st ) - { - assert( !ts.stack.empty() ); - std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ts.stack.back() << " "; - failure( in, st... ); - ts.stack.pop_back(); - } - - template< template< typename... > class Action, typename Iterator, typename Input, typename... States > - static auto apply( const Iterator& begin, const Input& in, States&&... st ) - -> decltype( normal< Rule >::template apply< Action >( begin, in, st... ) ) - { - std::cerr << in.position() << " apply " << internal::demangle< Rule >() << std::endl; - return normal< Rule >::template apply< Action >( begin, in, st... ); - } - - template< template< typename... > class Action, typename Iterator, typename Input, typename... States > - static auto apply( const Iterator& begin, const Input& in, trace_state& ts, States&&... st ) - -> decltype( apply< Action >( begin, in, st... ) ) - { - std::cerr << std::setw( 6 ) << ++ts.line << " "; - return apply< Action >( begin, in, st... ); - } - - template< template< typename... > class Action, typename Input, typename... States > - static auto apply0( const Input& in, States&&... st ) - -> decltype( normal< Rule >::template apply0< Action >( in, st... ) ) - { - std::cerr << in.position() << " apply0 " << internal::demangle< Rule >() << std::endl; - return normal< Rule >::template apply0< Action >( in, st... ); - } - - template< template< typename... > class Action, typename Input, typename... States > - static auto apply0( const Input& in, trace_state& ts, States&&... st ) - -> decltype( apply0< Action >( in, st... ) ) - { - std::cerr << std::setw( 6 ) << ++ts.line << " "; - return apply0< Action >( in, st... ); - } - }; - -#else - - template< template< typename... > class Base > - struct trace - { - template< typename Rule > - struct control - : Base< Rule > - { - template< typename Input, typename... States > - static void start( const Input& in, States&&... st ) - { - std::cerr << in.position() << " start " << internal::demangle< Rule >() << "; current "; - print_current( in ); - std::cerr << std::endl; - Base< Rule >::start( in, st... ); - } - - template< typename Input, typename... States > - static void start( const Input& in, trace_state& ts, States&&... st ) - { - std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ++ts.rule << " "; - start( in, st... ); - ts.stack.push_back( ts.rule ); - } - - template< typename Input, typename... States > - static void success( const Input& in, States&&... st ) - { - std::cerr << in.position() << " success " << internal::demangle< Rule >() << "; next "; - print_current( in ); - std::cerr << std::endl; - Base< Rule >::success( in, st... ); - } - - template< typename Input, typename... States > - static void success( const Input& in, trace_state& ts, States&&... st ) - { - assert( !ts.stack.empty() ); - std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ts.stack.back() << " "; - success( in, st... ); - ts.stack.pop_back(); - } - - template< typename Input, typename... States > - static void failure( const Input& in, States&&... st ) - { - std::cerr << in.position() << " failure " << internal::demangle< Rule >() << std::endl; - Base< Rule >::failure( in, st... ); - } - - template< typename Input, typename... States > - static void failure( const Input& in, trace_state& ts, States&&... st ) - { - assert( !ts.stack.empty() ); - std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ts.stack.back() << " "; - failure( in, st... ); - ts.stack.pop_back(); - } - - template< template< typename... > class Action, typename Iterator, typename Input, typename... States > - static auto apply( const Iterator& begin, const Input& in, States&&... st ) - -> decltype( Base< Rule >::template apply< Action >( begin, in, st... ) ) - { - std::cerr << in.position() << " apply " << internal::demangle< Rule >() << std::endl; - return Base< Rule >::template apply< Action >( begin, in, st... ); - } - - template< template< typename... > class Action, typename Iterator, typename Input, typename... States > - static auto apply( const Iterator& begin, const Input& in, trace_state& ts, States&&... st ) - -> decltype( apply< Action >( begin, in, st... ) ) - { - std::cerr << std::setw( 6 ) << ++ts.line << " "; - return apply< Action >( begin, in, st... ); - } - - template< template< typename... > class Action, typename Input, typename... States > - static auto apply0( const Input& in, States&&... st ) - -> decltype( Base< Rule >::template apply0< Action >( in, st... ) ) - { - std::cerr << in.position() << " apply0 " << internal::demangle< Rule >() << std::endl; - return Base< Rule >::template apply0< Action >( in, st... ); - } - - template< template< typename... > class Action, typename Input, typename... States > - static auto apply0( const Input& in, trace_state& ts, States&&... st ) - -> decltype( apply0< Action >( in, st... ) ) - { - std::cerr << std::setw( 6 ) << ++ts.line << " "; - return apply0< Action >( in, st... ); - } - }; - }; - - template< typename Rule > - using tracer = trace< normal >::control< Rule >; - -#endif - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/unescape.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/unescape.hpp deleted file mode 100644 index 9b6090a..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/unescape.hpp +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_UNESCAPE_HPP -#define TAO_PEGTL_CONTRIB_UNESCAPE_HPP - -#include -#include - -#include "../ascii.hpp" -#include "../config.hpp" -#include "../parse_error.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace unescape - { - // Utility functions for the unescape actions. - - inline bool utf8_append_utf32( std::string& string, const unsigned utf32 ) - { - if( utf32 <= 0x7f ) { - string += char( utf32 & 0xff ); - return true; - } - if( utf32 <= 0x7ff ) { - char tmp[] = { char( ( ( utf32 & 0x7c0 ) >> 6 ) | 0xc0 ), // NOLINT - char( ( ( utf32 & 0x03f ) ) | 0x80 ) }; - string.append( tmp, sizeof( tmp ) ); - return true; - } - if( utf32 <= 0xffff ) { - if( utf32 >= 0xd800 && utf32 <= 0xdfff ) { - // nope, this is a UTF-16 surrogate - return false; - } - char tmp[] = { char( ( ( utf32 & 0xf000 ) >> 12 ) | 0xe0 ), // NOLINT - char( ( ( utf32 & 0x0fc0 ) >> 6 ) | 0x80 ), - char( ( ( utf32 & 0x003f ) ) | 0x80 ) }; - string.append( tmp, sizeof( tmp ) ); - return true; - } - if( utf32 <= 0x10ffff ) { - char tmp[] = { char( ( ( utf32 & 0x1c0000 ) >> 18 ) | 0xf0 ), // NOLINT - char( ( ( utf32 & 0x03f000 ) >> 12 ) | 0x80 ), - char( ( ( utf32 & 0x000fc0 ) >> 6 ) | 0x80 ), - char( ( ( utf32 & 0x00003f ) ) | 0x80 ) }; - string.append( tmp, sizeof( tmp ) ); - return true; - } - return false; - } - - // This function MUST only be called for characters matching TAO_PEGTL_NAMESPACE::ascii::xdigit! - template< typename I > - I unhex_char( const char c ) - { - switch( c ) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return I( c - '0' ); - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - return I( c - 'a' + 10 ); - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - return I( c - 'A' + 10 ); - default: // LCOV_EXCL_LINE - throw std::runtime_error( "invalid character in unhex" ); // NOLINT, LCOV_EXCL_LINE - } - } - - template< typename I > - I unhex_string( const char* begin, const char* end ) - { - I r = 0; - while( begin != end ) { - r <<= 4; - r += unhex_char< I >( *begin++ ); - } - return r; - } - - // Actions for common unescape situations. - - struct append_all - { - template< typename Input > - static void apply( const Input& in, std::string& s ) - { - s.append( in.begin(), in.size() ); - } - }; - - // This action MUST be called for a character matching T which MUST be TAO_PEGTL_NAMESPACE::one< ... >. - template< typename T, char... Rs > - struct unescape_c - { - template< typename Input > - static void apply( const Input& in, std::string& s ) - { - assert( in.size() == 1 ); - s += apply_one( in, static_cast< const T* >( nullptr ) ); - } - - template< typename Input, char... Qs > - static char apply_one( const Input& in, const one< Qs... >* /*unused*/ ) - { - static_assert( sizeof...( Qs ) == sizeof...( Rs ), "size mismatch between escaped characters and their mappings" ); - return apply_two( in, { Qs... }, { Rs... } ); - } - - template< typename Input > - static char apply_two( const Input& in, const std::initializer_list< char >& q, const std::initializer_list< char >& r ) - { - const char c = *in.begin(); - for( std::size_t i = 0; i < q.size(); ++i ) { - if( *( q.begin() + i ) == c ) { - return *( r.begin() + i ); - } - } - throw parse_error( "invalid character in unescape", in ); // NOLINT, LCOV_EXCL_LINE - } - }; - - // See src/example/pegtl/unescape.cpp for why the following two actions - // skip the first input character. They also MUST be called - // with non-empty matched inputs! - - struct unescape_u - { - template< typename Input > - static void apply( const Input& in, std::string& s ) - { - assert( !in.empty() ); // First character MUST be present, usually 'u' or 'U'. - if( !utf8_append_utf32( s, unhex_string< unsigned >( in.begin() + 1, in.end() ) ) ) { - throw parse_error( "invalid escaped unicode code point", in ); - } - } - }; - - struct unescape_x - { - template< typename Input > - static void apply( const Input& in, std::string& s ) - { - assert( !in.empty() ); // First character MUST be present, usually 'x'. - s += unhex_string< char >( in.begin() + 1, in.end() ); - } - }; - - // The unescape_j action is similar to unescape_u, however unlike - // unescape_u it - // (a) assumes exactly 4 hexdigits per escape sequence, - // (b) accepts multiple consecutive escaped 16-bit values. - // When applied to more than one escape sequence, unescape_j - // translates UTF-16 surrogate pairs in the input into a single - // UTF-8 sequence in s, as required for JSON by RFC 8259. - - struct unescape_j - { - template< typename Input > - static void apply( const Input& in, std::string& s ) - { - assert( ( ( in.size() + 1 ) % 6 ) == 0 ); // Expects multiple "\\u1234", starting with the first "u". - for( const char* b = in.begin() + 1; b < in.end(); b += 6 ) { - const auto c = unhex_string< unsigned >( b, b + 4 ); - if( ( 0xd800 <= c ) && ( c <= 0xdbff ) && ( b + 6 < in.end() ) ) { - const auto d = unhex_string< unsigned >( b + 6, b + 10 ); - if( ( 0xdc00 <= d ) && ( d <= 0xdfff ) ) { - b += 6; - (void)utf8_append_utf32( s, ( ( ( c & 0x03ff ) << 10 ) | ( d & 0x03ff ) ) + 0x10000 ); - continue; - } - } - if( !utf8_append_utf32( s, c ) ) { - throw parse_error( "invalid escaped unicode code point", in ); - } - } - } - }; - - } // namespace unescape - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/uri.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/uri.hpp deleted file mode 100644 index f86d2de..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/contrib/uri.hpp +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_URI_HPP -#define TAO_PEGTL_CONTRIB_URI_HPP - -#include "../ascii.hpp" -#include "../config.hpp" -#include "../rules.hpp" -#include "../utf8.hpp" - -#include "abnf.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace uri - { - // URI grammar according to RFC 3986. - - // This grammar is a direct PEG translation of the original URI grammar. - // It should be considered experimental -- in case of any issues, in particular - // missing rules for attached actions, please contact the developers. - - // Note that this grammar has multiple top-level rules. - - using dot = one< '.' >; - using colon = one< ':' >; - - // clang-format off - struct dec_octet : sor< one< '0' >, - rep_min_max< 1, 2, abnf::DIGIT >, - seq< one< '1' >, abnf::DIGIT, abnf::DIGIT >, - seq< one< '2' >, range< '0', '4' >, abnf::DIGIT >, - seq< string< '2', '5' >, range< '0', '5' > > > {}; - - struct IPv4address : seq< dec_octet, dot, dec_octet, dot, dec_octet, dot, dec_octet > {}; - - struct h16 : rep_min_max< 1, 4, abnf::HEXDIG > {}; - struct ls32 : sor< seq< h16, colon, h16 >, IPv4address > {}; - - struct dcolon : two< ':' > {}; - - struct IPv6address : sor< seq< rep< 6, h16, colon >, ls32 >, - seq< dcolon, rep< 5, h16, colon >, ls32 >, - seq< opt< h16 >, dcolon, rep< 4, h16, colon >, ls32 >, - seq< opt< h16, opt< colon, h16 > >, dcolon, rep< 3, h16, colon >, ls32 >, - seq< opt< h16, rep_opt< 2, colon, h16 > >, dcolon, rep< 2, h16, colon >, ls32 >, - seq< opt< h16, rep_opt< 3, colon, h16 > >, dcolon, h16, colon, ls32 >, - seq< opt< h16, rep_opt< 4, colon, h16 > >, dcolon, ls32 >, - seq< opt< h16, rep_opt< 5, colon, h16 > >, dcolon, h16 >, - seq< opt< h16, rep_opt< 6, colon, h16 > >, dcolon > > {}; - - struct gen_delims : one< ':', '/', '?', '#', '[', ']', '@' > {}; - struct sub_delims : one< '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=' > {}; - - struct unreserved : sor< abnf::ALPHA, abnf::DIGIT, one< '-', '.', '_', '~' > > {}; - struct reserved : sor< gen_delims, sub_delims > {}; - - struct IPvFuture : if_must< one< 'v' >, plus< abnf::HEXDIG >, dot, plus< sor< unreserved, sub_delims, colon > > > {}; - - struct IP_literal : if_must< one< '[' >, sor< IPvFuture, IPv6address >, one< ']' > > {}; - - struct pct_encoded : if_must< one< '%' >, abnf::HEXDIG, abnf::HEXDIG > {}; - struct pchar : sor< unreserved, pct_encoded, sub_delims, one< ':', '@' > > {}; - - struct query : star< sor< pchar, one< '/', '?' > > > {}; - struct fragment : star< sor< pchar, one< '/', '?' > > > {}; - - struct segment : star< pchar > {}; - struct segment_nz : plus< pchar > {}; - struct segment_nz_nc : plus< sor< unreserved, pct_encoded, sub_delims, one< '@' > > > {}; // non-zero-length segment without any colon ":" - - struct path_abempty : star< one< '/' >, segment > {}; - struct path_absolute : seq< one< '/' >, opt< segment_nz, star< one< '/' >, segment > > > {}; - struct path_noscheme : seq< segment_nz_nc, star< one< '/' >, segment > > {}; - struct path_rootless : seq< segment_nz, star< one< '/' >, segment > > {}; - struct path_empty : success {}; - - struct path : sor< path_noscheme, // begins with a non-colon segment - path_rootless, // begins with a segment - path_absolute, // begins with "/" but not "//" - path_abempty > {}; // begins with "/" or is empty - - struct reg_name : star< sor< unreserved, pct_encoded, sub_delims > > {}; - - struct port : star< abnf::DIGIT > {}; - struct host : sor< IP_literal, IPv4address, reg_name > {}; - struct userinfo : star< sor< unreserved, pct_encoded, sub_delims, colon > > {}; - struct opt_userinfo : opt< userinfo, one< '@' > > {}; - struct authority : seq< opt_userinfo, host, opt< colon, port > > {}; - - struct scheme : seq< abnf::ALPHA, star< sor< abnf::ALPHA, abnf::DIGIT, one< '+', '-', '.' > > > > {}; - - using dslash = two< '/' >; - using opt_query = opt_must< one< '?' >, query >; - using opt_fragment = opt_must< one< '#' >, fragment >; - - struct hier_part : sor< if_must< dslash, authority, path_abempty >, path_rootless, path_absolute, path_empty > {}; - struct relative_part : sor< if_must< dslash, authority, path_abempty >, path_noscheme, path_absolute, path_empty > {}; - struct relative_ref : seq< relative_part, opt_query, opt_fragment > {}; - - struct URI : seq< scheme, one< ':' >, hier_part, opt_query, opt_fragment > {}; - struct URI_reference : sor< URI, relative_ref > {}; - struct absolute_URI : seq< scheme, one< ':' >, hier_part, opt_query > {}; - // clang-format on - - } // namespace uri - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/cstream_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/cstream_input.hpp deleted file mode 100644 index d14e828..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/cstream_input.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CSTREAM_INPUT_HPP -#define TAO_PEGTL_CSTREAM_INPUT_HPP - -#include - -#include "buffer_input.hpp" -#include "config.hpp" -#include "eol.hpp" - -#include "internal/cstream_reader.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - template< typename Eol = eol::lf_crlf, std::size_t Chunk = 64 > - struct cstream_input - : buffer_input< internal::cstream_reader, Eol, std::string, Chunk > - { - template< typename T > - cstream_input( std::FILE* in_stream, const std::size_t in_maximum, T&& in_source ) - : buffer_input< internal::cstream_reader, Eol, std::string, Chunk >( std::forward< T >( in_source ), in_maximum, in_stream ) - { - } - }; - -#ifdef __cpp_deduction_guides - template< typename... Ts > - cstream_input( Ts&&... )->cstream_input<>; -#endif - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/disable_action.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/disable_action.hpp deleted file mode 100644 index de51f0b..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/disable_action.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_DISABLE_ACTION_HPP -#define TAO_PEGTL_DISABLE_ACTION_HPP - -#include "apply_mode.hpp" -#include "config.hpp" -#include "match.hpp" -#include "nothing.hpp" -#include "rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - struct disable_action - : maybe_nothing - { - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return TAO_PEGTL_NAMESPACE::match< Rule, apply_mode::nothing, M, Action, Control >( in, st... ); - } - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input.hpp deleted file mode 100644 index e2e226f..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_DISCARD_INPUT_HPP -#define TAO_PEGTL_DISCARD_INPUT_HPP - -#include "apply_mode.hpp" -#include "config.hpp" -#include "match.hpp" -#include "nothing.hpp" -#include "rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - struct discard_input - : maybe_nothing - { - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - const bool result = TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... ); - in.discard(); - return result; - } - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input_on_failure.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input_on_failure.hpp deleted file mode 100644 index 1be1bdb..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input_on_failure.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_DISCARD_INPUT_ON_FAILURE_HPP -#define TAO_PEGTL_DISCARD_INPUT_ON_FAILURE_HPP - -#include "apply_mode.hpp" -#include "config.hpp" -#include "match.hpp" -#include "nothing.hpp" -#include "rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - struct discard_input_on_failure - : maybe_nothing - { - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - const bool result = TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... ); - if( !result ) { - in.discard(); - } - return result; - } - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input_on_success.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input_on_success.hpp deleted file mode 100644 index 56cc1cb..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/discard_input_on_success.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_DISCARD_INPUT_ON_SUCCESS_HPP -#define TAO_PEGTL_DISCARD_INPUT_ON_SUCCESS_HPP - -#include "apply_mode.hpp" -#include "config.hpp" -#include "match.hpp" -#include "nothing.hpp" -#include "rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - struct discard_input_on_success - : maybe_nothing - { - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - const bool result = TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... ); - if( result ) { - in.discard(); - } - return result; - } - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/enable_action.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/enable_action.hpp deleted file mode 100644 index 12447c3..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/enable_action.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_ENABLE_ACTION_HPP -#define TAO_PEGTL_ENABLE_ACTION_HPP - -#include "apply_mode.hpp" -#include "config.hpp" -#include "match.hpp" -#include "nothing.hpp" -#include "rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - struct enable_action - : maybe_nothing - { - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return TAO_PEGTL_NAMESPACE::match< Rule, apply_mode::action, M, Action, Control >( in, st... ); - } - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/eol.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/eol.hpp deleted file mode 100644 index e815064..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/eol.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_EOL_HPP -#define TAO_PEGTL_EOL_HPP - -#include "config.hpp" - -#include "internal/eol.hpp" - -#include "internal/cr_crlf_eol.hpp" -#include "internal/cr_eol.hpp" -#include "internal/crlf_eol.hpp" -#include "internal/lf_crlf_eol.hpp" -#include "internal/lf_eol.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - inline namespace ascii - { - // this is both a rule and a pseudo-namespace for eol::cr, ... - struct eol : internal::eol - { - // clang-format off - struct cr : internal::cr_eol {}; - struct cr_crlf : internal::cr_crlf_eol {}; - struct crlf : internal::crlf_eol {}; - struct lf : internal::lf_eol {}; - struct lf_crlf : internal::lf_crlf_eol {}; - // clang-format on - }; - - } // namespace ascii - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/eol_pair.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/eol_pair.hpp deleted file mode 100644 index 5e3072b..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/eol_pair.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_EOL_PAIR_HPP -#define TAO_PEGTL_EOL_PAIR_HPP - -#include -#include - -#include "config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - using eol_pair = std::pair< bool, std::size_t >; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/file_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/file_input.hpp deleted file mode 100644 index b2c66d9..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/file_input.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2015-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_FILE_INPUT_HPP -#define TAO_PEGTL_FILE_INPUT_HPP - -#include "config.hpp" -#include "eol.hpp" -#include "tracking_mode.hpp" - -#if defined( __unix__ ) || ( defined( __APPLE__ ) && defined( __MACH__ ) ) -#include // Required for _POSIX_MAPPED_FILES -#endif - -#if defined( _POSIX_MAPPED_FILES ) || defined( _WIN32 ) -#include "mmap_input.hpp" -#else -#include "read_input.hpp" -#endif - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { -#if defined( _POSIX_MAPPED_FILES ) || defined( _WIN32 ) - template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > - struct file_input - : mmap_input< P, Eol > - { - using mmap_input< P, Eol >::mmap_input; - }; -#else - template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > - struct file_input - : read_input< P, Eol > - { - using read_input< P, Eol >::read_input; - }; -#endif - -#ifdef __cpp_deduction_guides - template< typename... Ts > - explicit file_input( Ts&&... )->file_input<>; -#endif - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/input_error.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/input_error.hpp deleted file mode 100644 index 08cb00b..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/input_error.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INPUT_ERROR_HPP -#define TAO_PEGTL_INPUT_ERROR_HPP - -#include -#include -#include - -#include "config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - struct input_error - : std::runtime_error - { - input_error( const std::string& message, const int in_errorno ) - : std::runtime_error( message ), - errorno( in_errorno ) - { - } - - int errorno; - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#define TAO_PEGTL_INTERNAL_UNWRAP( ... ) __VA_ARGS__ - -#define TAO_PEGTL_THROW_INPUT_ERROR( MESSAGE ) \ - do { \ - const int errorno = errno; \ - std::ostringstream oss; \ - oss << "pegtl: " << TAO_PEGTL_INTERNAL_UNWRAP( MESSAGE ) << " errno " << errorno; \ - throw tao::TAO_PEGTL_NAMESPACE::input_error( oss.str(), errorno ); \ - } while( false ) - -#define TAO_PEGTL_THROW_INPUT_WIN32_ERROR( MESSAGE ) \ - do { \ - const int errorno = GetLastError(); \ - std::ostringstream oss; \ - oss << "pegtl: " << TAO_PEGTL_INTERNAL_UNWRAP( MESSAGE ) << " GetLastError() " << errorno; \ - throw tao::TAO_PEGTL_NAMESPACE::input_error( oss.str(), errorno ); \ - } while( false ) - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/action.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/action.hpp deleted file mode 100644 index ac69362..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/action.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_ACTION_HPP -#define TAO_PEGTL_INTERNAL_ACTION_HPP - -#include "../config.hpp" - -#include "seq.hpp" -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< template< typename... > class Action, typename... Rules > - struct action - : action< Action, seq< Rules... > > - { - }; - - template< template< typename... > class Action, typename Rule > - struct action< Action, Rule > - { - using analyze_t = analysis::generic< analysis::rule_type::seq, Rule >; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return Control< Rule >::template match< A, M, Action, Control >( in, st... ); - } - }; - - template< template< typename... > class Action, typename... Rules > - struct skip_control< action< Action, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/action_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/action_input.hpp deleted file mode 100644 index 023bae9..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/action_input.hpp +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_ACTION_INPUT_HPP -#define TAO_PEGTL_INTERNAL_ACTION_INPUT_HPP - -#include -#include -#include - -#include "iterator.hpp" - -#include "../config.hpp" -#include "../position.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - inline const char* begin_c_ptr( const char* p ) noexcept - { - return p; - } - - inline const char* begin_c_ptr( const iterator& it ) noexcept - { - return it.data; - } - - template< typename Input > - class action_input - { - public: - using input_t = Input; - using iterator_t = typename Input::iterator_t; - - action_input( const iterator_t& in_begin, const Input& in_input ) noexcept - : m_begin( in_begin ), - m_input( in_input ) - { - } - - action_input( const action_input& ) = delete; - action_input( action_input&& ) = delete; - - ~action_input() = default; - - action_input& operator=( const action_input& ) = delete; - action_input& operator=( action_input&& ) = delete; - - const iterator_t& iterator() const noexcept - { - return m_begin; - } - - const Input& input() const noexcept - { - return m_input; - } - - const char* begin() const noexcept - { - return begin_c_ptr( iterator() ); - } - - const char* end() const noexcept - { - return input().current(); - } - - bool empty() const noexcept - { - return begin() == end(); - } - - std::size_t size() const noexcept - { - return std::size_t( end() - begin() ); - } - - std::string string() const - { - return std::string( begin(), end() ); - } - - char peek_char( const std::size_t offset = 0 ) const noexcept - { - return begin()[ offset ]; - } - - std::uint8_t peek_uint8( const std::size_t offset = 0 ) const noexcept - { - return static_cast< std::uint8_t >( peek_char( offset ) ); - } - - // Compatibility, remove with 3.0.0 - std::uint8_t peek_byte( const std::size_t offset = 0 ) const noexcept - { - return static_cast< std::uint8_t >( peek_char( offset ) ); - } - - TAO_PEGTL_NAMESPACE::position position() const - { - return input().position( iterator() ); // NOTE: Not efficient with lazy inputs. - } - - protected: - const iterator_t m_begin; - const Input& m_input; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/alnum.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/alnum.hpp deleted file mode 100644 index de96d3a..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/alnum.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_ALNUM_HPP -#define TAO_PEGTL_INTERNAL_ALNUM_HPP - -#include "../config.hpp" - -#include "peek_char.hpp" -#include "ranges.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - using alnum = ranges< peek_char, 'a', 'z', 'A', 'Z', '0', '9' >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/alpha.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/alpha.hpp deleted file mode 100644 index aeeebfd..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/alpha.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_ALPHA_HPP -#define TAO_PEGTL_INTERNAL_ALPHA_HPP - -#include "../config.hpp" - -#include "peek_char.hpp" -#include "ranges.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - using alpha = ranges< peek_char, 'a', 'z', 'A', 'Z' >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/always_false.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/always_false.hpp deleted file mode 100644 index 8683cad..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/always_false.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_ALWAYS_FALSE_HPP -#define TAO_PEGTL_INTERNAL_ALWAYS_FALSE_HPP - -#include "../config.hpp" - -#include - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename... > - struct always_false - : std::false_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/any.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/any.hpp deleted file mode 100644 index b1aee22..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/any.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_ANY_HPP -#define TAO_PEGTL_INTERNAL_ANY_HPP - -#include "../config.hpp" - -#include "peek_char.hpp" -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Peek > - struct any; - - template<> - struct any< peek_char > - { - using analyze_t = analysis::generic< analysis::rule_type::any >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.empty() ) ) - { - if( !in.empty() ) { - in.bump(); - return true; - } - return false; - } - }; - - template< typename Peek > - struct any - { - using analyze_t = analysis::generic< analysis::rule_type::any >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) ) - { - if( const auto t = Peek::peek( in ) ) { - in.bump( t.size ); - return true; - } - return false; - } - }; - - template< typename Peek > - struct skip_control< any< Peek > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply.hpp deleted file mode 100644 index a2d35d8..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply.hpp +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_APPLY_HPP -#define TAO_PEGTL_INTERNAL_APPLY_HPP - -#include "../config.hpp" - -#include "apply_single.hpp" -#include "skip_control.hpp" - -#include "../analysis/counted.hpp" -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< apply_mode A, typename... Actions > - struct apply_impl; - - template<> - struct apply_impl< apply_mode::action > - { - template< typename Input, typename... States > - static bool match( Input& /*unused*/, States&&... /*unused*/ ) - { - return true; - } - }; - - template< typename... Actions > - struct apply_impl< apply_mode::action, Actions... > - { - template< typename Input, typename... States > - static bool match( Input& in, States&&... st ) - { - using action_t = typename Input::action_t; - const action_t i2( in.iterator(), in ); // No data -- range is from begin to begin. -#ifdef __cpp_fold_expressions - return ( apply_single< Actions >::match( i2, st... ) && ... ); -#else - bool result = true; - using swallow = bool[]; - (void)swallow{ result = result && apply_single< Actions >::match( i2, st... )... }; - return result; -#endif - } - }; - - template< typename... Actions > - struct apply_impl< apply_mode::nothing, Actions... > - { - template< typename Input, typename... States > - static bool match( Input& /*unused*/, States&&... /*unused*/ ) - { - return true; - } - }; - - template< typename... Actions > - struct apply - { - using analyze_t = analysis::counted< analysis::rule_type::any, 0 >; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return apply_impl< A, Actions... >::match( in, st... ); - } - }; - - template< typename... Actions > - struct skip_control< apply< Actions... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply0.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply0.hpp deleted file mode 100644 index 192c9c5..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply0.hpp +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_APPLY0_HPP -#define TAO_PEGTL_INTERNAL_APPLY0_HPP - -#include "../config.hpp" - -#include "apply0_single.hpp" -#include "skip_control.hpp" - -#include "../analysis/counted.hpp" -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< apply_mode A, typename... Actions > - struct apply0_impl; - - template<> - struct apply0_impl< apply_mode::action > - { - template< typename... States > - static bool match( States&&... /*unused*/ ) noexcept - { - return true; - } - }; - - template< typename... Actions > - struct apply0_impl< apply_mode::action, Actions... > - { - template< typename... States > - static bool match( States&&... st ) - { -#ifdef __cpp_fold_expressions - return ( apply0_single< Actions >::match( st... ) && ... ); -#else - bool result = true; - using swallow = bool[]; - (void)swallow{ result = result && apply0_single< Actions >::match( st... )... }; - return result; -#endif - } - }; - - template< typename... Actions > - struct apply0_impl< apply_mode::nothing, Actions... > - { - template< typename... States > - static bool match( States&&... /*unused*/ ) noexcept - { - return true; - } - }; - - template< typename... Actions > - struct apply0 - { - using analyze_t = analysis::counted< analysis::rule_type::any, 0 >; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& /*unused*/, States&&... st ) - { - return apply0_impl< A, Actions... >::match( st... ); - } - }; - - template< typename... Actions > - struct skip_control< apply0< Actions... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply0_single.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply0_single.hpp deleted file mode 100644 index 7fe8cac..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply0_single.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_APPLY0_SINGLE_HPP -#define TAO_PEGTL_INTERNAL_APPLY0_SINGLE_HPP - -#include "../config.hpp" - -#include - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Action > - struct apply0_single - { - template< typename... States > - static auto match( States&&... st ) - -> typename std::enable_if< std::is_same< decltype( Action::apply0( st... ) ), void >::value, bool >::type - { - Action::apply0( st... ); - return true; - } - - template< typename... States > - static auto match( States&&... st ) - -> typename std::enable_if< std::is_same< decltype( Action::apply0( st... ) ), bool >::value, bool >::type - { - return Action::apply0( st... ); - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply_single.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply_single.hpp deleted file mode 100644 index 5300cbc..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/apply_single.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_APPLY_SINGLE_HPP -#define TAO_PEGTL_INTERNAL_APPLY_SINGLE_HPP - -#include "../config.hpp" - -#include - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Action > - struct apply_single - { - template< typename Input, typename... States > - static auto match( const Input& i2, States&&... st ) - -> typename std::enable_if< std::is_same< decltype( Action::apply( i2, st... ) ), void >::value, bool >::type - { - Action::apply( i2, st... ); - return true; - } - - template< typename Input, typename... States > - static auto match( const Input& i2, States&&... st ) - -> typename std::enable_if< std::is_same< decltype( Action::apply( i2, st... ) ), bool >::value, bool >::type - { - return Action::apply( i2, st... ); - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/at.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/at.hpp deleted file mode 100644 index 688bda7..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/at.hpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_AT_HPP -#define TAO_PEGTL_INTERNAL_AT_HPP - -#include "../config.hpp" - -#include "seq.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename... Rules > - struct at - : at< seq< Rules... > > - { - }; - - template<> - struct at<> - : trivial< true > - { - }; - - template< typename Rule > - struct at< Rule > - { - using analyze_t = analysis::generic< analysis::rule_type::opt, Rule >; - - template< apply_mode, - rewind_mode, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - const auto m = in.template mark< rewind_mode::required >(); - return Control< Rule >::template match< apply_mode::nothing, rewind_mode::active, Action, Control >( in, st... ); - } - }; - - template< typename... Rules > - struct skip_control< at< Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bof.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bof.hpp deleted file mode 100644 index 2f7327e..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bof.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_BOF_HPP -#define TAO_PEGTL_INTERNAL_BOF_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct bof - { - using analyze_t = analysis::generic< analysis::rule_type::opt >; - - template< typename Input > - static bool match( Input& in ) noexcept - { - return in.byte() == 0; - } - }; - - template<> - struct skip_control< bof > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bol.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bol.hpp deleted file mode 100644 index 0eb3ef7..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bol.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_BOL_HPP -#define TAO_PEGTL_INTERNAL_BOL_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct bol - { - using analyze_t = analysis::generic< analysis::rule_type::opt >; - - template< typename Input > - static bool match( Input& in ) noexcept - { - return in.byte_in_line() == 0; - } - }; - - template<> - struct skip_control< bol > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bump.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bump.hpp deleted file mode 100644 index bbaeb0e..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bump.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_BUMP_HPP -#define TAO_PEGTL_INTERNAL_BUMP_HPP - -#include "../config.hpp" - -#include "iterator.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - inline void bump( iterator& iter, const std::size_t count, const int ch ) noexcept - { - for( std::size_t i = 0; i < count; ++i ) { - if( iter.data[ i ] == ch ) { - ++iter.line; - iter.byte_in_line = 0; - } - else { - ++iter.byte_in_line; - } - } - iter.byte += count; - iter.data += count; - } - - inline void bump_in_this_line( iterator& iter, const std::size_t count ) noexcept - { - iter.data += count; - iter.byte += count; - iter.byte_in_line += count; - } - - inline void bump_to_next_line( iterator& iter, const std::size_t count ) noexcept - { - ++iter.line; - iter.byte += count; - iter.byte_in_line = 0; - iter.data += count; - } - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bump_help.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bump_help.hpp deleted file mode 100644 index fce2fad..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bump_help.hpp +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2015-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_BUMP_HELP_HPP -#define TAO_PEGTL_INTERNAL_BUMP_HELP_HPP - -#include -#include - -#include "../config.hpp" - -#include "result_on_found.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< bool > - struct bump_impl; - - template<> - struct bump_impl< true > - { - template< typename Input > - static void bump( Input& in, const std::size_t count ) noexcept - { - in.bump( count ); - } - }; - - template<> - struct bump_impl< false > - { - template< typename Input > - static void bump( Input& in, const std::size_t count ) noexcept - { - in.bump_in_this_line( count ); - } - }; - - template< bool... > - struct bool_list - { - }; - - template< bool... Bs > - using bool_and = std::is_same< bool_list< Bs..., true >, bool_list< true, Bs... > >; - - template< result_on_found R, typename Input, typename Char, Char... Cs > - void bump_help( Input& in, const std::size_t count ) noexcept - { - bump_impl< bool_and< ( Cs != Input::eol_t::ch )... >::value != bool( R ) >::bump( in, count ); - } - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bytes.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bytes.hpp deleted file mode 100644 index 10c6c85..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/bytes.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_BYTES_HPP -#define TAO_PEGTL_INTERNAL_BYTES_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/counted.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< unsigned Num > - struct bytes - { - using analyze_t = analysis::counted< analysis::rule_type::any, Num >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) ) - { - if( in.size( Num ) >= Num ) { - in.bump( Num ); - return true; - } - return false; - } - }; - - template< unsigned Num > - struct skip_control< bytes< Num > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/control.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/control.hpp deleted file mode 100644 index dcef9a4..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/control.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_CONTROL_HPP -#define TAO_PEGTL_INTERNAL_CONTROL_HPP - -#include "../config.hpp" - -#include "seq.hpp" -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< template< typename... > class Control, typename... Rules > - struct control - : control< Control, seq< Rules... > > - { - }; - - template< template< typename... > class Control, typename Rule > - struct control< Control, Rule > - { - using analyze_t = analysis::generic< analysis::rule_type::seq, Rule >; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return Control< Rule >::template match< A, M, Action, Control >( in, st... ); - } - }; - - template< template< typename... > class Control, typename... Rules > - struct skip_control< control< Control, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cr_crlf_eol.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cr_crlf_eol.hpp deleted file mode 100644 index ee75ea3..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cr_crlf_eol.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_CR_CRLF_EOL_HPP -#define TAO_PEGTL_INTERNAL_CR_CRLF_EOL_HPP - -#include "../config.hpp" -#include "../eol_pair.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct cr_crlf_eol - { - static constexpr int ch = '\r'; - - template< typename Input > - static eol_pair match( Input& in ) noexcept( noexcept( in.size( 2 ) ) ) - { - eol_pair p = { false, in.size( 2 ) }; - if( p.second ) { - if( in.peek_char() == '\r' ) { - in.bump_to_next_line( 1 + ( ( p.second > 1 ) && ( in.peek_char( 1 ) == '\n' ) ) ); - p.first = true; - } - } - return p; - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cr_eol.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cr_eol.hpp deleted file mode 100644 index 1ad25f8..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cr_eol.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_CR_EOL_HPP -#define TAO_PEGTL_INTERNAL_CR_EOL_HPP - -#include "../config.hpp" -#include "../eol_pair.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct cr_eol - { - static constexpr int ch = '\r'; - - template< typename Input > - static eol_pair match( Input& in ) noexcept( noexcept( in.size( 1 ) ) ) - { - eol_pair p = { false, in.size( 1 ) }; - if( p.second ) { - if( in.peek_char() == '\r' ) { - in.bump_to_next_line(); - p.first = true; - } - } - return p; - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/crlf_eol.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/crlf_eol.hpp deleted file mode 100644 index 21556ad..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/crlf_eol.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_CRLF_EOL_HPP -#define TAO_PEGTL_INTERNAL_CRLF_EOL_HPP - -#include "../config.hpp" -#include "../eol_pair.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct crlf_eol - { - static constexpr int ch = '\n'; - - template< typename Input > - static eol_pair match( Input& in ) noexcept( noexcept( in.size( 2 ) ) ) - { - eol_pair p = { false, in.size( 2 ) }; - if( p.second > 1 ) { - if( ( in.peek_char() == '\r' ) && ( in.peek_char( 1 ) == '\n' ) ) { - in.bump_to_next_line( 2 ); - p.first = true; - } - } - return p; - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cstream_reader.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cstream_reader.hpp deleted file mode 100644 index 412d45e..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cstream_reader.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_CSTREAM_READER_HPP -#define TAO_PEGTL_INTERNAL_CSTREAM_READER_HPP - -#include -#include -#include - -#include "../config.hpp" -#include "../input_error.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct cstream_reader - { - explicit cstream_reader( std::FILE* s ) noexcept - : m_cstream( s ) - { - assert( m_cstream != nullptr ); - } - - std::size_t operator()( char* buffer, const std::size_t length ) const - { - if( const auto r = std::fread( buffer, 1, length, m_cstream ) ) { - return r; - } - if( std::feof( m_cstream ) != 0 ) { - return 0; - } - // Please contact us if you know how to provoke the following exception. - // The example on cppreference.com doesn't work, at least not on macOS. - TAO_PEGTL_THROW_INPUT_ERROR( "error in fread() from cstream" ); // LCOV_EXCL_LINE - } - - std::FILE* m_cstream; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cstring_reader.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cstring_reader.hpp deleted file mode 100644 index c3a8a08..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/cstring_reader.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_CSTRING_READER_HPP -#define TAO_PEGTL_INTERNAL_CSTRING_READER_HPP - -#include -#include - -#include "../config.hpp" -#include "../input_error.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct cstring_reader - { - explicit cstring_reader( const char* zero_terminated ) noexcept - : m_cstring( zero_terminated ) - { - assert( m_cstring != nullptr ); - } - - std::size_t operator()( char* buffer, const std::size_t length ) noexcept - { - std::size_t i = 0; - char c; - - while( ( i < length ) && ( ( c = m_cstring[ i ] ) != 0 ) ) { - *buffer++ = c; - ++i; - } - m_cstring += i; - return i; - } - - const char* m_cstring; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle.hpp deleted file mode 100644 index f0bd799..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle.hpp +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_DEMANGLE_HPP -#define TAO_PEGTL_INTERNAL_DEMANGLE_HPP - -#include -#include - -#include "../config.hpp" - -#if defined( __clang__ ) -#if __has_feature( cxx_rtti ) -#define TAO_PEGTL_RTTI_ENABLED -#endif -#elif defined( __GNUC__ ) -#if defined( __GXX_RTTI ) -#define TAO_PEGTL_RTTI_ENABLED -#endif -#elif defined( _MSC_VER ) -#if defined( _CPPRTTI ) -#define TAO_PEGTL_RTTI_ENABLED -#endif -#else -#define TAO_PEGTL_RTTI_ENABLED -#endif - -#if !defined( TAO_PEGTL_RTTI_ENABLED ) -#include -#include -#endif - -#if defined( TAO_PEGTL_RTTI_ENABLED ) -#if defined( __GLIBCXX__ ) -#define TAO_PEGTL_USE_CXXABI_DEMANGLE -#elif defined( __has_include ) -#if __has_include( ) -#define TAO_PEGTL_USE_CXXABI_DEMANGLE -#endif -#endif -#endif - -#if defined( TAO_PEGTL_USE_CXXABI_DEMANGLE ) -#include "demangle_cxxabi.hpp" -#undef TAO_PEGTL_USE_CXXABI_DEMANGLE -#else -#include "demangle_nop.hpp" -#endif - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename T > - std::string demangle() - { -#if defined( TAO_PEGTL_RTTI_ENABLED ) - return demangle( typeid( T ).name() ); -#else - const char* start = nullptr; - const char* stop = nullptr; -#if defined( __clang__ ) || defined( __GNUC__ ) - start = std::strchr( __PRETTY_FUNCTION__, '=' ) + 2; - stop = std::strrchr( start, ';' ); -#elif defined( _MSC_VER ) - start = std::strstr( __FUNCSIG__, "demangle<" ) + ( sizeof( "demangle<" ) - 1 ); - stop = std::strrchr( start, '>' ); -#else - static_assert( false, "expected to use rtti with this compiler" ); -#endif - assert( start != nullptr ); - assert( stop != nullptr ); - return { start, std::size_t( stop - start ) }; -#endif - } - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_cxxabi.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_cxxabi.hpp deleted file mode 100644 index 5027e7f..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_cxxabi.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_DEMANGLE_CXXABI_HPP -#define TAO_PEGTL_INTERNAL_DEMANGLE_CXXABI_HPP - -#include -#include -#include -#include - -#include "../config.hpp" - -#include "demangle_sanitise.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - inline std::string demangle( const char* symbol ) - { - const std::unique_ptr< char, decltype( &std::free ) > demangled( abi::__cxa_demangle( symbol, nullptr, nullptr, nullptr ), &std::free ); - if( !demangled ) { - return symbol; - } - std::string result( demangled.get() ); -#ifdef TAO_PEGTL_PRETTY_DEMANGLE - demangle_sanitise_chars( result ); // LCOV_EXCL_LINE -#endif - return result; - } - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_nop.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_nop.hpp deleted file mode 100644 index caea50e..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_nop.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_DEMANGLE_NOP_HPP -#define TAO_PEGTL_INTERNAL_DEMANGLE_NOP_HPP - -#include - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - inline std::string demangle( const char* symbol ) - { - return symbol; - } - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_sanitise.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_sanitise.hpp deleted file mode 100644 index 378f5b0..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/demangle_sanitise.hpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_DEMANGLE_SANITISE_HPP -#define TAO_PEGTL_INTERNAL_DEMANGLE_SANITISE_HPP - -#include - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - inline void demangle_sanitise_chars( std::string& s ) - { - std::string::size_type p; - while( ( p = s.find( "(char)" ) ) != std::string::npos ) { - int c = 0; - std::string::size_type q; - for( q = p + 6; ( q < s.size() ) && ( s[ q ] >= '0' ) && ( s[ q ] <= '9' ); ++q ) { - c *= 10; - c += s[ q ] - '0'; - } - if( c == '\'' ) { - s.replace( p, q - p, "'\\''" ); - } - else if( c == '\\' ) { - s.replace( p, q - p, "'\\\\'" ); - } - else if( ( c < 32 ) || ( c > 126 ) ) { - s.replace( p, 6, std::string() ); - } - else { - s.replace( p, q - p, std::string( 1, '\'' ) + char( c ) + '\'' ); - } - } - } - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/disable.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/disable.hpp deleted file mode 100644 index 3f6238e..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/disable.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_DISABLE_HPP -#define TAO_PEGTL_INTERNAL_DISABLE_HPP - -#include "../config.hpp" - -#include "seq.hpp" -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename... Rules > - struct disable - : disable< seq< Rules... > > - { - }; - - template< typename Rule > - struct disable< Rule > - { - using analyze_t = analysis::generic< analysis::rule_type::seq, Rule >; - - template< apply_mode, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return Control< Rule >::template match< apply_mode::nothing, M, Action, Control >( in, st... ); - } - }; - - template< typename... Rules > - struct skip_control< disable< Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/discard.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/discard.hpp deleted file mode 100644 index 05ca46f..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/discard.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_DISCARD_HPP -#define TAO_PEGTL_INTERNAL_DISCARD_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct discard - { - using analyze_t = analysis::generic< analysis::rule_type::opt >; - - template< typename Input > - static bool match( Input& in ) noexcept - { - static_assert( noexcept( in.discard() ), "an input's discard()-method must be noexcept" ); - in.discard(); - return true; - } - }; - - template<> - struct skip_control< discard > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/dusel_mode.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/dusel_mode.hpp deleted file mode 100644 index a0e0aba..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/dusel_mode.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_DUSEL_MODE_HPP -#define TAO_PEGTL_INTERNAL_DUSEL_MODE_HPP - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - enum class dusel_mode : char - { - nothing = 0, - control = 1, - control_and_apply_void = 2, - control_and_apply_bool = 3, - control_and_apply0_void = 4, - control_and_apply0_bool = 5, - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/duseltronik.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/duseltronik.hpp deleted file mode 100644 index fc58270..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/duseltronik.hpp +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_DUSELTRONIK_HPP -#define TAO_PEGTL_INTERNAL_DUSELTRONIK_HPP - -#include "../apply_mode.hpp" -#include "../config.hpp" -#include "../rewind_mode.hpp" - -#include "dusel_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - dusel_mode = dusel_mode::nothing > - struct duseltronik; - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control > - struct duseltronik< Rule, A, M, Action, Control, dusel_mode::nothing > - { - template< typename Input, typename... States > - static auto match( Input& in, States&&... st ) - -> decltype( Rule::template match< A, M, Action, Control >( in, st... ), true ) - { - return Rule::template match< A, M, Action, Control >( in, st... ); - } - - // NOTE: The additional "int = 0" is a work-around for missing expression SFINAE in VS2015. - - template< typename Input, typename... States, int = 0 > - static auto match( Input& in, States&&... /*unused*/ ) - -> decltype( Rule::match( in ), true ) - { - return Rule::match( in ); - } - }; - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control > - struct duseltronik< Rule, A, M, Action, Control, dusel_mode::control > - { - template< typename Input, typename... States > - static bool match( Input& in, States&&... st ) - { - Control< Rule >::start( static_cast< const Input& >( in ), st... ); - - if( duseltronik< Rule, A, M, Action, Control, dusel_mode::nothing >::match( in, st... ) ) { - Control< Rule >::success( static_cast< const Input& >( in ), st... ); - return true; - } - Control< Rule >::failure( static_cast< const Input& >( in ), st... ); - return false; - } - }; - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control > - struct duseltronik< Rule, A, M, Action, Control, dusel_mode::control_and_apply_void > - { - template< typename Input, typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< rewind_mode::required >(); - - Control< Rule >::start( static_cast< const Input& >( in ), st... ); - - if( duseltronik< Rule, A, rewind_mode::active, Action, Control, dusel_mode::nothing >::match( in, st... ) ) { - Control< Rule >::template apply< Action >( m.iterator(), static_cast< const Input& >( in ), st... ); - Control< Rule >::success( static_cast< const Input& >( in ), st... ); - return m( true ); - } - Control< Rule >::failure( static_cast< const Input& >( in ), st... ); - return false; - } - }; - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control > - struct duseltronik< Rule, A, M, Action, Control, dusel_mode::control_and_apply_bool > - { - template< typename Input, typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< rewind_mode::required >(); - - Control< Rule >::start( static_cast< const Input& >( in ), st... ); - - if( duseltronik< Rule, A, rewind_mode::active, Action, Control, dusel_mode::nothing >::match( in, st... ) ) { - if( Control< Rule >::template apply< Action >( m.iterator(), static_cast< const Input& >( in ), st... ) ) { - Control< Rule >::success( static_cast< const Input& >( in ), st... ); - return m( true ); - } - } - Control< Rule >::failure( static_cast< const Input& >( in ), st... ); - return false; - } - }; - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control > - struct duseltronik< Rule, A, M, Action, Control, dusel_mode::control_and_apply0_void > - { - template< typename Input, typename... States > - static bool match( Input& in, States&&... st ) - { - Control< Rule >::start( static_cast< const Input& >( in ), st... ); - - if( duseltronik< Rule, A, M, Action, Control, dusel_mode::nothing >::match( in, st... ) ) { - Control< Rule >::template apply0< Action >( static_cast< const Input& >( in ), st... ); - Control< Rule >::success( static_cast< const Input& >( in ), st... ); - return true; - } - Control< Rule >::failure( static_cast< const Input& >( in ), st... ); - return false; - } - }; - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control > - struct duseltronik< Rule, A, M, Action, Control, dusel_mode::control_and_apply0_bool > - { - template< typename Input, typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< rewind_mode::required >(); - - Control< Rule >::start( static_cast< const Input& >( in ), st... ); - - if( duseltronik< Rule, A, rewind_mode::active, Action, Control, dusel_mode::nothing >::match( in, st... ) ) { - if( Control< Rule >::template apply0< Action >( static_cast< const Input& >( in ), st... ) ) { - Control< Rule >::success( static_cast< const Input& >( in ), st... ); - return m( true ); - } - } - Control< Rule >::failure( static_cast< const Input& >( in ), st... ); - return false; - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/enable.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/enable.hpp deleted file mode 100644 index 0b7b2d4..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/enable.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_ENABLE_HPP -#define TAO_PEGTL_INTERNAL_ENABLE_HPP - -#include "../config.hpp" - -#include "seq.hpp" -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename... Rules > - struct enable - : enable< seq< Rules... > > - { - }; - - template< typename Rule > - struct enable< Rule > - { - using analyze_t = analysis::generic< analysis::rule_type::seq, Rule >; - - template< apply_mode, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return Control< Rule >::template match< apply_mode::action, M, Action, Control >( in, st... ); - } - }; - - template< typename... Rules > - struct skip_control< enable< Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian.hpp deleted file mode 100644 index 2aa2c53..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_ENDIAN_HPP -#define TAO_PEGTL_INTERNAL_ENDIAN_HPP - -#include -#include - -#include "../config.hpp" - -#if defined( _WIN32 ) && !defined( __MINGW32__ ) -#include "endian_win.hpp" -#else -#include "endian_gcc.hpp" -#endif - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename N > - N h_to_be( const N n ) noexcept - { - return N( to_and_from_be< sizeof( N ) >::convert( n ) ); - } - - template< typename N > - N be_to_h( const N n ) noexcept - { - return h_to_be( n ); - } - - template< typename N > - N be_to_h( const void* p ) noexcept - { - N n; - std::memcpy( &n, p, sizeof( n ) ); - return internal::be_to_h( n ); - } - - template< typename N > - N h_to_le( const N n ) noexcept - { - return N( to_and_from_le< sizeof( N ) >::convert( n ) ); - } - - template< typename N > - N le_to_h( const N n ) noexcept - { - return h_to_le( n ); - } - - template< typename N > - N le_to_h( const void* p ) noexcept - { - N n; - std::memcpy( &n, p, sizeof( n ) ); - return internal::le_to_h( n ); - } - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian_gcc.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian_gcc.hpp deleted file mode 100644 index 2e180f0..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian_gcc.hpp +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_ENDIAN_GCC_HPP -#define TAO_PEGTL_INTERNAL_ENDIAN_GCC_HPP - -#include -#include - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { -#if !defined( __BYTE_ORDER__ ) -#error No byte order defined! -#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ - - template< std::size_t S > - struct to_and_from_be - { - template< typename T > - static T convert( const T n ) noexcept - { - return n; - } - }; - - template< std::size_t S > - struct to_and_from_le; - - template<> - struct to_and_from_le< 1 > - { - static std::uint8_t convert( const std::uint8_t n ) noexcept - { - return n; - } - - static std::int8_t convert( const std::int8_t n ) noexcept - { - return n; - } - }; - - template<> - struct to_and_from_le< 2 > - { - static std::int16_t convert( const std::int16_t n ) noexcept - { - return static_cast< std::int16_t >( __builtin_bswap16( static_cast< std::uint16_t >( n ) ) ); - } - - static std::uint16_t convert( const std::uint16_t n ) noexcept - { - return __builtin_bswap16( n ); - } - }; - - template<> - struct to_and_from_le< 4 > - { - static float convert( float n ) noexcept - { - std::uint32_t u; - std::memcpy( &u, &n, 4 ); - u = convert( u ); - std::memcpy( &n, &u, 4 ); - return n; - } - - static std::int32_t convert( const std::int32_t n ) noexcept - { - return static_cast< std::int32_t >( __builtin_bswap32( static_cast< std::uint32_t >( n ) ) ); - } - - static std::uint32_t convert( const std::uint32_t n ) noexcept - { - return __builtin_bswap32( n ); - } - }; - - template<> - struct to_and_from_le< 8 > - { - static double convert( double n ) noexcept - { - std::uint64_t u; - std::memcpy( &u, &n, 8 ); - u = convert( u ); - std::memcpy( &n, &u, 8 ); - return n; - } - - static std::int64_t convert( const std::int64_t n ) noexcept - { - return static_cast< std::int64_t >( __builtin_bswap64( static_cast< std::uint64_t >( n ) ) ); - } - - static std::uint64_t convert( const std::uint64_t n ) noexcept - { - return __builtin_bswap64( n ); - } - }; - -#define TAO_PEGTL_NATIVE_ORDER be -#define TAO_PEGTL_NATIVE_UTF16 utf16_be -#define TAO_PEGTL_NATIVE_UTF32 utf32_be - -#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - - template< std::size_t S > - struct to_and_from_le - { - template< typename T > - static T convert( const T n ) noexcept - { - return n; - } - }; - - template< std::size_t S > - struct to_and_from_be; - - template<> - struct to_and_from_be< 1 > - { - static std::int8_t convert( const std::int8_t n ) noexcept - { - return n; - } - - static std::uint8_t convert( const std::uint8_t n ) noexcept - { - return n; - } - }; - - template<> - struct to_and_from_be< 2 > - { - static std::int16_t convert( const std::int16_t n ) noexcept - { - return static_cast< std::int16_t >( __builtin_bswap16( static_cast< std::uint16_t >( n ) ) ); - } - - static std::uint16_t convert( const std::uint16_t n ) noexcept - { - return __builtin_bswap16( n ); - } - }; - - template<> - struct to_and_from_be< 4 > - { - static float convert( float n ) noexcept - { - std::uint32_t u; - std::memcpy( &u, &n, 4 ); - u = convert( u ); - std::memcpy( &n, &u, 4 ); - return n; - } - - static std::int32_t convert( const std::int32_t n ) noexcept - { - return static_cast< std::int32_t >( __builtin_bswap32( static_cast< std::uint32_t >( n ) ) ); - } - - static std::uint32_t convert( const std::uint32_t n ) noexcept - { - return __builtin_bswap32( n ); - } - }; - - template<> - struct to_and_from_be< 8 > - { - static double convert( double n ) noexcept - { - std::uint64_t u; - std::memcpy( &u, &n, 8 ); - u = convert( u ); - std::memcpy( &n, &u, 8 ); - return n; - } - - static std::int64_t convert( const std::int64_t n ) noexcept - { - return static_cast< std::int64_t >( __builtin_bswap64( static_cast< std::uint64_t >( n ) ) ); - } - - static std::uint64_t convert( const std::uint64_t n ) noexcept - { - return __builtin_bswap64( n ); - } - }; - -#define TAO_PEGTL_NATIVE_ORDER le -#define TAO_PEGTL_NATIVE_UTF16 utf16_le -#define TAO_PEGTL_NATIVE_UTF32 utf32_le - -#else -#error Unknown host byte order! -#endif - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian_win.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian_win.hpp deleted file mode 100644 index 19d62aa..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/endian_win.hpp +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_ENDIAN_WIN_HPP -#define TAO_PEGTL_INTERNAL_ENDIAN_WIN_HPP - -#include -#include - -#include - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< std::size_t S > - struct to_and_from_le - { - template< typename T > - static T convert( const T t ) noexcept - { - return t; - } - }; - - template< std::size_t S > - struct to_and_from_be; - - template<> - struct to_and_from_be< 1 > - { - static std::int8_t convert( const std::int8_t n ) noexcept - { - return n; - } - - static std::uint8_t convert( const std::uint8_t n ) noexcept - { - return n; - } - }; - - template<> - struct to_and_from_be< 2 > - { - static std::int16_t convert( const std::int16_t n ) noexcept - { - return std::int16_t( _byteswap_ushort( std::uint16_t( n ) ) ); - } - - static std::uint16_t convert( const std::uint16_t n ) noexcept - { - return _byteswap_ushort( n ); - } - }; - - template<> - struct to_and_from_be< 4 > - { - static float convert( float n ) noexcept - { - std::uint32_t u; - std::memcpy( &u, &n, 4 ); - u = convert( u ); - std::memcpy( &n, &u, 4 ); - return n; - } - - static std::int32_t convert( const std::int32_t n ) noexcept - { - return std::int32_t( _byteswap_ulong( std::uint32_t( n ) ) ); - } - - static std::uint32_t convert( const std::uint32_t n ) noexcept - { - return _byteswap_ulong( n ); - } - }; - - template<> - struct to_and_from_be< 8 > - { - static double convert( double n ) noexcept - { - std::uint64_t u; - std::memcpy( &u, &n, 8 ); - u = convert( u ); - std::memcpy( &n, &u, 8 ); - return n; - } - - static std::int64_t convert( const std::int64_t n ) noexcept - { - return std::int64_t( _byteswap_uint64( std::uint64_t( n ) ) ); - } - - static std::uint64_t convert( const std::uint64_t n ) noexcept - { - return _byteswap_uint64( n ); - } - }; - -#define TAO_PEGTL_NATIVE_ORDER le -#define TAO_PEGTL_NATIVE_UTF16 utf16_le -#define TAO_PEGTL_NATIVE_UTF32 utf32_le - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eof.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eof.hpp deleted file mode 100644 index b3a7542..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eof.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_EOF_HPP -#define TAO_PEGTL_INTERNAL_EOF_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct eof - { - using analyze_t = analysis::generic< analysis::rule_type::opt >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.empty() ) ) - { - return in.empty(); - } - }; - - template<> - struct skip_control< eof > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eol.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eol.hpp deleted file mode 100644 index 3878f95..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eol.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_EOL_HPP -#define TAO_PEGTL_INTERNAL_EOL_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct eol - { - using analyze_t = analysis::generic< analysis::rule_type::any >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( Input::eol_t::match( in ) ) ) - { - return Input::eol_t::match( in ).first; - } - }; - - template<> - struct skip_control< eol > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eolf.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eolf.hpp deleted file mode 100644 index a3fae89..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/eolf.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_EOLF_HPP -#define TAO_PEGTL_INTERNAL_EOLF_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct eolf - { - using analyze_t = analysis::generic< analysis::rule_type::opt >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( Input::eol_t::match( in ) ) ) - { - const auto p = Input::eol_t::match( in ); - return p.first || ( !p.second ); - } - }; - - template<> - struct skip_control< eolf > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_mapper_posix.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_mapper_posix.hpp deleted file mode 100644 index c77529e..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_mapper_posix.hpp +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_FILE_MAPPER_POSIX_HPP -#define TAO_PEGTL_INTERNAL_FILE_MAPPER_POSIX_HPP - -#include -#include - -#include "../config.hpp" - -#include "file_opener.hpp" - -#include "../input_error.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - class file_mapper - { - public: - explicit file_mapper( const char* filename ) - : file_mapper( file_opener( filename ) ) - { - } - - explicit file_mapper( const file_opener& reader ) - : m_size( reader.size() ), - m_data( static_cast< const char* >( ::mmap( nullptr, m_size, PROT_READ, MAP_PRIVATE, reader.m_fd, 0 ) ) ) - { - if( ( m_size != 0 ) && ( intptr_t( m_data ) == -1 ) ) { - TAO_PEGTL_THROW_INPUT_ERROR( "unable to mmap() file " << reader.m_source << " descriptor " << reader.m_fd ); - } - } - - file_mapper( const file_mapper& ) = delete; - file_mapper( file_mapper&& ) = delete; - - ~file_mapper() noexcept - { - // Legacy C interface requires pointer-to-mutable but does not write through the pointer. - ::munmap( const_cast< char* >( m_data ), m_size ); // NOLINT - } - - void operator=( const file_mapper& ) = delete; - void operator=( file_mapper&& ) = delete; - - bool empty() const noexcept - { - return m_size == 0; - } - - std::size_t size() const noexcept - { - return m_size; - } - - using iterator = const char*; - using const_iterator = const char*; - - iterator data() const noexcept - { - return m_data; - } - - iterator begin() const noexcept - { - return m_data; - } - - iterator end() const noexcept - { - return m_data + m_size; - } - - std::string string() const - { - return std::string( m_data, m_size ); - } - - private: - const std::size_t m_size; - const char* const m_data; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_mapper_win32.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_mapper_win32.hpp deleted file mode 100644 index a8cc1a4..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_mapper_win32.hpp +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_FILE_MAPPER_WIN32_HPP -#define TAO_PEGTL_INTERNAL_FILE_MAPPER_WIN32_HPP - -#if !defined( NOMINMAX ) -#define NOMINMAX -#define TAO_PEGTL_NOMINMAX_WAS_DEFINED -#endif - -#if !defined( WIN32_LEAN_AND_MEAN ) -#define WIN32_LEAN_AND_MEAN -#define TAO_PEGTL_WIN32_LEAN_AND_MEAN_WAS_DEFINED -#endif - -#include - -#if defined( TAO_PEGTL_NOMINMAX_WAS_DEFINED ) -#undef NOMINMAX -#undef TAO_PEGTL_NOMINMAX_WAS_DEFINED -#endif - -#if defined( TAO_PEGTL_WIN32_LEAN_AND_MEAN_WAS_DEFINED ) -#undef WIN32_LEAN_AND_MEAN -#undef TAO_PEGTL_WIN32_LEAN_AND_MEAN_WAS_DEFINED -#endif - -#include "../config.hpp" -#include "../input_error.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct win32_file_opener - { - explicit win32_file_opener( const char* filename ) - : m_source( filename ), - m_handle( open() ) - { - } - - win32_file_opener( const win32_file_opener& ) = delete; - win32_file_opener( win32_file_opener&& ) = delete; - - ~win32_file_opener() noexcept - { - ::CloseHandle( m_handle ); - } - - void operator=( const win32_file_opener& ) = delete; - void operator=( win32_file_opener&& ) = delete; - - std::size_t size() const - { - LARGE_INTEGER size; - if( !::GetFileSizeEx( m_handle, &size ) ) { - TAO_PEGTL_THROW_INPUT_WIN32_ERROR( "unable to GetFileSizeEx() file " << m_source << " handle " << m_handle ); - } - return std::size_t( size.QuadPart ); - } - - const char* const m_source; - const HANDLE m_handle; - - private: - HANDLE open() const - { - SetLastError( 0 ); - std::wstring ws( m_source, m_source + strlen( m_source ) ); - -#if( _WIN32_WINNT >= 0x0602 ) - const HANDLE handle = ::CreateFile2( ws.c_str(), - GENERIC_READ, - FILE_SHARE_READ, - OPEN_EXISTING, - nullptr ); - if( handle != INVALID_HANDLE_VALUE ) { - return handle; - } - TAO_PEGTL_THROW_INPUT_WIN32_ERROR( "CreateFile2() failed opening file " << m_source << " for reading" ); -#else - const HANDLE handle = ::CreateFileW( ws.c_str(), - GENERIC_READ, - FILE_SHARE_READ, - nullptr, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - nullptr ); - if( handle != INVALID_HANDLE_VALUE ) { - return handle; - } - TAO_PEGTL_THROW_INPUT_WIN32_ERROR( "CreateFileW() failed opening file " << m_source << " for reading" ); -#endif - } - }; - - struct win32_file_mapper - { - explicit win32_file_mapper( const char* filename ) - : win32_file_mapper( win32_file_opener( filename ) ) - { - } - - explicit win32_file_mapper( const win32_file_opener& reader ) - : m_size( reader.size() ), - m_handle( open( reader ) ) - { - } - - win32_file_mapper( const win32_file_mapper& ) = delete; - win32_file_mapper( win32_file_mapper&& ) = delete; - - ~win32_file_mapper() noexcept - { - ::CloseHandle( m_handle ); - } - - void operator=( const win32_file_mapper& ) = delete; - void operator=( win32_file_mapper&& ) = delete; - - const size_t m_size; - const HANDLE m_handle; - - private: - HANDLE open( const win32_file_opener& reader ) const - { - const uint64_t file_size = reader.size(); - SetLastError( 0 ); - // Use `CreateFileMappingW` because a) we're not specifying a - // mapping name, so the character type is of no consequence, and - // b) it's defined in `memoryapi.h`, unlike - // `CreateFileMappingA`(?!) - const HANDLE handle = ::CreateFileMappingW( reader.m_handle, - nullptr, - PAGE_READONLY, - DWORD( file_size >> 32 ), - DWORD( file_size & 0xffffffff ), - nullptr ); - if( handle != NULL || file_size == 0 ) { - return handle; - } - TAO_PEGTL_THROW_INPUT_WIN32_ERROR( "unable to CreateFileMappingW() file " << reader.m_source << " for reading" ); - } - }; - - class file_mapper - { - public: - explicit file_mapper( const char* filename ) - : file_mapper( win32_file_mapper( filename ) ) - { - } - - explicit file_mapper( const win32_file_mapper& mapper ) - : m_size( mapper.m_size ), - m_data( static_cast< const char* >( ::MapViewOfFile( mapper.m_handle, - FILE_MAP_READ, - 0, - 0, - 0 ) ) ) - { - if( ( m_size != 0 ) && ( intptr_t( m_data ) == 0 ) ) { - TAO_PEGTL_THROW_INPUT_WIN32_ERROR( "unable to MapViewOfFile() file mapping object with handle " << mapper.m_handle ); - } - } - - file_mapper( const file_mapper& ) = delete; - file_mapper( file_mapper&& ) = delete; - - ~file_mapper() noexcept - { - ::UnmapViewOfFile( LPCVOID( m_data ) ); - } - - void operator=( const file_mapper& ) = delete; - void operator=( file_mapper&& ) = delete; - - bool empty() const noexcept - { - return m_size == 0; - } - - std::size_t size() const noexcept - { - return m_size; - } - - using iterator = const char*; - using const_iterator = const char*; - - iterator data() const noexcept - { - return m_data; - } - - iterator begin() const noexcept - { - return m_data; - } - - iterator end() const noexcept - { - return m_data + m_size; - } - - std::string string() const - { - return std::string( m_data, m_size ); - } - - private: - const std::size_t m_size; - const char* const m_data; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_opener.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_opener.hpp deleted file mode 100644 index 33eccb6..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_opener.hpp +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_FILE_OPENER_HPP -#define TAO_PEGTL_INTERNAL_FILE_OPENER_HPP - -#include -#include -#include -#include - -#include - -#include "../config.hpp" -#include "../input_error.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct file_opener - { - explicit file_opener( const char* filename ) - : m_source( filename ), - m_fd( open() ) - { - } - - file_opener( const file_opener& ) = delete; - file_opener( file_opener&& ) = delete; - - ~file_opener() noexcept - { - ::close( m_fd ); - } - - void operator=( const file_opener& ) = delete; - void operator=( file_opener&& ) = delete; - - std::size_t size() const - { - struct stat st; // NOLINT - errno = 0; - if( ::fstat( m_fd, &st ) < 0 ) { - TAO_PEGTL_THROW_INPUT_ERROR( "unable to fstat() file " << m_source << " descriptor " << m_fd ); - } - return std::size_t( st.st_size ); - } - - const char* const m_source; - const int m_fd; - - private: - int open() const - { - errno = 0; - const int fd = ::open( m_source, // NOLINT - O_RDONLY -#ifdef O_CLOEXEC - | O_CLOEXEC -#endif - ); - if( fd >= 0 ) { - return fd; - } - TAO_PEGTL_THROW_INPUT_ERROR( "unable to open() file " << m_source << " for reading" ); - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_reader.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_reader.hpp deleted file mode 100644 index c309aef..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/file_reader.hpp +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_FILE_READER_HPP -#define TAO_PEGTL_INTERNAL_FILE_READER_HPP - -#include -#include -#include -#include - -#include "../config.hpp" -#include "../input_error.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - inline std::FILE* file_open( const char* filename ) - { - errno = 0; -#if defined( _MSC_VER ) - std::FILE* file; - if( ::fopen_s( &file, filename, "rb" ) == 0 ) -#elif defined( __MINGW32__ ) - if( auto* file = std::fopen( filename, "rb" ) ) // NOLINT -#else - if( auto* file = std::fopen( filename, "rbe" ) ) // NOLINT -#endif - { - return file; - } - TAO_PEGTL_THROW_INPUT_ERROR( "unable to fopen() file " << filename << " for reading" ); - } - - struct file_close - { - void operator()( FILE* f ) const noexcept - { - std::fclose( f ); // NOLINT - } - }; - - class file_reader - { - public: - explicit file_reader( const char* filename ) - : m_source( filename ), - m_file( file_open( m_source ) ) - { - } - - file_reader( FILE* file, const char* filename ) noexcept - : m_source( filename ), - m_file( file ) - { - } - - file_reader( const file_reader& ) = delete; - file_reader( file_reader&& ) = delete; - - ~file_reader() = default; - - void operator=( const file_reader& ) = delete; - void operator=( file_reader&& ) = delete; - - std::size_t size() const - { - errno = 0; - if( std::fseek( m_file.get(), 0, SEEK_END ) != 0 ) { - TAO_PEGTL_THROW_INPUT_ERROR( "unable to fseek() to end of file " << m_source ); // LCOV_EXCL_LINE - } - errno = 0; - const auto s = std::ftell( m_file.get() ); - if( s < 0 ) { - TAO_PEGTL_THROW_INPUT_ERROR( "unable to ftell() file size of file " << m_source ); // LCOV_EXCL_LINE - } - errno = 0; - if( std::fseek( m_file.get(), 0, SEEK_SET ) != 0 ) { - TAO_PEGTL_THROW_INPUT_ERROR( "unable to fseek() to beginning of file " << m_source ); // LCOV_EXCL_LINE - } - return std::size_t( s ); - } - - std::string read() const - { - std::string nrv; - nrv.resize( size() ); - errno = 0; - if( !nrv.empty() && ( std::fread( &nrv[ 0 ], nrv.size(), 1, m_file.get() ) != 1 ) ) { - TAO_PEGTL_THROW_INPUT_ERROR( "unable to fread() file " << m_source << " size " << nrv.size() ); // LCOV_EXCL_LINE - } - return nrv; - } - - private: - const char* const m_source; - const std::unique_ptr< std::FILE, file_close > m_file; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_apply.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_apply.hpp deleted file mode 100644 index f0daf96..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_apply.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_HAS_APPLY_HPP -#define TAO_PEGTL_INTERNAL_HAS_APPLY_HPP - -#include - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename, typename, template< typename... > class, typename... > - struct has_apply - : std::false_type - {}; - - template< typename C, template< typename... > class Action, typename... S > - struct has_apply< C, decltype( C::template apply< Action >( std::declval< S >()... ) ), Action, S... > - : std::true_type - {}; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_apply0.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_apply0.hpp deleted file mode 100644 index b54c60b..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_apply0.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_HAS_APPLY0_HPP -#define TAO_PEGTL_INTERNAL_HAS_APPLY0_HPP - -#include - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename, typename, template< typename... > class, typename... > - struct has_apply0 - : std::false_type - {}; - - template< typename C, template< typename... > class Action, typename... S > - struct has_apply0< C, decltype( C::template apply0< Action >( std::declval< S >()... ) ), Action, S... > - : std::true_type - {}; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_match.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_match.hpp deleted file mode 100644 index af3c2bb..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/has_match.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_HAS_MATCH_HPP -#define TAO_PEGTL_INTERNAL_HAS_MATCH_HPP - -#include -#include - -#include "../apply_mode.hpp" -#include "../config.hpp" -#include "../rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename, - typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - struct has_match - : std::false_type - {}; - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - struct has_match< decltype( Action< Rule >::template match< Rule, A, M, Action, Control >( std::declval< Input& >(), std::declval< States&& >()... ), void() ), Rule, A, M, Action, Control, Input, States... > - : std::true_type - {}; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/identifier.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/identifier.hpp deleted file mode 100644 index 8194266..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/identifier.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_IDENTIFIER_HPP -#define TAO_PEGTL_INTERNAL_IDENTIFIER_HPP - -#include "../config.hpp" - -#include "peek_char.hpp" -#include "ranges.hpp" -#include "seq.hpp" -#include "star.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - using identifier_first = ranges< peek_char, 'a', 'z', 'A', 'Z', '_' >; - using identifier_other = ranges< peek_char, 'a', 'z', 'A', 'Z', '0', '9', '_' >; - using identifier = seq< identifier_first, star< identifier_other > >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_apply.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_apply.hpp deleted file mode 100644 index df2b306..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_apply.hpp +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_IF_APPLY_HPP -#define TAO_PEGTL_INTERNAL_IF_APPLY_HPP - -#include "../config.hpp" - -#include "apply_single.hpp" -#include "skip_control.hpp" - -#include "../analysis/counted.hpp" -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< apply_mode A, typename Rule, typename... Actions > - struct if_apply_impl; - - template< typename Rule > - struct if_apply_impl< apply_mode::action, Rule > - { - template< rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return Control< Rule >::template match< apply_mode::action, M, Action, Control >( in, st... ); - } - }; - - template< typename Rule, typename... Actions > - struct if_apply_impl< apply_mode::action, Rule, Actions... > - { - template< rewind_mode, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - using action_t = typename Input::action_t; - - auto m = in.template mark< rewind_mode::required >(); - - if( Control< Rule >::template match< apply_mode::action, rewind_mode::active, Action, Control >( in, st... ) ) { - const action_t i2( m.iterator(), in ); -#ifdef __cpp_fold_expressions - return m( ( apply_single< Actions >::match( i2, st... ) && ... ) ); -#else - bool result = true; - using swallow = bool[]; - (void)swallow{ result = result && apply_single< Actions >::match( i2, st... )... }; - return m( result ); -#endif - } - return false; - } - }; - - template< typename Rule, typename... Actions > - struct if_apply_impl< apply_mode::nothing, Rule, Actions... > - { - template< rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return Control< Rule >::template match< apply_mode::nothing, M, Action, Control >( in, st... ); - } - }; - - template< typename Rule, typename... Actions > - struct if_apply - { - using analyze_t = typename Rule::analyze_t; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return if_apply_impl< A, Rule, Actions... >::template match< M, Action, Control >( in, st... ); - } - }; - - template< typename Rule, typename... Actions > - struct skip_control< if_apply< Rule, Actions... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_missing.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_missing.hpp deleted file mode 100644 index d0aa8ab..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_missing.hpp +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_IF_MISSING_HPP -#define TAO_PEGTL_INTERNAL_IF_MISSING_HPP - -#include "../config.hpp" -#include "../rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< bool > - struct if_missing; - - template<> - struct if_missing< true > - { - template< typename Control, - template< typename... > - class Action, - typename Input, - typename... States > - static void apply( Input& in, States&&... st ) - { - auto m = in.template mark< rewind_mode::required >(); - Control::template apply< Action >( m.iterator(), in, st... ); - } - - template< typename Control, - template< typename... > - class Action, - typename Input, - typename... States > - static void apply0( Input& in, States&&... st ) - { - Control::template apply0< Action >( in, st... ); - } - }; - - template<> - struct if_missing< false > - { - template< typename Control, - template< typename... > - class Action, - typename Input, - typename... States > - static void apply( Input& /*unused*/, States&&... /*unused*/ ) - { - } - - template< typename Control, - template< typename... > - class Action, - typename Input, - typename... States > - static void apply0( Input& /*unused*/, States&&... /*unused*/ ) - { - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_must.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_must.hpp deleted file mode 100644 index 0cbd08c..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_must.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_IF_MUST_HPP -#define TAO_PEGTL_INTERNAL_IF_MUST_HPP - -#include "../config.hpp" - -#include "must.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/counted.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< bool Default, typename Cond, typename... Rules > - struct if_must - { - using analyze_t = analysis::counted< analysis::rule_type::seq, Default ? 0 : 1, Cond, must< Rules... > >; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - if( Control< Cond >::template match< A, M, Action, Control >( in, st... ) ) { - Control< must< Rules... > >::template match< A, M, Action, Control >( in, st... ); - return true; - } - return Default; - } - }; - - template< bool Default, typename Cond, typename... Rules > - struct skip_control< if_must< Default, Cond, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_must_else.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_must_else.hpp deleted file mode 100644 index 74db045..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_must_else.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_IF_MUST_ELSE_HPP -#define TAO_PEGTL_INTERNAL_IF_MUST_ELSE_HPP - -#include "../config.hpp" - -#include "if_then_else.hpp" -#include "must.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Cond, typename Then, typename Else > - using if_must_else = if_then_else< Cond, must< Then >, must< Else > >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_then_else.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_then_else.hpp deleted file mode 100644 index 7d7b30f..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/if_then_else.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_IF_THEN_ELSE_HPP -#define TAO_PEGTL_INTERNAL_IF_THEN_ELSE_HPP - -#include "../config.hpp" - -#include "not_at.hpp" -#include "seq.hpp" -#include "skip_control.hpp" -#include "sor.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Cond, typename Then, typename Else > - struct if_then_else - { - using analyze_t = analysis::generic< analysis::rule_type::sor, seq< Cond, Then >, seq< not_at< Cond >, Else > >; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< M >(); - using m_t = decltype( m ); - - if( Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { - return m( Control< Then >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ); - } - return m( Control< Else >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ); - } - }; - - template< typename Cond, typename Then, typename Else > - struct skip_control< if_then_else< Cond, Then, Else > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/input_pair.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/input_pair.hpp deleted file mode 100644 index f586a05..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/input_pair.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_INPUT_PAIR_HPP -#define TAO_PEGTL_INTERNAL_INPUT_PAIR_HPP - -#include - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Data > - struct input_pair - { - Data data; - std::uint8_t size; - - using data_t = Data; - - explicit operator bool() const noexcept - { - return size > 0; - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/integer_sequence.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/integer_sequence.hpp deleted file mode 100644 index 74e461d..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/integer_sequence.hpp +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_INTEGER_SEQUENCE_HPP -#define TAO_PEGTL_INTERNAL_INTEGER_SEQUENCE_HPP - -#include -#include -#include - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename T, T... Ns > - struct integer_sequence - { - using value_type = T; - - static constexpr std::size_t size() noexcept - { - return sizeof...( Ns ); - } - }; - - template< std::size_t... Ns > - using index_sequence = integer_sequence< std::size_t, Ns... >; - - template< bool V, bool E > - struct generate_sequence; - - template<> - struct generate_sequence< false, true > - { - template< typename T, T M, T N, std::size_t S, T... Ns > - using f = integer_sequence< T, Ns... >; - }; - - template<> - struct generate_sequence< true, true > - { - template< typename T, T M, T N, std::size_t S, T... Ns > - using f = integer_sequence< T, Ns..., S >; - }; - - template<> - struct generate_sequence< false, false > - { - template< typename T, T M, T N, std::size_t S, T... Ns > - using f = typename generate_sequence< ( N & ( M / 2 ) ) != 0, ( M / 2 ) == 0 >::template f< T, M / 2, N, 2 * S, Ns..., ( Ns + S )... >; - }; - - template<> - struct generate_sequence< true, false > - { - template< typename T, T M, T N, std::size_t S, T... Ns > - using f = typename generate_sequence< ( N & ( M / 2 ) ) != 0, ( M / 2 ) == 0 >::template f< T, M / 2, N, 2 * S + 1, Ns..., ( Ns + S )..., 2 * S >; - }; - - template< typename T, T N > - struct memoize_sequence - { - static_assert( N < T( 1 << 20 ), "N too large" ); - using type = typename generate_sequence< false, false >::template f< T, ( N < T( 1 << 1 ) ) ? T( 1 << 1 ) : ( N < T( 1 << 2 ) ) ? T( 1 << 2 ) : ( N < T( 1 << 3 ) ) ? T( 1 << 3 ) : ( N < T( 1 << 4 ) ) ? T( 1 << 4 ) : ( N < T( 1 << 5 ) ) ? T( 1 << 5 ) : ( N < T( 1 << 6 ) ) ? T( 1 << 6 ) : ( N < T( 1 << 7 ) ) ? T( 1 << 7 ) : ( N < T( 1 << 8 ) ) ? T( 1 << 8 ) : ( N < T( 1 << 9 ) ) ? T( 1 << 9 ) : ( N < T( 1 << 10 ) ) ? T( 1 << 10 ) : ( N < T( 1 << 11 ) ) ? T( 1 << 11 ) : ( N < T( 1 << 12 ) ) ? T( 1 << 12 ) : ( N < T( 1 << 13 ) ) ? T( 1 << 13 ) : ( N < T( 1 << 14 ) ) ? T( 1 << 14 ) : ( N < T( 1 << 15 ) ) ? T( 1 << 15 ) : ( N < T( 1 << 16 ) ) ? T( 1 << 16 ) : ( N < T( 1 << 17 ) ) ? T( 1 << 17 ) : ( N < T( 1 << 18 ) ) ? T( 1 << 18 ) : ( N < T( 1 << 19 ) ) ? T( 1 << 19 ) : T( 1 << 20 ), N, 0 >; - }; - - template< typename T, T N > - using make_integer_sequence = typename memoize_sequence< T, N >::type; - - template< std::size_t N > - using make_index_sequence = make_integer_sequence< std::size_t, N >; - - template< typename... Ts > - using index_sequence_for = make_index_sequence< sizeof...( Ts ) >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/istream_reader.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/istream_reader.hpp deleted file mode 100644 index 77744e0..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/istream_reader.hpp +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_ISTREAM_READER_HPP -#define TAO_PEGTL_INTERNAL_ISTREAM_READER_HPP - -#include - -#include "../config.hpp" -#include "../input_error.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct istream_reader - { - explicit istream_reader( std::istream& s ) noexcept - : m_istream( s ) - { - } - - std::size_t operator()( char* buffer, const std::size_t length ) - { - m_istream.read( buffer, std::streamsize( length ) ); - - if( const auto r = m_istream.gcount() ) { - return std::size_t( r ); - } - if( m_istream.eof() ) { - return 0; - } - TAO_PEGTL_THROW_INPUT_ERROR( "error in istream.read()" ); - } - - std::istream& m_istream; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/istring.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/istring.hpp deleted file mode 100644 index 9aabba8..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/istring.hpp +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_ISTRING_HPP -#define TAO_PEGTL_INTERNAL_ISTRING_HPP - -#include - -#include "../config.hpp" - -#include "bump_help.hpp" -#include "result_on_found.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../analysis/counted.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< char C > - using is_alpha = std::integral_constant< bool, ( ( 'a' <= C ) && ( C <= 'z' ) ) || ( ( 'A' <= C ) && ( C <= 'Z' ) ) >; - - template< char C, bool A = is_alpha< C >::value > - struct ichar_equal; - - template< char C > - struct ichar_equal< C, true > - { - static bool match( const char c ) noexcept - { - return ( C | 0x20 ) == ( c | 0x20 ); - } - }; - - template< char C > - struct ichar_equal< C, false > - { - static bool match( const char c ) noexcept - { - return c == C; - } - }; - - template< char... Cs > - struct istring_equal; - - template<> - struct istring_equal<> - { - static bool match( const char* /*unused*/ ) noexcept - { - return true; - } - }; - - template< char C, char... Cs > - struct istring_equal< C, Cs... > - { - static bool match( const char* r ) noexcept - { - return ichar_equal< C >::match( *r ) && istring_equal< Cs... >::match( r + 1 ); - } - }; - - template< char... Cs > - struct istring; - - template<> - struct istring<> - : trivial< true > - { - }; - - template< char... Cs > - struct istring - { - using analyze_t = analysis::counted< analysis::rule_type::any, sizeof...( Cs ) >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) ) - { - if( in.size( sizeof...( Cs ) ) >= sizeof...( Cs ) ) { - if( istring_equal< Cs... >::match( in.current() ) ) { - bump_help< result_on_found::success, Input, char, Cs... >( in, sizeof...( Cs ) ); - return true; - } - } - return false; - } - }; - - template< char... Cs > - struct skip_control< istring< Cs... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/iterator.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/iterator.hpp deleted file mode 100644 index cf2cd98..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/iterator.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_ITERATOR_HPP -#define TAO_PEGTL_INTERNAL_ITERATOR_HPP - -#include - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct iterator - { - iterator() noexcept = default; - - explicit iterator( const char* in_data ) noexcept - : data( in_data ) - { - } - - iterator( const char* in_data, const std::size_t in_byte, const std::size_t in_line, const std::size_t in_byte_in_line ) noexcept - : data( in_data ), - byte( in_byte ), - line( in_line ), - byte_in_line( in_byte_in_line ) - { - } - - iterator( const iterator& ) = default; - iterator( iterator&& ) = default; - - ~iterator() = default; - - iterator& operator=( const iterator& ) = default; - iterator& operator=( iterator&& ) = default; - - void reset() noexcept - { - *this = iterator(); - } - - const char* data = nullptr; - - std::size_t byte = 0; - std::size_t line = 1; - std::size_t byte_in_line = 0; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/lf_crlf_eol.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/lf_crlf_eol.hpp deleted file mode 100644 index 042c7be..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/lf_crlf_eol.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_LF_CRLF_EOL_HPP -#define TAO_PEGTL_INTERNAL_LF_CRLF_EOL_HPP - -#include "../config.hpp" -#include "../eol_pair.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct lf_crlf_eol - { - static constexpr int ch = '\n'; - - template< typename Input > - static eol_pair match( Input& in ) noexcept( noexcept( in.size( 2 ) ) ) - { - eol_pair p = { false, in.size( 2 ) }; - if( p.second ) { - const auto a = in.peek_char(); - if( a == '\n' ) { - in.bump_to_next_line(); - p.first = true; - } - else if( ( a == '\r' ) && ( p.second > 1 ) && ( in.peek_char( 1 ) == '\n' ) ) { - in.bump_to_next_line( 2 ); - p.first = true; - } - } - return p; - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/lf_eol.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/lf_eol.hpp deleted file mode 100644 index 566442c..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/lf_eol.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_LF_EOL_HPP -#define TAO_PEGTL_INTERNAL_LF_EOL_HPP - -#include "../config.hpp" -#include "../eol_pair.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct lf_eol - { - static constexpr int ch = '\n'; - - template< typename Input > - static eol_pair match( Input& in ) noexcept( noexcept( in.size( 1 ) ) ) - { - eol_pair p = { false, in.size( 1 ) }; - if( p.second ) { - if( in.peek_char() == '\n' ) { - in.bump_to_next_line(); - p.first = true; - } - } - return p; - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list.hpp deleted file mode 100644 index c0a5c06..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_LIST_HPP -#define TAO_PEGTL_INTERNAL_LIST_HPP - -#include "../config.hpp" - -#include "seq.hpp" -#include "star.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Sep > - using list = seq< Rule, star< Sep, Rule > >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_must.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_must.hpp deleted file mode 100644 index 9f03ed5..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_must.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_LIST_MUST_HPP -#define TAO_PEGTL_INTERNAL_LIST_MUST_HPP - -#include "../config.hpp" - -#include "must.hpp" -#include "seq.hpp" -#include "star.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Sep > - using list_must = seq< Rule, star< Sep, must< Rule > > >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_tail.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_tail.hpp deleted file mode 100644 index fca4119..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_tail.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_LIST_TAIL_HPP -#define TAO_PEGTL_INTERNAL_LIST_TAIL_HPP - -#include "../config.hpp" - -#include "list.hpp" -#include "opt.hpp" -#include "seq.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Sep > - using list_tail = seq< list< Rule, Sep >, opt< Sep > >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_tail_pad.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_tail_pad.hpp deleted file mode 100644 index 006e3c1..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/list_tail_pad.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_LIST_TAIL_PAD_HPP -#define TAO_PEGTL_INTERNAL_LIST_TAIL_PAD_HPP - -#include "../config.hpp" - -#include "list.hpp" -#include "opt.hpp" -#include "pad.hpp" -#include "seq.hpp" -#include "star.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Sep, typename Pad > - using list_tail_pad = seq< list< Rule, pad< Sep, Pad > >, opt< star< Pad >, Sep > >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/marker.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/marker.hpp deleted file mode 100644 index a358978..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/marker.hpp +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_MARKER_HPP -#define TAO_PEGTL_INTERNAL_MARKER_HPP - -#include "../config.hpp" -#include "../rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Iterator, rewind_mode M > - class marker - { - public: - static constexpr rewind_mode next_rewind_mode = M; - - explicit marker( const Iterator& /*unused*/ ) noexcept - { - } - - marker( const marker& ) = delete; - - marker( marker&& /*unused*/ ) noexcept - { - } - - ~marker() = default; - - void operator=( const marker& ) = delete; - void operator=( marker&& ) = delete; - - bool operator()( const bool result ) const noexcept - { - return result; - } - }; - - template< typename Iterator > - class marker< Iterator, rewind_mode::required > - { - public: - static constexpr rewind_mode next_rewind_mode = rewind_mode::active; - - explicit marker( Iterator& i ) noexcept - : m_saved( i ), - m_input( &i ) - { - } - - marker( const marker& ) = delete; - - marker( marker&& i ) noexcept - : m_saved( i.m_saved ), - m_input( i.m_input ) - { - i.m_input = nullptr; - } - - ~marker() noexcept - { - if( m_input != nullptr ) { - ( *m_input ) = m_saved; - } - } - - void operator=( const marker& ) = delete; - void operator=( marker&& ) = delete; - - bool operator()( const bool result ) noexcept - { - if( result ) { - m_input = nullptr; - return true; - } - return false; - } - - const Iterator& iterator() const noexcept - { - return m_saved; - } - - private: - const Iterator m_saved; - Iterator* m_input; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/mmap_file.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/mmap_file.hpp deleted file mode 100644 index 83fa993..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/mmap_file.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2022 Dr. Colin Hirsch and Daniel Frey -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) - -#ifndef TAO_PEGTL_INTERNAL_MMAP_FILE_HPP -#define TAO_PEGTL_INTERNAL_MMAP_FILE_HPP - -#if defined( __unix__ ) || ( defined( __APPLE__ ) && defined( __MACH__ ) ) -#include // Required for _POSIX_MAPPED_FILES -#endif - -#if defined( _POSIX_MAPPED_FILES ) -#include "mmap_file_posix.hpp" -#elif defined( _WIN32 ) -#include "mmap_file_win32.hpp" -#else -#endif - -#include "filesystem.hpp" - -namespace tao::pegtl::internal -{ - struct mmap_file - { - const mmap_file_impl data; - - explicit mmap_file( const internal::filesystem::path& path ) - : data( path ) - {} - - mmap_file( const mmap_file& ) = delete; - mmap_file( mmap_file&& ) = delete; - - ~mmap_file() = default; - - mmap_file& operator=( const mmap_file& ) = delete; - mmap_file& operator=( mmap_file&& ) = delete; - }; - -} // namespace tao::pegtl::internal - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/mmap_file_win32.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/mmap_file_win32.hpp deleted file mode 100644 index c82bc3f..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/mmap_file_win32.hpp +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) - -#ifndef TAO_PEGTL_INTERNAL_MMAP_FILE_WIN32_HPP -#define TAO_PEGTL_INTERNAL_MMAP_FILE_WIN32_HPP - -#if !defined( NOMINMAX ) -#define NOMINMAX -#define TAO_PEGTL_NOMINMAX_WAS_DEFINED -#endif - -#if !defined( WIN32_LEAN_AND_MEAN ) -#define WIN32_LEAN_AND_MEAN -#define TAO_PEGTL_WIN32_LEAN_AND_MEAN_WAS_DEFINED -#endif - -#include - -#if defined( TAO_PEGTL_NOMINMAX_WAS_DEFINED ) -#undef NOMINMAX -#undef TAO_PEGTL_NOMINMAX_WAS_DEFINED -#endif - -#if defined( TAO_PEGTL_WIN32_LEAN_AND_MEAN_WAS_DEFINED ) -#undef WIN32_LEAN_AND_MEAN -#undef TAO_PEGTL_WIN32_LEAN_AND_MEAN_WAS_DEFINED -#endif - -#if !defined( __cpp_exceptions ) -#include -#include -#endif - -#include "filesystem.hpp" - -namespace tao::pegtl::internal -{ - struct mmap_file_open - { - explicit mmap_file_open( const internal::filesystem::path& path ) - : m_path( path ), - m_handle( open() ) - {} - - mmap_file_open( const mmap_file_open& ) = delete; - mmap_file_open( mmap_file_open&& ) = delete; - - ~mmap_file_open() - { - ::CloseHandle( m_handle ); - } - - mmap_file_open& operator=( const mmap_file_open& ) = delete; - mmap_file_open& operator=( mmap_file_open&& ) = delete; - - [[nodiscard]] std::size_t size() const - { - LARGE_INTEGER size; - if( !::GetFileSizeEx( m_handle, &size ) ) { -#if defined( __cpp_exceptions ) - internal::error_code ec( ::GetLastError(), internal::system_category() ); - throw internal::filesystem::filesystem_error( "GetFileSizeEx() failed", m_path, ec ); -#else - std::perror( "GetFileSizeEx() failed" ); - std::terminate(); -#endif - } - return std::size_t( size.QuadPart ); - } - - const internal::filesystem::path m_path; - const HANDLE m_handle; - - private: - [[nodiscard]] HANDLE open() const - { - SetLastError( 0 ); -#if( _WIN32_WINNT >= 0x0602 ) - const HANDLE handle = ::CreateFile2( m_path.c_str(), - GENERIC_READ, - FILE_SHARE_READ, - OPEN_EXISTING, - nullptr ); - if( handle != INVALID_HANDLE_VALUE ) { - return handle; - } -#if defined( __cpp_exceptions ) - internal::error_code ec( ::GetLastError(), internal::system_category() ); - throw internal::filesystem::filesystem_error( "CreateFile2() failed", m_path, ec ); -#else - std::perror( "CreateFile2() failed" ); - std::terminate(); -#endif -#else - const HANDLE handle = ::CreateFileW( m_path.c_str(), - GENERIC_READ, - FILE_SHARE_READ, - nullptr, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - nullptr ); - if( handle != INVALID_HANDLE_VALUE ) { - return handle; - } -#if defined( __cpp_exceptions ) - internal::error_code ec( ::GetLastError(), internal::system_category() ); - throw internal::filesystem::filesystem_error( "CreateFileW()", m_path, ec ); -#else - std::perror( "CreateFileW() failed" ); - std::terminate(); -#endif -#endif - } - }; - - struct mmap_file_mmap - { - explicit mmap_file_mmap( const internal::filesystem::path& path ) - : mmap_file_mmap( mmap_file_open( path ) ) - {} - - explicit mmap_file_mmap( const mmap_file_open& reader ) - : m_size( reader.size() ), - m_handle( open( reader ) ) - {} - - mmap_file_mmap( const mmap_file_mmap& ) = delete; - mmap_file_mmap( mmap_file_mmap&& ) = delete; - - ~mmap_file_mmap() - { - ::CloseHandle( m_handle ); - } - - mmap_file_mmap& operator=( const mmap_file_mmap& ) = delete; - mmap_file_mmap& operator=( mmap_file_mmap&& ) = delete; - - const size_t m_size; - const HANDLE m_handle; - - private: - [[nodiscard]] HANDLE open( const mmap_file_open& reader ) const - { - const uint64_t file_size = reader.size(); - SetLastError( 0 ); - // Use `CreateFileMappingW` because a) we're not specifying a - // mapping name, so the character type is of no consequence, and - // b) it's defined in `memoryapi.h`, unlike - // `CreateFileMappingA`(?!) - const HANDLE handle = ::CreateFileMappingW( reader.m_handle, - nullptr, - PAGE_READONLY, - DWORD( file_size >> 32 ), - DWORD( file_size & 0xffffffff ), - nullptr ); - if( handle != NULL || file_size == 0 ) { - return handle; - } -#if defined( __cpp_exceptions ) - internal::error_code ec( ::GetLastError(), internal::system_category() ); - throw internal::filesystem::filesystem_error( "CreateFileMappingW() failed", reader.m_path, ec ); -#else - std::perror( "CreateFileMappingW() failed" ); - std::terminate(); -#endif - } - }; - - class mmap_file_win32 - { - public: - explicit mmap_file_win32( const internal::filesystem::path& path ) - : mmap_file_win32( mmap_file_mmap( path ) ) - {} - - explicit mmap_file_win32( const mmap_file_mmap& mapper ) - : m_size( mapper.m_size ), - m_data( static_cast< const char* >( ::MapViewOfFile( mapper.m_handle, - FILE_MAP_READ, - 0, - 0, - 0 ) ) ) - { - if( ( m_size != 0 ) && ( intptr_t( m_data ) == 0 ) ) { -#if defined( __cpp_exceptions ) - internal::error_code ec( ::GetLastError(), internal::system_category() ); - throw internal::filesystem::filesystem_error( "MapViewOfFile() failed", ec ); -#else - std::perror( "MapViewOfFile() failed" ); - std::terminate(); -#endif - } - } - - mmap_file_win32( const mmap_file_win32& ) = delete; - mmap_file_win32( mmap_file_win32&& ) = delete; - - ~mmap_file_win32() - { - ::UnmapViewOfFile( LPCVOID( m_data ) ); - } - - mmap_file_win32& operator=( const mmap_file_win32& ) = delete; - mmap_file_win32& operator=( mmap_file_win32&& ) = delete; - - [[nodiscard]] bool empty() const noexcept - { - return m_size == 0; - } - - [[nodiscard]] std::size_t size() const noexcept - { - return m_size; - } - - using iterator = const char*; - using const_iterator = const char*; - - [[nodiscard]] iterator data() const noexcept - { - return m_data; - } - - [[nodiscard]] iterator begin() const noexcept - { - return m_data; - } - - [[nodiscard]] iterator end() const noexcept - { - return m_data + m_size; - } - - private: - const std::size_t m_size; - const char* const m_data; - }; - - using mmap_file_impl = mmap_file_win32; - -} // namespace tao::pegtl::internal - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/must.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/must.hpp deleted file mode 100644 index 3572728..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/must.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_MUST_HPP -#define TAO_PEGTL_INTERNAL_MUST_HPP - -#include "../config.hpp" - -#include "raise.hpp" -#include "seq.hpp" -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - // The general case applies must<> to each of the - // rules in the 'Rules' parameter pack individually. - - template< typename... Rules > - struct must - : seq< must< Rules >... > - { - }; - - // While in theory the implementation for a single rule could - // be simplified to must< Rule > = sor< Rule, raise< Rule > >, this - // would result in some unnecessary run-time overhead. - - template< typename Rule > - struct must< Rule > - { - using analyze_t = typename Rule::analyze_t; - - template< apply_mode A, - rewind_mode, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - if( !Control< Rule >::template match< A, rewind_mode::dontcare, Action, Control >( in, st... ) ) { - raise< Rule >::template match< A, rewind_mode::dontcare, Action, Control >( in, st... ); - } - return true; - } - }; - - template< typename... Rules > - struct skip_control< must< Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/not_at.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/not_at.hpp deleted file mode 100644 index e1ba9be..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/not_at.hpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_NOT_AT_HPP -#define TAO_PEGTL_INTERNAL_NOT_AT_HPP - -#include "../config.hpp" - -#include "seq.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename... Rules > - struct not_at - : not_at< seq< Rules... > > - { - }; - - template<> - struct not_at<> - : trivial< false > - { - }; - - template< typename Rule > - struct not_at< Rule > - { - using analyze_t = analysis::generic< analysis::rule_type::opt, Rule >; - - template< apply_mode, - rewind_mode, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - const auto m = in.template mark< rewind_mode::required >(); - return !Control< Rule >::template match< apply_mode::nothing, rewind_mode::active, Action, Control >( in, st... ); - } - }; - - template< typename... Rules > - struct skip_control< not_at< Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/one.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/one.hpp deleted file mode 100644 index 9734be1..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/one.hpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_ONE_HPP -#define TAO_PEGTL_INTERNAL_ONE_HPP - -#include -#include - -#include "../config.hpp" - -#include "bump_help.hpp" -#include "result_on_found.hpp" -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Char > - bool contains( const Char c, const std::initializer_list< Char >& l ) noexcept - { - return std::find( l.begin(), l.end(), c ) != l.end(); - } - - template< result_on_found R, typename Peek, typename Peek::data_t... Cs > - struct one - { - using analyze_t = analysis::generic< analysis::rule_type::any >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) ) - { - if( const auto t = Peek::peek( in ) ) { - if( contains( t.data, { Cs... } ) == bool( R ) ) { - bump_help< R, Input, typename Peek::data_t, Cs... >( in, t.size ); - return true; - } - } - return false; - } - }; - - template< result_on_found R, typename Peek, typename Peek::data_t C > - struct one< R, Peek, C > - { - using analyze_t = analysis::generic< analysis::rule_type::any >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) ) - { - if( const auto t = Peek::peek( in ) ) { - if( ( t.data == C ) == bool( R ) ) { - bump_help< R, Input, typename Peek::data_t, C >( in, t.size ); - return true; - } - } - return false; - } - }; - - template< result_on_found R, typename Peek, typename Peek::data_t... Cs > - struct skip_control< one< R, Peek, Cs... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/opt.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/opt.hpp deleted file mode 100644 index 0877439..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/opt.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_OPT_HPP -#define TAO_PEGTL_INTERNAL_OPT_HPP - -#include - -#include "../config.hpp" - -#include "seq.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename... Rules > - struct opt - : opt< seq< Rules... > > - { - }; - - template<> - struct opt<> - : trivial< true > - { - }; - - template< typename Rule > - struct opt< Rule > - { - using analyze_t = analysis::generic< analysis::rule_type::opt, Rule >; - - template< apply_mode A, - rewind_mode, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - Control< Rule >::template match< A, rewind_mode::required, Action, Control >( in, st... ); - return true; - } - }; - - template< typename... Rules > - struct skip_control< opt< Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pad.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pad.hpp deleted file mode 100644 index bab590a..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pad.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_PAD_HPP -#define TAO_PEGTL_INTERNAL_PAD_HPP - -#include "../config.hpp" - -#include "seq.hpp" -#include "star.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Pad1, typename Pad2 = Pad1 > - using pad = seq< star< Pad1 >, Rule, star< Pad2 > >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pad_opt.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pad_opt.hpp deleted file mode 100644 index 38bab54..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pad_opt.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_PAD_OPT_HPP -#define TAO_PEGTL_INTERNAL_PAD_OPT_HPP - -#include "../config.hpp" - -#include "opt.hpp" -#include "seq.hpp" -#include "star.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Pad > - using pad_opt = seq< star< Pad >, opt< Rule, star< Pad > > >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_char.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_char.hpp deleted file mode 100644 index 2ef3f63..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_char.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_PEEK_CHAR_HPP -#define TAO_PEGTL_INTERNAL_PEEK_CHAR_HPP - -#include - -#include "../config.hpp" - -#include "input_pair.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct peek_char - { - using data_t = char; - using pair_t = input_pair< char >; - - template< typename Input > - static pair_t peek( Input& in ) noexcept( noexcept( in.empty() ) ) - { - if( in.empty() ) { - return { 0, 0 }; - } - return { in.peek_char(), 1 }; - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_mask_uint.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_mask_uint.hpp deleted file mode 100644 index 257a1cd..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_mask_uint.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_PEEK_MASK_UINT_HPP -#define TAO_PEGTL_INTERNAL_PEEK_MASK_UINT_HPP - -#include -#include - -#include "../config.hpp" - -#include "input_pair.hpp" -#include "read_uint.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename R, typename R::type M > - struct peek_mask_uint_impl - { - using data_t = typename R::type; - using pair_t = input_pair< data_t >; - - template< typename Input > - static pair_t peek( Input& in ) noexcept( noexcept( in.size( sizeof( data_t ) ) ) ) - { - if( in.size( sizeof( data_t ) ) < sizeof( data_t ) ) { - return { 0, 0 }; - } - const data_t data = R::read( in.current() ) & M; - return { data, sizeof( data_t ) }; - } - }; - - template< std::uint16_t M > - using peek_mask_uint16_be = peek_mask_uint_impl< read_uint16_be, M >; - - template< std::uint16_t M > - using peek_mask_uint16_le = peek_mask_uint_impl< read_uint16_le, M >; - - template< std::uint32_t M > - using peek_mask_uint32_be = peek_mask_uint_impl< read_uint32_be, M >; - - template< std::uint32_t M > - using peek_mask_uint32_le = peek_mask_uint_impl< read_uint32_le, M >; - - template< std::uint64_t M > - using peek_mask_uint64_be = peek_mask_uint_impl< read_uint64_be, M >; - - template< std::uint64_t M > - using peek_mask_uint64_le = peek_mask_uint_impl< read_uint64_le, M >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_mask_uint8.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_mask_uint8.hpp deleted file mode 100644 index a8db523..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_mask_uint8.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_PEEK_MASK_UINT8_HPP -#define TAO_PEGTL_INTERNAL_PEEK_MASK_UINT8_HPP - -#include -#include - -#include "../config.hpp" - -#include "input_pair.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< std::uint8_t M > - struct peek_mask_uint8 - { - using data_t = std::uint8_t; - using pair_t = input_pair< std::uint8_t >; - - template< typename Input > - static pair_t peek( Input& in ) noexcept( noexcept( in.empty() ) ) - { - if( in.empty() ) { - return { 0, 0 }; - } - return { std::uint8_t( in.peek_uint8() & M ), 1 }; - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_uint.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_uint.hpp deleted file mode 100644 index 973a540..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_uint.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_PEEK_UINT_HPP -#define TAO_PEGTL_INTERNAL_PEEK_UINT_HPP - -#include -#include - -#include "../config.hpp" - -#include "input_pair.hpp" -#include "read_uint.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename R > - struct peek_uint_impl - { - using data_t = typename R::type; - using pair_t = input_pair< data_t >; - - template< typename Input > - static pair_t peek( Input& in ) noexcept( noexcept( in.size( sizeof( data_t ) ) ) ) - { - if( in.size( sizeof( data_t ) ) < sizeof( data_t ) ) { - return { 0, 0 }; - } - const data_t data = R::read( in.current() ); - return { data, sizeof( data_t ) }; - } - }; - - using peek_uint16_be = peek_uint_impl< read_uint16_be >; - using peek_uint16_le = peek_uint_impl< read_uint16_le >; - - using peek_uint32_be = peek_uint_impl< read_uint32_be >; - using peek_uint32_le = peek_uint_impl< read_uint32_le >; - - using peek_uint64_be = peek_uint_impl< read_uint64_be >; - using peek_uint64_le = peek_uint_impl< read_uint64_le >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_uint8.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_uint8.hpp deleted file mode 100644 index 2b8fe07..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_uint8.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_PEEK_UINT8_HPP -#define TAO_PEGTL_INTERNAL_PEEK_UINT8_HPP - -#include -#include - -#include "../config.hpp" - -#include "input_pair.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct peek_uint8 - { - using data_t = std::uint8_t; - using pair_t = input_pair< std::uint8_t >; - - template< typename Input > - static pair_t peek( Input& in ) noexcept( noexcept( in.empty() ) ) - { - if( in.empty() ) { - return { 0, 0 }; - } - return { in.peek_uint8(), 1 }; - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf16.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf16.hpp deleted file mode 100644 index 490e8e3..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf16.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_PEEK_UTF16_HPP -#define TAO_PEGTL_INTERNAL_PEEK_UTF16_HPP - -#include - -#include "../config.hpp" - -#include "input_pair.hpp" -#include "read_uint.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename R > - struct peek_utf16_impl - { - using data_t = char32_t; - using pair_t = input_pair< char32_t >; - - using short_t = std::make_unsigned< char16_t >::type; - - static_assert( sizeof( short_t ) == 2, "expected size 2 for 16bit value" ); - static_assert( sizeof( char16_t ) == 2, "expected size 2 for 16bit value" ); - - template< typename Input > - static pair_t peek( Input& in ) noexcept( noexcept( in.size( 4 ) ) ) - { - if( in.size( 2 ) < 2 ) { - return { 0, 0 }; - } - const char32_t t = R::read( in.current() ); - if( ( t < 0xd800 ) || ( t > 0xdfff ) ) { - return { t, 2 }; - } - if( ( t >= 0xdc00 ) || ( in.size( 4 ) < 4 ) ) { - return { 0, 0 }; - } - const char32_t u = R::read( in.current() + 2 ); - if( ( u >= 0xdc00 ) && ( u <= 0xdfff ) ) { - const auto cp = ( ( ( t & 0x03ff ) << 10 ) | ( u & 0x03ff ) ) + 0x10000; - return { cp, 4 }; - } - return { 0, 0 }; - } - }; - - using peek_utf16_be = peek_utf16_impl< read_uint16_be >; - using peek_utf16_le = peek_utf16_impl< read_uint16_le >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf32.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf32.hpp deleted file mode 100644 index 7ddeba6..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf32.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_PEEK_UTF32_HPP -#define TAO_PEGTL_INTERNAL_PEEK_UTF32_HPP - -#include - -#include "../config.hpp" - -#include "input_pair.hpp" -#include "read_uint.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename R > - struct peek_utf32_impl - { - using data_t = char32_t; - using pair_t = input_pair< char32_t >; - - static_assert( sizeof( char32_t ) == 4, "expected size 4 for 32bit value" ); - - template< typename Input > - static pair_t peek( Input& in ) noexcept( noexcept( in.size( 4 ) ) ) - { - if( in.size( 4 ) < 4 ) { - return { 0, 0 }; - } - const char32_t t = R::read( in.current() ); - if( ( t <= 0x10ffff ) && !( t >= 0xd800 && t <= 0xdfff ) ) { - return { t, 4 }; - } - return { 0, 0 }; - } - }; - - using peek_utf32_be = peek_utf32_impl< read_uint32_be >; - using peek_utf32_le = peek_utf32_impl< read_uint32_le >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf8.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf8.hpp deleted file mode 100644 index 2c573e8..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/peek_utf8.hpp +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_PEEK_UTF8_HPP -#define TAO_PEGTL_INTERNAL_PEEK_UTF8_HPP - -#include "../config.hpp" - -#include "input_pair.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct peek_utf8 - { - using data_t = char32_t; - using pair_t = input_pair< char32_t >; - - template< typename Input > - static pair_t peek( Input& in ) noexcept( noexcept( in.empty() ) ) - { - if( in.empty() ) { - return { 0, 0 }; - } - char32_t c0 = in.peek_uint8(); - if( ( c0 & 0x80 ) == 0 ) { - return { c0, 1 }; - } - return peek_impl( in, c0 ); - } - - private: - template< typename Input > - static pair_t peek_impl( Input& in, char32_t c0 ) noexcept( noexcept( in.size( 4 ) ) ) - { - if( ( c0 & 0xE0 ) == 0xC0 ) { - if( in.size( 2 ) >= 2 ) { - const char32_t c1 = in.peek_uint8( 1 ); - if( ( c1 & 0xC0 ) == 0x80 ) { - c0 &= 0x1F; - c0 <<= 6; - c0 |= ( c1 & 0x3F ); - if( c0 >= 0x80 ) { - return { c0, 2 }; - } - } - } - } - else if( ( c0 & 0xF0 ) == 0xE0 ) { - if( in.size( 3 ) >= 3 ) { - const char32_t c1 = in.peek_uint8( 1 ); - const char32_t c2 = in.peek_uint8( 2 ); - if( ( ( c1 & 0xC0 ) == 0x80 ) && ( ( c2 & 0xC0 ) == 0x80 ) ) { - c0 &= 0x0F; - c0 <<= 6; - c0 |= ( c1 & 0x3F ); - c0 <<= 6; - c0 |= ( c2 & 0x3F ); - if( c0 >= 0x800 && !( c0 >= 0xD800 && c0 <= 0xDFFF ) ) { - return { c0, 3 }; - } - } - } - } - else if( ( c0 & 0xF8 ) == 0xF0 ) { - if( in.size( 4 ) >= 4 ) { - const char32_t c1 = in.peek_uint8( 1 ); - const char32_t c2 = in.peek_uint8( 2 ); - const char32_t c3 = in.peek_uint8( 3 ); - if( ( ( c1 & 0xC0 ) == 0x80 ) && ( ( c2 & 0xC0 ) == 0x80 ) && ( ( c3 & 0xC0 ) == 0x80 ) ) { - c0 &= 0x07; - c0 <<= 6; - c0 |= ( c1 & 0x3F ); - c0 <<= 6; - c0 |= ( c2 & 0x3F ); - c0 <<= 6; - c0 |= ( c3 & 0x3F ); - if( c0 >= 0x10000 && c0 <= 0x10FFFF ) { - return { c0, 4 }; - } - } - } - } - return { 0, 0 }; - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pegtl_string.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pegtl_string.hpp deleted file mode 100644 index f5700af..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/pegtl_string.hpp +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) 2015-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_PEGTL_STRING_HPP -#define TAO_PEGTL_INTERNAL_PEGTL_STRING_HPP - -#include -#include - -#include "../ascii.hpp" -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - // Inspired by https://github.com/irrequietus/typestring - // Rewritten and reduced to what is needed for the PEGTL - // and to work with Visual Studio 2015. - - namespace internal - { - template< typename, typename, typename, typename, typename, typename, typename, typename > - struct string_join; - - template< template< char... > class S, char... C0s, char... C1s, char... C2s, char... C3s, char... C4s, char... C5s, char... C6s, char... C7s > - struct string_join< S< C0s... >, S< C1s... >, S< C2s... >, S< C3s... >, S< C4s... >, S< C5s... >, S< C6s... >, S< C7s... > > - { - using type = S< C0s..., C1s..., C2s..., C3s..., C4s..., C5s..., C6s..., C7s... >; - }; - - template< template< char... > class S, char, bool > - struct string_at - { - using type = S<>; - }; - - template< template< char... > class S, char C > - struct string_at< S, C, true > - { - using type = S< C >; - }; - - template< typename T, std::size_t S > - struct string_max_length - { - static_assert( S <= 512, "String longer than 512 (excluding terminating \\0)!" ); - using type = T; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#define TAO_PEGTL_INTERNAL_EMPTY() -#define TAO_PEGTL_INTERNAL_DEFER( X ) X TAO_PEGTL_INTERNAL_EMPTY() -#define TAO_PEGTL_INTERNAL_EXPAND( ... ) __VA_ARGS__ - -#define TAO_PEGTL_INTERNAL_STRING_AT( S, x, n ) \ - tao::TAO_PEGTL_NAMESPACE::internal::string_at< S, ( 0##n < ( sizeof( x ) / sizeof( char ) ) ) ? ( x )[ 0##n ] : 0, ( 0##n < ( sizeof( x ) / sizeof( char ) ) - 1 ) >::type - -#define TAO_PEGTL_INTERNAL_JOIN_8( M, S, x, n ) \ - tao::TAO_PEGTL_NAMESPACE::internal::string_join< TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##0 ), \ - TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##1 ), \ - TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##2 ), \ - TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##3 ), \ - TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##4 ), \ - TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##5 ), \ - TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##6 ), \ - TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##7 ) >::type - -#define TAO_PEGTL_INTERNAL_STRING_8( S, x, n ) \ - TAO_PEGTL_INTERNAL_JOIN_8( TAO_PEGTL_INTERNAL_STRING_AT, S, x, n ) - -#define TAO_PEGTL_INTERNAL_STRING_64( S, x, n ) \ - TAO_PEGTL_INTERNAL_JOIN_8( TAO_PEGTL_INTERNAL_STRING_8, S, x, n ) - -#define TAO_PEGTL_INTERNAL_STRING_512( S, x, n ) \ - TAO_PEGTL_INTERNAL_JOIN_8( TAO_PEGTL_INTERNAL_STRING_64, S, x, n ) - -#define TAO_PEGTL_INTERNAL_STRING( S, x ) \ - TAO_PEGTL_INTERNAL_EXPAND( \ - TAO_PEGTL_INTERNAL_EXPAND( \ - TAO_PEGTL_INTERNAL_EXPAND( \ - tao::TAO_PEGTL_NAMESPACE::internal::string_max_length< TAO_PEGTL_INTERNAL_STRING_512( S, x, ), sizeof( x ) - 1 >::type ) ) ) - -#define TAO_PEGTL_STRING( x ) \ - TAO_PEGTL_INTERNAL_STRING( tao::TAO_PEGTL_NAMESPACE::ascii::string, x ) - -#define TAO_PEGTL_ISTRING( x ) \ - TAO_PEGTL_INTERNAL_STRING( tao::TAO_PEGTL_NAMESPACE::ascii::istring, x ) - -#define TAO_PEGTL_KEYWORD( x ) \ - TAO_PEGTL_INTERNAL_STRING( tao::TAO_PEGTL_NAMESPACE::ascii::keyword, x ) - -// Compatibility, remove with 3.0.0 -#define TAOCPP_PEGTL_STRING( x ) TAO_PEGTL_STRING( x ) -#define TAOCPP_PEGTL_ISTRING( x ) TAO_PEGTL_ISTRING( x ) -#define TAOCPP_PEGTL_KEYWORD( x ) TAO_PEGTL_KEYWORD( x ) - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/plus.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/plus.hpp deleted file mode 100644 index 2454ec2..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/plus.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_PLUS_HPP -#define TAO_PEGTL_INTERNAL_PLUS_HPP - -#include - -#include "../config.hpp" - -#include "opt.hpp" -#include "seq.hpp" -#include "skip_control.hpp" -#include "star.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - // While plus<> could easily be implemented with - // seq< Rule, Rules ..., star< Rule, Rules ... > > we - // provide an explicit implementation to optimise away - // the otherwise created input mark. - - template< typename Rule, typename... Rules > - struct plus - : plus< seq< Rule, Rules... > > - { - }; - - template< typename Rule > - struct plus< Rule > - { - using analyze_t = analysis::generic< analysis::rule_type::seq, Rule, opt< plus > >; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return Control< Rule >::template match< A, M, Action, Control >( in, st... ) && Control< star< Rule > >::template match< A, M, Action, Control >( in, st... ); - } - }; - - template< typename Rule, typename... Rules > - struct skip_control< plus< Rule, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/raise.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/raise.hpp deleted file mode 100644 index d4f6643..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/raise.hpp +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_RAISE_HPP -#define TAO_PEGTL_INTERNAL_RAISE_HPP - -#include -#include -#include - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename T > - struct raise - { - using analyze_t = analysis::generic< analysis::rule_type::any >; - -#ifdef _MSC_VER -#pragma warning( push ) -#pragma warning( disable : 4702 ) -#endif - template< apply_mode, - rewind_mode, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - Control< T >::raise( static_cast< const Input& >( in ), st... ); - throw std::logic_error( "code should be unreachable: Control< T >::raise() did not throw an exception" ); // NOLINT, LCOV_EXCL_LINE -#ifdef _MSC_VER -#pragma warning( pop ) -#endif - } - }; - - template< typename T > - struct skip_control< raise< T > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/range.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/range.hpp deleted file mode 100644 index 650eb79..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/range.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_RANGE_HPP -#define TAO_PEGTL_INTERNAL_RANGE_HPP - -#include "../config.hpp" - -#include "bump_help.hpp" -#include "result_on_found.hpp" -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< result_on_found R, typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi > - struct range - { - static_assert( Lo <= Hi, "invalid range detected" ); - - using analyze_t = analysis::generic< analysis::rule_type::any >; - - template< int Eol > - struct can_match_eol - { - static constexpr bool value = ( ( ( Lo <= Eol ) && ( Eol <= Hi ) ) == bool( R ) ); - }; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) ) - { - if( const auto t = Peek::peek( in ) ) { - if( ( ( Lo <= t.data ) && ( t.data <= Hi ) ) == bool( R ) ) { - bump_impl< can_match_eol< Input::eol_t::ch >::value >::bump( in, t.size ); - return true; - } - } - return false; - } - }; - - template< result_on_found R, typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi > - struct skip_control< range< R, Peek, Lo, Hi > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/ranges.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/ranges.hpp deleted file mode 100644 index 9621759..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/ranges.hpp +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_RANGES_HPP -#define TAO_PEGTL_INTERNAL_RANGES_HPP - -#include "../config.hpp" - -#include "bump_help.hpp" -#include "range.hpp" -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< int Eol, typename Char, Char... Cs > - struct ranges_impl; - - template< int Eol, typename Char > - struct ranges_impl< Eol, Char > - { - static constexpr bool can_match_eol = false; - - static bool match( const Char /*unused*/ ) noexcept - { - return false; - } - }; - - template< int Eol, typename Char, Char Eq > - struct ranges_impl< Eol, Char, Eq > - { - static constexpr bool can_match_eol = ( Eq == Eol ); - - static bool match( const Char c ) noexcept - { - return c == Eq; - } - }; - - template< int Eol, typename Char, Char Lo, Char Hi, Char... Cs > - struct ranges_impl< Eol, Char, Lo, Hi, Cs... > - { - static_assert( Lo <= Hi, "invalid range detected" ); - - static constexpr bool can_match_eol = ( ( ( Lo <= Eol ) && ( Eol <= Hi ) ) || ranges_impl< Eol, Char, Cs... >::can_match_eol ); - - static bool match( const Char c ) noexcept - { - return ( ( Lo <= c ) && ( c <= Hi ) ) || ranges_impl< Eol, Char, Cs... >::match( c ); - } - }; - - template< typename Peek, typename Peek::data_t... Cs > - struct ranges - { - using analyze_t = analysis::generic< analysis::rule_type::any >; - - template< int Eol > - struct can_match_eol - { - static constexpr bool value = ranges_impl< Eol, typename Peek::data_t, Cs... >::can_match_eol; - }; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) ) - { - if( const auto t = Peek::peek( in ) ) { - if( ranges_impl< Input::eol_t::ch, typename Peek::data_t, Cs... >::match( t.data ) ) { - bump_impl< can_match_eol< Input::eol_t::ch >::value >::bump( in, t.size ); - return true; - } - } - return false; - } - }; - - template< typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi > - struct ranges< Peek, Lo, Hi > - : range< result_on_found::success, Peek, Lo, Hi > - { - }; - - template< typename Peek, typename Peek::data_t... Cs > - struct skip_control< ranges< Peek, Cs... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/read_uint.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/read_uint.hpp deleted file mode 100644 index 9e975ae..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/read_uint.hpp +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_READ_UINT_HPP -#define TAO_PEGTL_INTERNAL_READ_UINT_HPP - -#include - -#include "../config.hpp" - -#include "endian.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct read_uint16_be - { - using type = std::uint16_t; - - static std::uint16_t read( const void* d ) noexcept - { - return be_to_h< std::uint16_t >( d ); - } - }; - - struct read_uint16_le - { - using type = std::uint16_t; - - static std::uint16_t read( const void* d ) noexcept - { - return le_to_h< std::uint16_t >( d ); - } - }; - - struct read_uint32_be - { - using type = std::uint32_t; - - static std::uint32_t read( const void* d ) noexcept - { - return be_to_h< std::uint32_t >( d ); - } - }; - - struct read_uint32_le - { - using type = std::uint32_t; - - static std::uint32_t read( const void* d ) noexcept - { - return le_to_h< std::uint32_t >( d ); - } - }; - - struct read_uint64_be - { - using type = std::uint64_t; - - static std::uint64_t read( const void* d ) noexcept - { - return be_to_h< std::uint64_t >( d ); - } - }; - - struct read_uint64_le - { - using type = std::uint64_t; - - static std::uint64_t read( const void* d ) noexcept - { - return le_to_h< std::uint64_t >( d ); - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rematch.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rematch.hpp deleted file mode 100644 index a43ef89..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rematch.hpp +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_REMATCH_HPP -#define TAO_PEGTL_INTERNAL_REMATCH_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../memory_input.hpp" -#include "../rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Head, typename... Rules > - struct rematch; - - template< typename Head > - struct rematch< Head > - { - using analyze_t = typename Head::analyze_t; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return Control< Head >::template match< A, M, Action, Control >( in, st... ); - } - }; - - template< typename Head, typename Rule, typename... Rules > - struct rematch< Head, Rule, Rules... > - { - using analyze_t = typename Head::analyze_t; // NOTE: Rule and Rules are ignored for analyze(). - - template< apply_mode A, - rewind_mode, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< rewind_mode::required >(); - - if( Control< Head >::template match< A, rewind_mode::active, Action, Control >( in, st... ) ) { - memory_input< Input::tracking_mode_v, typename Input::eol_t, typename Input::source_t > i2( m.iterator(), in.current(), in.source() ); -#ifdef __cpp_fold_expressions - return m( ( Control< Rule >::template match< A, rewind_mode::active, Action, Control >( i2, st... ) && ... && ( i2.restart( m ), Control< Rules >::template match< A, rewind_mode::active, Action, Control >( i2, st... ) ) ) ); -#else - bool result = Control< Rule >::template match< A, rewind_mode::active, Action, Control >( i2, st... ); - using swallow = bool[]; - (void)swallow{ result = result && ( i2.restart( m ), Control< Rules >::template match< A, rewind_mode::active, Action, Control >( i2, st... ) )..., true }; - return m( result ); -#endif - } - return false; - } - }; - - template< typename Head, typename... Rules > - struct skip_control< rematch< Head, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep.hpp deleted file mode 100644 index 58cddef..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep.hpp +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_REP_HPP -#define TAO_PEGTL_INTERNAL_REP_HPP - -#include "../config.hpp" - -#include "seq.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/counted.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< unsigned Num, typename... Rules > - struct rep - : rep< Num, seq< Rules... > > - { - }; - - template< unsigned Num > - struct rep< Num > - : trivial< true > - { - }; - - template< typename Rule > - struct rep< 0, Rule > - : trivial< true > - { - }; - - template< unsigned Num, typename Rule > - struct rep< Num, Rule > - { - using analyze_t = analysis::counted< analysis::rule_type::seq, Num, Rule >; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< M >(); - using m_t = decltype( m ); - - for( unsigned i = 0; i != Num; ++i ) { - if( !Control< Rule >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) { - return false; - } - } - return m( true ); - } - }; - - template< unsigned Num, typename... Rules > - struct skip_control< rep< Num, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_min.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_min.hpp deleted file mode 100644 index 869ac11..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_min.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_REP_MIN_HPP -#define TAO_PEGTL_INTERNAL_REP_MIN_HPP - -#include "../config.hpp" - -#include "rep.hpp" -#include "seq.hpp" -#include "star.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< unsigned Min, typename Rule, typename... Rules > - using rep_min = seq< rep< Min, Rule, Rules... >, star< Rule, Rules... > >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_min_max.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_min_max.hpp deleted file mode 100644 index e584969..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_min_max.hpp +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_REP_MIN_MAX_HPP -#define TAO_PEGTL_INTERNAL_REP_MIN_MAX_HPP - -#include - -#include "../config.hpp" - -#include "not_at.hpp" -#include "seq.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/counted.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< unsigned Min, unsigned Max, typename... Rules > - struct rep_min_max - : rep_min_max< Min, Max, seq< Rules... > > - { - }; - - template< unsigned Min, unsigned Max > - struct rep_min_max< Min, Max > - : trivial< false > - { - static_assert( Min <= Max, "invalid rep_min_max rule (maximum number of repetitions smaller than minimum)" ); - }; - - template< typename Rule > - struct rep_min_max< 0, 0, Rule > - : not_at< Rule > - { - }; - - template< unsigned Min, unsigned Max, typename Rule > - struct rep_min_max< Min, Max, Rule > - { - using analyze_t = analysis::counted< analysis::rule_type::seq, Min, Rule >; - - static_assert( Min <= Max, "invalid rep_min_max rule (maximum number of repetitions smaller than minimum)" ); - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< M >(); - using m_t = decltype( m ); - - for( unsigned i = 0; i != Min; ++i ) { - if( !Control< Rule >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) { - return false; - } - } - for( unsigned i = Min; i != Max; ++i ) { - if( !Control< Rule >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { - return m( true ); - } - } - return m( Control< not_at< Rule > >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ); // NOTE that not_at<> will always rewind. - } - }; - - template< unsigned Min, unsigned Max, typename... Rules > - struct skip_control< rep_min_max< Min, Max, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_opt.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_opt.hpp deleted file mode 100644 index 59ca8eb..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rep_opt.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_REP_OPT_HPP -#define TAO_PEGTL_INTERNAL_REP_OPT_HPP - -#include "../config.hpp" - -#include "seq.hpp" -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< unsigned Max, typename... Rules > - struct rep_opt - : rep_opt< Max, seq< Rules... > > - { - }; - - template< unsigned Max, typename Rule > - struct rep_opt< Max, Rule > - { - using analyze_t = analysis::generic< analysis::rule_type::opt, Rule >; - - template< apply_mode A, - rewind_mode, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - for( unsigned i = 0; ( i != Max ) && Control< Rule >::template match< A, rewind_mode::required, Action, Control >( in, st... ); ++i ) { - } - return true; - } - }; - - template< unsigned Max, typename... Rules > - struct skip_control< rep_opt< Max, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/require.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/require.hpp deleted file mode 100644 index 043a5b7..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/require.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_REQUIRE_HPP -#define TAO_PEGTL_INTERNAL_REQUIRE_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< unsigned Amount > - struct require; - - template<> - struct require< 0 > - : trivial< true > - { - }; - - template< unsigned Amount > - struct require - { - using analyze_t = analysis::generic< analysis::rule_type::opt >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) ) - { - return in.size( Amount ) >= Amount; - } - }; - - template< unsigned Amount > - struct skip_control< require< Amount > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/result_on_found.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/result_on_found.hpp deleted file mode 100644 index 79a1976..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/result_on_found.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_RESULT_ON_FOUND_HPP -#define TAO_PEGTL_INTERNAL_RESULT_ON_FOUND_HPP - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - enum class result_on_found : bool - { - success = true, - failure = false, - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rules.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rules.hpp deleted file mode 100644 index fc56a6e..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/rules.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_RULES_HPP -#define TAO_PEGTL_INTERNAL_RULES_HPP - -#include "action.hpp" -#include "alnum.hpp" -#include "alpha.hpp" -#include "any.hpp" -#include "apply.hpp" -#include "apply0.hpp" -#include "at.hpp" -#include "bof.hpp" -#include "bol.hpp" -#include "bytes.hpp" -#include "control.hpp" -#include "disable.hpp" -#include "discard.hpp" -#include "enable.hpp" -#include "eof.hpp" -#include "eol.hpp" -#include "eolf.hpp" -#include "identifier.hpp" -#include "if_apply.hpp" -#include "if_must.hpp" -#include "if_must_else.hpp" -#include "if_then_else.hpp" -#include "istring.hpp" -#include "list.hpp" -#include "list_must.hpp" -#include "list_tail.hpp" -#include "list_tail_pad.hpp" -#include "must.hpp" -#include "not_at.hpp" -#include "one.hpp" -#include "opt.hpp" -#include "pad.hpp" -#include "pad_opt.hpp" -#include "plus.hpp" -#include "raise.hpp" -#include "range.hpp" -#include "ranges.hpp" -#include "rematch.hpp" -#include "rep.hpp" -#include "rep_min.hpp" -#include "rep_min_max.hpp" -#include "rep_opt.hpp" -#include "require.hpp" -#include "seq.hpp" -#include "skip_control.hpp" -#include "sor.hpp" -#include "star.hpp" -#include "star_must.hpp" -#include "state.hpp" -#include "string.hpp" -#include "trivial.hpp" -#include "try_catch_type.hpp" -#include "until.hpp" - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/seq.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/seq.hpp deleted file mode 100644 index ab03575..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/seq.hpp +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_SEQ_HPP -#define TAO_PEGTL_INTERNAL_SEQ_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename... Rules > - struct seq; - - template<> - struct seq<> - : trivial< true > - { - }; - - template< typename Rule > - struct seq< Rule > - { - using analyze_t = typename Rule::analyze_t; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return Control< Rule >::template match< A, M, Action, Control >( in, st... ); - } - }; - - template< typename... Rules > - struct seq - { - using analyze_t = analysis::generic< analysis::rule_type::seq, Rules... >; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< M >(); - using m_t = decltype( m ); -#ifdef __cpp_fold_expressions - return m( ( Control< Rules >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) && ... ) ); -#else - bool result = true; - using swallow = bool[]; - (void)swallow{ result = result && Control< Rules >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... )... }; - return m( result ); -#endif - } - - }; // namespace internal - - template< typename... Rules > - struct skip_control< seq< Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/skip_control.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/skip_control.hpp deleted file mode 100644 index 2375d4c..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/skip_control.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_SKIP_CONTROL_HPP -#define TAO_PEGTL_INTERNAL_SKIP_CONTROL_HPP - -#include - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - // This class is a simple tagging mechanism. - // By default, skip_control< Rule >::value - // is 'false'. Each internal (!) rule that should - // be hidden from the control and action class' - // callbacks simply specializes skip_control<> - // to return 'true' for the above expression. - - template< typename Rule > - struct skip_control : std::false_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/sor.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/sor.hpp deleted file mode 100644 index 7be085d..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/sor.hpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_SOR_HPP -#define TAO_PEGTL_INTERNAL_SOR_HPP - -#include "../config.hpp" - -#include "integer_sequence.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename... Rules > - struct sor; - - template<> - struct sor<> - : trivial< false > - { - }; - - template< typename... Rules > - struct sor - : sor< index_sequence_for< Rules... >, Rules... > - { - }; - - template< std::size_t... Indices, typename... Rules > - struct sor< index_sequence< Indices... >, Rules... > - { - using analyze_t = analysis::generic< analysis::rule_type::sor, Rules... >; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { -#ifdef __cpp_fold_expressions - return ( Control< Rules >::template match < A, ( Indices == ( sizeof...( Rules ) - 1 ) ) ? M : rewind_mode::required, Action, Control > ( in, st... ) || ... ); -#else - bool result = false; - using swallow = bool[]; - (void)swallow{ result = result || Control< Rules >::template match < A, ( Indices == ( sizeof...( Rules ) - 1 ) ) ? M : rewind_mode::required, Action, Control > ( in, st... )... }; - return result; -#endif - } - }; - - template< typename... Rules > - struct skip_control< sor< Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/star.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/star.hpp deleted file mode 100644 index d46479f..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/star.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_STAR_HPP -#define TAO_PEGTL_INTERNAL_STAR_HPP - -#include - -#include "../config.hpp" - -#include "seq.hpp" -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename... Rules > - struct star - : star< seq< Rule, Rules... > > - {}; - - template< typename Rule > - struct star< Rule > - { - using analyze_t = analysis::generic< analysis::rule_type::opt, Rule, star >; - - template< apply_mode A, - rewind_mode, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - while( Control< Rule >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { - } - return true; - } - }; - - template< typename Rule, typename... Rules > - struct skip_control< star< Rule, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/star_must.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/star_must.hpp deleted file mode 100644 index 84e5a44..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/star_must.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_STAR_MUST_HPP -#define TAO_PEGTL_INTERNAL_STAR_MUST_HPP - -#include "../config.hpp" - -#include "if_must.hpp" -#include "star.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Cond, typename... Rules > - using star_must = star< if_must< false, Cond, Rules... > >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/state.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/state.hpp deleted file mode 100644 index 891d80b..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/state.hpp +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_STATE_HPP -#define TAO_PEGTL_INTERNAL_STATE_HPP - -#include "../config.hpp" - -#include "seq.hpp" -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename State, typename... Rules > - struct state - : state< State, seq< Rules... > > - { - }; - - template< typename State, typename Rule > - struct state< State, Rule > - { - using analyze_t = analysis::generic< analysis::rule_type::seq, Rule >; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static auto success( State& s, const Input& in, States&&... st ) - -> decltype( s.template success< A, M, Action, Control >( in, st... ), void() ) - { - s.template success< A, M, Action, Control >( in, st... ); - } - - // NOTE: The additional "int = 0" is a work-around for missing expression SFINAE in VS2015. - - template< apply_mode, - rewind_mode, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States, - int = 0 > - static auto success( State& s, const Input& in, States&&... st ) - -> decltype( s.success( in, st... ), void() ) - { - s.success( in, st... ); - } - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - State s( static_cast< const Input& >( in ), st... ); - - if( Control< Rule >::template match< A, M, Action, Control >( in, s ) ) { - success< A, M, Action, Control >( s, in, st... ); - return true; - } - return false; - } - }; - - template< typename State, typename... Rules > - struct skip_control< state< State, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/string.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/string.hpp deleted file mode 100644 index 3190328..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/string.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_STRING_HPP -#define TAO_PEGTL_INTERNAL_STRING_HPP - -#include -#include - -#include "../config.hpp" - -#include "bump_help.hpp" -#include "result_on_found.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../analysis/counted.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - inline bool unsafe_equals( const char* s, const std::initializer_list< char >& l ) noexcept - { - return std::memcmp( s, &*l.begin(), l.size() ) == 0; - } - - template< char... Cs > - struct string; - - template<> - struct string<> - : trivial< true > - { - }; - - template< char... Cs > - struct string - { - using analyze_t = analysis::counted< analysis::rule_type::any, sizeof...( Cs ) >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) ) - { - if( in.size( sizeof...( Cs ) ) >= sizeof...( Cs ) ) { - if( unsafe_equals( in.current(), { Cs... } ) ) { - bump_help< result_on_found::success, Input, char, Cs... >( in, sizeof...( Cs ) ); - return true; - } - } - return false; - } - }; - - template< char... Cs > - struct skip_control< string< Cs... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/trivial.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/trivial.hpp deleted file mode 100644 index 9b764dc..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/trivial.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_TRIVIAL_HPP -#define TAO_PEGTL_INTERNAL_TRIVIAL_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/counted.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< bool Result > - struct trivial - { - using analyze_t = analysis::counted< analysis::rule_type::any, unsigned( !Result ) >; - - template< typename Input > - static bool match( Input& /*unused*/ ) noexcept - { - return Result; - } - }; - - template< bool Result > - struct skip_control< trivial< Result > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/try_catch_type.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/try_catch_type.hpp deleted file mode 100644 index 3612c19..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/try_catch_type.hpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_TRY_CATCH_TYPE_HPP -#define TAO_PEGTL_INTERNAL_TRY_CATCH_TYPE_HPP - -#include - -#include "../config.hpp" - -#include "seq.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Exception, typename... Rules > - struct try_catch_type - : try_catch_type< Exception, seq< Rules... > > - { - }; - - template< typename Exception > - struct try_catch_type< Exception > - : trivial< true > - { - }; - - template< typename Exception, typename Rule > - struct try_catch_type< Exception, Rule > - { - using analyze_t = analysis::generic< analysis::rule_type::seq, Rule >; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< M >(); - using m_t = decltype( m ); - - try { - return m( Control< Rule >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ); - } - catch( const Exception& ) { - return false; - } - } - }; - - template< typename Exception, typename... Rules > - struct skip_control< try_catch_type< Exception, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/until.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/until.hpp deleted file mode 100644 index 3e44dc2..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/internal/until.hpp +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_UNTIL_HPP -#define TAO_PEGTL_INTERNAL_UNTIL_HPP - -#include "../config.hpp" - -#include "bytes.hpp" -#include "eof.hpp" -#include "not_at.hpp" -#include "seq.hpp" -#include "skip_control.hpp" -#include "star.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Cond, typename... Rules > - struct until - : until< Cond, seq< Rules... > > - { - }; - - template< typename Cond > - struct until< Cond > - { - using analyze_t = analysis::generic< analysis::rule_type::seq, star< not_at< Cond >, not_at< eof >, bytes< 1 > >, Cond >; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< M >(); - - while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { - if( in.empty() ) { - return false; - } - in.bump(); - } - return m( true ); - } - }; - - template< typename Cond, typename Rule > - struct until< Cond, Rule > - { - using analyze_t = analysis::generic< analysis::rule_type::seq, star< not_at< Cond >, not_at< eof >, Rule >, Cond >; - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< M >(); - using m_t = decltype( m ); - - while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { - if( !Control< Rule >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) { - return false; - } - } - return m( true ); - } - }; - - template< typename Cond, typename... Rules > - struct skip_control< until< Cond, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/istream_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/istream_input.hpp deleted file mode 100644 index 4dfe01f..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/istream_input.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_ISTREAM_INPUT_HPP -#define TAO_PEGTL_ISTREAM_INPUT_HPP - -#include - -#include "buffer_input.hpp" -#include "config.hpp" -#include "eol.hpp" - -#include "internal/istream_reader.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - template< typename Eol = eol::lf_crlf, std::size_t Chunk = 64 > - struct istream_input - : buffer_input< internal::istream_reader, Eol, std::string, Chunk > - { - template< typename T > - istream_input( std::istream& in_stream, const std::size_t in_maximum, T&& in_source ) - : buffer_input< internal::istream_reader, Eol, std::string, Chunk >( std::forward< T >( in_source ), in_maximum, in_stream ) - { - } - }; - -#ifdef __cpp_deduction_guides - template< typename... Ts > - istream_input( Ts&&... )->istream_input<>; -#endif - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/match.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/match.hpp deleted file mode 100644 index 802e715..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/match.hpp +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_MATCH_HPP -#define TAO_PEGTL_MATCH_HPP - -#include - -#include "apply_mode.hpp" -#include "config.hpp" -#include "nothing.hpp" -#include "require_apply.hpp" -#include "require_apply0.hpp" -#include "rewind_mode.hpp" - -#include "internal/dusel_mode.hpp" -#include "internal/duseltronik.hpp" -#include "internal/has_apply.hpp" -#include "internal/has_apply0.hpp" -#include "internal/if_missing.hpp" -#include "internal/skip_control.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - bool match( Input& in, States&&... st ) - { - constexpr bool enable_control = !internal::skip_control< Rule >::value; - constexpr bool enable_action = enable_control && ( A == apply_mode::action ); - - using iterator_t = typename Input::iterator_t; - constexpr bool has_apply_void = enable_action && internal::has_apply< Control< Rule >, void, Action, const iterator_t&, const Input&, States... >::value; - constexpr bool has_apply_bool = enable_action && internal::has_apply< Control< Rule >, bool, Action, const iterator_t&, const Input&, States... >::value; - constexpr bool has_apply = has_apply_void || has_apply_bool; - - constexpr bool has_apply0_void = enable_action && internal::has_apply0< Control< Rule >, void, Action, const Input&, States... >::value; - constexpr bool has_apply0_bool = enable_action && internal::has_apply0< Control< Rule >, bool, Action, const Input&, States... >::value; - constexpr bool has_apply0 = has_apply0_void || has_apply0_bool; - - static_assert( !( has_apply && has_apply0 ), "both apply() and apply0() defined" ); - - constexpr bool is_nothing = std::is_base_of< nothing< Rule >, Action< Rule > >::value; - static_assert( !( has_apply && is_nothing ), "unexpected apply() defined" ); - static_assert( !( has_apply0 && is_nothing ), "unexpected apply0() defined" ); - - internal::if_missing< !has_apply && std::is_base_of< require_apply, Action< Rule > >::value >::template apply< Control< Rule >, Action >( in, st... ); - internal::if_missing< !has_apply0 && std::is_base_of< require_apply0, Action< Rule > >::value >::template apply0< Control< Rule >, Action >( in, st... ); - - constexpr bool validate_nothing = std::is_base_of< maybe_nothing, Action< void > >::value; - constexpr bool is_maybe_nothing = std::is_base_of< maybe_nothing, Action< Rule > >::value; - static_assert( !enable_action || !validate_nothing || is_nothing || is_maybe_nothing || has_apply || has_apply0, "either apply() or apply0() must be defined" ); - - constexpr auto mode = static_cast< internal::dusel_mode >( enable_control + has_apply_void + 2 * has_apply_bool + 3 * has_apply0_void + 4 * has_apply0_bool ); - return internal::duseltronik< Rule, A, M, Action, Control, mode >::match( in, st... ); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/memory_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/memory_input.hpp deleted file mode 100644 index 0ce7890..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/memory_input.hpp +++ /dev/null @@ -1,378 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_MEMORY_INPUT_HPP -#define TAO_PEGTL_MEMORY_INPUT_HPP - -#include -#include -#include -#include -#include -#include - -#include "config.hpp" -#include "eol.hpp" -#include "normal.hpp" -#include "nothing.hpp" -#include "position.hpp" -#include "tracking_mode.hpp" - -#include "internal/action_input.hpp" -#include "internal/at.hpp" -#include "internal/bump.hpp" -#include "internal/eolf.hpp" -#include "internal/iterator.hpp" -#include "internal/marker.hpp" -#include "internal/until.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< tracking_mode, typename Eol, typename Source > - class memory_input_base; - - template< typename Eol, typename Source > - class memory_input_base< tracking_mode::eager, Eol, Source > - { - public: - using iterator_t = internal::iterator; - - template< typename T > - memory_input_base( const iterator_t& in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) - : m_begin( in_begin.data ), - m_current( in_begin ), - m_end( in_end ), - m_source( std::forward< T >( in_source ) ) - { - } - - template< typename T > - memory_input_base( const char* in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) - : m_begin( in_begin ), - m_current( in_begin ), - m_end( in_end ), - m_source( std::forward< T >( in_source ) ) - { - } - - memory_input_base( const memory_input_base& ) = delete; - memory_input_base( memory_input_base&& ) = delete; - - ~memory_input_base() = default; - - memory_input_base operator=( const memory_input_base& ) = delete; - memory_input_base operator=( memory_input_base&& ) = delete; - - const char* current() const noexcept - { - return m_current.data; - } - - const char* begin() const noexcept - { - return m_begin; - } - - const char* end( const std::size_t /*unused*/ = 0 ) const noexcept - { - return m_end; - } - - std::size_t byte() const noexcept - { - return m_current.byte; - } - - std::size_t line() const noexcept - { - return m_current.line; - } - - std::size_t byte_in_line() const noexcept - { - return m_current.byte_in_line; - } - - void bump( const std::size_t in_count = 1 ) noexcept - { - internal::bump( m_current, in_count, Eol::ch ); - } - - void bump_in_this_line( const std::size_t in_count = 1 ) noexcept - { - internal::bump_in_this_line( m_current, in_count ); - } - - void bump_to_next_line( const std::size_t in_count = 1 ) noexcept - { - internal::bump_to_next_line( m_current, in_count ); - } - - TAO_PEGTL_NAMESPACE::position position( const iterator_t& it ) const - { - return TAO_PEGTL_NAMESPACE::position( it, m_source ); - } - - void restart( const std::size_t in_byte = 0, const std::size_t in_line = 1, const std::size_t in_byte_in_line = 0 ) - { - m_current.data = m_begin; - m_current.byte = in_byte; - m_current.line = in_line; - m_current.byte_in_line = in_byte_in_line; - } - - protected: - const char* const m_begin; - iterator_t m_current; - const char* const m_end; - const Source m_source; - }; - - template< typename Eol, typename Source > - class memory_input_base< tracking_mode::lazy, Eol, Source > - { - public: - using iterator_t = const char*; - - template< typename T > - memory_input_base( const internal::iterator& in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) - : m_begin( in_begin ), - m_current( in_begin.data ), - m_end( in_end ), - m_source( std::forward< T >( in_source ) ) - { - } - - template< typename T > - memory_input_base( const char* in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) - : m_begin( in_begin ), - m_current( in_begin ), - m_end( in_end ), - m_source( std::forward< T >( in_source ) ) - { - } - - memory_input_base( const memory_input_base& ) = delete; - memory_input_base( memory_input_base&& ) = delete; - - ~memory_input_base() = default; - - memory_input_base operator=( const memory_input_base& ) = delete; - memory_input_base operator=( memory_input_base&& ) = delete; - - const char* current() const noexcept - { - return m_current; - } - - const char* begin() const noexcept - { - return m_begin.data; - } - - const char* end( const std::size_t /*unused*/ = 0 ) const noexcept - { - return m_end; - } - - std::size_t byte() const noexcept - { - return std::size_t( current() - m_begin.data ); - } - - void bump( const std::size_t in_count = 1 ) noexcept - { - m_current += in_count; - } - - void bump_in_this_line( const std::size_t in_count = 1 ) noexcept - { - m_current += in_count; - } - - void bump_to_next_line( const std::size_t in_count = 1 ) noexcept - { - m_current += in_count; - } - - TAO_PEGTL_NAMESPACE::position position( const iterator_t it ) const - { - internal::iterator c( m_begin ); - internal::bump( c, std::size_t( it - m_begin.data ), Eol::ch ); - return TAO_PEGTL_NAMESPACE::position( c, m_source ); - } - - void restart() - { - m_current = m_begin.data; - } - - protected: - const internal::iterator m_begin; - iterator_t m_current; - const char* const m_end; - const Source m_source; - }; - - } // namespace internal - - template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf, typename Source = std::string > - class memory_input - : public internal::memory_input_base< P, Eol, Source > - { - public: - static constexpr tracking_mode tracking_mode_v = P; - - using eol_t = Eol; - using source_t = Source; - - using typename internal::memory_input_base< P, Eol, Source >::iterator_t; - - using action_t = internal::action_input< memory_input >; - - using internal::memory_input_base< P, Eol, Source >::memory_input_base; - - template< typename T > - memory_input( const char* in_begin, const std::size_t in_size, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) - : memory_input( in_begin, in_begin + in_size, std::forward< T >( in_source ) ) - { - } - - template< typename T > - memory_input( const std::string& in_string, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) - : memory_input( in_string.data(), in_string.size(), std::forward< T >( in_source ) ) - { - } - - template< typename T > - memory_input( std::string&&, T&& ) = delete; - - template< typename T > - memory_input( const char* in_begin, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) - : memory_input( in_begin, std::strlen( in_begin ), std::forward< T >( in_source ) ) - { - } - - template< typename T > - memory_input( const char* in_begin, const char* in_end, T&& in_source, const std::size_t in_byte, const std::size_t in_line, const std::size_t in_byte_in_line ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) - : memory_input( { in_begin, in_byte, in_line, in_byte_in_line }, in_end, std::forward< T >( in_source ) ) - { - } - - memory_input( const memory_input& ) = delete; - memory_input( memory_input&& ) = delete; - - ~memory_input() = default; - - memory_input operator=( const memory_input& ) = delete; - memory_input operator=( memory_input&& ) = delete; - - const Source& source() const noexcept - { - return this->m_source; - } - - bool empty() const noexcept - { - return this->current() == this->end(); - } - - std::size_t size( const std::size_t /*unused*/ = 0 ) const noexcept - { - return std::size_t( this->end() - this->current() ); - } - - char peek_char( const std::size_t offset = 0 ) const noexcept - { - return this->current()[ offset ]; - } - - std::uint8_t peek_uint8( const std::size_t offset = 0 ) const noexcept - { - return static_cast< std::uint8_t >( peek_char( offset ) ); - } - - // Compatibility, remove with 3.0.0 - std::uint8_t peek_byte( const std::size_t offset = 0 ) const noexcept - { - return static_cast< std::uint8_t >( peek_char( offset ) ); - } - - iterator_t& iterator() noexcept - { - return this->m_current; - } - - const iterator_t& iterator() const noexcept - { - return this->m_current; - } - - using internal::memory_input_base< P, Eol, Source >::restart; - - template< rewind_mode M > - void restart( const internal::marker< iterator_t, M >& m ) - { - iterator() = m.iterator(); - } - - using internal::memory_input_base< P, Eol, Source >::position; - - TAO_PEGTL_NAMESPACE::position position() const - { - return position( iterator() ); - } - - void discard() const noexcept - { - } - - void require( const std::size_t /*unused*/ ) const noexcept - { - } - - template< rewind_mode M > - internal::marker< iterator_t, M > mark() noexcept - { - return internal::marker< iterator_t, M >( iterator() ); - } - - const char* at( const TAO_PEGTL_NAMESPACE::position& p ) const noexcept - { - return this->begin() + p.byte; - } - - const char* begin_of_line( const TAO_PEGTL_NAMESPACE::position& p ) const noexcept - { - return at( p ) - p.byte_in_line; - } - - const char* end_of_line( const TAO_PEGTL_NAMESPACE::position& p ) const noexcept - { - using input_t = memory_input< tracking_mode::lazy, Eol, const char* >; - input_t in( at( p ), this->end(), "" ); - using grammar = internal::until< internal::at< internal::eolf > >; - normal< grammar >::match< apply_mode::nothing, rewind_mode::dontcare, nothing, normal >( in ); - return in.current(); - } - - std::string line_at( const TAO_PEGTL_NAMESPACE::position& p ) const - { - return std::string( begin_of_line( p ), end_of_line( p ) ); - } - }; - -#ifdef __cpp_deduction_guides - template< typename... Ts > - memory_input( Ts&&... )->memory_input<>; -#endif - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/mmap_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/mmap_input.hpp deleted file mode 100644 index f5f2b8c..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/mmap_input.hpp +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_MMAP_INPUT_HPP -#define TAO_PEGTL_MMAP_INPUT_HPP - -#include -#include - -#include "config.hpp" -#include "eol.hpp" -#include "memory_input.hpp" -#include "tracking_mode.hpp" - -#if defined( __unix__ ) || ( defined( __APPLE__ ) && defined( __MACH__ ) ) -#include // Required for _POSIX_MAPPED_FILES -#endif - -#if defined( _POSIX_MAPPED_FILES ) -#include "internal/file_mapper_posix.hpp" -#elif defined( _WIN32 ) -#include "internal/file_mapper_win32.hpp" -#else -#endif - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct mmap_holder - { - const std::string filename; - const file_mapper data; - - template< typename T > - explicit mmap_holder( T&& in_filename ) - : filename( std::forward< T >( in_filename ) ), - data( filename.c_str() ) - { - } - - mmap_holder( const mmap_holder& ) = delete; - mmap_holder( mmap_holder&& ) = delete; - - ~mmap_holder() = default; - - void operator=( const mmap_holder& ) = delete; - void operator=( mmap_holder&& ) = delete; - }; - - } // namespace internal - - template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > - struct mmap_input - : private internal::mmap_holder, - public memory_input< P, Eol, const char* > - { - template< typename T > - explicit mmap_input( T&& in_filename ) - : internal::mmap_holder( std::forward< T >( in_filename ) ), - memory_input< P, Eol, const char* >( data.begin(), data.end(), filename.c_str() ) - { - } - - mmap_input( const mmap_input& ) = delete; - mmap_input( mmap_input&& ) = delete; - - ~mmap_input() = default; - - void operator=( const mmap_input& ) = delete; - void operator=( mmap_input&& ) = delete; - }; - -#ifdef __cpp_deduction_guides - template< typename... Ts > - explicit mmap_input( Ts&&... )->mmap_input<>; -#endif - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/normal.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/normal.hpp deleted file mode 100644 index 9db70d4..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/normal.hpp +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_NORMAL_HPP -#define TAO_PEGTL_NORMAL_HPP - -#include -#include - -#include "apply_mode.hpp" -#include "config.hpp" -#include "match.hpp" -#include "parse_error.hpp" -#include "rewind_mode.hpp" - -#include "internal/demangle.hpp" -#include "internal/has_match.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - template< typename Rule > - struct normal - { - template< typename Input, typename... States > - static void start( const Input& /*unused*/, States&&... /*unused*/ ) noexcept - { - } - - template< typename Input, typename... States > - static void success( const Input& /*unused*/, States&&... /*unused*/ ) noexcept - { - } - - template< typename Input, typename... States > - static void failure( const Input& /*unused*/, States&&... /*unused*/ ) noexcept - { - } - - template< typename Input, typename... States > - static void raise( const Input& in, States&&... /*unused*/ ) - { - throw parse_error( "parse error matching " + internal::demangle< Rule >(), in ); - } - - template< template< typename... > class Action, typename Input, typename... States > - static auto apply0( const Input& /*unused*/, States&&... st ) - -> decltype( Action< Rule >::apply0( st... ) ) - { - return Action< Rule >::apply0( st... ); - } - - template< template< typename... > class Action, typename Iterator, typename Input, typename... States > - static auto apply( const Iterator& begin, const Input& in, States&&... st ) - -> decltype( Action< Rule >::apply( std::declval< typename Input::action_t >(), st... ) ) - { - const typename Input::action_t action_input( begin, in ); - return Action< Rule >::apply( action_input, st... ); - } - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States > - static auto match( Input& in, States&&... st ) - -> typename std::enable_if< internal::has_match< void, Rule, A, M, Action, Control, Input, States... >::value, bool >::type - { - return Action< Rule >::template match< Rule, A, M, Action, Control >( in, st... ); - } - - template< apply_mode A, - rewind_mode M, - template< typename... > - class Action, - template< typename... > - class Control, - typename Input, - typename... States, - int = 1 > - static auto match( Input& in, States&&... st ) - -> typename std::enable_if< !internal::has_match< void, Rule, A, M, Action, Control, Input, States... >::value, bool >::type - { - return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... ); - } - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/nothing.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/nothing.hpp deleted file mode 100644 index 974afdb..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/nothing.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_NOTHING_HPP -#define TAO_PEGTL_NOTHING_HPP - -#include "config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - template< typename Rule > - struct nothing - { - }; - - using maybe_nothing = nothing< void >; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/parse.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/parse.hpp deleted file mode 100644 index d6093e0..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/parse.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_PARSE_HPP -#define TAO_PEGTL_PARSE_HPP - -#include - -#include "apply_mode.hpp" -#include "config.hpp" -#include "normal.hpp" -#include "nothing.hpp" -#include "parse_error.hpp" -#include "rewind_mode.hpp" - -#include "internal/action_input.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - template< typename Rule, - template< typename... > class Action = nothing, - template< typename... > class Control = normal, - apply_mode A = apply_mode::action, - rewind_mode M = rewind_mode::required, - typename Input, - typename... States > - bool parse( Input&& in, States&&... st ) - { - return Control< Rule >::template match< A, M, Action, Control >( in, st... ); - } - - template< typename Rule, - template< typename... > class Action = nothing, - template< typename... > class Control = normal, - apply_mode A = apply_mode::action, - rewind_mode M = rewind_mode::required, - typename Outer, - typename Input, - typename... States > - bool parse_nested( const Outer& oi, Input&& in, States&&... st ) - { - try { - return parse< Rule, Action, Control, A, M >( in, st... ); - } - catch( parse_error& e ) { - e.positions.push_back( oi.position() ); - throw; - } - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/parse_error.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/parse_error.hpp deleted file mode 100644 index 21ce850..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/parse_error.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_PARSE_ERROR_HPP -#define TAO_PEGTL_PARSE_ERROR_HPP - -#include -#include - -#include "config.hpp" -#include "position.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - struct parse_error - : public std::runtime_error - { - parse_error( const std::string& msg, std::vector< position >&& in_positions ) - : std::runtime_error( msg ), - positions( std::move( in_positions ) ) - { - } - - template< typename Input > - parse_error( const std::string& msg, const Input& in ) - : parse_error( msg, in.position() ) - { - } - - parse_error( const std::string& msg, const position& pos ) - : std::runtime_error( to_string( pos ) + ": " + msg ), - positions( 1, pos ) - { - } - - parse_error( const std::string& msg, position&& pos ) - : std::runtime_error( to_string( pos ) + ": " + msg ) - { - positions.emplace_back( std::move( pos ) ); - } - - std::vector< position > positions; - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/position.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/position.hpp deleted file mode 100644 index 46a982d..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/position.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_POSITION_HPP -#define TAO_PEGTL_POSITION_HPP - -#include -#include -#include -#include -#include - -#include "config.hpp" - -#include "internal/iterator.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - struct position - { - template< typename T > - position( const internal::iterator& in_iter, T&& in_source ) - : byte( in_iter.byte ), - line( in_iter.line ), - byte_in_line( in_iter.byte_in_line ), - source( std::forward< T >( in_source ) ) - { - } - - std::size_t byte; - std::size_t line; - std::size_t byte_in_line; - std::string source; - }; - - inline std::ostream& operator<<( std::ostream& o, const position& p ) - { - return o << p.source << ':' << p.line << ':' << p.byte_in_line << '(' << p.byte << ')'; - } - - inline std::string to_string( const position& p ) - { - std::ostringstream o; - o << p; - return o.str(); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/read_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/read_input.hpp deleted file mode 100644 index 9e79358..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/read_input.hpp +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_READ_INPUT_HPP -#define TAO_PEGTL_READ_INPUT_HPP - -#include - -#include "config.hpp" -#include "eol.hpp" -#include "string_input.hpp" -#include "tracking_mode.hpp" - -#include "internal/file_reader.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct filename_holder - { - const std::string filename; - - template< typename T > - explicit filename_holder( T&& in_filename ) - : filename( std::forward< T >( in_filename ) ) - { - } - - filename_holder( const filename_holder& ) = delete; - filename_holder( filename_holder&& ) = delete; - - ~filename_holder() = default; - - void operator=( const filename_holder& ) = delete; - void operator=( filename_holder&& ) = delete; - }; - - } // namespace internal - - template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > - struct read_input - : private internal::filename_holder, - public string_input< P, Eol, const char* > - { - template< typename T > - explicit read_input( T&& in_filename ) - : internal::filename_holder( std::forward< T >( in_filename ) ), - string_input< P, Eol, const char* >( internal::file_reader( filename.c_str() ).read(), filename.c_str() ) - { - } - - template< typename T > - read_input( FILE* in_file, T&& in_filename ) - : internal::filename_holder( std::forward< T >( in_filename ) ), - string_input< P, Eol, const char* >( internal::file_reader( in_file, filename.c_str() ).read(), filename.c_str() ) - { - } - - read_input( const read_input& ) = delete; - read_input( read_input&& ) = delete; - - ~read_input() = default; - - void operator=( const read_input& ) = delete; - void operator=( read_input&& ) = delete; - }; - -#ifdef __cpp_deduction_guides - template< typename... Ts > - explicit read_input( Ts&&... )->read_input<>; -#endif - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/require_apply.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/require_apply.hpp deleted file mode 100644 index 8e53de5..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/require_apply.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_REQUIRE_APPLY_HPP -#define TAO_PEGTL_REQUIRE_APPLY_HPP - -#include "config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - struct require_apply - {}; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/require_apply0.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/require_apply0.hpp deleted file mode 100644 index e99afbb..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/require_apply0.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2019-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_REQUIRE_APPLY0_HPP -#define TAO_PEGTL_REQUIRE_APPLY0_HPP - -#include "config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - struct require_apply0 - {}; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/rewind_mode.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/rewind_mode.hpp deleted file mode 100644 index 037b937..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/rewind_mode.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_REWIND_MODE_HPP -#define TAO_PEGTL_REWIND_MODE_HPP - -#include "config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - enum class rewind_mode : char - { - active, - required, - dontcare, - - // Compatibility, remove with 3.0.0 - ACTIVE = active, - REQUIRED = required, - DONTCARE = dontcare - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/rules.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/rules.hpp deleted file mode 100644 index 8f0ce39..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/rules.hpp +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_RULES_HPP -#define TAO_PEGTL_RULES_HPP - -#include "config.hpp" -#include "parse_error.hpp" - -#include "internal/rules.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - // clang-format off - template< typename... Actions > struct apply : internal::apply< Actions... > {}; - template< typename... Actions > struct apply0 : internal::apply0< Actions... > {}; - template< template< typename... > class Action, typename... Rules > struct action : internal::action< Action, Rules... > {}; - template< typename... Rules > struct at : internal::at< Rules... > {}; - struct bof : internal::bof {}; - struct bol : internal::bol {}; - template< unsigned Num > struct bytes : internal::bytes< Num > {}; - template< template< typename... > class Control, typename... Rules > struct control : internal::control< Control, Rules... > {}; - template< typename... Rules > struct disable : internal::disable< Rules... > {}; - struct discard : internal::discard {}; - template< typename... Rules > struct enable : internal::enable< Rules... > {}; - struct eof : internal::eof {}; - struct failure : internal::trivial< false > {}; - template< typename Rule, typename... Actions > struct if_apply : internal::if_apply< Rule, Actions... > {}; - template< typename Cond, typename... Thens > struct if_must : internal::if_must< false, Cond, Thens... > {}; - template< typename Cond, typename Then, typename Else > struct if_must_else : internal::if_must_else< Cond, Then, Else > {}; - template< typename Cond, typename Then, typename Else > struct if_then_else : internal::if_then_else< Cond, Then, Else > {}; - template< typename Rule, typename Sep, typename Pad = void > struct list : internal::list< Rule, internal::pad< Sep, Pad > > {}; - template< typename Rule, typename Sep > struct list< Rule, Sep, void > : internal::list< Rule, Sep > {}; - template< typename Rule, typename Sep, typename Pad = void > struct list_must : internal::list_must< Rule, internal::pad< Sep, Pad > > {}; - template< typename Rule, typename Sep > struct list_must< Rule, Sep, void > : internal::list_must< Rule, Sep > {}; - template< typename Rule, typename Sep, typename Pad = void > struct list_tail : internal::list_tail_pad< Rule, Sep, Pad > {}; - template< typename Rule, typename Sep > struct list_tail< Rule, Sep, void > : internal::list_tail< Rule, Sep > {}; - template< typename M, typename S > struct minus : internal::rematch< M, internal::not_at< S, internal::eof > > {}; - template< typename... Rules > struct must : internal::must< Rules... > {}; - template< typename... Rules > struct not_at : internal::not_at< Rules... > {}; - template< typename... Rules > struct opt : internal::opt< Rules... > {}; - template< typename Cond, typename... Rules > struct opt_must : internal::if_must< true, Cond, Rules... > {}; - template< typename Rule, typename Pad1, typename Pad2 = Pad1 > struct pad : internal::pad< Rule, Pad1, Pad2 > {}; - template< typename Rule, typename Pad > struct pad_opt : internal::pad_opt< Rule, Pad > {}; - template< typename Rule, typename... Rules > struct plus : internal::plus< Rule, Rules... > {}; - template< typename Exception > struct raise : internal::raise< Exception > {}; - template< typename Head, typename... Rules > struct rematch : internal::rematch< Head, Rules... > {}; - template< unsigned Num, typename... Rules > struct rep : internal::rep< Num, Rules... > {}; - template< unsigned Max, typename... Rules > struct rep_max : internal::rep_min_max< 0, Max, Rules... > {}; - template< unsigned Min, typename Rule, typename... Rules > struct rep_min : internal::rep_min< Min, Rule, Rules... > {}; - template< unsigned Min, unsigned Max, typename... Rules > struct rep_min_max : internal::rep_min_max< Min, Max, Rules... > {}; - template< unsigned Max, typename... Rules > struct rep_opt : internal::rep_opt< Max, Rules... > {}; - template< unsigned Amount > struct require : internal::require< Amount > {}; - template< typename... Rules > struct seq : internal::seq< Rules... > {}; - template< typename... Rules > struct sor : internal::sor< Rules... > {}; - template< typename Rule, typename... Rules > struct star : internal::star< Rule, Rules... > {}; - template< typename Cond, typename... Rules > struct star_must : internal::star_must< Cond, Rules... > {}; - template< typename State, typename... Rules > struct state : internal::state< State, Rules... > {}; - struct success : internal::trivial< true > {}; - template< typename... Rules > struct try_catch : internal::seq< internal::try_catch_type< parse_error, Rules... > > {}; - template< typename Exception, typename... Rules > struct try_catch_type : internal::seq< internal::try_catch_type< Exception, Rules... > > {}; - template< typename Cond, typename... Rules > struct until : internal::until< Cond, Rules... > {}; - // clang-format on - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/string_input.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/string_input.hpp deleted file mode 100644 index 1c8bd5f..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/string_input.hpp +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_STRING_INPUT_HPP -#define TAO_PEGTL_STRING_INPUT_HPP - -#include -#include - -#include "config.hpp" -#include "eol.hpp" -#include "memory_input.hpp" -#include "tracking_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct string_holder - { - const std::string data; - - template< typename T > - explicit string_holder( T&& in_data ) - : data( std::forward< T >( in_data ) ) - { - } - - string_holder( const string_holder& ) = delete; - string_holder( string_holder&& ) = delete; - - ~string_holder() = default; - - void operator=( const string_holder& ) = delete; - void operator=( string_holder&& ) = delete; - }; - - } // namespace internal - - template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf, typename Source = std::string > - struct string_input - : private internal::string_holder, - public memory_input< P, Eol, Source > - { - template< typename V, typename T, typename... Ts > - explicit string_input( V&& in_data, T&& in_source, Ts&&... ts ) - : internal::string_holder( std::forward< V >( in_data ) ), - memory_input< P, Eol, Source >( data.data(), data.size(), std::forward< T >( in_source ), std::forward< Ts >( ts )... ) - { - } - - string_input( const string_input& ) = delete; - string_input( string_input&& ) = delete; - - ~string_input() = default; - - void operator=( const string_input& ) = delete; - void operator=( string_input&& ) = delete; - }; - -#ifdef __cpp_deduction_guides - template< typename... Ts > - explicit string_input( Ts&&... )->string_input<>; -#endif - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/tracking_mode.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/tracking_mode.hpp deleted file mode 100644 index 9def6be..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/tracking_mode.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_TRACKING_MODE_HPP -#define TAO_PEGTL_TRACKING_MODE_HPP - -#include "config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - enum class tracking_mode : bool - { - eager, - lazy, - - // Compatibility, remove with 3.0.0 - IMMEDIATE = eager, - LAZY = lazy - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint16.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint16.hpp deleted file mode 100644 index 0080df4..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint16.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_UINT16_HPP -#define TAO_PEGTL_UINT16_HPP - -#include "config.hpp" - -#include "internal/peek_mask_uint.hpp" -#include "internal/peek_uint.hpp" -#include "internal/result_on_found.hpp" -#include "internal/rules.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace uint16_be - { - // clang-format off - struct any : internal::any< internal::peek_uint16_be > {}; - - template< std::uint16_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint16_be, Cs... > {}; - template< std::uint16_t Lo, std::uint16_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint16_be, Lo, Hi > {}; - template< std::uint16_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint16_be, Cs... > {}; - template< std::uint16_t Lo, std::uint16_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint16_be, Lo, Hi > {}; - template< std::uint16_t... Cs > struct ranges : internal::ranges< internal::peek_uint16_be, Cs... > {}; - template< std::uint16_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint16_be, Cs >... > {}; - - template< std::uint16_t M, std::uint16_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint16_be< M >, Cs... > {}; - template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint16_be< M >, Lo, Hi > {}; - template< std::uint16_t M, std::uint16_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint16_be< M >, Cs... > {}; - template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint16_be< M >, Lo, Hi > {}; - template< std::uint16_t M, std::uint16_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint16_be< M >, Cs... > {}; - template< std::uint16_t M, std::uint16_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint16_be< M >, Cs >... > {}; - // clang-format on - - } // namespace uint16_be - - namespace uint16_le - { - // clang-format off - struct any : internal::any< internal::peek_uint16_le > {}; - - template< std::uint16_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint16_le, Cs... > {}; - template< std::uint16_t Lo, std::uint16_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint16_le, Lo, Hi > {}; - template< std::uint16_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint16_le, Cs... > {}; - template< std::uint16_t Lo, std::uint16_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint16_le, Lo, Hi > {}; - template< std::uint16_t... Cs > struct ranges : internal::ranges< internal::peek_uint16_le, Cs... > {}; - template< std::uint16_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint16_le, Cs >... > {}; - - template< std::uint16_t M, std::uint16_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint16_le< M >, Cs... > {}; - template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint16_le< M >, Lo, Hi > {}; - template< std::uint16_t M, std::uint16_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint16_le< M >, Cs... > {}; - template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint16_le< M >, Lo, Hi > {}; - template< std::uint16_t M, std::uint16_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint16_le< M >, Cs... > {}; - template< std::uint16_t M, std::uint16_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint16_le< M >, Cs >... > {}; - // clang-format on - - } // namespace uint16_le - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint32.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint32.hpp deleted file mode 100644 index af54cf3..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint32.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_UINT32_HPP -#define TAO_PEGTL_UINT32_HPP - -#include "config.hpp" - -#include "internal/peek_mask_uint.hpp" -#include "internal/peek_uint.hpp" -#include "internal/result_on_found.hpp" -#include "internal/rules.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace uint32_be - { - // clang-format off - struct any : internal::any< internal::peek_uint32_be > {}; - - template< std::uint32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint32_be, Cs... > {}; - template< std::uint32_t Lo, std::uint32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint32_be, Lo, Hi > {}; - template< std::uint32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint32_be, Cs... > {}; - template< std::uint32_t Lo, std::uint32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint32_be, Lo, Hi > {}; - template< std::uint32_t... Cs > struct ranges : internal::ranges< internal::peek_uint32_be, Cs... > {}; - template< std::uint32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint32_be, Cs >... > {}; - - template< std::uint32_t M, std::uint32_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint32_be< M >, Cs... > {}; - template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint32_be< M >, Lo, Hi > {}; - template< std::uint32_t M, std::uint32_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint32_be< M >, Cs... > {}; - template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint32_be< M >, Lo, Hi > {}; - template< std::uint32_t M, std::uint32_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint32_be< M >, Cs... > {}; - template< std::uint32_t M, std::uint32_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint32_be< M >, Cs >... > {}; - // clang-format on - - } // namespace uint32_be - - namespace uint32_le - { - // clang-format off - struct any : internal::any< internal::peek_uint32_le > {}; - - template< std::uint32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint32_le, Cs... > {}; - template< std::uint32_t Lo, std::uint32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint32_le, Lo, Hi > {}; - template< std::uint32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint32_le, Cs... > {}; - template< std::uint32_t Lo, std::uint32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint32_le, Lo, Hi > {}; - template< std::uint32_t... Cs > struct ranges : internal::ranges< internal::peek_uint32_le, Cs... > {}; - template< std::uint32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint32_le, Cs >... > {}; - - template< std::uint32_t M, std::uint32_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint32_le< M >, Cs... > {}; - template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint32_le< M >, Lo, Hi > {}; - template< std::uint32_t M, std::uint32_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint32_le< M >, Cs... > {}; - template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint32_le< M >, Lo, Hi > {}; - template< std::uint32_t M, std::uint32_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint32_le< M >, Cs... > {}; - template< std::uint32_t M, std::uint32_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint32_le< M >, Cs >... > {}; - // clang-format on - - } // namespace uint32_le - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint64.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint64.hpp deleted file mode 100644 index 86074f8..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint64.hpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_UINT64_HPP -#define TAO_PEGTL_UINT64_HPP - -#include "config.hpp" - -#include "internal/peek_mask_uint.hpp" -#include "internal/peek_uint.hpp" -#include "internal/result_on_found.hpp" -#include "internal/rules.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace uint64_be - { - // clang-format off - struct any : internal::any< internal::peek_uint64_be > {}; - - template< std::uint64_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint64_be, Cs... > {}; - template< std::uint64_t Lo, std::uint64_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint64_be, Lo, Hi > {}; - template< std::uint64_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint64_be, Cs... > {}; - template< std::uint64_t Lo, std::uint64_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint64_be, Lo, Hi > {}; - template< std::uint64_t... Cs > struct ranges : internal::ranges< internal::peek_uint64_be, Cs... > {}; - template< std::uint64_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint64_be, Cs >... > {}; - - - template< std::uint64_t M, std::uint64_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint64_be< M >, Cs... > {}; - template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint64_be< M >, Lo, Hi > {}; - template< std::uint64_t M, std::uint64_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint64_be< M >, Cs... > {}; - template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint64_be< M >, Lo, Hi > {}; - template< std::uint64_t M, std::uint64_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint64_be< M >, Cs... > {}; - template< std::uint64_t M, std::uint64_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint64_be< M >, Cs >... > {}; - // clang-format on - - } // namespace uint64_be - - namespace uint64_le - { - // clang-format off - struct any : internal::any< internal::peek_uint64_le > {}; - - template< std::uint64_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint64_le, Cs... > {}; - template< std::uint64_t Lo, std::uint64_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint64_le, Lo, Hi > {}; - template< std::uint64_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint64_le, Cs... > {}; - template< std::uint64_t Lo, std::uint64_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint64_le, Lo, Hi > {}; - template< std::uint64_t... Cs > struct ranges : internal::ranges< internal::peek_uint64_le, Cs... > {}; - template< std::uint64_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint64_le, Cs >... > {}; - - template< std::uint64_t M, std::uint64_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint64_le< M >, Cs... > {}; - template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint64_le< M >, Lo, Hi > {}; - template< std::uint64_t M, std::uint64_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint64_le< M >, Cs... > {}; - template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint64_le< M >, Lo, Hi > {}; - template< std::uint64_t M, std::uint64_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint64_le< M >, Cs... > {}; - template< std::uint64_t M, std::uint64_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint64_le< M >, Cs >... > {}; - // clang-format on - - } // namespace uint64_le - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint8.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint8.hpp deleted file mode 100644 index fe2e11a..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/uint8.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2018-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_UINT8_HPP -#define TAO_PEGTL_UINT8_HPP - -#include "config.hpp" - -#include "internal/peek_mask_uint8.hpp" -#include "internal/peek_uint8.hpp" -#include "internal/result_on_found.hpp" -#include "internal/rules.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace uint8 - { - // clang-format off - struct any : internal::any< internal::peek_uint8 > {}; - - template< std::uint8_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint8, Cs... > {}; - template< std::uint8_t Lo, std::uint8_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint8, Lo, Hi > {}; - template< std::uint8_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint8, Cs... > {}; - template< std::uint8_t Lo, std::uint8_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint8, Lo, Hi > {}; - template< std::uint8_t... Cs > struct ranges : internal::ranges< internal::peek_uint8, Cs... > {}; - template< std::uint8_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint8, Cs >... > {}; - - template< std::uint8_t M, std::uint8_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint8< M >, Cs... > {}; - template< std::uint8_t M, std::uint8_t Lo, std::uint8_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint8< M >, Lo, Hi > {}; - template< std::uint8_t M, std::uint8_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint8< M >, Cs... > {}; - template< std::uint8_t M, std::uint8_t Lo, std::uint8_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint8< M >, Lo, Hi > {}; - template< std::uint8_t M, std::uint8_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint8< M >, Cs... > {}; - template< std::uint8_t M, std::uint8_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint8< M >, Cs >... > {}; - // clang-format on - - } // namespace uint8 - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf16.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf16.hpp deleted file mode 100644 index 37f6190..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf16.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2015-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_UTF16_HPP -#define TAO_PEGTL_UTF16_HPP - -#include "config.hpp" - -#include "internal/peek_utf16.hpp" -#include "internal/result_on_found.hpp" -#include "internal/rules.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace utf16_be - { - // clang-format off - struct any : internal::any< internal::peek_utf16_be > {}; - struct bom : internal::one< internal::result_on_found::success, internal::peek_utf16_be, 0xfeff > {}; - template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf16_be, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf16_be, Lo, Hi > {}; - template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf16_be, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf16_be, Lo, Hi > {}; - template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf16_be, Cs... > {}; - template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf16_be, Cs >... > {}; - // clang-format on - - } // namespace utf16_be - - namespace utf16_le - { - // clang-format off - struct any : internal::any< internal::peek_utf16_le > {}; - struct bom : internal::one< internal::result_on_found::success, internal::peek_utf16_le, 0xfeff > {}; - template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf16_le, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf16_le, Lo, Hi > {}; - template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf16_le, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf16_le, Lo, Hi > {}; - template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf16_le, Cs... > {}; - template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf16_le, Cs >... > {}; - // clang-format on - - } // namespace utf16_le - - namespace utf16 = TAO_PEGTL_NATIVE_UTF16; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf32.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf32.hpp deleted file mode 100644 index e9bafa0..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf32.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_UTF32_HPP -#define TAO_PEGTL_UTF32_HPP - -#include "config.hpp" - -#include "internal/peek_utf32.hpp" -#include "internal/result_on_found.hpp" -#include "internal/rules.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace utf32_be - { - // clang-format off - struct any : internal::any< internal::peek_utf32_be > {}; - struct bom : internal::one< internal::result_on_found::success, internal::peek_utf32_be, 0xfeff > {}; - template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf32_be, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf32_be, Lo, Hi > {}; - template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf32_be, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf32_be, Lo, Hi > {}; - template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf32_be, Cs... > {}; - template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf32_be, Cs >... > {}; - // clang-format on - - } // namespace utf32_be - - namespace utf32_le - { - // clang-format off - struct any : internal::any< internal::peek_utf32_le > {}; - struct bom : internal::one< internal::result_on_found::success, internal::peek_utf32_le, 0xfeff > {}; - template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf32_le, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf32_le, Lo, Hi > {}; - template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf32_le, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf32_le, Lo, Hi > {}; - template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf32_le, Cs... > {}; - template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf32_le, Cs >... > {}; - // clang-format on - - } // namespace utf32_le - - namespace utf32 = TAO_PEGTL_NATIVE_UTF32; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf8.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf8.hpp deleted file mode 100644 index 4f4befb..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/utf8.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_UTF8_HPP -#define TAO_PEGTL_UTF8_HPP - -#include "config.hpp" - -#include "internal/peek_utf8.hpp" -#include "internal/result_on_found.hpp" -#include "internal/rules.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace utf8 - { - // clang-format off - struct any : internal::any< internal::peek_utf8 > {}; - struct bom : internal::one< internal::result_on_found::success, internal::peek_utf8, 0xfeff > {}; - template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf8, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf8, Lo, Hi > {}; - template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf8, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf8, Lo, Hi > {}; - template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf8, Cs... > {}; - template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf8, Cs >... > {}; - // clang-format on - - } // namespace utf8 - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/version.hpp b/common_content_filter/thirdparty/taocpp-pegtl/pegtl/version.hpp deleted file mode 100644 index 4a5e8cf..0000000 --- a/common_content_filter/thirdparty/taocpp-pegtl/pegtl/version.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_VERSION_HPP -#define TAO_PEGTL_VERSION_HPP - -#define TAO_PEGTL_VERSION "2.8.3" - -#define TAO_PEGTL_VERSION_MAJOR 2 -#define TAO_PEGTL_VERSION_MINOR 8 -#define TAO_PEGTL_VERSION_PATCH 3 - -// Compatibility, remove with 3.0.0 -#define TAOCPP_PEGTL_VERSION TAO_PEGTL_VERSION -#define TAOCPP_PEGTL_VERSION_MAJOR TAO_PEGTL_VERSION_MAJOR -#define TAOCPP_PEGTL_VERSION_MINOR TAO_PEGTL_VERSION_MINOR -#define TAOCPP_PEGTL_VERSION_PATCH TAO_PEGTL_VERSION_PATCH - -#endif diff --git a/tao_pegtl_vendor/CMakeLists.txt b/tao_pegtl_vendor/CMakeLists.txt new file mode 100644 index 0000000..ea9b0be --- /dev/null +++ b/tao_pegtl_vendor/CMakeLists.txt @@ -0,0 +1,77 @@ +cmake_minimum_required(VERSION 3.5) + +project(tao_pegtl_vendor) + +find_package(ament_cmake REQUIRED) + +macro(build_tao_pegtl) + set(extra_cmake_args) + if(DEFINED CMAKE_BUILD_TYPE) + list(APPEND extra_cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) + endif() + if(DEFINED CMAKE_TOOLCHAIN_FILE) + list(APPEND extra_cmake_args "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") + if(ANDROID) + if(DEFINED ANDROID_ABI) + list(APPEND extra_cmake_args "-DANDROID_ABI=${ANDROID_ABI}") + endif() + if(DEFINED ANDROID_CPP_FEATURES) + list(APPEND extra_cmake_args "-DANDROID_CPP_FEATURES=${ANDROID_CPP_FEATURES}") + endif() + if(DEFINED ANDROID_FUNCTION_LEVEL_LINKING) + list(APPEND extra_cmake_args "-DANDROID_FUNCTION_LEVEL_LINKING=${ANDROID_FUNCTION_LEVEL_LINKING}") + endif() + if(DEFINED ANDROID_NATIVE_API_LEVEL) + list(APPEND extra_cmake_args "-DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL}") + endif() + if(DEFINED ANDROID_NDK) + list(APPEND extra_cmake_args "-DANDROID_NDK=${ANDROID_NDK}") + endif() + if(DEFINED ANDROID_STL) + list(APPEND extra_cmake_args "-DANDROID_STL=${ANDROID_STL}") + endif() + if(DEFINED ANDROID_TOOLCHAIN_NAME) + list(APPEND extra_cmake_args "-DANDROID_TOOLCHAIN_NAME=${ANDROID_TOOLCHAIN_NAME}") + endif() + endif() + else() + list(APPEND extra_cmake_args "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") + endif() + list(APPEND extra_cmake_args "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}") + list(APPEND extra_cmake_args "-DPEGTL_BUILD_TESTS=OFF") + list(APPEND extra_cmake_args "-DPEGTL_BUILD_EXAMPLES=OFF") + + include(ExternalProject) + + # Get pegtl 2.8.1 + externalproject_add(pegtl-2.8.1 + URL https://github.com/taocpp/PEGTL/archive/refs/tags/2.8.1.tar.gz + URL_MD5 10d625fb1da9e95c8e29c51be5e0e5e1 + TIMEOUT 60 + CMAKE_ARGS + -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_install + ${extra_cmake_args} + ) + + # The external project will install to the build folder, but we'll install that on make install. + install( + DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_install/ + DESTINATION + ${CMAKE_INSTALL_PREFIX} + USE_SOURCE_PERMISSIONS + ) +endmacro() + +# force to build pegtl, as pegtl might not available in the stable version on some platforms +build_tao_pegtl() + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() +endif() + +# this ensures that the package has an environment hook setting the PATH +ament_package( + CONFIG_EXTRAS "tao_pegtl_vendor-extras.cmake" +) diff --git a/tao_pegtl_vendor/CONTRIBUTING.md b/tao_pegtl_vendor/CONTRIBUTING.md new file mode 100644 index 0000000..cfba094 --- /dev/null +++ b/tao_pegtl_vendor/CONTRIBUTING.md @@ -0,0 +1,18 @@ +Any contribution that you make to this repository will +be under the Apache 2 License, as dictated by that +[license](http://www.apache.org/licenses/LICENSE-2.0.html): + +~~~ +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. +~~~ + +Contributors must sign-off each commit by adding a `Signed-off-by: ...` +line to commit messages to certify that they have the right to submit +the code they are contributing to the project according to the +[Developer Certificate of Origin (DCO)](https://developercertificate.org/). diff --git a/tao_pegtl_vendor/LICENSE b/tao_pegtl_vendor/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/tao_pegtl_vendor/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/tao_pegtl_vendor/README.md b/tao_pegtl_vendor/README.md new file mode 100644 index 0000000..0148591 --- /dev/null +++ b/tao_pegtl_vendor/README.md @@ -0,0 +1,2 @@ +# tao_pegtl_vendor +CMake shim over the taocpp PEGTL library: https://github.com/taocpp/PEGTL.git diff --git a/tao_pegtl_vendor/package.xml b/tao_pegtl_vendor/package.xml new file mode 100644 index 0000000..79301a7 --- /dev/null +++ b/tao_pegtl_vendor/package.xml @@ -0,0 +1,24 @@ + + + + tao_pegtl_vendor + 0.0.1 + + Wrapper around pegtl, providing nothing but a dependency on pegtl, on some systems. + On others, it provides an ExternalProject build of spdlog. + + chenlh + Apache License 2.0 + MIT + + https://github.com/taocpp/PEGTL + + ament_cmake + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake b/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake new file mode 100644 index 0000000..a281b05 --- /dev/null +++ b/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake @@ -0,0 +1,16 @@ +# Copyright 2019-2020 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +find_package(pegtl REQUIRED) +list(APPEND tao_pegtl_vendor_TARGETS taocpp::pegtl) From d75a22d20aa3dd569b251b848ac7401ee998e415 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 11 Jul 2022 12:39:29 +0800 Subject: [PATCH 36/51] add/update readme with simple description Signed-off-by: Chen Lihui --- README.md | 4 ++++ common_content_filter/README.md | 2 ++ test_content_filter_msgs/README.md | 2 ++ 3 files changed, 8 insertions(+) create mode 100644 test_content_filter_msgs/README.md diff --git a/README.md b/README.md index a100f2a..08b98b2 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,7 @@ This repository contains packages to support content filter fallback used in rcl. - [common_content_filter](common_content_filter/README.md) + + - [tao_pegtl_vendor](tao_pegtl_vendor/README.md) + + - [test_content_filter_msgs](test_content_filter_msgs/README.md) diff --git a/common_content_filter/README.md b/common_content_filter/README.md index e69de29..ad00969 100644 --- a/common_content_filter/README.md +++ b/common_content_filter/README.md @@ -0,0 +1,2 @@ +# common_content_filter +To support the content topic filter (a CFT fallback on the DDS) in the reader side used in rcl. diff --git a/test_content_filter_msgs/README.md b/test_content_filter_msgs/README.md new file mode 100644 index 0000000..12f6bf4 --- /dev/null +++ b/test_content_filter_msgs/README.md @@ -0,0 +1,2 @@ +# test_content_filter_msgs +A complex message to test common content filter api From 0f26f5d520c713267580e692bea21affb365b4fd Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 11 Jul 2022 12:43:31 +0800 Subject: [PATCH 37/51] update the year of copyright Signed-off-by: Chen Lihui --- tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake b/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake index a281b05..559f801 100644 --- a/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake +++ b/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake @@ -1,4 +1,4 @@ -# Copyright 2019-2020 Open Source Robotics Foundation, Inc. +# Copyright 2022 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 4389596cc049078fbdb5884b323a8b65da706494 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 11 Jul 2022 13:43:53 +0800 Subject: [PATCH 38/51] update/add new test cases Signed-off-by: Chen Lihui --- common_content_filter/src/api.cpp | 4 +- common_content_filter/test/test_api.cpp | 434 ++++++++++++------------ 2 files changed, 223 insertions(+), 215 deletions(-) diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index 50bbcce..fb48edb 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -127,7 +127,7 @@ class ContentFilterWrapper const rmw_serialized_message_t * serialized_message = (const rmw_serialized_message_t *)ros_data; if (!deserialized_buffer_) { - deserialized_buffer_ = std::move(get_message_buffer(type_support_)); + deserialized_buffer_ = get_message_buffer(type_support_); } rmw_ret_t rmw_ret = rmw_deserialize(serialized_message, type_support_, deserialized_buffer_.get()); @@ -146,7 +146,7 @@ class ContentFilterWrapper const std::vector & expression_parameters) { std::lock_guard lock(mutex_); - const char * tip = filter_instance_ ? "create" : "set"; + const char * tip = (filter_instance_ == nullptr) ? "create" : "set"; DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->create_content_filter( type_support_, filter_expression.c_str(), diff --git a/common_content_filter/test/test_api.cpp b/common_content_filter/test/test_api.cpp index 19fc35d..61cd3f9 100644 --- a/common_content_filter/test/test_api.cpp +++ b/common_content_filter/test/test_api.cpp @@ -26,23 +26,13 @@ #include "common_content_filter/api.h" -class TestCommonContentFilterAPI : public ::testing::Test +class TestAPIBase { protected: - void SetUp() - { - type_support = ROSIDL_GET_MSG_TYPE_SUPPORT(test_msgs, msg, BasicTypes); - instance = common_content_filter_create(type_support); - EXPECT_NE(instance, nullptr); - } - - void TearDown() - { - common_content_filter_destroy(instance); - } - -protected: - void set_options() + bool set_options( + const char * filter_expression, + size_t expression_parameter_argc, + const char * expression_parameter_argv[]) { rcutils_allocator_t allocator = rcutils_get_default_allocator(); rmw_subscription_content_filter_options_t options = @@ -61,20 +51,38 @@ class TestCommonContentFilterAPI : public ::testing::Test rmw_subscription_content_filter_options_fini(&options, &allocator); }); - EXPECT_TRUE(common_content_filter_set(instance, &options)); + return common_content_filter_set(instance, &options); } void * instance; const rosidl_message_type_support_t * type_support; +}; + +class TestCommonContentFilterAPI : public ::testing::Test, public TestAPIBase +{ +protected: + void SetUp() + { + type_support = ROSIDL_GET_MSG_TYPE_SUPPORT(test_msgs, msg, BasicTypes); + instance = common_content_filter_create(type_support); + EXPECT_NE(instance, nullptr); + } + + void TearDown() + { + common_content_filter_destroy(instance); + } + +protected: const char * filter_expression = "int32_value = %0"; - size_t expression_parameter_argc = 1; - const char * expression_parameter_argv[1] = {"4"}; + std::vector expression_parameter = {"4"}; }; TEST_F(TestCommonContentFilterAPI, is_enabled) { EXPECT_FALSE(common_content_filter_is_enabled(nullptr)); EXPECT_FALSE(common_content_filter_is_enabled(instance)); - set_options(); + EXPECT_TRUE( + set_options(filter_expression, expression_parameter.size(), expression_parameter.data())); EXPECT_TRUE(common_content_filter_is_enabled(instance)); } @@ -114,7 +122,8 @@ TEST_F(TestCommonContentFilterAPI, evaluate) { EXPECT_TRUE(common_content_filter_evaluate(instance, &msg, false)); EXPECT_TRUE(common_content_filter_evaluate(instance, &serialized_message, true)); // after setting filter with "int32_value = 4" - set_options(); + EXPECT_TRUE( + set_options(filter_expression, expression_parameter.size(), expression_parameter.data())); // expect msg(int32_value = 3) return false EXPECT_FALSE(common_content_filter_evaluate(instance, &msg, false)); EXPECT_FALSE(common_content_filter_evaluate(instance, &serialized_message, true)); @@ -132,13 +141,19 @@ TEST_F(TestCommonContentFilterAPI, evaluate) { TEST_F(TestCommonContentFilterAPI, set) { EXPECT_FALSE(common_content_filter_set(nullptr, nullptr)); EXPECT_FALSE(common_content_filter_set(instance, nullptr)); - set_options(); + EXPECT_TRUE( + set_options(filter_expression, expression_parameter.size(), expression_parameter.data())); + + const char * filter_expression_error = "error_int32_value = %0"; + EXPECT_FALSE( + set_options(filter_expression_error, expression_parameter.size(), expression_parameter.data())); } TEST_F(TestCommonContentFilterAPI, get) { EXPECT_FALSE(common_content_filter_get(nullptr, nullptr, nullptr)); EXPECT_FALSE(common_content_filter_get(instance, nullptr, nullptr)); - set_options(); + EXPECT_TRUE( + set_options(filter_expression, expression_parameter.size(), expression_parameter.data())); rcutils_allocator_t allocator = rcutils_get_default_allocator(); EXPECT_FALSE(common_content_filter_get(instance, &allocator, nullptr)); @@ -151,13 +166,13 @@ TEST_F(TestCommonContentFilterAPI, get) { }); EXPECT_STREQ(options.filter_expression, filter_expression); - ASSERT_EQ(expression_parameter_argc, options.expression_parameters.size); - for (size_t i = 0; i < expression_parameter_argc; ++i) { - EXPECT_STREQ(options.expression_parameters.data[i], expression_parameter_argv[i]); + ASSERT_EQ(expression_parameter.size(), options.expression_parameters.size); + for (size_t i = 0; i < expression_parameter.size(); ++i) { + EXPECT_STREQ(options.expression_parameters.data[i], expression_parameter[i]); } } -class TestComplexMsgCommonContentFilterAPI : public ::testing::Test +class TestComplexMsgCommonContentFilterAPI : public ::testing::Test, public TestAPIBase { protected: void SetUp() @@ -174,38 +189,9 @@ class TestComplexMsgCommonContentFilterAPI : public ::testing::Test { common_content_filter_destroy(instance); } - -protected: - void set_options( - const char * filter_expression, - size_t expression_parameter_argc, - const char * expression_parameter_argv[]) - { - rcutils_allocator_t allocator = rcutils_get_default_allocator(); - rmw_subscription_content_filter_options_t options = - rmw_get_zero_initialized_content_filter_options(); - EXPECT_EQ( - RMW_RET_OK, - rmw_subscription_content_filter_options_init( - filter_expression, - expression_parameter_argc, - expression_parameter_argv, - &allocator, - &options) - ); - OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( - { - rmw_subscription_content_filter_options_fini(&options, &allocator); - }); - - EXPECT_TRUE(common_content_filter_set(instance, &options)); - } - - void * instance; - const rosidl_message_type_support_t * type_support; }; -TEST_F(TestComplexMsgCommonContentFilterAPI, get) { +TEST_F(TestComplexMsgCommonContentFilterAPI, set_and_evaluate) { // default is zero test_msgs::msg::BasicTypes basic_types_data_zero; @@ -261,181 +247,203 @@ TEST_F(TestComplexMsgCommonContentFilterAPI, get) { msg.name = "complex_name"; // name + // no filter, expect the true value by evaluating a message EXPECT_TRUE(common_content_filter_evaluate(instance, &msg, false)); struct Info { const char * filter_expression; std::vector expression_parameter; - bool expectation; + bool set_expectation; + bool evaluate_expectation; }; std::vector expectation = { // name with string or string array - {"name=%0", {"'complex_name'"}, true}, - {"name=%0", {"'not_complex_name'"}, false}, - - {"data.names[0]=%0", {"'intermedia_first_name'"}, true}, - {"data.names[0]=%0", {"'intermedia_second_name'"}, false}, - {"data.names[1]=%0", {"'intermedia_first_name'"}, false}, - {"data.names[1]=%0", {"'intermedia_second_name'"}, true}, - - {"data.basic_array[0].names[0]=%0", {"'basic_zero_one_first_name'"}, true}, - {"data.basic_array[0].names[0]=%0", {"'basic_zero_one_second_name'"}, false}, - {"data.basic_array[0].names[1]=%0", {"'basic_zero_one_first_name'"}, false}, - {"data.basic_array[0].names[1]=%0", {"'basic_zero_one_second_name'"}, true}, - - {"data.basic_array[1].names[0]=%0", {"'basic_one_zero_first_name'"}, true}, - {"data.basic_array[1].names[0]=%0", {"'basic_one_zero_second_name'"}, false}, - {"data.basic_array[1].names[1]=%0", {"'basic_one_zero_first_name'"}, false}, - {"data.basic_array[1].names[1]=%0", {"'basic_one_zero_second_name'"}, true}, - - {"name=%0 and data.names[0]=%1", {"'complex_name'", "'intermedia_first_name'"}, true}, - {"name=%0 and data.names[0]=%1", {"'not_complex_name'", "'intermedia_first_name'"}, false}, - {"name=%0 or data.names[0]=%1", {"'complex_name'", "'intermedia_first_name'"}, true}, - {"name=%0 or data.names[0]=%1", {"'not_complex_name'", "'intermedia_first_name'"}, true}, - {"name=%0 or data.names[0]=%1", {"'complex_name'", "'intermedia_second_name'"}, true}, + {"name=%0", {"'complex_name'"}, true, true}, + {"name=%0", {"'not_complex_name'"}, true, false}, + + {"data.names[0]=%0", {"'intermedia_first_name'"}, true, true}, + {"data.names[0]=%0", {"'intermedia_second_name'"}, true, false}, + {"data.names[1]=%0", {"'intermedia_first_name'"}, true, false}, + {"data.names[1]=%0", {"'intermedia_second_name'"}, true, true}, + + {"data.basic_array[0].names[0]=%0", {"'basic_zero_one_first_name'"}, true, true}, + {"data.basic_array[0].names[0]=%0", {"'basic_zero_one_second_name'"}, true, false}, + {"data.basic_array[0].names[1]=%0", {"'basic_zero_one_first_name'"}, true, false}, + {"data.basic_array[0].names[1]=%0", {"'basic_zero_one_second_name'"}, true, true}, + + {"data.basic_array[1].names[0]=%0", {"'basic_one_zero_first_name'"}, true, true}, + {"data.basic_array[1].names[0]=%0", {"'basic_one_zero_second_name'"}, true, false}, + {"data.basic_array[1].names[1]=%0", {"'basic_one_zero_first_name'"}, true, false}, + {"data.basic_array[1].names[1]=%0", {"'basic_one_zero_second_name'"}, true, true}, + + {"name=%0 and data.names[0]=%1", {"'complex_name'", "'intermedia_first_name'"}, true, true}, + {"name=%0 and data.names[0]=%1", {"'not_complex_name'", "'intermedia_first_name'"}, true, + false}, + {"name=%0 or data.names[0]=%1", {"'complex_name'", "'intermedia_first_name'"}, true, true}, + {"name=%0 or data.names[0]=%1", {"'not_complex_name'", "'intermedia_first_name'"}, true, true}, + {"name=%0 or data.names[0]=%1", {"'complex_name'", "'intermedia_second_name'"}, true, true}, // basic types array - // 0 0 - {"data.basic_array[0].basic_types[0].bool_value=%0", {"false"}, true}, - {"data.basic_array[0].basic_types[0].byte_value=%0", {"0"}, true}, - {"data.basic_array[0].basic_types[0].char_value=%0", {"0"}, true}, - {"data.basic_array[0].basic_types[0].float32_value=%0", {"0"}, true}, - {"data.basic_array[0].basic_types[0].float64_value=%0", {"0"}, true}, - {"data.basic_array[0].basic_types[0].int8_value=%0", {"0"}, true}, - {"data.basic_array[0].basic_types[0].uint8_value=%0", {"0"}, true}, - {"data.basic_array[0].basic_types[0].int16_value=%0", {"0"}, true}, - {"data.basic_array[0].basic_types[0].uint16_value=%0", {"0"}, true}, - {"data.basic_array[0].basic_types[0].int32_value=%0", {"0"}, true}, - {"data.basic_array[0].basic_types[0].uint32_value=%0", {"0"}, true}, - {"data.basic_array[0].basic_types[0].int64_value=%0", {"0"}, true}, - {"data.basic_array[0].basic_types[0].uint64_value=%0", {"0"}, true}, - {"data.basic_array[0].unbounded_int32_data[0]=%0", {"0"}, true}, - {"data.basic_array[0].bounded_float64_data[0]=%0", {"0"}, true}, - - {"data.basic_array[0].basic_types[0].bool_value=%0", {"true"}, false}, - {"data.basic_array[0].basic_types[0].byte_value=%0", {"1"}, false}, - {"data.basic_array[0].basic_types[0].char_value=%0", {"1"}, false}, - {"data.basic_array[0].basic_types[0].float32_value=%0", {"1"}, false}, - {"data.basic_array[0].basic_types[0].float64_value=%0", {"1"}, false}, - {"data.basic_array[0].basic_types[0].int8_value=%0", {"1"}, false}, - {"data.basic_array[0].basic_types[0].uint8_value=%0", {"1"}, false}, - {"data.basic_array[0].basic_types[0].int16_value=%0", {"1"}, false}, - {"data.basic_array[0].basic_types[0].uint16_value=%0", {"1"}, false}, - {"data.basic_array[0].basic_types[0].int32_value=%0", {"1"}, false}, - {"data.basic_array[0].basic_types[0].uint32_value=%0", {"1"}, false}, - {"data.basic_array[0].basic_types[0].int64_value=%0", {"1"}, false}, - {"data.basic_array[0].basic_types[0].uint64_value=%0", {"1"}, false}, - {"data.basic_array[0].unbounded_int32_data[0]=%0", {"1"}, false}, - {"data.basic_array[0].bounded_float64_data[0]=%0", {"1"}, false}, - - // 0 1 - {"data.basic_array[0].basic_types[1].bool_value=%0", {"false"}, false}, - {"data.basic_array[0].basic_types[1].byte_value=%0", {"0"}, false}, - {"data.basic_array[0].basic_types[1].char_value=%0", {"0"}, false}, - {"data.basic_array[0].basic_types[1].float32_value=%0", {"0"}, false}, - {"data.basic_array[0].basic_types[1].float64_value=%0", {"0"}, false}, - {"data.basic_array[0].basic_types[1].int8_value=%0", {"0"}, false}, - {"data.basic_array[0].basic_types[1].uint8_value=%0", {"0"}, false}, - {"data.basic_array[0].basic_types[1].int16_value=%0", {"0"}, false}, - {"data.basic_array[0].basic_types[1].uint16_value=%0", {"0"}, false}, - {"data.basic_array[0].basic_types[1].int32_value=%0", {"0"}, false}, - {"data.basic_array[0].basic_types[1].uint32_value=%0", {"0"}, false}, - {"data.basic_array[0].basic_types[1].int64_value=%0", {"0"}, false}, - {"data.basic_array[0].basic_types[1].uint64_value=%0", {"0"}, false}, - {"data.basic_array[0].unbounded_int32_data[1]=%0", {"0"}, false}, - {"data.basic_array[0].bounded_float64_data[1]=%0", {"0"}, false}, - - {"data.basic_array[0].basic_types[1].bool_value=%0", {"true"}, true}, - {"data.basic_array[0].basic_types[1].byte_value=%0", {"1"}, true}, - {"data.basic_array[0].basic_types[1].char_value=%0", {"1"}, true}, - {"data.basic_array[0].basic_types[1].float32_value=%0", {"1"}, true}, - {"data.basic_array[0].basic_types[1].float64_value=%0", {"1"}, true}, - {"data.basic_array[0].basic_types[1].int8_value=%0", {"1"}, true}, - {"data.basic_array[0].basic_types[1].uint8_value=%0", {"1"}, true}, - {"data.basic_array[0].basic_types[1].int16_value=%0", {"1"}, true}, - {"data.basic_array[0].basic_types[1].uint16_value=%0", {"1"}, true}, - {"data.basic_array[0].basic_types[1].int32_value=%0", {"1"}, true}, - {"data.basic_array[0].basic_types[1].uint32_value=%0", {"1"}, true}, - {"data.basic_array[0].basic_types[1].int64_value=%0", {"1"}, true}, - {"data.basic_array[0].basic_types[1].uint64_value=%0", {"1"}, true}, - {"data.basic_array[0].unbounded_int32_data[1]=%0", {"1"}, true}, - {"data.basic_array[0].bounded_float64_data[1]=%0", {"1"}, true}, + // [0] [0] + {"data.basic_array[0].basic_types[0].bool_value=%0", {"false"}, true, true}, + {"data.basic_array[0].basic_types[0].byte_value=%0", {"0"}, true, true}, + {"data.basic_array[0].basic_types[0].char_value=%0", {"0"}, true, true}, + {"data.basic_array[0].basic_types[0].float32_value=%0", {"0"}, true, true}, + {"data.basic_array[0].basic_types[0].float64_value=%0", {"0"}, true, true}, + {"data.basic_array[0].basic_types[0].int8_value=%0", {"0"}, true, true}, + {"data.basic_array[0].basic_types[0].uint8_value=%0", {"0"}, true, true}, + {"data.basic_array[0].basic_types[0].int16_value=%0", {"0"}, true, true}, + {"data.basic_array[0].basic_types[0].uint16_value=%0", {"0"}, true, true}, + {"data.basic_array[0].basic_types[0].int32_value=%0", {"0"}, true, true}, + {"data.basic_array[0].basic_types[0].uint32_value=%0", {"0"}, true, true}, + {"data.basic_array[0].basic_types[0].int64_value=%0", {"0"}, true, true}, + {"data.basic_array[0].basic_types[0].uint64_value=%0", {"0"}, true, true}, + {"data.basic_array[0].unbounded_int32_data[0]=%0", {"0"}, true, true}, + {"data.basic_array[0].bounded_float64_data[0]=%0", {"0"}, true, true}, + + {"data.basic_array[0].basic_types[0].bool_value=%0", {"true"}, true, false}, + {"data.basic_array[0].basic_types[0].byte_value=%0", {"1"}, true, false}, + {"data.basic_array[0].basic_types[0].char_value=%0", {"1"}, true, false}, + {"data.basic_array[0].basic_types[0].float32_value=%0", {"1"}, true, false}, + {"data.basic_array[0].basic_types[0].float64_value=%0", {"1"}, true, false}, + {"data.basic_array[0].basic_types[0].int8_value=%0", {"1"}, true, false}, + {"data.basic_array[0].basic_types[0].uint8_value=%0", {"1"}, true, false}, + {"data.basic_array[0].basic_types[0].int16_value=%0", {"1"}, true, false}, + {"data.basic_array[0].basic_types[0].uint16_value=%0", {"1"}, true, false}, + {"data.basic_array[0].basic_types[0].int32_value=%0", {"1"}, true, false}, + {"data.basic_array[0].basic_types[0].uint32_value=%0", {"1"}, true, false}, + {"data.basic_array[0].basic_types[0].int64_value=%0", {"1"}, true, false}, + {"data.basic_array[0].basic_types[0].uint64_value=%0", {"1"}, true, false}, + {"data.basic_array[0].unbounded_int32_data[0]=%0", {"1"}, true, false}, + {"data.basic_array[0].bounded_float64_data[0]=%0", {"1"}, true, false}, + + // [0] [1] + {"data.basic_array[0].basic_types[1].bool_value=%0", {"false"}, true, false}, + {"data.basic_array[0].basic_types[1].byte_value=%0", {"0"}, true, false}, + {"data.basic_array[0].basic_types[1].char_value=%0", {"0"}, true, false}, + {"data.basic_array[0].basic_types[1].float32_value=%0", {"0"}, true, false}, + {"data.basic_array[0].basic_types[1].float64_value=%0", {"0"}, true, false}, + {"data.basic_array[0].basic_types[1].int8_value=%0", {"0"}, true, false}, + {"data.basic_array[0].basic_types[1].uint8_value=%0", {"0"}, true, false}, + {"data.basic_array[0].basic_types[1].int16_value=%0", {"0"}, true, false}, + {"data.basic_array[0].basic_types[1].uint16_value=%0", {"0"}, true, false}, + {"data.basic_array[0].basic_types[1].int32_value=%0", {"0"}, true, false}, + {"data.basic_array[0].basic_types[1].uint32_value=%0", {"0"}, true, false}, + {"data.basic_array[0].basic_types[1].int64_value=%0", {"0"}, true, false}, + {"data.basic_array[0].basic_types[1].uint64_value=%0", {"0"}, true, false}, + {"data.basic_array[0].unbounded_int32_data[1]=%0", {"0"}, true, false}, + {"data.basic_array[0].bounded_float64_data[1]=%0", {"0"}, true, false}, + + {"data.basic_array[0].basic_types[1].bool_value=%0", {"true"}, true, true}, + {"data.basic_array[0].basic_types[1].byte_value=%0", {"1"}, true, true}, + {"data.basic_array[0].basic_types[1].char_value=%0", {"1"}, true, true}, + {"data.basic_array[0].basic_types[1].float32_value=%0", {"1"}, true, true}, + {"data.basic_array[0].basic_types[1].float64_value=%0", {"1"}, true, true}, + {"data.basic_array[0].basic_types[1].int8_value=%0", {"1"}, true, true}, + {"data.basic_array[0].basic_types[1].uint8_value=%0", {"1"}, true, true}, + {"data.basic_array[0].basic_types[1].int16_value=%0", {"1"}, true, true}, + {"data.basic_array[0].basic_types[1].uint16_value=%0", {"1"}, true, true}, + {"data.basic_array[0].basic_types[1].int32_value=%0", {"1"}, true, true}, + {"data.basic_array[0].basic_types[1].uint32_value=%0", {"1"}, true, true}, + {"data.basic_array[0].basic_types[1].int64_value=%0", {"1"}, true, true}, + {"data.basic_array[0].basic_types[1].uint64_value=%0", {"1"}, true, true}, + {"data.basic_array[0].unbounded_int32_data[1]=%0", {"1"}, true, true}, + {"data.basic_array[0].bounded_float64_data[1]=%0", {"1"}, true, true}, // [1][0] - {"data.basic_array[1].basic_types[0].bool_value=%0", {"false"}, false}, - {"data.basic_array[1].basic_types[0].byte_value=%0", {"0"}, false}, - {"data.basic_array[1].basic_types[0].char_value=%0", {"0"}, false}, - {"data.basic_array[1].basic_types[0].float32_value=%0", {"0"}, false}, - {"data.basic_array[1].basic_types[0].float64_value=%0", {"0"}, false}, - {"data.basic_array[1].basic_types[0].int8_value=%0", {"0"}, false}, - {"data.basic_array[1].basic_types[0].uint8_value=%0", {"0"}, false}, - {"data.basic_array[1].basic_types[0].int16_value=%0", {"0"}, false}, - {"data.basic_array[1].basic_types[0].uint16_value=%0", {"0"}, false}, - {"data.basic_array[1].basic_types[0].int32_value=%0", {"0"}, false}, - {"data.basic_array[1].basic_types[0].uint32_value=%0", {"0"}, false}, - {"data.basic_array[1].basic_types[0].int64_value=%0", {"0"}, false}, - {"data.basic_array[1].basic_types[0].uint64_value=%0", {"0"}, false}, - {"data.basic_array[1].unbounded_int32_data[0]=%0", {"0"}, false}, - {"data.basic_array[1].bounded_float64_data[0]=%0", {"0"}, false}, - - {"data.basic_array[1].basic_types[0].bool_value=%0", {"true"}, true}, - {"data.basic_array[1].basic_types[0].byte_value=%0", {"1"}, true}, - {"data.basic_array[1].basic_types[0].char_value=%0", {"1"}, true}, - {"data.basic_array[1].basic_types[0].float32_value=%0", {"1"}, true}, - {"data.basic_array[1].basic_types[0].float64_value=%0", {"1"}, true}, - {"data.basic_array[1].basic_types[0].int8_value=%0", {"1"}, true}, - {"data.basic_array[1].basic_types[0].uint8_value=%0", {"1"}, true}, - {"data.basic_array[1].basic_types[0].int16_value=%0", {"1"}, true}, - {"data.basic_array[1].basic_types[0].uint16_value=%0", {"1"}, true}, - {"data.basic_array[1].basic_types[0].int32_value=%0", {"1"}, true}, - {"data.basic_array[1].basic_types[0].uint32_value=%0", {"1"}, true}, - {"data.basic_array[1].basic_types[0].int64_value=%0", {"1"}, true}, - {"data.basic_array[1].basic_types[0].uint64_value=%0", {"1"}, true}, - {"data.basic_array[1].unbounded_int32_data[0]=%0", {"1"}, true}, - {"data.basic_array[1].bounded_float64_data[0]=%0", {"1"}, true}, + {"data.basic_array[1].basic_types[0].bool_value=%0", {"false"}, true, false}, + {"data.basic_array[1].basic_types[0].byte_value=%0", {"0"}, true, false}, + {"data.basic_array[1].basic_types[0].char_value=%0", {"0"}, true, false}, + {"data.basic_array[1].basic_types[0].float32_value=%0", {"0"}, true, false}, + {"data.basic_array[1].basic_types[0].float64_value=%0", {"0"}, true, false}, + {"data.basic_array[1].basic_types[0].int8_value=%0", {"0"}, true, false}, + {"data.basic_array[1].basic_types[0].uint8_value=%0", {"0"}, true, false}, + {"data.basic_array[1].basic_types[0].int16_value=%0", {"0"}, true, false}, + {"data.basic_array[1].basic_types[0].uint16_value=%0", {"0"}, true, false}, + {"data.basic_array[1].basic_types[0].int32_value=%0", {"0"}, true, false}, + {"data.basic_array[1].basic_types[0].uint32_value=%0", {"0"}, true, false}, + {"data.basic_array[1].basic_types[0].int64_value=%0", {"0"}, true, false}, + {"data.basic_array[1].basic_types[0].uint64_value=%0", {"0"}, true, false}, + {"data.basic_array[1].unbounded_int32_data[0]=%0", {"0"}, true, false}, + {"data.basic_array[1].bounded_float64_data[0]=%0", {"0"}, true, false}, + + {"data.basic_array[1].basic_types[0].bool_value=%0", {"true"}, true, true}, + {"data.basic_array[1].basic_types[0].byte_value=%0", {"1"}, true, true}, + {"data.basic_array[1].basic_types[0].char_value=%0", {"1"}, true, true}, + {"data.basic_array[1].basic_types[0].float32_value=%0", {"1"}, true, true}, + {"data.basic_array[1].basic_types[0].float64_value=%0", {"1"}, true, true}, + {"data.basic_array[1].basic_types[0].int8_value=%0", {"1"}, true, true}, + {"data.basic_array[1].basic_types[0].uint8_value=%0", {"1"}, true, true}, + {"data.basic_array[1].basic_types[0].int16_value=%0", {"1"}, true, true}, + {"data.basic_array[1].basic_types[0].uint16_value=%0", {"1"}, true, true}, + {"data.basic_array[1].basic_types[0].int32_value=%0", {"1"}, true, true}, + {"data.basic_array[1].basic_types[0].uint32_value=%0", {"1"}, true, true}, + {"data.basic_array[1].basic_types[0].int64_value=%0", {"1"}, true, true}, + {"data.basic_array[1].basic_types[0].uint64_value=%0", {"1"}, true, true}, + {"data.basic_array[1].unbounded_int32_data[0]=%0", {"1"}, true, true}, + {"data.basic_array[1].bounded_float64_data[0]=%0", {"1"}, true, true}, // [1][1] - {"data.basic_array[1].basic_types[1].bool_value=%0", {"false"}, true}, - {"data.basic_array[1].basic_types[1].byte_value=%0", {"0"}, true}, - {"data.basic_array[1].basic_types[1].char_value=%0", {"0"}, true}, - {"data.basic_array[1].basic_types[1].float32_value=%0", {"0"}, true}, - {"data.basic_array[1].basic_types[1].float64_value=%0", {"0"}, true}, - {"data.basic_array[1].basic_types[1].int8_value=%0", {"0"}, true}, - {"data.basic_array[1].basic_types[1].uint8_value=%0", {"0"}, true}, - {"data.basic_array[1].basic_types[1].int16_value=%0", {"0"}, true}, - {"data.basic_array[1].basic_types[1].uint16_value=%0", {"0"}, true}, - {"data.basic_array[1].basic_types[1].int32_value=%0", {"0"}, true}, - {"data.basic_array[1].basic_types[1].uint32_value=%0", {"0"}, true}, - {"data.basic_array[1].basic_types[1].int64_value=%0", {"0"}, true}, - {"data.basic_array[1].basic_types[1].uint64_value=%0", {"0"}, true}, - {"data.basic_array[1].unbounded_int32_data[1]=%0", {"0"}, true}, - {"data.basic_array[1].bounded_float64_data[1]=%0", {"0"}, true}, - - {"data.basic_array[1].basic_types[1].bool_value=%0", {"true"}, false}, - {"data.basic_array[1].basic_types[1].byte_value=%0", {"1"}, false}, - {"data.basic_array[1].basic_types[1].char_value=%0", {"1"}, false}, - {"data.basic_array[1].basic_types[1].float32_value=%0", {"1"}, false}, - {"data.basic_array[1].basic_types[1].float64_value=%0", {"1"}, false}, - {"data.basic_array[1].basic_types[1].int8_value=%0", {"1"}, false}, - {"data.basic_array[1].basic_types[1].uint8_value=%0", {"1"}, false}, - {"data.basic_array[1].basic_types[1].int16_value=%0", {"1"}, false}, - {"data.basic_array[1].basic_types[1].uint16_value=%0", {"1"}, false}, - {"data.basic_array[1].basic_types[1].int32_value=%0", {"1"}, false}, - {"data.basic_array[1].basic_types[1].uint32_value=%0", {"1"}, false}, - {"data.basic_array[1].basic_types[1].int64_value=%0", {"1"}, false}, - {"data.basic_array[1].basic_types[1].uint64_value=%0", {"1"}, false}, - {"data.basic_array[1].unbounded_int32_data[1]=%0", {"1"}, false}, - {"data.basic_array[1].bounded_float64_data[1]=%0", {"1"}, false}, + {"data.basic_array[1].basic_types[1].bool_value=%0", {"false"}, true, true}, + {"data.basic_array[1].basic_types[1].byte_value=%0", {"0"}, true, true}, + {"data.basic_array[1].basic_types[1].char_value=%0", {"0"}, true, true}, + {"data.basic_array[1].basic_types[1].float32_value=%0", {"0"}, true, true}, + {"data.basic_array[1].basic_types[1].float64_value=%0", {"0"}, true, true}, + {"data.basic_array[1].basic_types[1].int8_value=%0", {"0"}, true, true}, + {"data.basic_array[1].basic_types[1].uint8_value=%0", {"0"}, true, true}, + {"data.basic_array[1].basic_types[1].int16_value=%0", {"0"}, true, true}, + {"data.basic_array[1].basic_types[1].uint16_value=%0", {"0"}, true, true}, + {"data.basic_array[1].basic_types[1].int32_value=%0", {"0"}, true, true}, + {"data.basic_array[1].basic_types[1].uint32_value=%0", {"0"}, true, true}, + {"data.basic_array[1].basic_types[1].int64_value=%0", {"0"}, true, true}, + {"data.basic_array[1].basic_types[1].uint64_value=%0", {"0"}, true, true}, + {"data.basic_array[1].unbounded_int32_data[1]=%0", {"0"}, true, true}, + {"data.basic_array[1].bounded_float64_data[1]=%0", {"0"}, true, true}, + + {"data.basic_array[1].basic_types[1].bool_value=%0", {"true"}, true, false}, + {"data.basic_array[1].basic_types[1].byte_value=%0", {"1"}, true, false}, + {"data.basic_array[1].basic_types[1].char_value=%0", {"1"}, true, false}, + {"data.basic_array[1].basic_types[1].float32_value=%0", {"1"}, true, false}, + {"data.basic_array[1].basic_types[1].float64_value=%0", {"1"}, true, false}, + {"data.basic_array[1].basic_types[1].int8_value=%0", {"1"}, true, false}, + {"data.basic_array[1].basic_types[1].uint8_value=%0", {"1"}, true, false}, + {"data.basic_array[1].basic_types[1].int16_value=%0", {"1"}, true, false}, + {"data.basic_array[1].basic_types[1].uint16_value=%0", {"1"}, true, false}, + {"data.basic_array[1].basic_types[1].int32_value=%0", {"1"}, true, false}, + {"data.basic_array[1].basic_types[1].uint32_value=%0", {"1"}, true, false}, + {"data.basic_array[1].basic_types[1].int64_value=%0", {"1"}, true, false}, + {"data.basic_array[1].basic_types[1].uint64_value=%0", {"1"}, true, false}, + {"data.basic_array[1].unbounded_int32_data[1]=%0", {"1"}, true, false}, + {"data.basic_array[1].bounded_float64_data[1]=%0", {"1"}, true, false}, + + // some other cases + // bad field name + {"error_name=%0", {"'complex_name'"}, false, true}, + {"errordata.names[0]=%0", {"'intermedia_first_name'"}, false, true}, + + // unbound case + {"data.names[10]=%0", {"'unbound_name'"}, true, false}, + + // bound case, the size of bounded_float64_data is 2 + {"data.basic_array[0].bounded_float64_data[10]=%0", {"0"}, false, true}, + + // TODO. if bugs found, add new test cases and fix source code }; for (auto & item : expectation) { - set_options( - item.filter_expression, - item.expression_parameter.size(), - item.expression_parameter.data()); - EXPECT_EQ(common_content_filter_evaluate(instance, &msg, false), item.expectation) - << "Error happened by the filter expression:" << item.filter_expression; + EXPECT_EQ( + item.set_expectation, + set_options( + item.filter_expression, + item.expression_parameter.size(), + item.expression_parameter.data())) + << "Set error happened by the filter expression:" << item.filter_expression; + EXPECT_EQ(item.evaluate_expectation, common_content_filter_evaluate(instance, &msg, false)) + << "Evaluate error happened by the filter expression:" << item.filter_expression; + + // reset + EXPECT_TRUE(set_options("", 0, nullptr)); } } From a8f48e2e5d08e06fbc321325315d182f75724188 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 11 Jul 2022 15:04:21 +0800 Subject: [PATCH 39/51] update Signed-off-by: Chen Lihui --- common_content_filter/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/common_content_filter/CMakeLists.txt b/common_content_filter/CMakeLists.txt index f2bb6bc..f54299f 100644 --- a/common_content_filter/CMakeLists.txt +++ b/common_content_filter/CMakeLists.txt @@ -76,6 +76,7 @@ ament_export_dependencies(rmw) ament_export_dependencies(rmw_implementation) ament_export_dependencies(rosidl_typesupport_introspection_c) ament_export_dependencies(rosidl_typesupport_introspection_cpp) +ament_export_dependencies(tao_pegtl_vendor) install( DIRECTORY include/ From 5579db44143757c32dca33d17a03f451e81af635 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 12 Jul 2022 09:34:36 +0800 Subject: [PATCH 40/51] use the fixed version Signed-off-by: Chen Lihui --- tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake b/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake index 559f801..08a9c83 100644 --- a/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake +++ b/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake @@ -12,5 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -find_package(pegtl REQUIRED) +# use the fixed version to prevent future compilation issues +# the number version 2.8.1 is from CMakeLists.txt +find_package(pegtl 2.8.1 REQUIRED) list(APPEND tao_pegtl_vendor_TARGETS taocpp::pegtl) From c81ac250ee32816468bbb53a873bc76b34e9ba78 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 12 Jul 2022 10:05:12 +0800 Subject: [PATCH 41/51] update log Signed-off-by: Chen Lihui --- common_content_filter/src/DDSFilterFactory.cpp | 1 - common_content_filter/src/Log.hpp | 1 + common_content_filter/src/Utilities.cpp | 12 +++++++----- common_content_filter/src/api.cpp | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/common_content_filter/src/DDSFilterFactory.cpp b/common_content_filter/src/DDSFilterFactory.cpp index 41c5a79..1b6ea50 100644 --- a/common_content_filter/src/DDSFilterFactory.cpp +++ b/common_content_filter/src/DDSFilterFactory.cpp @@ -434,7 +434,6 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( } else { auto node = parser::parse_filter_expression(filter_expression, type_support); if (node) { - // logDebug(DDSSQLFILTER, "parser::parse_filter_expression success "); DDSFilterExpression * expr = get_expression(); size_t n_params = filter_parameters.size(); expr->parameters.reserve(n_params); diff --git a/common_content_filter/src/Log.hpp b/common_content_filter/src/Log.hpp index e8a8959..1215516 100644 --- a/common_content_filter/src/Log.hpp +++ b/common_content_filter/src/Log.hpp @@ -16,6 +16,7 @@ #define COMMON_CONTENT_FILTER__LOG_HPP_ #include +#include #define common_content_filter_log_(level, cat, msg) \ { \ diff --git a/common_content_filter/src/Utilities.cpp b/common_content_filter/src/Utilities.cpp index d1ab6ab..52aade9 100644 --- a/common_content_filter/src/Utilities.cpp +++ b/common_content_filter/src/Utilities.cpp @@ -21,6 +21,8 @@ #include #include +#include "Log.hpp" + const rosidl_message_type_support_t * get_type_support_introspection( const rosidl_message_type_support_t * type_support) @@ -39,12 +41,12 @@ get_type_support_introspection( if (nullptr == type_support_introspection) { rcutils_error_string_t error_string = rcutils_get_error_string(); rcutils_reset_error(); - RMW_SET_ERROR_MSG_WITH_FORMAT_STRING( + logError( + DDSSQLFILTER, "Type support not from this implementation. Got:\n" - " %s\n" - " %s\n" - "while fetching it", - prev_error_string.str, error_string.str); + << " " << prev_error_string.str << "\n" + << " " << error_string.str << "\n" + << "while fetching it"); return nullptr; } } diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index fb48edb..93557c6 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -295,7 +295,7 @@ common_content_filter_set( options->filter_expression, expression_parameters ); } catch (const std::runtime_error & e) { - logInfo(DDSSQLFILTER, "Failed to create content filter: " << e.what()); + logError(DDSSQLFILTER, "Failed to create content filter: " << e.what()); } return ret; @@ -344,6 +344,7 @@ common_content_filter_get( if (rmw_ret != RMW_RET_OK) { logError(DDSSQLFILTER, rmw_get_error_string().str); + rmw_reset_error(); return false; } From 8144c130d5d9e397e0fd467edc237f1f8c85b28d Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 12 Jul 2022 10:37:39 +0800 Subject: [PATCH 42/51] use pegtl with original version 2.8.3 from fastdds Signed-off-by: Chen Lihui --- tao_pegtl_vendor/CMakeLists.txt | 8 ++++---- tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tao_pegtl_vendor/CMakeLists.txt b/tao_pegtl_vendor/CMakeLists.txt index ea9b0be..e138f99 100644 --- a/tao_pegtl_vendor/CMakeLists.txt +++ b/tao_pegtl_vendor/CMakeLists.txt @@ -43,10 +43,10 @@ macro(build_tao_pegtl) include(ExternalProject) - # Get pegtl 2.8.1 - externalproject_add(pegtl-2.8.1 - URL https://github.com/taocpp/PEGTL/archive/refs/tags/2.8.1.tar.gz - URL_MD5 10d625fb1da9e95c8e29c51be5e0e5e1 + # Get pegtl 2.8.3 + externalproject_add(pegtl-2.8.3 + URL https://github.com/taocpp/PEGTL/archive/refs/tags/2.8.3.tar.gz + URL_MD5 28b3c455d9ec392dd4230402383a8c6f TIMEOUT 60 CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_install diff --git a/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake b/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake index 08a9c83..80233f8 100644 --- a/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake +++ b/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake @@ -13,6 +13,6 @@ # limitations under the License. # use the fixed version to prevent future compilation issues -# the number version 2.8.1 is from CMakeLists.txt -find_package(pegtl 2.8.1 REQUIRED) +# the number version 2.8.3 is from CMakeLists.txt +find_package(pegtl 2.8.3 EXACT REQUIRED) list(APPEND tao_pegtl_vendor_TARGETS taocpp::pegtl) From 2892f235f2e98c5295f150fd18a1019a58112c08 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 12 Jul 2022 11:08:29 +0800 Subject: [PATCH 43/51] build pegtl only if it's not available Signed-off-by: Chen Lihui --- tao_pegtl_vendor/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tao_pegtl_vendor/CMakeLists.txt b/tao_pegtl_vendor/CMakeLists.txt index e138f99..cdf9e28 100644 --- a/tao_pegtl_vendor/CMakeLists.txt +++ b/tao_pegtl_vendor/CMakeLists.txt @@ -63,8 +63,11 @@ macro(build_tao_pegtl) ) endmacro() -# force to build pegtl, as pegtl might not available in the stable version on some platforms -build_tao_pegtl() +# build pegtl 2.8.3 if it's not available in the system or ros2 environment +find_package(pegtl QUIET) +if(NOT pegtl_FOUND OR NOT "${pegtl_VERSION}" VERSION_EQUAL 2.8.3) + build_tao_pegtl() +endif() if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) From 04f9464956d09c56cfcd342b2ea63d58863d278c Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Wed, 13 Jul 2022 16:20:02 +0800 Subject: [PATCH 44/51] tiny fix Signed-off-by: Chen Lihui --- common_content_filter/package.xml | 2 +- common_content_filter/src/DDSFilterCompoundCondition.hpp | 6 +++--- common_content_filter/src/DDSFilterGrammar.hpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common_content_filter/package.xml b/common_content_filter/package.xml index 494b45a..ea8e45c 100644 --- a/common_content_filter/package.xml +++ b/common_content_filter/package.xml @@ -15,7 +15,7 @@ rmw_implementation rosidl_typesupport_introspection_c rosidl_typesupport_introspection_cpp - tao_pegtl_vendor + tao_pegtl_vendor ament_cmake_gtest ament_lint_auto diff --git a/common_content_filter/src/DDSFilterCompoundCondition.hpp b/common_content_filter/src/DDSFilterCompoundCondition.hpp index 6532ae9..d1a4eb3 100644 --- a/common_content_filter/src/DDSFilterCompoundCondition.hpp +++ b/common_content_filter/src/DDSFilterCompoundCondition.hpp @@ -16,8 +16,8 @@ * @file DDSFilterCompoundCondition.hpp */ -#ifndef _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCOMPOUNDCONDITION_HPP_ -#define _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCOMPOUNDCONDITION_HPP_ +#ifndef COMMON_CONTENT_FILTER__DDSFILTERCOMPOUNDCONDITION_HPP_ +#define COMMON_CONTENT_FILTER__DDSFILTERCOMPOUNDCONDITION_HPP_ #include @@ -82,4 +82,4 @@ class DDSFilterCompoundCondition final : public DDSFilterCondition } // namespace fastdds } // namespace eprosima_common -#endif // _FASTDDS_TOPIC_DDSSQLFILTER_DDSFILTERCOMPOUNDCONDITION_HPP_ +#endif // COMMON_CONTENT_FILTER__DDSFILTERCOMPOUNDCONDITION_HPP_ diff --git a/common_content_filter/src/DDSFilterGrammar.hpp b/common_content_filter/src/DDSFilterGrammar.hpp index d929043..8f2ab16 100644 --- a/common_content_filter/src/DDSFilterGrammar.hpp +++ b/common_content_filter/src/DDSFilterGrammar.hpp @@ -45,7 +45,7 @@ struct fieldname_part : seq< identifier, opt< index_part > > {}; struct fieldname : list {}; // CHARVALUE, STRING, ENUMERATEDVALUE -struct open_quote : one< '`', '\'' > {}; +struct open_quote : one< '\'' > {}; struct close_quote : one< '\'' > {}; struct char_value : seq< open_quote, any, close_quote > {}; struct string_content : star< not_one< '\'', '\r', '\n'> > {}; From 3982265b8e20f5622f6dbf8b23e9029590ec6308 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 19 Jul 2022 16:39:59 +0800 Subject: [PATCH 45/51] rename files remove DDS and use common_content_filter instead of eprosima*::fastdds::dds Signed-off-by: Chen Lihui --- common_content_filter/CMakeLists.txt | 16 +- .../src/DDSFilterConditionState.hpp | 51 --- .../DDSFilterExpressionParserImpl/Readme.md | 7 - ...dition.cpp => FilterCompoundCondition.cpp} | 44 ++- ...dition.hpp => FilterCompoundCondition.hpp} | 44 ++- ...ilterCondition.hpp => FilterCondition.hpp} | 46 ++- .../src/FilterConditionState.hpp | 45 +++ ...pression.hpp => FilterEmptyExpression.hpp} | 24 +- ...terExpression.cpp => FilterExpression.cpp} | 32 +- ...terExpression.hpp => FilterExpression.hpp} | 38 +-- ...nParser.cpp => FilterExpressionParser.cpp} | 52 ++-- ...nParser.hpp => FilterExpressionParser.hpp} | 28 +- .../src/FilterExpressionParserImpl/Readme.md | 7 + .../identifiers.hpp | 24 +- .../literal_values.hpp | 18 +- .../parameters.hpp | 2 +- .../rearrange.hpp | 2 +- ...DDSFilterFactory.cpp => FilterFactory.cpp} | 292 +++++++++--------- ...DDSFilterFactory.hpp => FilterFactory.hpp} | 50 ++- .../{DDSFilterField.cpp => FilterField.cpp} | 30 +- .../{DDSFilterField.hpp => FilterField.hpp} | 50 ++- ...DDSFilterGrammar.hpp => FilterGrammar.hpp} | 27 +- ...ilterParameter.cpp => FilterParameter.cpp} | 24 +- ...ilterParameter.hpp => FilterParameter.hpp} | 32 +- ...ilterParseNode.hpp => FilterParseNode.hpp} | 32 +- ...ilterPredicate.cpp => FilterPredicate.cpp} | 30 +- ...ilterPredicate.hpp => FilterPredicate.hpp} | 46 ++- .../{DDSFilterValue.cpp => FilterValue.cpp} | 80 +++-- .../{DDSFilterValue.hpp => FilterValue.hpp} | 90 +++--- common_content_filter/src/IContentFilter.hpp | 10 +- .../src/IContentFilterFactory.hpp | 10 +- common_content_filter/src/ObjectPool.hpp | 7 +- common_content_filter/src/Utilities.cpp | 2 +- common_content_filter/src/api.cpp | 42 +-- 34 files changed, 596 insertions(+), 738 deletions(-) delete mode 100644 common_content_filter/src/DDSFilterConditionState.hpp delete mode 100644 common_content_filter/src/DDSFilterExpressionParserImpl/Readme.md rename common_content_filter/src/{DDSFilterCompoundCondition.cpp => FilterCompoundCondition.cpp} (60%) rename common_content_filter/src/{DDSFilterCompoundCondition.hpp => FilterCompoundCondition.hpp} (54%) rename common_content_filter/src/{DDSFilterCondition.hpp => FilterCondition.hpp} (68%) create mode 100644 common_content_filter/src/FilterConditionState.hpp rename common_content_filter/src/{DDSFilterEmptyExpression.hpp => FilterEmptyExpression.hpp} (65%) rename common_content_filter/src/{DDSFilterExpression.cpp => FilterExpression.cpp} (62%) rename common_content_filter/src/{DDSFilterExpression.hpp => FilterExpression.hpp} (57%) rename common_content_filter/src/{DDSFilterExpressionParser.cpp => FilterExpressionParser.cpp} (71%) rename common_content_filter/src/{DDSFilterExpressionParser.hpp => FilterExpressionParser.hpp} (72%) create mode 100644 common_content_filter/src/FilterExpressionParserImpl/Readme.md rename common_content_filter/src/{DDSFilterExpressionParserImpl => FilterExpressionParserImpl}/identifiers.hpp (89%) rename common_content_filter/src/{DDSFilterExpressionParserImpl => FilterExpressionParserImpl}/literal_values.hpp (78%) rename common_content_filter/src/{DDSFilterExpressionParserImpl => FilterExpressionParserImpl}/parameters.hpp (95%) rename common_content_filter/src/{DDSFilterExpressionParserImpl => FilterExpressionParserImpl}/rearrange.hpp (97%) rename common_content_filter/src/{DDSFilterFactory.cpp => FilterFactory.cpp} (50%) rename common_content_filter/src/{DDSFilterFactory.hpp => FilterFactory.hpp} (61%) rename common_content_filter/src/{DDSFilterField.cpp => FilterField.cpp} (92%) rename common_content_filter/src/{DDSFilterField.hpp => FilterField.hpp} (74%) rename common_content_filter/src/{DDSFilterGrammar.hpp => FilterGrammar.hpp} (89%) rename common_content_filter/src/{DDSFilterParameter.cpp => FilterParameter.cpp} (68%) rename common_content_filter/src/{DDSFilterParameter.hpp => FilterParameter.hpp} (57%) rename common_content_filter/src/{DDSFilterParseNode.hpp => FilterParseNode.hpp} (68%) rename common_content_filter/src/{DDSFilterPredicate.cpp => FilterPredicate.cpp} (78%) rename common_content_filter/src/{DDSFilterPredicate.hpp => FilterPredicate.hpp} (62%) rename common_content_filter/src/{DDSFilterValue.cpp => FilterValue.cpp} (82%) rename common_content_filter/src/{DDSFilterValue.hpp => FilterValue.hpp} (66%) diff --git a/common_content_filter/CMakeLists.txt b/common_content_filter/CMakeLists.txt index f54299f..d30c32e 100644 --- a/common_content_filter/CMakeLists.txt +++ b/common_content_filter/CMakeLists.txt @@ -22,14 +22,14 @@ find_package(tao_pegtl_vendor REQUIRED) add_library(${PROJECT_NAME}_library SHARED src/api.cpp - src/DDSFilterCompoundCondition.cpp - src/DDSFilterExpression.cpp - src/DDSFilterExpressionParser.cpp - src/DDSFilterFactory.cpp - src/DDSFilterField.cpp - src/DDSFilterParameter.cpp - src/DDSFilterPredicate.cpp - src/DDSFilterValue.cpp + src/FilterCompoundCondition.cpp + src/FilterExpression.cpp + src/FilterExpressionParser.cpp + src/FilterFactory.cpp + src/FilterField.cpp + src/FilterParameter.cpp + src/FilterPredicate.cpp + src/FilterValue.cpp src/Utilities.cpp) set_target_properties(${PROJECT_NAME}_library diff --git a/common_content_filter/src/DDSFilterConditionState.hpp b/common_content_filter/src/DDSFilterConditionState.hpp deleted file mode 100644 index f149f0a..0000000 --- a/common_content_filter/src/DDSFilterConditionState.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file DDSFilterConditionState.hpp - */ - -#ifndef COMMON_CONTENT_FILTER__DDSFILTERCONDITIONSTATE_HPP_ -#define COMMON_CONTENT_FILTER__DDSFILTERCONDITIONSTATE_HPP_ - -namespace eprosima_common -{ -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter -{ - -/** - * Possible states of a DDSFilterCondition. - */ -enum class DDSFilterConditionState : char -{ - /// Initial state of the DDSFilterCondition, indicating there is no result. - UNDECIDED, - - /// State indicating that the DDSFilterCondition evaluates to @c false. - RESULT_FALSE, - - /// State indicating that the DDSFilterCondition evaluates to @c true. - RESULT_TRUE -}; - -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common - -#endif // COMMON_CONTENT_FILTER__DDSFILTERCONDITIONSTATE_HPP_ diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/Readme.md b/common_content_filter/src/DDSFilterExpressionParserImpl/Readme.md deleted file mode 100644 index 2e88d50..0000000 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/Readme.md +++ /dev/null @@ -1,7 +0,0 @@ -## Internal support classes for DataReaderImpl - -This folder contains the declaration of several internal support classes to improve -maintenance and readability of DDSFilterExpressionParser.hpp. - -They are not meant to be used outside DDSFilterExpressionParser and their functionality should be -fully covered by the unit tests of DDSFilterFactory. diff --git a/common_content_filter/src/DDSFilterCompoundCondition.cpp b/common_content_filter/src/FilterCompoundCondition.cpp similarity index 60% rename from common_content_filter/src/DDSFilterCompoundCondition.cpp rename to common_content_filter/src/FilterCompoundCondition.cpp index 5ec21bd..27709b8 100644 --- a/common_content_filter/src/DDSFilterCompoundCondition.cpp +++ b/common_content_filter/src/FilterCompoundCondition.cpp @@ -13,29 +13,25 @@ // limitations under the License. /** - * @file DDSFilterCompoundCondition.cpp + * @file FilterCompoundCondition.cpp */ -#include "DDSFilterCompoundCondition.hpp" +#include "FilterCompoundCondition.hpp" #include #include -#include "DDSFilterCondition.hpp" +#include "FilterCondition.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { -DDSFilterCompoundCondition::DDSFilterCompoundCondition( +FilterCompoundCondition::FilterCompoundCondition( OperationKind op, - std::unique_ptr && left, - std::unique_ptr && right) + std::unique_ptr && left, + std::unique_ptr && right) : op_(op) , left_(std::move(left)) , right_(std::move(right)) @@ -49,7 +45,7 @@ DDSFilterCompoundCondition::DDSFilterCompoundCondition( } } -void DDSFilterCompoundCondition::propagate_reset() noexcept +void FilterCompoundCondition::propagate_reset() noexcept { num_children_decided_ = 0; @@ -59,22 +55,22 @@ void DDSFilterCompoundCondition::propagate_reset() noexcept } } -void DDSFilterCompoundCondition::child_has_changed( - const DDSFilterCondition & child) noexcept +void FilterCompoundCondition::child_has_changed( + const FilterCondition & child) noexcept { - DDSFilterConditionState child_state = child.get_state(); - assert(DDSFilterConditionState::UNDECIDED != child_state); + FilterConditionState child_state = child.get_state(); + assert(FilterConditionState::UNDECIDED != child_state); ++num_children_decided_; - if (DDSFilterConditionState::UNDECIDED == get_state()) { + if (FilterConditionState::UNDECIDED == get_state()) { switch (op_) { case OperationKind::NOT: - set_result(DDSFilterConditionState::RESULT_FALSE == child_state); + set_result(FilterConditionState::RESULT_FALSE == child_state); break; case OperationKind::AND: - if (DDSFilterConditionState::RESULT_FALSE == child_state) { + if (FilterConditionState::RESULT_FALSE == child_state) { set_result(false); } else { if (2 == num_children_decided_) { @@ -84,7 +80,7 @@ void DDSFilterCompoundCondition::child_has_changed( break; case OperationKind::OR: - if (DDSFilterConditionState::RESULT_TRUE == child_state) { + if (FilterConditionState::RESULT_TRUE == child_state) { set_result(true); } else { if (2 == num_children_decided_) { @@ -99,7 +95,5 @@ void DDSFilterCompoundCondition::child_has_changed( } } -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter diff --git a/common_content_filter/src/DDSFilterCompoundCondition.hpp b/common_content_filter/src/FilterCompoundCondition.hpp similarity index 54% rename from common_content_filter/src/DDSFilterCompoundCondition.hpp rename to common_content_filter/src/FilterCompoundCondition.hpp index d1a4eb3..5ab5ea4 100644 --- a/common_content_filter/src/DDSFilterCompoundCondition.hpp +++ b/common_content_filter/src/FilterCompoundCondition.hpp @@ -13,29 +13,25 @@ // limitations under the License. /** - * @file DDSFilterCompoundCondition.hpp + * @file FilterCompoundCondition.hpp */ -#ifndef COMMON_CONTENT_FILTER__DDSFILTERCOMPOUNDCONDITION_HPP_ -#define COMMON_CONTENT_FILTER__DDSFILTERCOMPOUNDCONDITION_HPP_ +#ifndef COMMON_CONTENT_FILTER__FILTERCOMPOUNDCONDITION_HPP_ +#define COMMON_CONTENT_FILTER__FILTERCOMPOUNDCONDITION_HPP_ #include -#include "DDSFilterCondition.hpp" +#include "FilterCondition.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { /** - * A DDSFilterCondition that performs a logical operation over one or two DDSFilterCondition objects. + * A FilterCondition that performs a logical operation over one or two FilterCondition objects. */ -class DDSFilterCompoundCondition final : public DDSFilterCondition +class FilterCompoundCondition final : public FilterCondition { public: @@ -50,36 +46,34 @@ class DDSFilterCompoundCondition final : public DDSFilterCondition }; /** - * Construct a DDSFilterCompoundCondition. + * Construct a FilterCompoundCondition. * * @param[in] op Operation to perform. * @param[in] left Left operand. * @param[in] right Right operand. */ - DDSFilterCompoundCondition( + FilterCompoundCondition( OperationKind op, - std::unique_ptr && left, - std::unique_ptr && right); + std::unique_ptr && left, + std::unique_ptr && right); - virtual ~DDSFilterCompoundCondition() = default; + virtual ~FilterCompoundCondition() = default; protected: void propagate_reset() noexcept final; void child_has_changed( - const DDSFilterCondition & child) noexcept final; + const FilterCondition & child) noexcept final; private: OperationKind op_; - std::unique_ptr left_; - std::unique_ptr right_; + std::unique_ptr left_; + std::unique_ptr right_; uint8_t num_children_decided_ = 0; }; -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__DDSFILTERCOMPOUNDCONDITION_HPP_ +#endif // COMMON_CONTENT_FILTER__FILTERCOMPOUNDCONDITION_HPP_ diff --git a/common_content_filter/src/DDSFilterCondition.hpp b/common_content_filter/src/FilterCondition.hpp similarity index 68% rename from common_content_filter/src/DDSFilterCondition.hpp rename to common_content_filter/src/FilterCondition.hpp index 9410501..eddd101 100644 --- a/common_content_filter/src/DDSFilterCondition.hpp +++ b/common_content_filter/src/FilterCondition.hpp @@ -13,38 +13,34 @@ // limitations under the License. /** - * @file DDSFilterCondition.hpp + * @file FilterCondition.hpp */ -#ifndef COMMON_CONTENT_FILTER__DDSFILTERCONDITION_HPP_ -#define COMMON_CONTENT_FILTER__DDSFILTERCONDITION_HPP_ +#ifndef COMMON_CONTENT_FILTER__FILTERCONDITION_HPP_ +#define COMMON_CONTENT_FILTER__FILTERCONDITION_HPP_ -#include "DDSFilterConditionState.hpp" +#include "FilterConditionState.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { /** * Base class for conditions on a filter expression. */ -class DDSFilterCondition +class FilterCondition { public: - friend class DDSFilterCompoundCondition; + friend class FilterCompoundCondition; - virtual ~DDSFilterCondition() = default; + virtual ~FilterCondition() = default; /** * @return the current state of this condition. */ - inline DDSFilterConditionState get_state() const noexcept + inline FilterConditionState get_state() const noexcept { return state_; } @@ -57,7 +53,7 @@ class DDSFilterCondition */ inline void reset() noexcept { - state_ = DDSFilterConditionState::UNDECIDED; + state_ = FilterConditionState::UNDECIDED; propagate_reset(); } @@ -72,7 +68,7 @@ class DDSFilterCondition * @post The state of this condition will be @c state. */ inline void set_state( - DDSFilterConditionState state) noexcept + FilterConditionState state) noexcept { if (state != state_) { state_ = state; @@ -92,7 +88,7 @@ class DDSFilterCondition inline void set_result( bool result) noexcept { - set_state(result ? DDSFilterConditionState::RESULT_TRUE : DDSFilterConditionState::RESULT_FALSE); + set_state(result ? FilterConditionState::RESULT_TRUE : FilterConditionState::RESULT_FALSE); } /** @@ -101,7 +97,7 @@ class DDSFilterCondition * @param parent New parent to set. */ inline void set_parent( - DDSFilterCondition * parent) noexcept + FilterCondition * parent) noexcept { parent_ = parent; } @@ -118,17 +114,15 @@ class DDSFilterCondition * @param[in] child The child condition */ virtual void child_has_changed( - const DDSFilterCondition & child) noexcept = 0; + const FilterCondition & child) noexcept = 0; private: - DDSFilterConditionState state_ = DDSFilterConditionState::UNDECIDED; - DDSFilterCondition * parent_ = nullptr; + FilterConditionState state_ = FilterConditionState::UNDECIDED; + FilterCondition * parent_ = nullptr; }; -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__DDSFILTERCONDITION_HPP_ +#endif // COMMON_CONTENT_FILTER__FILTERCONDITION_HPP_ diff --git a/common_content_filter/src/FilterConditionState.hpp b/common_content_filter/src/FilterConditionState.hpp new file mode 100644 index 0000000..498b302 --- /dev/null +++ b/common_content_filter/src/FilterConditionState.hpp @@ -0,0 +1,45 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file FilterConditionState.hpp + */ + +#ifndef COMMON_CONTENT_FILTER__FILTERCONDITIONSTATE_HPP_ +#define COMMON_CONTENT_FILTER__FILTERCONDITIONSTATE_HPP_ + +namespace common_content_filter +{ +namespace SQLFilter +{ + +/** + * Possible states of a FilterCondition. + */ +enum class FilterConditionState : char +{ + /// Initial state of the FilterCondition, indicating there is no result. + UNDECIDED, + + /// State indicating that the FilterCondition evaluates to @c false. + RESULT_FALSE, + + /// State indicating that the FilterCondition evaluates to @c true. + RESULT_TRUE +}; + +} // namespace SQLFilter +} // namespace common_content_filter + +#endif // COMMON_CONTENT_FILTER__FILTERCONDITIONSTATE_HPP_ diff --git a/common_content_filter/src/DDSFilterEmptyExpression.hpp b/common_content_filter/src/FilterEmptyExpression.hpp similarity index 65% rename from common_content_filter/src/DDSFilterEmptyExpression.hpp rename to common_content_filter/src/FilterEmptyExpression.hpp index 94b2121..13a2812 100644 --- a/common_content_filter/src/DDSFilterEmptyExpression.hpp +++ b/common_content_filter/src/FilterEmptyExpression.hpp @@ -13,27 +13,23 @@ // limitations under the License. /** - * @file DDSFilterEmptyExpression.hpp + * @file FilterEmptyExpression.hpp */ -#ifndef COMMON_CONTENT_FILTER__DDSFILTEREMPTYEXPRESSION_HPP_ -#define COMMON_CONTENT_FILTER__DDSFILTEREMPTYEXPRESSION_HPP_ +#ifndef COMMON_CONTENT_FILTER__FILTEREMPTYEXPRESSION_HPP_ +#define COMMON_CONTENT_FILTER__FILTEREMPTYEXPRESSION_HPP_ #include "IContentFilter.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { /** * An IContentFilter for empty expressions that always evaluates to true. */ -class DDSFilterEmptyExpression final : public IContentFilter +class FilterEmptyExpression final : public IContentFilter { public: @@ -47,9 +43,7 @@ class DDSFilterEmptyExpression final : public IContentFilter }; -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__DDSFILTEREMPTYEXPRESSION_HPP_ +#endif // COMMON_CONTENT_FILTER__FILTEREMPTYEXPRESSION_HPP_ diff --git a/common_content_filter/src/DDSFilterExpression.cpp b/common_content_filter/src/FilterExpression.cpp similarity index 62% rename from common_content_filter/src/DDSFilterExpression.cpp rename to common_content_filter/src/FilterExpression.cpp index e37b25e..70f341f 100644 --- a/common_content_filter/src/DDSFilterExpression.cpp +++ b/common_content_filter/src/FilterExpression.cpp @@ -13,36 +13,32 @@ // limitations under the License. /** - * @file DDSFilterExpression.cpp + * @file FilterExpression.cpp */ -#include "DDSFilterExpression.hpp" +#include "FilterExpression.hpp" #include #include #include #include -#include "DDSFilterCondition.hpp" -#include "DDSFilterField.hpp" -#include "DDSFilterParameter.hpp" +#include "FilterCondition.hpp" +#include "FilterField.hpp" +#include "FilterParameter.hpp" #include "Log.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { -bool DDSFilterExpression::evaluate( +bool FilterExpression::evaluate( const void * payload) const { root->reset(); for (auto it = fields.begin(); - it != fields.end() && DDSFilterConditionState::UNDECIDED == root->get_state(); + it != fields.end() && FilterConditionState::UNDECIDED == root->get_state(); ++it) { if (!it->second->set_value(payload)) { @@ -50,10 +46,10 @@ bool DDSFilterExpression::evaluate( } } - return DDSFilterConditionState::RESULT_TRUE == root->get_state(); + return FilterConditionState::RESULT_TRUE == root->get_state(); } -void DDSFilterExpression::clear() +void FilterExpression::clear() { parameters.clear(); fields.clear(); @@ -61,7 +57,5 @@ void DDSFilterExpression::clear() } -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter diff --git a/common_content_filter/src/DDSFilterExpression.hpp b/common_content_filter/src/FilterExpression.hpp similarity index 57% rename from common_content_filter/src/DDSFilterExpression.hpp rename to common_content_filter/src/FilterExpression.hpp index f75d278..1dd7d12 100644 --- a/common_content_filter/src/DDSFilterExpression.hpp +++ b/common_content_filter/src/FilterExpression.hpp @@ -13,11 +13,11 @@ // limitations under the License. /** - * @file DDSFilterExpression.hpp + * @file FilterExpression.hpp */ -#ifndef COMMON_CONTENT_FILTER__DDSFILTEREXPRESSION_HPP_ -#define COMMON_CONTENT_FILTER__DDSFILTEREXPRESSION_HPP_ +#ifndef COMMON_CONTENT_FILTER__FILTEREXPRESSION_HPP_ +#define COMMON_CONTENT_FILTER__FILTEREXPRESSION_HPP_ #include #include @@ -25,23 +25,19 @@ #include #include "IContentFilter.hpp" -#include "DDSFilterCondition.hpp" -#include "DDSFilterField.hpp" -#include "DDSFilterParameter.hpp" +#include "FilterCondition.hpp" +#include "FilterField.hpp" +#include "FilterParameter.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { /** - * An IContentFilter that evaluates DDS-SQL filter expressions + * An IContentFilter that evaluates -SQL filter expressions */ -class DDSFilterExpression final : public IContentFilter +class FilterExpression final : public IContentFilter { public: @@ -54,16 +50,14 @@ class DDSFilterExpression final : public IContentFilter void clear(); /// The root condition of the expression tree. - std::unique_ptr root; + std::unique_ptr root; /// The fields referenced by this expression. - std::map> fields; + std::map> fields; /// The parameters referenced by this expression. - std::vector> parameters; + std::vector> parameters; }; -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__DDSFILTEREXPRESSION_HPP_ +#endif // COMMON_CONTENT_FILTER__FILTEREXPRESSION_HPP_ diff --git a/common_content_filter/src/DDSFilterExpressionParser.cpp b/common_content_filter/src/FilterExpressionParser.cpp similarity index 71% rename from common_content_filter/src/DDSFilterExpressionParser.cpp rename to common_content_filter/src/FilterExpressionParser.cpp index 15a41ed..170ebba 100644 --- a/common_content_filter/src/DDSFilterExpressionParser.cpp +++ b/common_content_filter/src/FilterExpressionParser.cpp @@ -13,10 +13,10 @@ // limitations under the License. /** - * @file DDSFilterExpressionParser.cpp + * @file FilterExpressionParser.cpp */ -#include "DDSFilterExpressionParser.hpp" +#include "FilterExpressionParser.hpp" // header files needed by identifiers.hpp #include @@ -31,30 +31,26 @@ #include #include -#include "DDSFilterGrammar.hpp" -#include "DDSFilterParseNode.hpp" -#include "DDSFilterValue.hpp" -#include "DDSFilterField.hpp" +#include "FilterGrammar.hpp" +#include "FilterParseNode.hpp" +#include "FilterValue.hpp" +#include "FilterField.hpp" #include "Log.hpp" #include "Utilities.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { namespace parser { using namespace tao::TAO_PEGTL_NAMESPACE; -#include "DDSFilterExpressionParserImpl/rearrange.hpp" -#include "DDSFilterExpressionParserImpl/literal_values.hpp" -#include "DDSFilterExpressionParserImpl/identifiers.hpp" -#include "DDSFilterExpressionParserImpl/parameters.hpp" +#include "FilterExpressionParserImpl/rearrange.hpp" +#include "FilterExpressionParserImpl/literal_values.hpp" +#include "FilterExpressionParserImpl/identifiers.hpp" +#include "FilterExpressionParserImpl/parameters.hpp" // select which rules in the grammar will produce parse tree nodes: template @@ -96,7 +92,7 @@ using selector = parse_tree::selector< BetweenPredicate, Range, Condition, - FilterExpression>, + ConditionList>, identifier_processor::on< fieldname_part, fieldname> @@ -113,11 +109,11 @@ std::unique_ptr parse_filter_expression( } catch (const parse_error & e) { const auto p = e.positions.front(); logError( - DDSSQLFILTER, "PARSE ERROR: " << e.what() << std::endl - << in.line_at(p) << std::endl - << std::string(p.byte_in_line, ' ') << '^'); + SQLFILTER, "PARSE ERROR: " << e.what() << std::endl + << in.line_at(p) << std::endl + << std::string(p.byte_in_line, ' ') << '^'); } catch (const std::exception & e) { - logError(DDSSQLFILTER, "ERROR '" << e.what() << "' while parsing " << expression); + logError(SQLFILTER, "ERROR '" << e.what() << "' while parsing " << expression); } return nullptr; @@ -133,18 +129,16 @@ std::unique_ptr parse_literal_value( } catch (const parse_error & e) { const auto p = e.positions.front(); logError( - DDSSQLFILTER, "PARSE ERROR: " << e.what() << std::endl - << in.line_at(p) << std::endl - << std::string(p.byte_in_line, ' ') << '^'); + SQLFILTER, "PARSE ERROR: " << e.what() << std::endl + << in.line_at(p) << std::endl + << std::string(p.byte_in_line, ' ') << '^'); } catch (const std::exception & e) { - logError(DDSSQLFILTER, "ERROR '" << e.what() << "' while parsing " << expression); + logError(SQLFILTER, "ERROR '" << e.what() << "' while parsing " << expression); } return nullptr; } } // namespace parser -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter diff --git a/common_content_filter/src/DDSFilterExpressionParser.hpp b/common_content_filter/src/FilterExpressionParser.hpp similarity index 72% rename from common_content_filter/src/DDSFilterExpressionParser.hpp rename to common_content_filter/src/FilterExpressionParser.hpp index 54aa737..b622a19 100644 --- a/common_content_filter/src/DDSFilterExpressionParser.hpp +++ b/common_content_filter/src/FilterExpressionParser.hpp @@ -13,30 +13,26 @@ // limitations under the License. /** - * @file DDSFilterExpressionParser.hpp + * @file FilterExpressionParser.hpp */ -#ifndef COMMON_CONTENT_FILTER__DDSFILTEREXPRESSIONPARSER_HPP_ -#define COMMON_CONTENT_FILTER__DDSFILTEREXPRESSIONPARSER_HPP_ +#ifndef COMMON_CONTENT_FILTER__FILTEREXPRESSIONPARSER_HPP_ +#define COMMON_CONTENT_FILTER__FILTEREXPRESSIONPARSER_HPP_ #include #include -#include "DDSFilterParseNode.hpp" +#include "FilterParseNode.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { namespace parser { /** - * Performs parsing of a string containing a DDS-SQL filter expression. + * Performs parsing of a string containing a -SQL filter expression. * * @param[in] expression The string to parse. * @param[in] type_support The type support representing the type of the data being filtered. @@ -55,15 +51,13 @@ std::unique_ptr parse_filter_expression( * @param[in] value The string to parse. * * @return nullptr when there is a parsing error. - * @return A simple tree consisting of a root node, with a single child that contains the generated DDSFilterValue. + * @return A simple tree consisting of a root node, with a single child that contains the generated FilterValue. */ std::unique_ptr parse_literal_value( const char * value); } // namespace parser -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__DDSFILTEREXPRESSIONPARSER_HPP_ +#endif // COMMON_CONTENT_FILTER__FILTEREXPRESSIONPARSER_HPP_ diff --git a/common_content_filter/src/FilterExpressionParserImpl/Readme.md b/common_content_filter/src/FilterExpressionParserImpl/Readme.md new file mode 100644 index 0000000..0251df6 --- /dev/null +++ b/common_content_filter/src/FilterExpressionParserImpl/Readme.md @@ -0,0 +1,7 @@ +## Internal support classes for DataReaderImpl + +This folder contains the declaration of several internal support classes to improve +maintenance and readability of FilterExpressionParser.hpp. + +They are not meant to be used outside FilterExpressionParser and their functionality should be +fully covered by the unit tests of FilterFactory. diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp similarity index 89% rename from common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp rename to common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp index de3cfa9..cd41525 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/identifiers.hpp +++ b/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp @@ -16,7 +16,7 @@ * @file identifiers.hpp * * Note: this is an implementation file, designed to be included inside the - * DDSFilterExpressionParser.hpp file of the parent folder. + * FilterExpressionParser.hpp file of the parent folder. */ @@ -28,7 +28,7 @@ struct CurrentIdentifierState uint8_t current_type; - std::vector access_path; + std::vector access_path; }; struct identifier_processor @@ -85,7 +85,7 @@ struct identifier_processor } identifier_state.access_path.emplace_back( - DDSFilterField::FieldAccessor{member_index, array_index, type_support_introspection}); + FilterField::FieldAccessor{member_index, array_index, type_support_introspection}); return; } @@ -115,34 +115,34 @@ struct identifier_processor } } - static DDSFilterValue::ValueKind get_value_kind( + static FilterValue::ValueKind get_value_kind( uint8_t type_id, const position & pos) { switch (type_id) { case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: - return DDSFilterValue::ValueKind::BOOLEAN; + return FilterValue::ValueKind::BOOLEAN; case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_CHAR: - return DDSFilterValue::ValueKind::CHAR; + return FilterValue::ValueKind::CHAR; case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: - return DDSFilterValue::ValueKind::STRING; + return FilterValue::ValueKind::STRING; case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT8: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT16: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT32: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT64: - return DDSFilterValue::ValueKind::SIGNED_INTEGER; + return FilterValue::ValueKind::SIGNED_INTEGER; case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_OCTET: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT8: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT16: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT32: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT64: - return DDSFilterValue::ValueKind::UNSIGNED_INTEGER; + return FilterValue::ValueKind::UNSIGNED_INTEGER; case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: - return DDSFilterValue::ValueKind::FLOAT_FIELD; + return FilterValue::ValueKind::FLOAT_FIELD; case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_DOUBLE: - return DDSFilterValue::ValueKind::DOUBLE_FIELD; + return FilterValue::ValueKind::DOUBLE_FIELD; case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_LONG_DOUBLE: - return DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD; + return FilterValue::ValueKind::LONG_DOUBLE_FIELD; case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/literal_values.hpp b/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp similarity index 78% rename from common_content_filter/src/DDSFilterExpressionParserImpl/literal_values.hpp rename to common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp index e97865a..7cae95f 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/literal_values.hpp +++ b/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp @@ -16,7 +16,7 @@ * @file literal_values.hpp * * Note: this is an implementation file, designed to be included inside the - * DDSFilterExpressionParser.hpp file of the parent folder. + * FilterExpressionParser.hpp file of the parent folder. */ struct literal_value_processor @@ -27,31 +27,31 @@ struct literal_value_processor std::unique_ptr & n, States &&... /*st*/) { - n->value.reset(new DDSFilterValue()); + n->value.reset(new FilterValue()); if (n->is()) { - n->value->kind = DDSFilterValue::ValueKind::BOOLEAN; + n->value->kind = FilterValue::ValueKind::BOOLEAN; n->value->boolean_value = true; } else if (n->is()) { - n->value->kind = DDSFilterValue::ValueKind::BOOLEAN; + n->value->kind = FilterValue::ValueKind::BOOLEAN; n->value->boolean_value = false; } else if (n->is() || n->is()) { if (n->m_begin.data[0] == '-') { - n->value->kind = DDSFilterValue::ValueKind::SIGNED_INTEGER; + n->value->kind = FilterValue::ValueKind::SIGNED_INTEGER; n->value->signed_integer_value = std::stoll(n->content(), nullptr, 0); } else { - n->value->kind = DDSFilterValue::ValueKind::UNSIGNED_INTEGER; + n->value->kind = FilterValue::ValueKind::UNSIGNED_INTEGER; n->value->unsigned_integer_value = std::stoull(n->content(), nullptr, 0); } } else if (n->is()) { - n->value->kind = DDSFilterValue::ValueKind::FLOAT_CONST; + n->value->kind = FilterValue::ValueKind::FLOAT_CONST; n->value->float_value = std::stold(n->content()); } else if (n->is()) { - n->value->kind = DDSFilterValue::ValueKind::CHAR; + n->value->kind = FilterValue::ValueKind::CHAR; n->value->char_value = n->m_begin.data[1]; } else if (n->is()) { @@ -60,7 +60,7 @@ struct literal_value_processor if (sizeof(n->value->string_value) < str_len) { throw parse_error("string constant has more than 255 characters", n->end()); } - n->value->kind = DDSFilterValue::ValueKind::STRING; + n->value->kind = FilterValue::ValueKind::STRING; strncpy(n->value->string_value, content_node.m_begin.data, str_len); } diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/parameters.hpp b/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp similarity index 95% rename from common_content_filter/src/DDSFilterExpressionParserImpl/parameters.hpp rename to common_content_filter/src/FilterExpressionParserImpl/parameters.hpp index 3d7ba7f..6469598 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/parameters.hpp +++ b/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp @@ -16,7 +16,7 @@ * @file parameters.hpp * * Note: this is an implementation file, designed to be included inside the - * DDSFilterExpressionParser.hpp file of the parent folder. + * FilterExpressionParser.hpp file of the parent folder. */ struct parameter_processor diff --git a/common_content_filter/src/DDSFilterExpressionParserImpl/rearrange.hpp b/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp similarity index 97% rename from common_content_filter/src/DDSFilterExpressionParserImpl/rearrange.hpp rename to common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp index 55ce6a8..8103f45 100644 --- a/common_content_filter/src/DDSFilterExpressionParserImpl/rearrange.hpp +++ b/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp @@ -16,7 +16,7 @@ * @file rearrange.hpp * * Note: this is an implementation file, designed to be included inside the - * DDSFilterExpressionParser.hpp file of the parent folder. + * FilterExpressionParser.hpp file of the parent folder. */ // after a node is stored successfully, you can add an optional transformer like this: diff --git a/common_content_filter/src/DDSFilterFactory.cpp b/common_content_filter/src/FilterFactory.cpp similarity index 50% rename from common_content_filter/src/DDSFilterFactory.cpp rename to common_content_filter/src/FilterFactory.cpp index 1b6ea50..354fcd4 100644 --- a/common_content_filter/src/DDSFilterFactory.cpp +++ b/common_content_filter/src/FilterFactory.cpp @@ -13,10 +13,10 @@ // limitations under the License. /** - * @file DDSFilterFactory.cpp + * @file FilterFactory.cpp */ -#include "DDSFilterFactory.hpp" +#include "FilterFactory.hpp" #include #include @@ -24,32 +24,28 @@ #include "IContentFilter.hpp" #include "IContentFilterFactory.hpp" -#include "DDSFilterGrammar.hpp" -#include "DDSFilterExpressionParser.hpp" -#include "DDSFilterParseNode.hpp" -#include "DDSFilterExpression.hpp" -#include "DDSFilterCompoundCondition.hpp" -#include "DDSFilterCondition.hpp" -#include "DDSFilterConditionState.hpp" -#include "DDSFilterEmptyExpression.hpp" -#include "DDSFilterExpression.hpp" -#include "DDSFilterField.hpp" -#include "DDSFilterParameter.hpp" -#include "DDSFilterPredicate.hpp" -#include "DDSFilterValue.hpp" +#include "FilterGrammar.hpp" +#include "FilterExpressionParser.hpp" +#include "FilterParseNode.hpp" +#include "FilterExpression.hpp" +#include "FilterCompoundCondition.hpp" +#include "FilterCondition.hpp" +#include "FilterConditionState.hpp" +#include "FilterEmptyExpression.hpp" +#include "FilterExpression.hpp" +#include "FilterField.hpp" +#include "FilterParameter.hpp" +#include "FilterPredicate.hpp" +#include "FilterValue.hpp" #include "Log.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { static IContentFilterFactory::ReturnCode_t transform_enum( - std::shared_ptr & value, + std::shared_ptr & value, uint8_t type, const std::string & string_value) { @@ -62,19 +58,19 @@ static IContentFilterFactory::ReturnCode_t transform_enum( } static IContentFilterFactory::ReturnCode_t transform_enums( - std::shared_ptr & left_value, + std::shared_ptr & left_value, uint8_t left_type, - std::shared_ptr & right_value, + std::shared_ptr & right_value, uint8_t right_type) { - if ((DDSFilterValue::ValueKind::ENUM == left_value->kind) && - (DDSFilterValue::ValueKind::STRING == right_value->kind)) + if ((FilterValue::ValueKind::ENUM == left_value->kind) && + (FilterValue::ValueKind::STRING == right_value->kind)) { return transform_enum(right_value, left_type, right_value->string_value); } - if ((DDSFilterValue::ValueKind::ENUM == right_value->kind) && - (DDSFilterValue::ValueKind::STRING == left_value->kind)) + if ((FilterValue::ValueKind::ENUM == right_value->kind) && + (FilterValue::ValueKind::STRING == left_value->kind)) { return transform_enum(left_value, right_type, left_value->string_value); } @@ -83,81 +79,81 @@ static IContentFilterFactory::ReturnCode_t transform_enums( } static bool check_value_compatibility( - DDSFilterValue::ValueKind left, - DDSFilterValue::ValueKind right, + FilterValue::ValueKind left, + FilterValue::ValueKind right, bool ignore_enum) { - if (!ignore_enum && DDSFilterValue::ValueKind::ENUM == right) { - return DDSFilterValue::ValueKind::ENUM == left || - DDSFilterValue::ValueKind::SIGNED_INTEGER == left || - DDSFilterValue::ValueKind::UNSIGNED_INTEGER == left || - DDSFilterValue::ValueKind::STRING == left; + if (!ignore_enum && FilterValue::ValueKind::ENUM == right) { + return FilterValue::ValueKind::ENUM == left || + FilterValue::ValueKind::SIGNED_INTEGER == left || + FilterValue::ValueKind::UNSIGNED_INTEGER == left || + FilterValue::ValueKind::STRING == left; } switch (left) { - case DDSFilterValue::ValueKind::BOOLEAN: - return DDSFilterValue::ValueKind::BOOLEAN == right || - DDSFilterValue::ValueKind::SIGNED_INTEGER == right || - DDSFilterValue::ValueKind::UNSIGNED_INTEGER == right; - - case DDSFilterValue::ValueKind::SIGNED_INTEGER: - case DDSFilterValue::ValueKind::UNSIGNED_INTEGER: - return DDSFilterValue::ValueKind::SIGNED_INTEGER == right || - DDSFilterValue::ValueKind::UNSIGNED_INTEGER == right || - DDSFilterValue::ValueKind::BOOLEAN == right || - DDSFilterValue::ValueKind::FLOAT_CONST == right || - DDSFilterValue::ValueKind::FLOAT_FIELD == right || - DDSFilterValue::ValueKind::DOUBLE_FIELD == right || - DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD == right; - - case DDSFilterValue::ValueKind::CHAR: - case DDSFilterValue::ValueKind::STRING: - return DDSFilterValue::ValueKind::CHAR == right || - DDSFilterValue::ValueKind::STRING == right; - - case DDSFilterValue::ValueKind::FLOAT_CONST: - case DDSFilterValue::ValueKind::FLOAT_FIELD: - case DDSFilterValue::ValueKind::DOUBLE_FIELD: - case DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD: - return DDSFilterValue::ValueKind::FLOAT_CONST == right || - DDSFilterValue::ValueKind::FLOAT_FIELD == right || - DDSFilterValue::ValueKind::DOUBLE_FIELD == right || - DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD == right || - DDSFilterValue::ValueKind::SIGNED_INTEGER == right || - DDSFilterValue::ValueKind::UNSIGNED_INTEGER == right; - - case DDSFilterValue::ValueKind::ENUM: + case FilterValue::ValueKind::BOOLEAN: + return FilterValue::ValueKind::BOOLEAN == right || + FilterValue::ValueKind::SIGNED_INTEGER == right || + FilterValue::ValueKind::UNSIGNED_INTEGER == right; + + case FilterValue::ValueKind::SIGNED_INTEGER: + case FilterValue::ValueKind::UNSIGNED_INTEGER: + return FilterValue::ValueKind::SIGNED_INTEGER == right || + FilterValue::ValueKind::UNSIGNED_INTEGER == right || + FilterValue::ValueKind::BOOLEAN == right || + FilterValue::ValueKind::FLOAT_CONST == right || + FilterValue::ValueKind::FLOAT_FIELD == right || + FilterValue::ValueKind::DOUBLE_FIELD == right || + FilterValue::ValueKind::LONG_DOUBLE_FIELD == right; + + case FilterValue::ValueKind::CHAR: + case FilterValue::ValueKind::STRING: + return FilterValue::ValueKind::CHAR == right || + FilterValue::ValueKind::STRING == right; + + case FilterValue::ValueKind::FLOAT_CONST: + case FilterValue::ValueKind::FLOAT_FIELD: + case FilterValue::ValueKind::DOUBLE_FIELD: + case FilterValue::ValueKind::LONG_DOUBLE_FIELD: + return FilterValue::ValueKind::FLOAT_CONST == right || + FilterValue::ValueKind::FLOAT_FIELD == right || + FilterValue::ValueKind::DOUBLE_FIELD == right || + FilterValue::ValueKind::LONG_DOUBLE_FIELD == right || + FilterValue::ValueKind::SIGNED_INTEGER == right || + FilterValue::ValueKind::UNSIGNED_INTEGER == right; + + case FilterValue::ValueKind::ENUM: if (!ignore_enum) { - return DDSFilterValue::ValueKind::ENUM == right || - DDSFilterValue::ValueKind::SIGNED_INTEGER == right || - DDSFilterValue::ValueKind::UNSIGNED_INTEGER == right || - DDSFilterValue::ValueKind::STRING == right; + return FilterValue::ValueKind::ENUM == right || + FilterValue::ValueKind::SIGNED_INTEGER == right || + FilterValue::ValueKind::UNSIGNED_INTEGER == right || + FilterValue::ValueKind::STRING == right; } } return false; } -static DDSFilterPredicate::OperationKind get_predicate_op( +static FilterPredicate::OperationKind get_predicate_op( const parser::ParseNode & node) { - DDSFilterPredicate::OperationKind ret_val = DDSFilterPredicate::OperationKind::EQUAL; + FilterPredicate::OperationKind ret_val = FilterPredicate::OperationKind::EQUAL; if (node.is()) { - ret_val = DDSFilterPredicate::OperationKind::EQUAL; + ret_val = FilterPredicate::OperationKind::EQUAL; } else if (node.is()) { - ret_val = DDSFilterPredicate::OperationKind::NOT_EQUAL; + ret_val = FilterPredicate::OperationKind::NOT_EQUAL; } else if (node.is()) { - ret_val = DDSFilterPredicate::OperationKind::LESS_THAN; + ret_val = FilterPredicate::OperationKind::LESS_THAN; } else if (node.is()) { - ret_val = DDSFilterPredicate::OperationKind::LESS_EQUAL; + ret_val = FilterPredicate::OperationKind::LESS_EQUAL; } else if (node.is()) { - ret_val = DDSFilterPredicate::OperationKind::GREATER_THAN; + ret_val = FilterPredicate::OperationKind::GREATER_THAN; } else if (node.is()) { - ret_val = DDSFilterPredicate::OperationKind::GREATER_EQUAL; + ret_val = FilterPredicate::OperationKind::GREATER_EQUAL; } else if (node.is()) { - ret_val = DDSFilterPredicate::OperationKind::LIKE; + ret_val = FilterPredicate::OperationKind::LIKE; } else if (node.is()) { - ret_val = DDSFilterPredicate::OperationKind::MATCH; + ret_val = FilterPredicate::OperationKind::MATCH; } else { assert(false); } @@ -169,31 +165,31 @@ struct ExpressionParsingState { const void * type_object; const IContentFilterFactory::ParameterSeq & filter_parameters; - DDSFilterExpression * filter; + FilterExpression * filter; }; template<> -IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( +IContentFilterFactory::ReturnCode_t FilterFactory::convert_tree( ExpressionParsingState & state, - std::unique_ptr & condition, + std::unique_ptr & condition, const parser::ParseNode & node); template<> -IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( +IContentFilterFactory::ReturnCode_t FilterFactory::convert_tree( ExpressionParsingState & state, - std::shared_ptr & value, + std::shared_ptr & value, const parser::ParseNode & node) { if (node.value) { - value = std::make_shared(); + value = std::make_shared(); value->copy_from(*node.value.get(), true); } else if (0 != node.type_id) { std::string field_name = node.content(); auto it = state.filter->fields.find(field_name); if (it == state.filter->fields.end()) { value = state.filter->fields[field_name] = - std::make_shared(node.type_id, node.field_access_path, node.field_kind); + std::make_shared(node.type_id, node.field_access_path, node.field_kind); } else { value = it->second; } @@ -206,7 +202,7 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_treeparameters[node.parameter_index]) { value = state.filter->parameters[node.parameter_index]; } else { - auto param_value = std::make_shared(); + auto param_value = std::make_shared(); if (!param_value->set_value(state.filter_parameters[node.parameter_index].c_str())) { return ReturnCode_t::RETCODE_BAD_PARAMETER; } @@ -218,22 +214,22 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree -IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( +IContentFilterFactory::ReturnCode_t FilterFactory::convert_tree( ExpressionParsingState & state, - std::unique_ptr & condition, + std::unique_ptr & condition, const parser::ParseNode & node) { - std::shared_ptr left; - std::shared_ptr right; - ReturnCode_t ret = convert_tree(state, left, node.left()); + std::shared_ptr left; + std::shared_ptr right; + ReturnCode_t ret = convert_tree(state, left, node.left()); if (ReturnCode_t::RETCODE_OK == ret) { - ret = convert_tree(state, right, node.right()); + ret = convert_tree(state, right, node.right()); if (ReturnCode_t::RETCODE_OK == ret) { bool ignore_enum = false; if (node.is() || node.is()) { // At least one fieldname should be a string - if (!((node.left().is() && (DDSFilterValue::ValueKind::STRING == left->kind)) || - (node.right().is() && (DDSFilterValue::ValueKind::STRING == right->kind)))) + if (!((node.left().is() && (FilterValue::ValueKind::STRING == left->kind)) || + (node.right().is() && (FilterValue::ValueKind::STRING == right->kind)))) { return ReturnCode_t::RETCODE_BAD_PARAMETER; } @@ -241,8 +237,8 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_treekind) && - (DDSFilterValue::ValueKind::ENUM == right->kind)) + if ((FilterValue::ValueKind::ENUM == left->kind) && + (FilterValue::ValueKind::ENUM == right->kind)) { if (node.left().type_id != node.right().type_id) { return ReturnCode_t::RETCODE_BAD_PARAMETER; @@ -253,7 +249,7 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree -IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( +IContentFilterFactory::ReturnCode_t FilterFactory::convert_tree( ExpressionParsingState & state, - std::unique_ptr & condition, + std::unique_ptr & condition, const parser::ParseNode & node) { /* The nodes here will be in the following situation: @@ -276,18 +272,18 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( * op1 op2 */ - std::shared_ptr field; - ReturnCode_t ret = convert_tree(state, field, node.left()); + std::shared_ptr field; + ReturnCode_t ret = convert_tree(state, field, node.left()); if (ReturnCode_t::RETCODE_OK == ret) { const parser::ParseNode & and_node = node.right(); assert(and_node.is()); - std::shared_ptr op1; - std::shared_ptr op2; + std::shared_ptr op1; + std::shared_ptr op2; - ret = convert_tree(state, op1, and_node.left()); + ret = convert_tree(state, op1, and_node.left()); if (ReturnCode_t::RETCODE_OK == ret) { - ret = convert_tree(state, op2, and_node.right()); + ret = convert_tree(state, op2, and_node.right()); } if (ReturnCode_t::RETCODE_OK == ret) { @@ -305,17 +301,17 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( } if (ReturnCode_t::RETCODE_OK == ret) { - DDSFilterPredicate::OperationKind binary_op = node.is() ? - DDSFilterPredicate::OperationKind::LESS_EQUAL : - DDSFilterPredicate::OperationKind::GREATER_THAN; - DDSFilterCompoundCondition::OperationKind logical_op = node.is() ? - DDSFilterCompoundCondition::OperationKind::AND : - DDSFilterCompoundCondition::OperationKind::OR; - - std::unique_ptr left_cond(new DDSFilterPredicate(binary_op, op1, field)); - std::unique_ptr right_cond(new DDSFilterPredicate(binary_op, field, op2)); + FilterPredicate::OperationKind binary_op = node.is() ? + FilterPredicate::OperationKind::LESS_EQUAL : + FilterPredicate::OperationKind::GREATER_THAN; + FilterCompoundCondition::OperationKind logical_op = node.is() ? + FilterCompoundCondition::OperationKind::AND : + FilterCompoundCondition::OperationKind::OR; + + std::unique_ptr left_cond(new FilterPredicate(binary_op, op1, field)); + std::unique_ptr right_cond(new FilterPredicate(binary_op, field, op2)); auto cond = - new DDSFilterCompoundCondition( + new FilterCompoundCondition( logical_op, std::move(left_cond), std::move( right_cond)); condition.reset(cond); @@ -326,67 +322,67 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( } template<> -IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( +IContentFilterFactory::ReturnCode_t FilterFactory::convert_tree( ExpressionParsingState & state, - std::unique_ptr & condition, + std::unique_ptr & condition, const parser::ParseNode & node) { ReturnCode_t ret = ReturnCode_t::RETCODE_UNSUPPORTED; - DDSFilterCompoundCondition::OperationKind op = DDSFilterCompoundCondition::OperationKind::NOT; - std::unique_ptr left; - std::unique_ptr right; + FilterCompoundCondition::OperationKind op = FilterCompoundCondition::OperationKind::NOT; + std::unique_ptr left; + std::unique_ptr right; if (node.is()) { - op = DDSFilterCompoundCondition::OperationKind::NOT; - ret = convert_tree(state, left, node.left()); + op = FilterCompoundCondition::OperationKind::NOT; + ret = convert_tree(state, left, node.left()); } else if (node.is()) { - op = DDSFilterCompoundCondition::OperationKind::AND; - ret = convert_tree(state, left, node.left()); + op = FilterCompoundCondition::OperationKind::AND; + ret = convert_tree(state, left, node.left()); if (ReturnCode_t::RETCODE_OK == ret) { - ret = convert_tree(state, right, node.right()); + ret = convert_tree(state, right, node.right()); } } else if (node.is()) { - op = DDSFilterCompoundCondition::OperationKind::OR; - ret = convert_tree(state, left, node.left()); + op = FilterCompoundCondition::OperationKind::OR; + ret = convert_tree(state, left, node.left()); if (ReturnCode_t::RETCODE_OK == ret) { - ret = convert_tree(state, right, node.right()); + ret = convert_tree(state, right, node.right()); } } else { assert(false); } if (ReturnCode_t::RETCODE_OK == ret) { - condition.reset(new DDSFilterCompoundCondition(op, std::move(left), std::move(right))); + condition.reset(new FilterCompoundCondition(op, std::move(left), std::move(right))); } return ret; } template<> -IContentFilterFactory::ReturnCode_t DDSFilterFactory::convert_tree( +IContentFilterFactory::ReturnCode_t FilterFactory::convert_tree( ExpressionParsingState & state, - std::unique_ptr & condition, + std::unique_ptr & condition, const parser::ParseNode & node) { if (node.is() || node.is() || node.is()) { - return convert_tree(state, condition, node); + return convert_tree(state, condition, node); } else if (node.is() || node.is()) { return convert_tree(state, condition, node); } - return convert_tree(state, condition, node); + return convert_tree(state, condition, node); } -DDSFilterFactory::~DDSFilterFactory() +FilterFactory::~FilterFactory() { auto & pool = expression_pool_.collection(); - for (DDSFilterExpression * item : pool) { + for (FilterExpression * item : pool) { delete item; } pool.clear(); } -IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( +IContentFilterFactory::ReturnCode_t FilterFactory::create_content_filter( const rosidl_message_type_support_t * type_support, const char * filter_expression, const IContentFilterFactory::ParameterSeq & filter_parameters, @@ -401,12 +397,12 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( } else { ret = ReturnCode_t::RETCODE_OK; if (&empty_expression_ != filter_instance) { - auto expr = static_cast(filter_instance); + auto expr = static_cast(filter_instance); auto n_params = expr->parameters.size(); if (filter_parameters.size() < n_params) { ret = ReturnCode_t::RETCODE_BAD_PARAMETER; } else { - std::vector old_values(n_params); + std::vector old_values(n_params); size_t n = n_params; while ((n > 0) && (ReturnCode_t::RETCODE_OK == ret)) { --n; @@ -434,14 +430,14 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( } else { auto node = parser::parse_filter_expression(filter_expression, type_support); if (node) { - DDSFilterExpression * expr = get_expression(); + FilterExpression * expr = get_expression(); size_t n_params = filter_parameters.size(); expr->parameters.reserve(n_params); while (expr->parameters.size() < n_params) { expr->parameters.emplace_back(); } ExpressionParsingState state{nullptr, filter_parameters, expr}; - ret = convert_tree(state, expr->root, *(node->children[0])); + ret = convert_tree(state, expr->root, *(node->children[0])); if (ReturnCode_t::RETCODE_OK == ret) { delete_content_filter(filter_instance); filter_instance = expr; @@ -456,7 +452,7 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::create_content_filter( return ret; } -IContentFilterFactory::ReturnCode_t DDSFilterFactory::delete_content_filter( +IContentFilterFactory::ReturnCode_t FilterFactory::delete_content_filter( IContentFilter * filter_instance) { if (nullptr == filter_instance) { @@ -464,14 +460,12 @@ IContentFilterFactory::ReturnCode_t DDSFilterFactory::delete_content_filter( } if (&empty_expression_ != filter_instance) { - auto expr = static_cast(filter_instance); + auto expr = static_cast(filter_instance); expr->clear(); expression_pool_.put(expr); } return ReturnCode_t::RETCODE_OK; } -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter diff --git a/common_content_filter/src/DDSFilterFactory.hpp b/common_content_filter/src/FilterFactory.hpp similarity index 61% rename from common_content_filter/src/DDSFilterFactory.hpp rename to common_content_filter/src/FilterFactory.hpp index 992aa46..e08a171 100644 --- a/common_content_filter/src/DDSFilterFactory.hpp +++ b/common_content_filter/src/FilterFactory.hpp @@ -13,37 +13,33 @@ // limitations under the License. /** - * @file DDSFilterFactory.hpp + * @file FilterFactory.hpp */ -#ifndef COMMON_CONTENT_FILTER__DDSFILTERFACTORY_HPP_ -#define COMMON_CONTENT_FILTER__DDSFILTERFACTORY_HPP_ +#ifndef COMMON_CONTENT_FILTER__FILTERFACTORY_HPP_ +#define COMMON_CONTENT_FILTER__FILTERFACTORY_HPP_ #include "IContentFilterFactory.hpp" #include "IContentFilter.hpp" -#include "DDSFilterEmptyExpression.hpp" -#include "DDSFilterExpression.hpp" +#include "FilterEmptyExpression.hpp" +#include "FilterExpression.hpp" #include "ObjectPool.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { /** - * An IContentFilterFactory that processes DDS-SQL filter expressions. + * An IContentFilterFactory that processes -SQL filter expressions. */ -class DDSFilterFactory final : public IContentFilterFactory +class FilterFactory final : public IContentFilterFactory { public: - ~DDSFilterFactory(); + ~FilterFactory(); ReturnCode_t create_content_filter( const rosidl_message_type_support_t * type_support, @@ -56,23 +52,23 @@ class DDSFilterFactory final : public IContentFilterFactory private: /** - * Retrieve a DDSFilterExpression from the pool. + * Retrieve a FilterExpression from the pool. * - * @return A pointer to an empty DDSFilterExpression. + * @return A pointer to an empty FilterExpression. */ - DDSFilterExpression * get_expression() + FilterExpression * get_expression() { return expression_pool_.get( [] { - return new DDSFilterExpression(); + return new FilterExpression(); }); } /** - * Generic method to perform processing of an AST node resulting from the parsing of a DDS-SQL filter expression. + * Generic method to perform processing of an AST node resulting from the parsing of a -SQL filter expression. * Provides a generic mechanism for methods that perform post-processing of the generated AST tree, so they could - * have access to the private fields of DDSFilterFactory. + * have access to the private fields of FilterFactory. * * @return return code indicating the conversion result. */ @@ -83,15 +79,13 @@ class DDSFilterFactory final : public IContentFilterFactory const _ParserNode & node); /// Empty expressions content filter - DDSFilterEmptyExpression empty_expression_; - /// Pool of DDSFilterExpression objects - ObjectPool expression_pool_; + FilterEmptyExpression empty_expression_; + /// Pool of FilterExpression objects + ObjectPool expression_pool_; }; -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__DDSFILTERFACTORY_HPP_ +#endif // COMMON_CONTENT_FILTER__FILTERFACTORY_HPP_ diff --git a/common_content_filter/src/DDSFilterField.cpp b/common_content_filter/src/FilterField.cpp similarity index 92% rename from common_content_filter/src/DDSFilterField.cpp rename to common_content_filter/src/FilterField.cpp index dba8d17..f94afcb 100644 --- a/common_content_filter/src/DDSFilterField.cpp +++ b/common_content_filter/src/FilterField.cpp @@ -13,10 +13,10 @@ // limitations under the License. /** - * @file DDSFilterField.cpp + * @file FilterField.cpp */ -#include "DDSFilterField.hpp" +#include "FilterField.hpp" #include #include @@ -29,23 +29,19 @@ #include #include -#include "DDSFilterPredicate.hpp" -#include "DDSFilterValue.hpp" +#include "FilterPredicate.hpp" +#include "FilterValue.hpp" #include "Log.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { template bool -DDSFilterField::get_msg_data_address( +FilterField::get_msg_data_address( const void * untype_members, FieldAccessor & accessor, const void * & data) @@ -78,7 +74,7 @@ DDSFilterField::get_msg_data_address( return true; } -bool DDSFilterField::set_value( +bool FilterField::set_value( const void * data, size_t n) { @@ -109,7 +105,7 @@ bool DDSFilterField::set_value( value_has_changed(); // Inform parent predicates - for (DDSFilterPredicate * parent : parents_) { + for (FilterPredicate * parent : parents_) { parent->value_has_changed(); } } else { @@ -120,7 +116,7 @@ bool DDSFilterField::set_value( return ret; } -bool DDSFilterField::set_member( +bool FilterField::set_member( const void * data, bool is_c_type_support) { @@ -201,7 +197,5 @@ bool DDSFilterField::set_member( return ret; } -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter diff --git a/common_content_filter/src/DDSFilterField.hpp b/common_content_filter/src/FilterField.hpp similarity index 74% rename from common_content_filter/src/DDSFilterField.hpp rename to common_content_filter/src/FilterField.hpp index ed0be99..80e4d17 100644 --- a/common_content_filter/src/DDSFilterField.hpp +++ b/common_content_filter/src/FilterField.hpp @@ -13,11 +13,11 @@ // limitations under the License. /** - * @file DDSFilterField.hpp + * @file FilterField.hpp */ -#ifndef COMMON_CONTENT_FILTER__DDSFILTERFIELD_HPP_ -#define COMMON_CONTENT_FILTER__DDSFILTERFIELD_HPP_ +#ifndef COMMON_CONTENT_FILTER__FILTERFIELD_HPP_ +#define COMMON_CONTENT_FILTER__FILTERFIELD_HPP_ #include #include @@ -25,22 +25,18 @@ #include -#include "DDSFilterPredicate.hpp" -#include "DDSFilterValue.hpp" +#include "FilterPredicate.hpp" +#include "FilterValue.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { /** - * A DDSFilterValue for fieldname-based expression values. + * A FilterValue for fieldname-based expression values. */ -class DDSFilterField final : public DDSFilterValue +class FilterField final : public FilterValue { public: @@ -60,28 +56,28 @@ class DDSFilterField final : public DDSFilterValue }; /** - * Construct a DDSFilterField. + * Construct a FilterField. * * @param[in] type_id TypeIdentifier representing the primitive data type of the fieldname. * @param[in] access_path Access path to the field. * @param[in] data_kind Kind of data the field represents. */ - DDSFilterField( + FilterField( uint8_t type_id, const std::vector & access_path, ValueKind data_kind) - : DDSFilterValue(data_kind) + : FilterValue(data_kind) , access_path_(access_path) , type_id_(type_id) { } - virtual ~DDSFilterField() = default; + virtual ~FilterField() = default; /** - * This method is used by a DDSFilterPredicate to check if this DDSFilterField can be used. + * This method is used by a FilterPredicate to check if this FilterField can be used. * - * @return whether this DDSFilterField has a value that can be used on a predicate. + * @return whether this FilterField has a value that can be used on a predicate. */ inline bool has_value() const noexcept final { @@ -98,8 +94,8 @@ class DDSFilterField final : public DDSFilterValue /** - * Perform the deserialization of the field represented by this DDSFilterField. - * Will notify the predicates where this DDSFilterField is being used. + * Perform the deserialization of the field represented by this FilterField. + * Will notify the predicates where this FilterField is being used. * * @param[in] data The dynamic representation of the payload being filtered. * @@ -129,7 +125,7 @@ class DDSFilterField final : public DDSFilterValue protected: inline void add_parent( - DDSFilterPredicate * parent) final + FilterPredicate * parent) final { assert(nullptr != parent); parents_.emplace(parent); @@ -150,12 +146,10 @@ class DDSFilterField final : public DDSFilterValue bool has_value_ = false; std::vector access_path_; uint8_t type_id_ = 0; - std::unordered_set parents_; + std::unordered_set parents_; }; -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__DDSFILTERFIELD_HPP_ +#endif // COMMON_CONTENT_FILTER__FILTERFIELD_HPP_ diff --git a/common_content_filter/src/DDSFilterGrammar.hpp b/common_content_filter/src/FilterGrammar.hpp similarity index 89% rename from common_content_filter/src/DDSFilterGrammar.hpp rename to common_content_filter/src/FilterGrammar.hpp index 8f2ab16..b5c4e65 100644 --- a/common_content_filter/src/DDSFilterGrammar.hpp +++ b/common_content_filter/src/FilterGrammar.hpp @@ -13,21 +13,17 @@ // limitations under the License. /** - * @file DDSFilterGrammar.hpp + * @file FilterGrammar.hpp */ -#ifndef COMMON_CONTENT_FILTER__DDSFILTERGRAMMAR_HPP_ -#define COMMON_CONTENT_FILTER__DDSFILTERGRAMMAR_HPP_ +#ifndef COMMON_CONTENT_FILTER__FILTERGRAMMAR_HPP_ +#define COMMON_CONTENT_FILTER__FILTERGRAMMAR_HPP_ #include -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { using namespace tao::TAO_PEGTL_NAMESPACE; @@ -102,7 +98,7 @@ struct Predicate : sor< ComparisonPredicate, BetweenPredicate > {}; struct open_bracket : seq< one< '(' >, star< space > > {}; struct close_bracket : seq< star< space >, one< ')' > > {}; -// Condition, FilterExpression +// Condition, ConditionList struct Condition; struct ConditionList : list_must< Condition, sor< and_op, or_op > > {}; struct Condition : sor< @@ -110,17 +106,14 @@ struct Condition : sor< seq< not_op, ConditionList >, Predicate > {}; -struct FilterExpression : ConditionList {}; // Main grammar -struct FilterExpressionGrammar : must< FilterExpression, tao::TAO_PEGTL_NAMESPACE::eof > {}; +struct FilterExpressionGrammar : must< ConditionList, tao::TAO_PEGTL_NAMESPACE::eof > {}; struct LiteralGrammar : must< Literal, tao::TAO_PEGTL_NAMESPACE::eof > {}; // *INDENT-ON* -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__DDSFILTERGRAMMAR_HPP_ +#endif // COMMON_CONTENT_FILTER__FILTERGRAMMAR_HPP_ diff --git a/common_content_filter/src/DDSFilterParameter.cpp b/common_content_filter/src/FilterParameter.cpp similarity index 68% rename from common_content_filter/src/DDSFilterParameter.cpp rename to common_content_filter/src/FilterParameter.cpp index 7627e42..a47cd5e 100644 --- a/common_content_filter/src/DDSFilterParameter.cpp +++ b/common_content_filter/src/FilterParameter.cpp @@ -13,30 +13,26 @@ // limitations under the License. /** - * @file DDSFilterParameter.cpp + * @file FilterParameter.cpp */ -#include "DDSFilterParameter.hpp" +#include "FilterParameter.hpp" -#include "DDSFilterExpressionParser.hpp" +#include "FilterExpressionParser.hpp" #include "Log.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { -bool DDSFilterParameter::set_value( +bool FilterParameter::set_value( const char * parameter) { auto node = parser::parse_literal_value(parameter); if (!node) { - logError(DDSSQLFILTER, "PARSE ERROR: parser::parse_literal_value"); + logError(SQLFILTER, "PARSE ERROR: parser::parse_literal_value"); return false; } @@ -47,7 +43,5 @@ bool DDSFilterParameter::set_value( return true; } -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter diff --git a/common_content_filter/src/DDSFilterParameter.hpp b/common_content_filter/src/FilterParameter.hpp similarity index 57% rename from common_content_filter/src/DDSFilterParameter.hpp rename to common_content_filter/src/FilterParameter.hpp index 4f674f8..7fb6ef3 100644 --- a/common_content_filter/src/DDSFilterParameter.hpp +++ b/common_content_filter/src/FilterParameter.hpp @@ -13,34 +13,30 @@ // limitations under the License. /** - * @file DDSFilterParameter.hpp + * @file FilterParameter.hpp */ -#ifndef COMMON_CONTENT_FILTER__DDSFILTERPARAMETER_HPP_ -#define COMMON_CONTENT_FILTER__DDSFILTERPARAMETER_HPP_ +#ifndef COMMON_CONTENT_FILTER__FILTERPARAMETER_HPP_ +#define COMMON_CONTENT_FILTER__FILTERPARAMETER_HPP_ -#include "DDSFilterValue.hpp" +#include "FilterValue.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { /** - * A DDSFilterValue for expression parameters (i.e. %nn). + * A FilterValue for expression parameters (i.e. %nn). */ -class DDSFilterParameter final : public DDSFilterValue +class FilterParameter final : public FilterValue { public: - virtual ~DDSFilterParameter() = default; + virtual ~FilterParameter() = default; /** - * Sets the value of this DDSFilterParameter given from an input string. + * Sets the value of this FilterParameter given from an input string. * * @param[in] parameter The string from which to set the value. * @@ -50,9 +46,7 @@ class DDSFilterParameter final : public DDSFilterValue const char * parameter); }; -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__DDSFILTERPARAMETER_HPP_ +#endif // COMMON_CONTENT_FILTER__FILTERPARAMETER_HPP_ diff --git a/common_content_filter/src/DDSFilterParseNode.hpp b/common_content_filter/src/FilterParseNode.hpp similarity index 68% rename from common_content_filter/src/DDSFilterParseNode.hpp rename to common_content_filter/src/FilterParseNode.hpp index 7f8ee59..a3f5e20 100644 --- a/common_content_filter/src/DDSFilterParseNode.hpp +++ b/common_content_filter/src/FilterParseNode.hpp @@ -13,27 +13,23 @@ // limitations under the License. /** - * @file DDSFilterParseNode.hpp + * @file FilterParseNode.hpp */ -#ifndef COMMON_CONTENT_FILTER__DDSFILTERPARSENODE_HPP_ -#define COMMON_CONTENT_FILTER__DDSFILTERPARSENODE_HPP_ +#ifndef COMMON_CONTENT_FILTER__FILTERPARSENODE_HPP_ +#define COMMON_CONTENT_FILTER__FILTERPARSENODE_HPP_ #include #include #include -#include "DDSFilterField.hpp" -#include "DDSFilterValue.hpp" +#include "FilterField.hpp" +#include "FilterValue.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { namespace parser { @@ -43,11 +39,11 @@ using namespace tao::TAO_PEGTL_NAMESPACE; struct ParseNode : parse_tree::basic_node { // When the node is a literal value, it will hold a pointer to it - std::unique_ptr value; + std::unique_ptr value; // When the node is a fieldname, it will hold the access path to the field, the data kind, and the type id - std::vector field_access_path; - DDSFilterValue::ValueKind field_kind = DDSFilterValue::ValueKind::STRING; + std::vector field_access_path; + FilterValue::ValueKind field_kind = FilterValue::ValueKind::STRING; // ros2 primitive type id uint8_t type_id = 0; @@ -67,9 +63,7 @@ struct ParseNode : parse_tree::basic_node }; } // namespace parser -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__DDSFILTERPARSENODE_HPP_ +#endif // COMMON_CONTENT_FILTER__FILTERPARSENODE_HPP_ diff --git a/common_content_filter/src/DDSFilterPredicate.cpp b/common_content_filter/src/FilterPredicate.cpp similarity index 78% rename from common_content_filter/src/DDSFilterPredicate.cpp rename to common_content_filter/src/FilterPredicate.cpp index 83b52d7..2870594 100644 --- a/common_content_filter/src/DDSFilterPredicate.cpp +++ b/common_content_filter/src/FilterPredicate.cpp @@ -13,29 +13,25 @@ // limitations under the License. /** - * @file DDSFilterPredicate.cpp + * @file FilterPredicate.cpp */ -#include "DDSFilterPredicate.hpp" +#include "FilterPredicate.hpp" #include #include -#include "DDSFilterValue.hpp" +#include "FilterValue.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { -DDSFilterPredicate::DDSFilterPredicate( +FilterPredicate::FilterPredicate( OperationKind op, - const std::shared_ptr & left, - const std::shared_ptr & right) + const std::shared_ptr & left, + const std::shared_ptr & right) : op_(op) , left_(left) , right_(right) @@ -53,7 +49,7 @@ DDSFilterPredicate::DDSFilterPredicate( } } -void DDSFilterPredicate::value_has_changed() +void FilterPredicate::value_has_changed() { if (left_->has_value() && right_->has_value()) { switch (op_) { @@ -92,13 +88,11 @@ void DDSFilterPredicate::value_has_changed() } } -void DDSFilterPredicate::propagate_reset() noexcept +void FilterPredicate::propagate_reset() noexcept { left_->reset(); right_->reset(); } -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter diff --git a/common_content_filter/src/DDSFilterPredicate.hpp b/common_content_filter/src/FilterPredicate.hpp similarity index 62% rename from common_content_filter/src/DDSFilterPredicate.hpp rename to common_content_filter/src/FilterPredicate.hpp index 0fdfb9c..3b6af1f 100644 --- a/common_content_filter/src/DDSFilterPredicate.hpp +++ b/common_content_filter/src/FilterPredicate.hpp @@ -13,30 +13,26 @@ // limitations under the License. /** - * @file DDSFilterPredicate.hpp + * @file FilterPredicate.hpp */ -#ifndef COMMON_CONTENT_FILTER__DDSFILTERPREDICATE_HPP_ -#define COMMON_CONTENT_FILTER__DDSFILTERPREDICATE_HPP_ +#ifndef COMMON_CONTENT_FILTER__FILTERPREDICATE_HPP_ +#define COMMON_CONTENT_FILTER__FILTERPREDICATE_HPP_ #include -#include "DDSFilterCondition.hpp" -#include "DDSFilterValue.hpp" +#include "FilterCondition.hpp" +#include "FilterValue.hpp" -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { /** - * A DDSFilterCondition for binary predicates (i.e. ). + * A FilterCondition for binary predicates (i.e. ). */ -class DDSFilterPredicate final : public DDSFilterCondition +class FilterPredicate final : public FilterCondition { public: @@ -56,18 +52,18 @@ class DDSFilterPredicate final : public DDSFilterCondition }; /** - * Construct a DDSFilterPredicate. + * Construct a FilterPredicate. * * @param[in] op Operation to perform. * @param[in] left Left operand. * @param[in] right Right operand. */ - DDSFilterPredicate( + FilterPredicate( OperationKind op, - const std::shared_ptr & left, - const std::shared_ptr & right); + const std::shared_ptr & left, + const std::shared_ptr & right); - virtual ~DDSFilterPredicate() = default; + virtual ~FilterPredicate() = default; /** * Called when the value of an operand is changed. @@ -78,21 +74,19 @@ class DDSFilterPredicate final : public DDSFilterCondition void propagate_reset() noexcept final; void child_has_changed( - const DDSFilterCondition & child) noexcept final + const FilterCondition & child) noexcept final { static_cast(child); } private: OperationKind op_; - std::shared_ptr left_; - std::shared_ptr right_; + std::shared_ptr left_; + std::shared_ptr right_; }; -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__DDSFILTERPREDICATE_HPP_ +#endif // COMMON_CONTENT_FILTER__FILTERPREDICATE_HPP_ diff --git a/common_content_filter/src/DDSFilterValue.cpp b/common_content_filter/src/FilterValue.cpp similarity index 82% rename from common_content_filter/src/DDSFilterValue.cpp rename to common_content_filter/src/FilterValue.cpp index bc342a2..11b1a58 100644 --- a/common_content_filter/src/DDSFilterValue.cpp +++ b/common_content_filter/src/FilterValue.cpp @@ -13,23 +13,19 @@ // limitations under the License. /** - * @file DDSFilterValue.cpp + * @file FilterValue.cpp */ -#include "DDSFilterValue.hpp" +#include "FilterValue.hpp" #include #include #include #include -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { template @@ -46,14 +42,14 @@ int compare_values( * Only used during promotion to UNSIGNED_INTEGER. */ static bool is_negative( - const DDSFilterValue & value) + const FilterValue & value) { switch (value.kind) { - case DDSFilterValue::ValueKind::BOOLEAN: + case FilterValue::ValueKind::BOOLEAN: return false; - case DDSFilterValue::ValueKind::ENUM: - case DDSFilterValue::ValueKind::SIGNED_INTEGER: + case FilterValue::ValueKind::ENUM: + case FilterValue::ValueKind::SIGNED_INTEGER: return value.signed_integer_value < 0; // The rest of the types shall never be promoted to UNSIGNED_INTEGER @@ -68,13 +64,13 @@ static bool is_negative( * Performs promotion to SIGNED_INTEGER */ static int64_t to_signed_integer( - const DDSFilterValue & value) + const FilterValue & value) { switch (value.kind) { - case DDSFilterValue::ValueKind::BOOLEAN: + case FilterValue::ValueKind::BOOLEAN: return value.boolean_value ? 1 : 0; - case DDSFilterValue::ValueKind::ENUM: + case FilterValue::ValueKind::ENUM: return value.signed_integer_value; // The rest of the types shall never be promoted to SIGNED_INTEGER @@ -89,14 +85,14 @@ static int64_t to_signed_integer( * Performs promotion to UNSIGNED_INTEGER */ static uint64_t to_unsigned_integer( - const DDSFilterValue & value) + const FilterValue & value) { switch (value.kind) { - case DDSFilterValue::ValueKind::BOOLEAN: + case FilterValue::ValueKind::BOOLEAN: return value.boolean_value ? 1 : 0; - case DDSFilterValue::ValueKind::ENUM: - case DDSFilterValue::ValueKind::SIGNED_INTEGER: + case FilterValue::ValueKind::ENUM: + case FilterValue::ValueKind::SIGNED_INTEGER: return static_cast(value.signed_integer_value); // The rest of the types shall never be promoted to UNSIGNED_INTEGER @@ -111,20 +107,20 @@ static uint64_t to_unsigned_integer( * Performs promotion to FLOAT */ static long double to_float( - const DDSFilterValue & value) + const FilterValue & value) { switch (value.kind) { - case DDSFilterValue::ValueKind::ENUM: - case DDSFilterValue::ValueKind::SIGNED_INTEGER: + case FilterValue::ValueKind::ENUM: + case FilterValue::ValueKind::SIGNED_INTEGER: return static_cast(value.signed_integer_value); - case DDSFilterValue::ValueKind::UNSIGNED_INTEGER: + case FilterValue::ValueKind::UNSIGNED_INTEGER: return static_cast(value.unsigned_integer_value); - case DDSFilterValue::ValueKind::FLOAT_CONST: - case DDSFilterValue::ValueKind::FLOAT_FIELD: - case DDSFilterValue::ValueKind::DOUBLE_FIELD: - case DDSFilterValue::ValueKind::LONG_DOUBLE_FIELD: + case FilterValue::ValueKind::FLOAT_CONST: + case FilterValue::ValueKind::FLOAT_FIELD: + case FilterValue::ValueKind::DOUBLE_FIELD: + case FilterValue::ValueKind::LONG_DOUBLE_FIELD: return value.float_value; // The rest of the types shall never be promoted to FLOAT @@ -139,15 +135,15 @@ static long double to_float( * Performs promotion to STRING */ static void to_string_value( - const DDSFilterValue & in, + const FilterValue & in, std::string & out) { - assert(DDSFilterValue::ValueKind::CHAR == in.kind); + assert(FilterValue::ValueKind::CHAR == in.kind); out.assign(&in.char_value, 1); } -void DDSFilterValue::copy_from( - const DDSFilterValue & other, +void FilterValue::copy_from( + const FilterValue & other, bool copy_regular_expression) noexcept { kind = other.kind; @@ -192,9 +188,9 @@ void DDSFilterValue::copy_from( } } -int DDSFilterValue::compare( - const DDSFilterValue & lhs, - const DDSFilterValue & rhs) noexcept +int FilterValue::compare( + const FilterValue & lhs, + const FilterValue & rhs) noexcept { if (lhs.kind == rhs.kind) { switch (lhs.kind) { @@ -237,7 +233,7 @@ int DDSFilterValue::compare( return -compare(rhs, lhs); } else { /* Type promotion rules are enforced during the construction of the expression tree on - * DDSFilterFactory. For the types on which promotion is supported, a corresponding to_xxx method exists + * FilterFactory. For the types on which promotion is supported, a corresponding to_xxx method exists * that will assert if an invalid promotion is performed. */ switch (lhs.kind) { @@ -285,7 +281,7 @@ int DDSFilterValue::compare( return 0; } -void DDSFilterValue::as_regular_expression( +void FilterValue::as_regular_expression( bool is_like_operand) { regular_expr_kind_ = is_like_operand ? RegExpKind::LIKE : RegExpKind::MATCH; @@ -294,7 +290,7 @@ void DDSFilterValue::as_regular_expression( } } -void DDSFilterValue::value_has_changed() +void FilterValue::value_has_changed() { if (RegExpKind::NONE != regular_expr_kind_) { std::string expr; @@ -323,8 +319,8 @@ void DDSFilterValue::value_has_changed() } } -bool DDSFilterValue::is_like( - const DDSFilterValue & other) const noexcept +bool FilterValue::is_like( + const FilterValue & other) const noexcept { assert(other.regular_expr_); @@ -354,7 +350,5 @@ bool DDSFilterValue::is_like( return false; } -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter diff --git a/common_content_filter/src/DDSFilterValue.hpp b/common_content_filter/src/FilterValue.hpp similarity index 66% rename from common_content_filter/src/DDSFilterValue.hpp rename to common_content_filter/src/FilterValue.hpp index 5ab42ac..930bdcd 100644 --- a/common_content_filter/src/DDSFilterValue.hpp +++ b/common_content_filter/src/FilterValue.hpp @@ -13,38 +13,34 @@ // limitations under the License. /** - * @file DDSFilterValue.hpp + * @file FilterValue.hpp */ -#ifndef COMMON_CONTENT_FILTER__DDSFILTERVALUE_HPP_ -#define COMMON_CONTENT_FILTER__DDSFILTERVALUE_HPP_ +#ifndef COMMON_CONTENT_FILTER__FILTERVALUE_HPP_ +#define COMMON_CONTENT_FILTER__FILTERVALUE_HPP_ #include #include -namespace eprosima_common +namespace common_content_filter { -namespace fastdds -{ -namespace dds -{ -namespace DDSSQLFilter +namespace SQLFilter { -class DDSFilterPredicate; +class FilterPredicate; /** * Represents a value (either constant, parameter or fieldname) on a filter expression. */ -class DDSFilterValue +class FilterValue { public: - // DDSFilterPredicate needs to call protected method add_parent - friend class DDSFilterPredicate; + // FilterPredicate needs to call protected method add_parent + friend class FilterPredicate; /** - * The high-level kind of a DDSFilterValue. + * The high-level kind of a FilterValue. * Please note that the constants here should follow the promotion order. */ enum class ValueKind @@ -61,7 +57,7 @@ class DDSFilterValue STRING ///< Value is a string }; - /// The kind of value held by this DDSFilterValue + /// The kind of value held by this FilterValue ValueKind kind; union { @@ -75,9 +71,9 @@ class DDSFilterValue /** * Default constructor. - * Constructs an empty string DDSFilterValue + * Constructs an empty string FilterValue */ - DDSFilterValue() noexcept + FilterValue() noexcept : kind(ValueKind::STRING) , string_value() { @@ -85,11 +81,11 @@ class DDSFilterValue /** * Explicit kind constructor. - * Constructs a zero-valued, specific kind DDSFilterValue. + * Constructs a zero-valued, specific kind FilterValue. * - * @param[in] kind The kind with which to construct the DDSFilterValue. + * @param[in] kind The kind with which to construct the FilterValue. */ - explicit DDSFilterValue( + explicit FilterValue( ValueKind data_kind) noexcept : kind(data_kind) , string_value() @@ -97,30 +93,30 @@ class DDSFilterValue } // *INDENT-OFF* - DDSFilterValue(const DDSFilterValue&) = delete; - DDSFilterValue& operator=(const DDSFilterValue&) = delete; - DDSFilterValue(DDSFilterValue&&) = default; - DDSFilterValue& operator=(DDSFilterValue&&) = default; + FilterValue(const FilterValue&) = delete; + FilterValue& operator=(const FilterValue&) = delete; + FilterValue(FilterValue&&) = default; + FilterValue& operator=(FilterValue&&) = default; // *INDENT-ON* - virtual ~DDSFilterValue() = default; + virtual ~FilterValue() = default; /** * Copy the state of this object from another one. * - * @param [in] other The DDSFilterValue from where to copy the state. + * @param [in] other The FilterValue from where to copy the state. * @param [in] copy_regular_expression Whether the regular expression state should be copied or not */ void copy_from( - const DDSFilterValue & other, + const FilterValue & other, bool copy_regular_expression) noexcept; /** - * This method is used by a DDSFilterPredicate to check if this DDSFilterValue can be used. + * This method is used by a FilterPredicate to check if this FilterValue can be used. * Constants and parameters will always have a value, but fieldname-based values can only be * used after deserialization. * - * @return whether this DDSFilterValue has a value that can be used on a predicate. + * @return whether this FilterValue has a value that can be used on a predicate. */ virtual bool has_value() const noexcept { @@ -146,64 +142,64 @@ class DDSFilterValue /** * @name Comparison operations * Methods implementing the comparison operators of binary predicates. - * Should only be called against a DDSFilterValue of a compatible kind, + * Should only be called against a FilterValue of a compatible kind, * according to the type promotion restrictions. */ ///@{ inline bool operator==( - const DDSFilterValue & other) const noexcept + const FilterValue & other) const noexcept { return compare(*this, other) == 0; } inline bool operator!=( - const DDSFilterValue & other) const noexcept + const FilterValue & other) const noexcept { return compare(*this, other) != 0; } inline bool operator<( - const DDSFilterValue & other) const noexcept + const FilterValue & other) const noexcept { return compare(*this, other) < 0; } inline bool operator<=( - const DDSFilterValue & other) const noexcept + const FilterValue & other) const noexcept { return compare(*this, other) <= 0; } inline bool operator>( - const DDSFilterValue & other) const noexcept + const FilterValue & other) const noexcept { return compare(*this, other) > 0; } inline bool operator>=( - const DDSFilterValue & other) const noexcept + const FilterValue & other) const noexcept { return compare(*this, other) >= 0; } bool is_like( - const DDSFilterValue & other) const noexcept; + const FilterValue & other) const noexcept; ///@} protected: /** - * Called when this DDSFilterValue is used on a DDSFilterPredicate. + * Called when this FilterValue is used on a FilterPredicate. * - * @param parent [in] The DDSFilterPredicate referencing this DDSFilterValue. + * @param parent [in] The FilterPredicate referencing this FilterValue. */ virtual void add_parent( - DDSFilterPredicate * parent) + FilterPredicate * parent) { static_cast(parent); } /** - * Called when the value of this DDSFilterValue has changed. + * Called when the value of this FilterValue has changed. * Will regenerate the regular expression object if as_regular_expression was called. */ void value_has_changed(); @@ -218,14 +214,12 @@ class DDSFilterValue std::unique_ptr regular_expr_; static int compare( - const DDSFilterValue & lhs, - const DDSFilterValue & rhs) noexcept; + const FilterValue & lhs, + const FilterValue & rhs) noexcept; }; -} // namespace DDSSQLFilter -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace SQLFilter +} // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__DDSFILTERVALUE_HPP_ +#endif // COMMON_CONTENT_FILTER__FILTERVALUE_HPP_ diff --git a/common_content_filter/src/IContentFilter.hpp b/common_content_filter/src/IContentFilter.hpp index 3a7882c..29fd9fa 100644 --- a/common_content_filter/src/IContentFilter.hpp +++ b/common_content_filter/src/IContentFilter.hpp @@ -20,11 +20,7 @@ #define COMMON_CONTENT_FILTER__ICONTENTFILTER_HPP_ -namespace eprosima_common -{ -namespace fastdds -{ -namespace dds +namespace common_content_filter { /** @@ -43,8 +39,6 @@ struct IContentFilter const void * payload) const = 0; }; -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace common_content_filter #endif // COMMON_CONTENT_FILTER__ICONTENTFILTER_HPP_ diff --git a/common_content_filter/src/IContentFilterFactory.hpp b/common_content_filter/src/IContentFilterFactory.hpp index cece093..b1cb5a4 100644 --- a/common_content_filter/src/IContentFilterFactory.hpp +++ b/common_content_filter/src/IContentFilterFactory.hpp @@ -27,11 +27,7 @@ #include "IContentFilter.hpp" -namespace eprosima_common -{ -namespace fastdds -{ -namespace dds +namespace common_content_filter { /** @@ -89,8 +85,6 @@ struct IContentFilterFactory IContentFilter * filter_instance) = 0; }; -} // namespace dds -} // namespace fastdds -} // namespace eprosima_common +} // namespace common_content_filter #endif // COMMON_CONTENT_FILTER__ICONTENTFILTERFACTORY_HPP_ diff --git a/common_content_filter/src/ObjectPool.hpp b/common_content_filter/src/ObjectPool.hpp index 115621a..670e9b0 100644 --- a/common_content_filter/src/ObjectPool.hpp +++ b/common_content_filter/src/ObjectPool.hpp @@ -24,9 +24,7 @@ #include #include -namespace eprosima_common -{ -namespace fastdds +namespace common_content_filter { /** @@ -94,7 +92,6 @@ struct ObjectPool final }; -} // namespace fastdds -} // namespace eprosima_common +} // namespace common_content_filter #endif // COMMON_CONTENT_FILTER_OBJECTPOOL_HPP_ diff --git a/common_content_filter/src/Utilities.cpp b/common_content_filter/src/Utilities.cpp index 52aade9..0e7c41d 100644 --- a/common_content_filter/src/Utilities.cpp +++ b/common_content_filter/src/Utilities.cpp @@ -42,7 +42,7 @@ get_type_support_introspection( rcutils_error_string_t error_string = rcutils_get_error_string(); rcutils_reset_error(); logError( - DDSSQLFILTER, + SQLFILTER, "Type support not from this implementation. Got:\n" << " " << prev_error_string.str << "\n" << " " << error_string.str << "\n" diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index 93557c6..7c9abcd 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -30,7 +30,7 @@ #include #include -#include "DDSFilterFactory.hpp" +#include "FilterFactory.hpp" #include "Log.hpp" #include "Utilities.hpp" @@ -40,13 +40,13 @@ namespace common_content_filter const int MAGIC = 0x434654; // 'C','F','T' -using DDSFilterFactory = eprosima_common::fastdds::dds::DDSSQLFilter::DDSFilterFactory; -using IContentFilter = eprosima_common::fastdds::dds::IContentFilter; +using FilterFactory = common_content_filter::SQLFilter::FilterFactory; +using IContentFilter = common_content_filter::IContentFilter; -DDSFilterFactory * +FilterFactory * get_common_content_filter_factory() { - static DDSFilterFactory content_filter_factory; + static FilterFactory content_filter_factory; return &content_filter_factory; } @@ -105,10 +105,10 @@ class ContentFilterWrapper { std::lock_guard lock(mutex_); if (filter_instance_) { - DDSFilterFactory::ReturnCode_t ret = + FilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->delete_content_filter(filter_instance_); - if (ret != DDSFilterFactory::RETCODE_OK) { - logError(DDSSQLFILTER, "Failed to delete content filter: " << ret); + if (ret != FilterFactory::RETCODE_OK) { + logError(SQLFILTER, "Failed to delete content filter: " << ret); } filter_instance_ = nullptr; @@ -119,7 +119,7 @@ class ContentFilterWrapper { std::lock_guard lock(mutex_); if (!filter_instance_) { - logWarning(DDSSQLFILTER, "Common content filter is not set"); + logWarning(SQLFILTER, "Common content filter is not set"); return true; } @@ -133,7 +133,7 @@ class ContentFilterWrapper rmw_deserialize(serialized_message, type_support_, deserialized_buffer_.get()); ros_data = deserialized_buffer_.get(); if (rmw_ret != RMW_RET_OK) { - logError(DDSSQLFILTER, "Failed to deserialize message"); + logError(SQLFILTER, "Failed to deserialize message"); return false; } } @@ -147,13 +147,13 @@ class ContentFilterWrapper { std::lock_guard lock(mutex_); const char * tip = (filter_instance_ == nullptr) ? "create" : "set"; - DDSFilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->create_content_filter( + FilterFactory::ReturnCode_t ret = get_common_content_filter_factory()->create_content_filter( type_support_, filter_expression.c_str(), expression_parameters, filter_instance_); - if (ret != DDSFilterFactory::RETCODE_OK) { - logError(DDSSQLFILTER, "failed to " << tip << " content filter, error code: " << ret); + if (ret != FilterFactory::RETCODE_OK) { + logError(SQLFILTER, "failed to " << tip << " content filter, error code: " << ret); return false; } @@ -170,7 +170,7 @@ class ContentFilterWrapper std::lock_guard lock(mutex_); if (!filter_instance_) { - logError(DDSSQLFILTER, "content filter instance is not created"); + logError(SQLFILTER, "content filter instance is not created"); return false; } @@ -211,7 +211,7 @@ common_content_filter::ContentFilterWrapper * validate(void * instance) auto content_filter_wrapper = static_cast(instance); if (!content_filter_wrapper || content_filter_wrapper->magic() != common_content_filter::MAGIC) { - logError(DDSSQLFILTER, "Invalid instance"); + logError(SQLFILTER, "Invalid instance"); return nullptr; } return content_filter_wrapper; @@ -253,7 +253,7 @@ common_content_filter_evaluate(void * instance, void * ros_data, bool serialized } if (!ros_data) { - logError(DDSSQLFILTER, "Invalid arguments"); + logError(SQLFILTER, "Invalid arguments"); return false; } @@ -261,7 +261,7 @@ common_content_filter_evaluate(void * instance, void * ros_data, bool serialized try { ret = content_filter_wrapper->evaluate(ros_data, serialized); } catch (const std::runtime_error & e) { - logError(DDSSQLFILTER, "Failed to evaluate: " << e.what()); + logError(SQLFILTER, "Failed to evaluate: " << e.what()); } return ret; @@ -280,7 +280,7 @@ common_content_filter_set( } if (!options) { - logError(DDSSQLFILTER, "Invalid arguments"); + logError(SQLFILTER, "Invalid arguments"); return false; } @@ -295,7 +295,7 @@ common_content_filter_set( options->filter_expression, expression_parameters ); } catch (const std::runtime_error & e) { - logError(DDSSQLFILTER, "Failed to create content filter: " << e.what()); + logError(SQLFILTER, "Failed to create content filter: " << e.what()); } return ret; @@ -315,7 +315,7 @@ common_content_filter_get( } if (!allocator || !options) { - logError(DDSSQLFILTER, "Invalid arguments"); + logError(SQLFILTER, "Invalid arguments"); return false; } @@ -343,7 +343,7 @@ common_content_filter_get( ); if (rmw_ret != RMW_RET_OK) { - logError(DDSSQLFILTER, rmw_get_error_string().str); + logError(SQLFILTER, rmw_get_error_string().str); rmw_reset_error(); return false; } From dd053d7b22ad89d41c244c6a9a39924933e43f07 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 19 Jul 2022 16:48:51 +0800 Subject: [PATCH 46/51] remove include Log.hpp that is not used Signed-off-by: Chen Lihui --- common_content_filter/src/FilterExpression.cpp | 1 - common_content_filter/src/FilterFactory.cpp | 1 - common_content_filter/src/FilterField.cpp | 1 - 3 files changed, 3 deletions(-) diff --git a/common_content_filter/src/FilterExpression.cpp b/common_content_filter/src/FilterExpression.cpp index 70f341f..9506bc4 100644 --- a/common_content_filter/src/FilterExpression.cpp +++ b/common_content_filter/src/FilterExpression.cpp @@ -26,7 +26,6 @@ #include "FilterCondition.hpp" #include "FilterField.hpp" #include "FilterParameter.hpp" -#include "Log.hpp" namespace common_content_filter { diff --git a/common_content_filter/src/FilterFactory.cpp b/common_content_filter/src/FilterFactory.cpp index 354fcd4..08fe2b3 100644 --- a/common_content_filter/src/FilterFactory.cpp +++ b/common_content_filter/src/FilterFactory.cpp @@ -37,7 +37,6 @@ #include "FilterParameter.hpp" #include "FilterPredicate.hpp" #include "FilterValue.hpp" -#include "Log.hpp" namespace common_content_filter { diff --git a/common_content_filter/src/FilterField.cpp b/common_content_filter/src/FilterField.cpp index f94afcb..ca0d244 100644 --- a/common_content_filter/src/FilterField.cpp +++ b/common_content_filter/src/FilterField.cpp @@ -31,7 +31,6 @@ #include "FilterPredicate.hpp" #include "FilterValue.hpp" -#include "Log.hpp" namespace common_content_filter { From f53b044d4ffaefaad77858c8d16db5dfaecc44d8 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Wed, 20 Jul 2022 10:10:43 +0800 Subject: [PATCH 47/51] fix issues detected by cpplint Signed-off-by: Chen Lihui --- common_content_filter/CMakeLists.txt | 7 ------ .../include/common_content_filter/api.h | 4 ++-- .../src/FilterCompoundCondition.cpp | 1 + .../src/FilterCompoundCondition.hpp | 8 +++---- common_content_filter/src/FilterCondition.hpp | 8 +++---- .../src/FilterConditionState.hpp | 6 ++--- .../src/FilterEmptyExpression.hpp | 8 +++---- .../src/FilterExpression.hpp | 7 +++--- .../src/FilterExpressionParser.cpp | 9 ++++---- .../src/FilterExpressionParser.hpp | 6 ++--- .../identifiers.hpp | 10 +++++++-- .../literal_values.hpp | 13 +++++------ .../FilterExpressionParserImpl/parameters.hpp | 7 +++++- .../FilterExpressionParserImpl/rearrange.hpp | 10 ++++++++- common_content_filter/src/FilterFactory.cpp | 13 +++++------ common_content_filter/src/FilterFactory.hpp | 8 +++---- common_content_filter/src/FilterField.cpp | 9 ++++---- common_content_filter/src/FilterField.hpp | 13 +++++------ common_content_filter/src/FilterGrammar.hpp | 22 ++++++++++++------- common_content_filter/src/FilterParameter.hpp | 7 +++--- common_content_filter/src/FilterParseNode.hpp | 12 +++++----- common_content_filter/src/FilterPredicate.hpp | 8 +++---- common_content_filter/src/FilterValue.cpp | 3 ++- common_content_filter/src/FilterValue.hpp | 8 +++---- common_content_filter/src/IContentFilter.hpp | 8 +++---- .../src/IContentFilterFactory.hpp | 8 +++---- common_content_filter/src/Log.hpp | 6 ++--- common_content_filter/src/ObjectPool.hpp | 8 +++---- common_content_filter/src/Utilities.cpp | 2 +- common_content_filter/src/Utilities.hpp | 6 ++--- common_content_filter/src/api.cpp | 11 +++++----- common_content_filter/test/test_api.cpp | 10 ++++----- 32 files changed, 136 insertions(+), 130 deletions(-) diff --git a/common_content_filter/CMakeLists.txt b/common_content_filter/CMakeLists.txt index d30c32e..4d1db23 100644 --- a/common_content_filter/CMakeLists.txt +++ b/common_content_filter/CMakeLists.txt @@ -89,13 +89,6 @@ if(BUILD_TESTING) find_package(test_msgs REQUIRED) find_package(osrf_testing_tools_cpp REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) ament_lint_auto_find_test_dependencies() ament_add_gtest(test_api test/test_api.cpp) diff --git a/common_content_filter/include/common_content_filter/api.h b/common_content_filter/include/common_content_filter/api.h index 1c0c249..3779129 100644 --- a/common_content_filter/include/common_content_filter/api.h +++ b/common_content_filter/include/common_content_filter/api.h @@ -15,12 +15,12 @@ #ifndef COMMON_CONTENT_FILTER__API_H_ #define COMMON_CONTENT_FILTER__API_H_ -#include "common_content_filter/visibility_control.h" - #include #include #include +#include "common_content_filter/visibility_control.h" + #ifdef __cplusplus extern "C" diff --git a/common_content_filter/src/FilterCompoundCondition.cpp b/common_content_filter/src/FilterCompoundCondition.cpp index 27709b8..3885035 100644 --- a/common_content_filter/src/FilterCompoundCondition.cpp +++ b/common_content_filter/src/FilterCompoundCondition.cpp @@ -20,6 +20,7 @@ #include #include +#include #include "FilterCondition.hpp" diff --git a/common_content_filter/src/FilterCompoundCondition.hpp b/common_content_filter/src/FilterCompoundCondition.hpp index 5ab5ea4..acdb00d 100644 --- a/common_content_filter/src/FilterCompoundCondition.hpp +++ b/common_content_filter/src/FilterCompoundCondition.hpp @@ -16,8 +16,8 @@ * @file FilterCompoundCondition.hpp */ -#ifndef COMMON_CONTENT_FILTER__FILTERCOMPOUNDCONDITION_HPP_ -#define COMMON_CONTENT_FILTER__FILTERCOMPOUNDCONDITION_HPP_ +#ifndef FILTERCOMPOUNDCONDITION_HPP_ +#define FILTERCOMPOUNDCONDITION_HPP_ #include @@ -33,7 +33,6 @@ namespace SQLFilter */ class FilterCompoundCondition final : public FilterCondition { - public: /** * Possible kinds of logical operations @@ -70,10 +69,9 @@ class FilterCompoundCondition final : public FilterCondition std::unique_ptr left_; std::unique_ptr right_; uint8_t num_children_decided_ = 0; - }; } // namespace SQLFilter } // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__FILTERCOMPOUNDCONDITION_HPP_ +#endif // FILTERCOMPOUNDCONDITION_HPP_ diff --git a/common_content_filter/src/FilterCondition.hpp b/common_content_filter/src/FilterCondition.hpp index eddd101..07ed62e 100644 --- a/common_content_filter/src/FilterCondition.hpp +++ b/common_content_filter/src/FilterCondition.hpp @@ -16,8 +16,8 @@ * @file FilterCondition.hpp */ -#ifndef COMMON_CONTENT_FILTER__FILTERCONDITION_HPP_ -#define COMMON_CONTENT_FILTER__FILTERCONDITION_HPP_ +#ifndef FILTERCONDITION_HPP_ +#define FILTERCONDITION_HPP_ #include "FilterConditionState.hpp" @@ -31,7 +31,6 @@ namespace SQLFilter */ class FilterCondition { - public: friend class FilterCompoundCondition; @@ -119,10 +118,9 @@ class FilterCondition private: FilterConditionState state_ = FilterConditionState::UNDECIDED; FilterCondition * parent_ = nullptr; - }; } // namespace SQLFilter } // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__FILTERCONDITION_HPP_ +#endif // FILTERCONDITION_HPP_ diff --git a/common_content_filter/src/FilterConditionState.hpp b/common_content_filter/src/FilterConditionState.hpp index 498b302..ea254ab 100644 --- a/common_content_filter/src/FilterConditionState.hpp +++ b/common_content_filter/src/FilterConditionState.hpp @@ -16,8 +16,8 @@ * @file FilterConditionState.hpp */ -#ifndef COMMON_CONTENT_FILTER__FILTERCONDITIONSTATE_HPP_ -#define COMMON_CONTENT_FILTER__FILTERCONDITIONSTATE_HPP_ +#ifndef FILTERCONDITIONSTATE_HPP_ +#define FILTERCONDITIONSTATE_HPP_ namespace common_content_filter { @@ -42,4 +42,4 @@ enum class FilterConditionState : char } // namespace SQLFilter } // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__FILTERCONDITIONSTATE_HPP_ +#endif // FILTERCONDITIONSTATE_HPP_ diff --git a/common_content_filter/src/FilterEmptyExpression.hpp b/common_content_filter/src/FilterEmptyExpression.hpp index 13a2812..8565a44 100644 --- a/common_content_filter/src/FilterEmptyExpression.hpp +++ b/common_content_filter/src/FilterEmptyExpression.hpp @@ -16,8 +16,8 @@ * @file FilterEmptyExpression.hpp */ -#ifndef COMMON_CONTENT_FILTER__FILTEREMPTYEXPRESSION_HPP_ -#define COMMON_CONTENT_FILTER__FILTEREMPTYEXPRESSION_HPP_ +#ifndef FILTEREMPTYEXPRESSION_HPP_ +#define FILTEREMPTYEXPRESSION_HPP_ #include "IContentFilter.hpp" @@ -31,7 +31,6 @@ namespace SQLFilter */ class FilterEmptyExpression final : public IContentFilter { - public: bool evaluate( const void * payload) const final @@ -40,10 +39,9 @@ class FilterEmptyExpression final : public IContentFilter return true; } - }; } // namespace SQLFilter } // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__FILTEREMPTYEXPRESSION_HPP_ +#endif // FILTEREMPTYEXPRESSION_HPP_ diff --git a/common_content_filter/src/FilterExpression.hpp b/common_content_filter/src/FilterExpression.hpp index 1dd7d12..be0df56 100644 --- a/common_content_filter/src/FilterExpression.hpp +++ b/common_content_filter/src/FilterExpression.hpp @@ -16,8 +16,8 @@ * @file FilterExpression.hpp */ -#ifndef COMMON_CONTENT_FILTER__FILTEREXPRESSION_HPP_ -#define COMMON_CONTENT_FILTER__FILTEREXPRESSION_HPP_ +#ifndef FILTEREXPRESSION_HPP_ +#define FILTEREXPRESSION_HPP_ #include #include @@ -39,7 +39,6 @@ namespace SQLFilter */ class FilterExpression final : public IContentFilter { - public: bool evaluate( const void * payload) const final; @@ -60,4 +59,4 @@ class FilterExpression final : public IContentFilter } // namespace SQLFilter } // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__FILTEREXPRESSION_HPP_ +#endif // FILTEREXPRESSION_HPP_ diff --git a/common_content_filter/src/FilterExpressionParser.cpp b/common_content_filter/src/FilterExpressionParser.cpp index 170ebba..ef97bb5 100644 --- a/common_content_filter/src/FilterExpressionParser.cpp +++ b/common_content_filter/src/FilterExpressionParser.cpp @@ -21,12 +21,13 @@ // header files needed by identifiers.hpp #include #include -#include #include -#include -#include #include +#include +#include +#include +#include #include #include @@ -45,7 +46,7 @@ namespace SQLFilter namespace parser { -using namespace tao::TAO_PEGTL_NAMESPACE; +using namespace tao::TAO_PEGTL_NAMESPACE; // NOLINT #include "FilterExpressionParserImpl/rearrange.hpp" #include "FilterExpressionParserImpl/literal_values.hpp" diff --git a/common_content_filter/src/FilterExpressionParser.hpp b/common_content_filter/src/FilterExpressionParser.hpp index b622a19..b95aedd 100644 --- a/common_content_filter/src/FilterExpressionParser.hpp +++ b/common_content_filter/src/FilterExpressionParser.hpp @@ -16,8 +16,8 @@ * @file FilterExpressionParser.hpp */ -#ifndef COMMON_CONTENT_FILTER__FILTEREXPRESSIONPARSER_HPP_ -#define COMMON_CONTENT_FILTER__FILTEREXPRESSIONPARSER_HPP_ +#ifndef FILTEREXPRESSIONPARSER_HPP_ +#define FILTEREXPRESSIONPARSER_HPP_ #include #include @@ -60,4 +60,4 @@ std::unique_ptr parse_literal_value( } // namespace SQLFilter } // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__FILTEREXPRESSIONPARSER_HPP_ +#endif // FILTEREXPRESSIONPARSER_HPP_ diff --git a/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp index cd41525..d45327b 100644 --- a/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp +++ b/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp @@ -19,7 +19,13 @@ * FilterExpressionParser.hpp file of the parent folder. */ +#ifndef FILTEREXPRESSIONPARSERIMPL__IDENTIFIERS_HPP_ +#define FILTEREXPRESSIONPARSERIMPL__IDENTIFIERS_HPP_ +#include +#include +#include +#include struct CurrentIdentifierState { const rosidl_message_type_support_t * type_support; @@ -34,7 +40,6 @@ struct CurrentIdentifierState struct identifier_processor : parse_tree::apply { - template static void add_access_path( @@ -178,5 +183,6 @@ struct identifier_processor n->children.clear(); } - }; + +#endif // FILTEREXPRESSIONPARSERIMPL__IDENTIFIERS_HPP_ diff --git a/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp b/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp index 7cae95f..4aa3a25 100644 --- a/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp +++ b/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp @@ -19,6 +19,10 @@ * FilterExpressionParser.hpp file of the parent folder. */ +#ifndef FILTEREXPRESSIONPARSERIMPL__LITERAL_VALUES_HPP_ +#define FILTEREXPRESSIONPARSERIMPL__LITERAL_VALUES_HPP_ + +#include struct literal_value_processor : parse_tree::apply { @@ -29,15 +33,12 @@ struct literal_value_processor { n->value.reset(new FilterValue()); if (n->is()) { - n->value->kind = FilterValue::ValueKind::BOOLEAN; n->value->boolean_value = true; } else if (n->is()) { - n->value->kind = FilterValue::ValueKind::BOOLEAN; n->value->boolean_value = false; } else if (n->is() || n->is()) { - if (n->m_begin.data[0] == '-') { n->value->kind = FilterValue::ValueKind::SIGNED_INTEGER; n->value->signed_integer_value = std::stoll(n->content(), nullptr, 0); @@ -46,15 +47,12 @@ struct literal_value_processor n->value->unsigned_integer_value = std::stoull(n->content(), nullptr, 0); } } else if (n->is()) { - n->value->kind = FilterValue::ValueKind::FLOAT_CONST; n->value->float_value = std::stold(n->content()); } else if (n->is()) { - n->value->kind = FilterValue::ValueKind::CHAR; n->value->char_value = n->m_begin.data[1]; } else if (n->is()) { - const ParseNode & content_node = n->left(); size_t str_len = content_node.m_end.byte - content_node.m_begin.byte; if (sizeof(n->value->string_value) < str_len) { @@ -66,5 +64,6 @@ struct literal_value_processor n->children.clear(); } - }; + +#endif // FILTEREXPRESSIONPARSERIMPL__LITERAL_VALUES_HPP_ diff --git a/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp b/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp index 6469598..b944622 100644 --- a/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp +++ b/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp @@ -19,6 +19,10 @@ * FilterExpressionParser.hpp file of the parent folder. */ +#ifndef FILTEREXPRESSIONPARSERIMPL__PARAMETERS_HPP_ +#define FILTEREXPRESSIONPARSERIMPL__PARAMETERS_HPP_ + +#include struct parameter_processor : parse_tree::apply { @@ -33,5 +37,6 @@ struct parameter_processor n->parameter_index += static_cast(n->m_begin.data[2] - '0'); } } - }; + +#endif // FILTEREXPRESSIONPARSERIMPL__PARAMETERS_HPP_ diff --git a/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp b/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp index 8103f45..0ab3a71 100644 --- a/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp +++ b/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp @@ -19,6 +19,13 @@ * FilterExpressionParser.hpp file of the parent folder. */ +#ifndef FILTEREXPRESSIONPARSERIMPL__REARRANGE_HPP_ +#define FILTEREXPRESSIONPARSERIMPL__REARRANGE_HPP_ + +#include +#include +#include + // after a node is stored successfully, you can add an optional transformer like this: struct rearrange : parse_tree::apply // allows bulk selection, see selector<...> @@ -63,5 +70,6 @@ struct rearrange } } } - }; + +#endif // FILTEREXPRESSIONPARSERIMPL__REARRANGE_HPP_ diff --git a/common_content_filter/src/FilterFactory.cpp b/common_content_filter/src/FilterFactory.cpp index 08fe2b3..a7359ac 100644 --- a/common_content_filter/src/FilterFactory.cpp +++ b/common_content_filter/src/FilterFactory.cpp @@ -19,21 +19,22 @@ #include "FilterFactory.hpp" #include +#include #include +#include #include #include "IContentFilter.hpp" #include "IContentFilterFactory.hpp" -#include "FilterGrammar.hpp" -#include "FilterExpressionParser.hpp" -#include "FilterParseNode.hpp" -#include "FilterExpression.hpp" #include "FilterCompoundCondition.hpp" #include "FilterCondition.hpp" #include "FilterConditionState.hpp" #include "FilterEmptyExpression.hpp" #include "FilterExpression.hpp" +#include "FilterExpressionParser.hpp" #include "FilterField.hpp" +#include "FilterGrammar.hpp" +#include "FilterParseNode.hpp" #include "FilterParameter.hpp" #include "FilterPredicate.hpp" #include "FilterValue.hpp" @@ -51,8 +52,7 @@ static IContentFilterFactory::ReturnCode_t transform_enum( static_cast(value); static_cast(type); static_cast(string_value); - // TODO. when enum supported in the rosidl - + // TODO(iuhilnehc-ynos): when enum supported in the rosidl return IContentFilterFactory::ReturnCode_t::RETCODE_BAD_PARAMETER; } @@ -387,7 +387,6 @@ IContentFilterFactory::ReturnCode_t FilterFactory::create_content_filter( const IContentFilterFactory::ParameterSeq & filter_parameters, IContentFilter * & filter_instance) { - ReturnCode_t ret = ReturnCode_t::RETCODE_UNSUPPORTED; if (nullptr == filter_expression) { diff --git a/common_content_filter/src/FilterFactory.hpp b/common_content_filter/src/FilterFactory.hpp index e08a171..90ec7a4 100644 --- a/common_content_filter/src/FilterFactory.hpp +++ b/common_content_filter/src/FilterFactory.hpp @@ -16,8 +16,8 @@ * @file FilterFactory.hpp */ -#ifndef COMMON_CONTENT_FILTER__FILTERFACTORY_HPP_ -#define COMMON_CONTENT_FILTER__FILTERFACTORY_HPP_ +#ifndef FILTERFACTORY_HPP_ +#define FILTERFACTORY_HPP_ #include "IContentFilterFactory.hpp" @@ -37,7 +37,6 @@ namespace SQLFilter */ class FilterFactory final : public IContentFilterFactory { - public: ~FilterFactory(); @@ -82,10 +81,9 @@ class FilterFactory final : public IContentFilterFactory FilterEmptyExpression empty_expression_; /// Pool of FilterExpression objects ObjectPool expression_pool_; - }; } // namespace SQLFilter } // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__FILTERFACTORY_HPP_ +#endif // FILTERFACTORY_HPP_ diff --git a/common_content_filter/src/FilterField.cpp b/common_content_filter/src/FilterField.cpp index ca0d244..e0152a9 100644 --- a/common_content_filter/src/FilterField.cpp +++ b/common_content_filter/src/FilterField.cpp @@ -18,16 +18,17 @@ #include "FilterField.hpp" +#include #include -#include #include -#include -#include -#include #include +#include #include #include +#include +#include +#include #include "FilterPredicate.hpp" #include "FilterValue.hpp" diff --git a/common_content_filter/src/FilterField.hpp b/common_content_filter/src/FilterField.hpp index 80e4d17..d910b9b 100644 --- a/common_content_filter/src/FilterField.hpp +++ b/common_content_filter/src/FilterField.hpp @@ -16,15 +16,15 @@ * @file FilterField.hpp */ -#ifndef COMMON_CONTENT_FILTER__FILTERFIELD_HPP_ -#define COMMON_CONTENT_FILTER__FILTERFIELD_HPP_ +#ifndef FILTERFIELD_HPP_ +#define FILTERFIELD_HPP_ + +#include #include #include #include -#include - #include "FilterPredicate.hpp" #include "FilterValue.hpp" @@ -38,7 +38,6 @@ namespace SQLFilter */ class FilterField final : public FilterValue { - public: /** * An element on the access path to the final field. @@ -106,7 +105,7 @@ class FilterField final : public FilterValue inline bool set_value( const void * data_value) { - return set_value(data_value, (size_t)0); + return set_value(data_value, static_cast(0)); } /** @@ -152,4 +151,4 @@ class FilterField final : public FilterValue } // namespace SQLFilter } // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__FILTERFIELD_HPP_ +#endif // FILTERFIELD_HPP_ diff --git a/common_content_filter/src/FilterGrammar.hpp b/common_content_filter/src/FilterGrammar.hpp index b5c4e65..67dfdc0 100644 --- a/common_content_filter/src/FilterGrammar.hpp +++ b/common_content_filter/src/FilterGrammar.hpp @@ -16,9 +16,11 @@ * @file FilterGrammar.hpp */ -#ifndef COMMON_CONTENT_FILTER__FILTERGRAMMAR_HPP_ -#define COMMON_CONTENT_FILTER__FILTERGRAMMAR_HPP_ +#ifndef FILTERGRAMMAR_HPP_ +#define FILTERGRAMMAR_HPP_ +#include +#include #include namespace common_content_filter @@ -26,7 +28,7 @@ namespace common_content_filter namespace SQLFilter { -using namespace tao::TAO_PEGTL_NAMESPACE; +using namespace tao::TAO_PEGTL_NAMESPACE; // NOLINT // *INDENT-OFF* Allow curly braces on the same line to improve grammar readability @@ -56,7 +58,8 @@ struct boolean_value : sor {}; struct integer_value : seq< opt< sign >, integer > {}; struct fractional : seq< dot_op, integer > {}; struct exponent : seq< one< 'e', 'E' >, integer_value > {}; -struct float_value : seq < opt< sign >, integer, sor < exponent, seq< fractional, opt< exponent > > > > {}; +struct float_value : + seq < opt< sign >, integer, sor < exponent, seq< fractional, opt< exponent > > > > {}; struct hex_value : seq< opt< sign >, one< '0' >, one< 'x', 'X' >, plus< xdigit > > {}; // PARAMETER @@ -66,8 +69,10 @@ struct parameter_value : seq< one< '%' >, digit, opt< digit > > {}; struct and_op : pad< sor< TAO_PEGTL_KEYWORD("AND"), TAO_PEGTL_KEYWORD("and") >, space > {}; struct or_op : pad< sor< TAO_PEGTL_KEYWORD("OR"), TAO_PEGTL_KEYWORD("or") >, space> {}; struct not_op : pad< sor< TAO_PEGTL_KEYWORD("NOT"), TAO_PEGTL_KEYWORD("not") >, space> {}; -struct between_op : pad< sor< TAO_PEGTL_KEYWORD("BETWEEN"), TAO_PEGTL_KEYWORD("between") >, space> {}; -struct not_between_op : pad< sor< TAO_PEGTL_KEYWORD("NOT BETWEEN"), TAO_PEGTL_KEYWORD("not between") >, space> {}; +struct between_op : + pad< sor< TAO_PEGTL_KEYWORD("BETWEEN"), TAO_PEGTL_KEYWORD("between") >, space> {}; +struct not_between_op : + pad< sor< TAO_PEGTL_KEYWORD("NOT BETWEEN"), TAO_PEGTL_KEYWORD("not between") >, space> {}; // RelOp struct eq_op : pad< one<'='>, space> {}; @@ -81,7 +86,8 @@ struct match_op : pad< sor< TAO_PEGTL_KEYWORD("MATCH"), TAO_PEGTL_KEYWORD("match struct rel_op : sor< match_op, like_op, ne_op, le_op, ge_op, lt_op, gt_op, eq_op > {}; // Parameter, Range -struct Literal : sor< boolean_value, float_value, hex_value, integer_value, char_value, string_value > {}; +struct Literal : + sor< boolean_value, float_value, hex_value, integer_value, char_value, string_value > {}; struct Parameter : sor< Literal, parameter_value > {}; struct Range : seq< Parameter, and_op, Parameter > {}; @@ -116,4 +122,4 @@ struct LiteralGrammar : must< Literal, tao::TAO_PEGTL_NAMESPACE::eof > {}; } // namespace SQLFilter } // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__FILTERGRAMMAR_HPP_ +#endif // FILTERGRAMMAR_HPP_ diff --git a/common_content_filter/src/FilterParameter.hpp b/common_content_filter/src/FilterParameter.hpp index 7fb6ef3..3560d7b 100644 --- a/common_content_filter/src/FilterParameter.hpp +++ b/common_content_filter/src/FilterParameter.hpp @@ -16,8 +16,8 @@ * @file FilterParameter.hpp */ -#ifndef COMMON_CONTENT_FILTER__FILTERPARAMETER_HPP_ -#define COMMON_CONTENT_FILTER__FILTERPARAMETER_HPP_ +#ifndef FILTERPARAMETER_HPP_ +#define FILTERPARAMETER_HPP_ #include "FilterValue.hpp" @@ -31,7 +31,6 @@ namespace SQLFilter */ class FilterParameter final : public FilterValue { - public: virtual ~FilterParameter() = default; @@ -49,4 +48,4 @@ class FilterParameter final : public FilterValue } // namespace SQLFilter } // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__FILTERPARAMETER_HPP_ +#endif // FILTERPARAMETER_HPP_ diff --git a/common_content_filter/src/FilterParseNode.hpp b/common_content_filter/src/FilterParseNode.hpp index a3f5e20..caf6103 100644 --- a/common_content_filter/src/FilterParseNode.hpp +++ b/common_content_filter/src/FilterParseNode.hpp @@ -16,8 +16,8 @@ * @file FilterParseNode.hpp */ -#ifndef COMMON_CONTENT_FILTER__FILTERPARSENODE_HPP_ -#define COMMON_CONTENT_FILTER__FILTERPARSENODE_HPP_ +#ifndef FILTERPARSENODE_HPP_ +#define FILTERPARSENODE_HPP_ #include #include @@ -34,14 +34,15 @@ namespace SQLFilter namespace parser { -using namespace tao::TAO_PEGTL_NAMESPACE; +using namespace tao::TAO_PEGTL_NAMESPACE; // NOLINT struct ParseNode : parse_tree::basic_node { // When the node is a literal value, it will hold a pointer to it std::unique_ptr value; - // When the node is a fieldname, it will hold the access path to the field, the data kind, and the type id + // When the node is a fieldname, it will hold the access path to the field, the data kind, + // and the type id std::vector field_access_path; FilterValue::ValueKind field_kind = FilterValue::ValueKind::STRING; // ros2 primitive type id @@ -59,11 +60,10 @@ struct ParseNode : parse_tree::basic_node { return *(children[1]); } - }; } // namespace parser } // namespace SQLFilter } // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__FILTERPARSENODE_HPP_ +#endif // FILTERPARSENODE_HPP_ diff --git a/common_content_filter/src/FilterPredicate.hpp b/common_content_filter/src/FilterPredicate.hpp index 3b6af1f..4f9479e 100644 --- a/common_content_filter/src/FilterPredicate.hpp +++ b/common_content_filter/src/FilterPredicate.hpp @@ -16,8 +16,8 @@ * @file FilterPredicate.hpp */ -#ifndef COMMON_CONTENT_FILTER__FILTERPREDICATE_HPP_ -#define COMMON_CONTENT_FILTER__FILTERPREDICATE_HPP_ +#ifndef FILTERPREDICATE_HPP_ +#define FILTERPREDICATE_HPP_ #include @@ -34,7 +34,6 @@ namespace SQLFilter */ class FilterPredicate final : public FilterCondition { - public: /** * Possible kinds of binary operations @@ -83,10 +82,9 @@ class FilterPredicate final : public FilterCondition OperationKind op_; std::shared_ptr left_; std::shared_ptr right_; - }; } // namespace SQLFilter } // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__FILTERPREDICATE_HPP_ +#endif // FILTERPREDICATE_HPP_ diff --git a/common_content_filter/src/FilterValue.cpp b/common_content_filter/src/FilterValue.cpp index 11b1a58..1b7743c 100644 --- a/common_content_filter/src/FilterValue.cpp +++ b/common_content_filter/src/FilterValue.cpp @@ -223,7 +223,8 @@ int FilterValue::compare( case ValueKind::STRING: return std::strcmp(lhs.string_value, rhs.string_value); - // As the grammar does not allow constant vs constant comparisons, FLOAT_CONST should never reach here + // As the grammar does not allow constant vs constant comparisons, FLOAT_CONST should never + // reach here case ValueKind::FLOAT_CONST: default: assert(false); diff --git a/common_content_filter/src/FilterValue.hpp b/common_content_filter/src/FilterValue.hpp index 930bdcd..0f26b77 100644 --- a/common_content_filter/src/FilterValue.hpp +++ b/common_content_filter/src/FilterValue.hpp @@ -16,8 +16,8 @@ * @file FilterValue.hpp */ -#ifndef COMMON_CONTENT_FILTER__FILTERVALUE_HPP_ -#define COMMON_CONTENT_FILTER__FILTERVALUE_HPP_ +#ifndef FILTERVALUE_HPP_ +#define FILTERVALUE_HPP_ #include #include @@ -34,7 +34,6 @@ class FilterPredicate; */ class FilterValue { - public: // FilterPredicate needs to call protected method add_parent friend class FilterPredicate; @@ -216,10 +215,9 @@ class FilterValue static int compare( const FilterValue & lhs, const FilterValue & rhs) noexcept; - }; } // namespace SQLFilter } // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__FILTERVALUE_HPP_ +#endif // FILTERVALUE_HPP_ diff --git a/common_content_filter/src/IContentFilter.hpp b/common_content_filter/src/IContentFilter.hpp index 29fd9fa..f6b013c 100644 --- a/common_content_filter/src/IContentFilter.hpp +++ b/common_content_filter/src/IContentFilter.hpp @@ -16,8 +16,8 @@ * @file IContentFilter.hpp */ -#ifndef COMMON_CONTENT_FILTER__ICONTENTFILTER_HPP_ -#define COMMON_CONTENT_FILTER__ICONTENTFILTER_HPP_ +#ifndef ICONTENTFILTER_HPP_ +#define ICONTENTFILTER_HPP_ namespace common_content_filter @@ -39,6 +39,6 @@ struct IContentFilter const void * payload) const = 0; }; -} // namespace common_content_filter +} // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__ICONTENTFILTER_HPP_ +#endif // ICONTENTFILTER_HPP_ diff --git a/common_content_filter/src/IContentFilterFactory.hpp b/common_content_filter/src/IContentFilterFactory.hpp index b1cb5a4..f8065e8 100644 --- a/common_content_filter/src/IContentFilterFactory.hpp +++ b/common_content_filter/src/IContentFilterFactory.hpp @@ -16,8 +16,8 @@ * @file IContentFilter.hpp */ -#ifndef COMMON_CONTENT_FILTER__ICONTENTFILTERFACTORY_HPP_ -#define COMMON_CONTENT_FILTER__ICONTENTFILTERFACTORY_HPP_ +#ifndef ICONTENTFILTERFACTORY_HPP_ +#define ICONTENTFILTERFACTORY_HPP_ #include @@ -85,6 +85,6 @@ struct IContentFilterFactory IContentFilter * filter_instance) = 0; }; -} // namespace common_content_filter +} // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER__ICONTENTFILTERFACTORY_HPP_ +#endif // ICONTENTFILTERFACTORY_HPP_ diff --git a/common_content_filter/src/Log.hpp b/common_content_filter/src/Log.hpp index 1215516..94483af 100644 --- a/common_content_filter/src/Log.hpp +++ b/common_content_filter/src/Log.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef COMMON_CONTENT_FILTER__LOG_HPP_ -#define COMMON_CONTENT_FILTER__LOG_HPP_ +#ifndef LOG_HPP_ +#define LOG_HPP_ #include #include @@ -30,4 +30,4 @@ #define logWarning(cat, msg) common_content_filter_log_(WARN, cat, msg) #define logError(cat, msg) common_content_filter_log_(ERROR, cat, msg) -#endif // COMMON_CONTENT_FILTER__LOG_HPP_ +#endif // LOG_HPP_ diff --git a/common_content_filter/src/ObjectPool.hpp b/common_content_filter/src/ObjectPool.hpp index 670e9b0..f79858f 100644 --- a/common_content_filter/src/ObjectPool.hpp +++ b/common_content_filter/src/ObjectPool.hpp @@ -17,11 +17,12 @@ * */ -#ifndef COMMON_CONTENT_FILTER_OBJECTPOOL_HPP_ -#define COMMON_CONTENT_FILTER_OBJECTPOOL_HPP_ +#ifndef OBJECTPOOL_HPP_ +#define OBJECTPOOL_HPP_ #include #include +#include #include namespace common_content_filter @@ -89,9 +90,8 @@ struct ObjectPool final private: _Collection collection_; - }; } // namespace common_content_filter -#endif // COMMON_CONTENT_FILTER_OBJECTPOOL_HPP_ +#endif // OBJECTPOOL_HPP_ diff --git a/common_content_filter/src/Utilities.cpp b/common_content_filter/src/Utilities.cpp index 0e7c41d..ff12a01 100644 --- a/common_content_filter/src/Utilities.cpp +++ b/common_content_filter/src/Utilities.cpp @@ -16,8 +16,8 @@ #include #include -#include #include +#include #include #include diff --git a/common_content_filter/src/Utilities.hpp b/common_content_filter/src/Utilities.hpp index fe0acad..e15c615 100644 --- a/common_content_filter/src/Utilities.hpp +++ b/common_content_filter/src/Utilities.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef COMMON_CONTENT_FILTER__UTILITIES_HPP_ -#define COMMON_CONTENT_FILTER__UTILITIES_HPP_ +#ifndef UTILITIES_HPP_ +#define UTILITIES_HPP_ #include @@ -21,4 +21,4 @@ const rosidl_message_type_support_t * get_type_support_introspection( const rosidl_message_type_support_t * type_support); -#endif // COMMON_CONTENT_FILTER__UTILITIES_HPP_ +#endif // UTILITIES_HPP_ diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index 7c9abcd..5cb000b 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -19,15 +19,16 @@ #include #include - #include -#include #include -#include -#include #include #include + +#include +#include +#include + #include #include "FilterFactory.hpp" @@ -97,7 +98,7 @@ auto get_message_buffer(const rosidl_message_type_support_t * type_support) class ContentFilterWrapper { public: - ContentFilterWrapper(const rosidl_message_type_support_t * type_support) + explicit ContentFilterWrapper(const rosidl_message_type_support_t * type_support) : type_support_(type_support) {} diff --git a/common_content_filter/test/test_api.cpp b/common_content_filter/test/test_api.cpp index 61cd3f9..3df3158 100644 --- a/common_content_filter/test/test_api.cpp +++ b/common_content_filter/test/test_api.cpp @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include -#include - #include #include #include +#include +#include +#include + #include #include #include @@ -429,7 +429,7 @@ TEST_F(TestComplexMsgCommonContentFilterAPI, set_and_evaluate) { // bound case, the size of bounded_float64_data is 2 {"data.basic_array[0].bounded_float64_data[10]=%0", {"0"}, false, true}, - // TODO. if bugs found, add new test cases and fix source code + // TODO(iuhilnehc-ynos): if bugs found, add new test cases and fix source code. }; for (auto & item : expectation) { From 80cdd97952c6920a3e675ee69e5a0f1cc636288d Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Sun, 31 Jul 2022 19:01:34 +0800 Subject: [PATCH 48/51] update copyright Signed-off-by: Chen Lihui --- common_content_filter/include/common_content_filter/api.h | 2 +- .../include/common_content_filter/visibility_control.h | 2 +- common_content_filter/src/FilterCompoundCondition.cpp | 1 + common_content_filter/src/FilterCompoundCondition.hpp | 1 + common_content_filter/src/FilterCondition.hpp | 1 + common_content_filter/src/FilterConditionState.hpp | 1 + common_content_filter/src/FilterEmptyExpression.hpp | 1 + common_content_filter/src/FilterExpression.cpp | 1 + common_content_filter/src/FilterExpression.hpp | 1 + common_content_filter/src/FilterExpressionParser.cpp | 1 + common_content_filter/src/FilterExpressionParser.hpp | 1 + .../src/FilterExpressionParserImpl/identifiers.hpp | 1 + .../src/FilterExpressionParserImpl/literal_values.hpp | 1 + .../src/FilterExpressionParserImpl/parameters.hpp | 1 + .../src/FilterExpressionParserImpl/rearrange.hpp | 1 + common_content_filter/src/FilterFactory.cpp | 1 + common_content_filter/src/FilterFactory.hpp | 1 + common_content_filter/src/FilterField.cpp | 1 + common_content_filter/src/FilterField.hpp | 1 + common_content_filter/src/FilterGrammar.hpp | 1 + common_content_filter/src/FilterParameter.cpp | 1 + common_content_filter/src/FilterParameter.hpp | 1 + common_content_filter/src/FilterParseNode.hpp | 1 + common_content_filter/src/FilterPredicate.cpp | 1 + common_content_filter/src/FilterPredicate.hpp | 1 + common_content_filter/src/FilterValue.cpp | 1 + common_content_filter/src/FilterValue.hpp | 1 + common_content_filter/src/IContentFilter.hpp | 1 + common_content_filter/src/IContentFilterFactory.hpp | 1 + common_content_filter/src/Log.hpp | 2 +- common_content_filter/src/ObjectPool.hpp | 1 + common_content_filter/src/Utilities.cpp | 2 +- common_content_filter/src/Utilities.hpp | 2 +- common_content_filter/src/api.cpp | 2 +- common_content_filter/test/test_api.cpp | 2 +- tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake | 2 +- 36 files changed, 36 insertions(+), 8 deletions(-) diff --git a/common_content_filter/include/common_content_filter/api.h b/common_content_filter/include/common_content_filter/api.h index 3779129..ce59492 100644 --- a/common_content_filter/include/common_content_filter/api.h +++ b/common_content_filter/include/common_content_filter/api.h @@ -1,4 +1,4 @@ -// Copyright 2022 Open Source Robotics Foundation, Inc. +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/include/common_content_filter/visibility_control.h b/common_content_filter/include/common_content_filter/visibility_control.h index 79fb0e2..90439c9 100644 --- a/common_content_filter/include/common_content_filter/visibility_control.h +++ b/common_content_filter/include/common_content_filter/visibility_control.h @@ -1,4 +1,4 @@ -// Copyright 2022 Open Source Robotics Foundation, Inc. +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterCompoundCondition.cpp b/common_content_filter/src/FilterCompoundCondition.cpp index 3885035..c98f127 100644 --- a/common_content_filter/src/FilterCompoundCondition.cpp +++ b/common_content_filter/src/FilterCompoundCondition.cpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterCompoundCondition.hpp b/common_content_filter/src/FilterCompoundCondition.hpp index acdb00d..e38b274 100644 --- a/common_content_filter/src/FilterCompoundCondition.hpp +++ b/common_content_filter/src/FilterCompoundCondition.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterCondition.hpp b/common_content_filter/src/FilterCondition.hpp index 07ed62e..6d1fa01 100644 --- a/common_content_filter/src/FilterCondition.hpp +++ b/common_content_filter/src/FilterCondition.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterConditionState.hpp b/common_content_filter/src/FilterConditionState.hpp index ea254ab..d21f839 100644 --- a/common_content_filter/src/FilterConditionState.hpp +++ b/common_content_filter/src/FilterConditionState.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterEmptyExpression.hpp b/common_content_filter/src/FilterEmptyExpression.hpp index 8565a44..2f57d20 100644 --- a/common_content_filter/src/FilterEmptyExpression.hpp +++ b/common_content_filter/src/FilterEmptyExpression.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterExpression.cpp b/common_content_filter/src/FilterExpression.cpp index 9506bc4..0fb96d0 100644 --- a/common_content_filter/src/FilterExpression.cpp +++ b/common_content_filter/src/FilterExpression.cpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterExpression.hpp b/common_content_filter/src/FilterExpression.hpp index be0df56..4b200c4 100644 --- a/common_content_filter/src/FilterExpression.hpp +++ b/common_content_filter/src/FilterExpression.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterExpressionParser.cpp b/common_content_filter/src/FilterExpressionParser.cpp index ef97bb5..b104d6f 100644 --- a/common_content_filter/src/FilterExpressionParser.cpp +++ b/common_content_filter/src/FilterExpressionParser.cpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterExpressionParser.hpp b/common_content_filter/src/FilterExpressionParser.hpp index b95aedd..0a6b624 100644 --- a/common_content_filter/src/FilterExpressionParser.hpp +++ b/common_content_filter/src/FilterExpressionParser.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp index d45327b..4b4cfcc 100644 --- a/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp +++ b/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp b/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp index 4aa3a25..cfa5712 100644 --- a/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp +++ b/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp b/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp index b944622..065fd88 100644 --- a/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp +++ b/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp b/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp index 0ab3a71..d219168 100644 --- a/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp +++ b/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterFactory.cpp b/common_content_filter/src/FilterFactory.cpp index a7359ac..c8bc7b8 100644 --- a/common_content_filter/src/FilterFactory.cpp +++ b/common_content_filter/src/FilterFactory.cpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterFactory.hpp b/common_content_filter/src/FilterFactory.hpp index 90ec7a4..05fd487 100644 --- a/common_content_filter/src/FilterFactory.hpp +++ b/common_content_filter/src/FilterFactory.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterField.cpp b/common_content_filter/src/FilterField.cpp index e0152a9..b6d9452 100644 --- a/common_content_filter/src/FilterField.cpp +++ b/common_content_filter/src/FilterField.cpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterField.hpp b/common_content_filter/src/FilterField.hpp index d910b9b..bdc2645 100644 --- a/common_content_filter/src/FilterField.hpp +++ b/common_content_filter/src/FilterField.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterGrammar.hpp b/common_content_filter/src/FilterGrammar.hpp index 67dfdc0..21d66fa 100644 --- a/common_content_filter/src/FilterGrammar.hpp +++ b/common_content_filter/src/FilterGrammar.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterParameter.cpp b/common_content_filter/src/FilterParameter.cpp index a47cd5e..d0178f7 100644 --- a/common_content_filter/src/FilterParameter.cpp +++ b/common_content_filter/src/FilterParameter.cpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterParameter.hpp b/common_content_filter/src/FilterParameter.hpp index 3560d7b..6acc715 100644 --- a/common_content_filter/src/FilterParameter.hpp +++ b/common_content_filter/src/FilterParameter.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterParseNode.hpp b/common_content_filter/src/FilterParseNode.hpp index caf6103..eec3be0 100644 --- a/common_content_filter/src/FilterParseNode.hpp +++ b/common_content_filter/src/FilterParseNode.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterPredicate.cpp b/common_content_filter/src/FilterPredicate.cpp index 2870594..24b0f07 100644 --- a/common_content_filter/src/FilterPredicate.cpp +++ b/common_content_filter/src/FilterPredicate.cpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterPredicate.hpp b/common_content_filter/src/FilterPredicate.hpp index 4f9479e..9cae1ad 100644 --- a/common_content_filter/src/FilterPredicate.hpp +++ b/common_content_filter/src/FilterPredicate.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterValue.cpp b/common_content_filter/src/FilterValue.cpp index 1b7743c..45b7cf1 100644 --- a/common_content_filter/src/FilterValue.cpp +++ b/common_content_filter/src/FilterValue.cpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterValue.hpp b/common_content_filter/src/FilterValue.hpp index 0f26b77..aaecac7 100644 --- a/common_content_filter/src/FilterValue.hpp +++ b/common_content_filter/src/FilterValue.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/IContentFilter.hpp b/common_content_filter/src/IContentFilter.hpp index f6b013c..9455a7f 100644 --- a/common_content_filter/src/IContentFilter.hpp +++ b/common_content_filter/src/IContentFilter.hpp @@ -1,4 +1,5 @@ // Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/IContentFilterFactory.hpp b/common_content_filter/src/IContentFilterFactory.hpp index f8065e8..e83e4d0 100644 --- a/common_content_filter/src/IContentFilterFactory.hpp +++ b/common_content_filter/src/IContentFilterFactory.hpp @@ -1,4 +1,5 @@ // Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/Log.hpp b/common_content_filter/src/Log.hpp index 94483af..4f3c612 100644 --- a/common_content_filter/src/Log.hpp +++ b/common_content_filter/src/Log.hpp @@ -1,4 +1,4 @@ -// Copyright 2022 Open Source Robotics Foundation, Inc. +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/ObjectPool.hpp b/common_content_filter/src/ObjectPool.hpp index f79858f..f9e007a 100644 --- a/common_content_filter/src/ObjectPool.hpp +++ b/common_content_filter/src/ObjectPool.hpp @@ -1,4 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/Utilities.cpp b/common_content_filter/src/Utilities.cpp index ff12a01..e639d4a 100644 --- a/common_content_filter/src/Utilities.cpp +++ b/common_content_filter/src/Utilities.cpp @@ -1,4 +1,4 @@ -// Copyright 2022 Open Source Robotics Foundation, Inc. +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/Utilities.hpp b/common_content_filter/src/Utilities.hpp index e15c615..cd8abc0 100644 --- a/common_content_filter/src/Utilities.hpp +++ b/common_content_filter/src/Utilities.hpp @@ -1,4 +1,4 @@ -// Copyright 2022 Open Source Robotics Foundation, Inc. +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index 5cb000b..f9442ad 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -1,4 +1,4 @@ -// Copyright 2022 Open Source Robotics Foundation, Inc. +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/test/test_api.cpp b/common_content_filter/test/test_api.cpp index 3df3158..f7589e8 100644 --- a/common_content_filter/test/test_api.cpp +++ b/common_content_filter/test/test_api.cpp @@ -1,4 +1,4 @@ -// Copyright 2022 Open Source Robotics Foundation, Inc. +// Copyright 2022 Sony Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake b/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake index 80233f8..914b75d 100644 --- a/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake +++ b/tao_pegtl_vendor/tao_pegtl_vendor-extras.cmake @@ -1,4 +1,4 @@ -# Copyright 2022 Open Source Robotics Foundation, Inc. +# Copyright 2022 Sony Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 27a263e986c32ba07322c6b50e7906954df659d4 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 1 Aug 2022 11:03:08 +0800 Subject: [PATCH 49/51] use Sony Group Corporation instead Signed-off-by: Chen Lihui --- common_content_filter/include/common_content_filter/api.h | 2 +- .../include/common_content_filter/visibility_control.h | 2 +- common_content_filter/src/FilterCompoundCondition.cpp | 2 +- common_content_filter/src/FilterCompoundCondition.hpp | 2 +- common_content_filter/src/FilterCondition.hpp | 2 +- common_content_filter/src/FilterConditionState.hpp | 2 +- common_content_filter/src/FilterEmptyExpression.hpp | 2 +- common_content_filter/src/FilterExpression.cpp | 2 +- common_content_filter/src/FilterExpression.hpp | 2 +- common_content_filter/src/FilterExpressionParser.cpp | 2 +- common_content_filter/src/FilterExpressionParser.hpp | 2 +- .../src/FilterExpressionParserImpl/identifiers.hpp | 2 +- .../src/FilterExpressionParserImpl/literal_values.hpp | 2 +- .../src/FilterExpressionParserImpl/parameters.hpp | 2 +- .../src/FilterExpressionParserImpl/rearrange.hpp | 2 +- common_content_filter/src/FilterFactory.cpp | 2 +- common_content_filter/src/FilterFactory.hpp | 2 +- common_content_filter/src/FilterField.cpp | 2 +- common_content_filter/src/FilterField.hpp | 2 +- common_content_filter/src/FilterGrammar.hpp | 2 +- common_content_filter/src/FilterParameter.cpp | 2 +- common_content_filter/src/FilterParameter.hpp | 2 +- common_content_filter/src/FilterParseNode.hpp | 2 +- common_content_filter/src/FilterPredicate.cpp | 2 +- common_content_filter/src/FilterPredicate.hpp | 2 +- common_content_filter/src/FilterValue.cpp | 2 +- common_content_filter/src/FilterValue.hpp | 2 +- common_content_filter/src/IContentFilter.hpp | 2 +- common_content_filter/src/IContentFilterFactory.hpp | 2 +- common_content_filter/src/Log.hpp | 2 +- common_content_filter/src/ObjectPool.hpp | 2 +- common_content_filter/src/Utilities.cpp | 2 +- common_content_filter/src/Utilities.hpp | 2 +- common_content_filter/src/api.cpp | 2 +- common_content_filter/test/test_api.cpp | 2 +- 35 files changed, 35 insertions(+), 35 deletions(-) diff --git a/common_content_filter/include/common_content_filter/api.h b/common_content_filter/include/common_content_filter/api.h index ce59492..f3c05bf 100644 --- a/common_content_filter/include/common_content_filter/api.h +++ b/common_content_filter/include/common_content_filter/api.h @@ -1,4 +1,4 @@ -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/include/common_content_filter/visibility_control.h b/common_content_filter/include/common_content_filter/visibility_control.h index 90439c9..77a0065 100644 --- a/common_content_filter/include/common_content_filter/visibility_control.h +++ b/common_content_filter/include/common_content_filter/visibility_control.h @@ -1,4 +1,4 @@ -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterCompoundCondition.cpp b/common_content_filter/src/FilterCompoundCondition.cpp index c98f127..da852c2 100644 --- a/common_content_filter/src/FilterCompoundCondition.cpp +++ b/common_content_filter/src/FilterCompoundCondition.cpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterCompoundCondition.hpp b/common_content_filter/src/FilterCompoundCondition.hpp index e38b274..c1ede6f 100644 --- a/common_content_filter/src/FilterCompoundCondition.hpp +++ b/common_content_filter/src/FilterCompoundCondition.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterCondition.hpp b/common_content_filter/src/FilterCondition.hpp index 6d1fa01..b1a60fd 100644 --- a/common_content_filter/src/FilterCondition.hpp +++ b/common_content_filter/src/FilterCondition.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterConditionState.hpp b/common_content_filter/src/FilterConditionState.hpp index d21f839..d0443cf 100644 --- a/common_content_filter/src/FilterConditionState.hpp +++ b/common_content_filter/src/FilterConditionState.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterEmptyExpression.hpp b/common_content_filter/src/FilterEmptyExpression.hpp index 2f57d20..b482d95 100644 --- a/common_content_filter/src/FilterEmptyExpression.hpp +++ b/common_content_filter/src/FilterEmptyExpression.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterExpression.cpp b/common_content_filter/src/FilterExpression.cpp index 0fb96d0..eb289f1 100644 --- a/common_content_filter/src/FilterExpression.cpp +++ b/common_content_filter/src/FilterExpression.cpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterExpression.hpp b/common_content_filter/src/FilterExpression.hpp index 4b200c4..017f4e5 100644 --- a/common_content_filter/src/FilterExpression.hpp +++ b/common_content_filter/src/FilterExpression.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterExpressionParser.cpp b/common_content_filter/src/FilterExpressionParser.cpp index b104d6f..e18613d 100644 --- a/common_content_filter/src/FilterExpressionParser.cpp +++ b/common_content_filter/src/FilterExpressionParser.cpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterExpressionParser.hpp b/common_content_filter/src/FilterExpressionParser.hpp index 0a6b624..c8fbbe7 100644 --- a/common_content_filter/src/FilterExpressionParser.hpp +++ b/common_content_filter/src/FilterExpressionParser.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp index 4b4cfcc..fc33d7d 100644 --- a/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp +++ b/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp b/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp index cfa5712..c4d63a0 100644 --- a/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp +++ b/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp b/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp index 065fd88..cfdf584 100644 --- a/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp +++ b/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp b/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp index d219168..686c170 100644 --- a/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp +++ b/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterFactory.cpp b/common_content_filter/src/FilterFactory.cpp index c8bc7b8..1fe8c33 100644 --- a/common_content_filter/src/FilterFactory.cpp +++ b/common_content_filter/src/FilterFactory.cpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterFactory.hpp b/common_content_filter/src/FilterFactory.hpp index 05fd487..1feebc1 100644 --- a/common_content_filter/src/FilterFactory.hpp +++ b/common_content_filter/src/FilterFactory.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterField.cpp b/common_content_filter/src/FilterField.cpp index b6d9452..24f81c0 100644 --- a/common_content_filter/src/FilterField.cpp +++ b/common_content_filter/src/FilterField.cpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterField.hpp b/common_content_filter/src/FilterField.hpp index bdc2645..54a9418 100644 --- a/common_content_filter/src/FilterField.hpp +++ b/common_content_filter/src/FilterField.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterGrammar.hpp b/common_content_filter/src/FilterGrammar.hpp index 21d66fa..be089d3 100644 --- a/common_content_filter/src/FilterGrammar.hpp +++ b/common_content_filter/src/FilterGrammar.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterParameter.cpp b/common_content_filter/src/FilterParameter.cpp index d0178f7..58d6f05 100644 --- a/common_content_filter/src/FilterParameter.cpp +++ b/common_content_filter/src/FilterParameter.cpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterParameter.hpp b/common_content_filter/src/FilterParameter.hpp index 6acc715..3380b16 100644 --- a/common_content_filter/src/FilterParameter.hpp +++ b/common_content_filter/src/FilterParameter.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterParseNode.hpp b/common_content_filter/src/FilterParseNode.hpp index eec3be0..428ab87 100644 --- a/common_content_filter/src/FilterParseNode.hpp +++ b/common_content_filter/src/FilterParseNode.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterPredicate.cpp b/common_content_filter/src/FilterPredicate.cpp index 24b0f07..f99fba6 100644 --- a/common_content_filter/src/FilterPredicate.cpp +++ b/common_content_filter/src/FilterPredicate.cpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterPredicate.hpp b/common_content_filter/src/FilterPredicate.hpp index 9cae1ad..ea1e53b 100644 --- a/common_content_filter/src/FilterPredicate.hpp +++ b/common_content_filter/src/FilterPredicate.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterValue.cpp b/common_content_filter/src/FilterValue.cpp index 45b7cf1..e9c0827 100644 --- a/common_content_filter/src/FilterValue.cpp +++ b/common_content_filter/src/FilterValue.cpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/FilterValue.hpp b/common_content_filter/src/FilterValue.hpp index aaecac7..3765bc3 100644 --- a/common_content_filter/src/FilterValue.hpp +++ b/common_content_filter/src/FilterValue.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/IContentFilter.hpp b/common_content_filter/src/IContentFilter.hpp index 9455a7f..641729d 100644 --- a/common_content_filter/src/IContentFilter.hpp +++ b/common_content_filter/src/IContentFilter.hpp @@ -1,5 +1,5 @@ // Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/IContentFilterFactory.hpp b/common_content_filter/src/IContentFilterFactory.hpp index e83e4d0..ae3ab88 100644 --- a/common_content_filter/src/IContentFilterFactory.hpp +++ b/common_content_filter/src/IContentFilterFactory.hpp @@ -1,5 +1,5 @@ // Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/Log.hpp b/common_content_filter/src/Log.hpp index 4f3c612..1599296 100644 --- a/common_content_filter/src/Log.hpp +++ b/common_content_filter/src/Log.hpp @@ -1,4 +1,4 @@ -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/ObjectPool.hpp b/common_content_filter/src/ObjectPool.hpp index f9e007a..500fa0c 100644 --- a/common_content_filter/src/ObjectPool.hpp +++ b/common_content_filter/src/ObjectPool.hpp @@ -1,5 +1,5 @@ // Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/Utilities.cpp b/common_content_filter/src/Utilities.cpp index e639d4a..d83b763 100644 --- a/common_content_filter/src/Utilities.cpp +++ b/common_content_filter/src/Utilities.cpp @@ -1,4 +1,4 @@ -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/Utilities.hpp b/common_content_filter/src/Utilities.hpp index cd8abc0..82f901c 100644 --- a/common_content_filter/src/Utilities.hpp +++ b/common_content_filter/src/Utilities.hpp @@ -1,4 +1,4 @@ -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/src/api.cpp b/common_content_filter/src/api.cpp index f9442ad..bde695f 100644 --- a/common_content_filter/src/api.cpp +++ b/common_content_filter/src/api.cpp @@ -1,4 +1,4 @@ -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_content_filter/test/test_api.cpp b/common_content_filter/test/test_api.cpp index f7589e8..862d698 100644 --- a/common_content_filter/test/test_api.cpp +++ b/common_content_filter/test/test_api.cpp @@ -1,4 +1,4 @@ -// Copyright 2022 Sony Corporation +// Copyright 2022 Sony Group Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. From daae0885df4104eb267bd55fb495213623d0d161 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 10 Oct 2022 10:04:42 +0800 Subject: [PATCH 50/51] fix build issue on ubuntu22 Signed-off-by: Chen Lihui --- .../src/FilterExpressionParser.cpp | 12 +- .../identifiers.hpp | 189 ------------------ .../literal_values.hpp | 70 ------- .../FilterExpressionParserImpl/parameters.hpp | 43 ---- .../FilterExpressionParserImpl/rearrange.hpp | 76 ------- 5 files changed, 8 insertions(+), 382 deletions(-) delete mode 100644 common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp delete mode 100644 common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp delete mode 100644 common_content_filter/src/FilterExpressionParserImpl/parameters.hpp delete mode 100644 common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp diff --git a/common_content_filter/src/FilterExpressionParser.cpp b/common_content_filter/src/FilterExpressionParser.cpp index e18613d..4be8df7 100644 --- a/common_content_filter/src/FilterExpressionParser.cpp +++ b/common_content_filter/src/FilterExpressionParser.cpp @@ -24,8 +24,12 @@ #include #include +#include +#include #include #include +#include +#include #include #include #include @@ -49,10 +53,10 @@ namespace parser using namespace tao::TAO_PEGTL_NAMESPACE; // NOLINT -#include "FilterExpressionParserImpl/rearrange.hpp" -#include "FilterExpressionParserImpl/literal_values.hpp" -#include "FilterExpressionParserImpl/identifiers.hpp" -#include "FilterExpressionParserImpl/parameters.hpp" +#include "FilterExpressionParserImpl/rearrange.inc" +#include "FilterExpressionParserImpl/literal_values.inc" +#include "FilterExpressionParserImpl/identifiers.inc" +#include "FilterExpressionParserImpl/parameters.inc" // select which rules in the grammar will produce parse tree nodes: template diff --git a/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp b/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp deleted file mode 100644 index fc33d7d..0000000 --- a/common_content_filter/src/FilterExpressionParserImpl/identifiers.hpp +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Group Corporation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file identifiers.hpp - * - * Note: this is an implementation file, designed to be included inside the - * FilterExpressionParser.hpp file of the parent folder. - */ - -#ifndef FILTEREXPRESSIONPARSERIMPL__IDENTIFIERS_HPP_ -#define FILTEREXPRESSIONPARSERIMPL__IDENTIFIERS_HPP_ - -#include -#include -#include -#include -struct CurrentIdentifierState -{ - const rosidl_message_type_support_t * type_support; - - const rosidl_message_type_support_t * current_type_support; - - uint8_t current_type; - - std::vector access_path; -}; - -struct identifier_processor - : parse_tree::apply -{ - template - static void - add_access_path( - CurrentIdentifierState & identifier_state, - std::unique_ptr & n, - const rosidl_message_type_support_t * type_support_introspection) - { - const MembersType * members = - static_cast(type_support_introspection->data); - if (!members) { - throw std::runtime_error("The data in the type support introspection is invalid."); - } - - size_t member_index = 0; - size_t array_index = std::numeric_limits::max(); - - const ParseNode & name_node = n->left(); - std::string parse_node_name = name_node.content(); - - for (uint32_t i = 0; i < members->member_count_; ++i) { - const auto member = members->members_ + i; - - if (member->name_ == parse_node_name) { - member_index = i; - bool has_index = n->children.size() > 1; - if (member->is_array_) { - if (!has_index) { - throw parse_error("field should have an index (i.e. [n])", n->left().end()); - } - - array_index = static_cast(std::stoul(n->right().left().content())); - - if (member->array_size_ && !member->is_upper_bound_) { - if (member->array_size_ <= array_index) { - throw parse_error("index is greater than maximum size", n->right().end()); - } - } - } else { - if (has_index) { - throw parse_error("field is not an array or sequence", n->right().begin()); - } - } - - identifier_state.current_type = member->type_id_; - - if (member->type_id_ == ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE) { - identifier_state.current_type_support = member->members_; - } - - identifier_state.access_path.emplace_back( - FilterField::FieldAccessor{member_index, array_index, type_support_introspection}); - - return; - } - } - throw parse_error("field not found", name_node.begin()); - } - - static void add_member_access( - std::unique_ptr & n, - CurrentIdentifierState & identifier_state, - const rosidl_message_type_support_t * type_support) - { - const rosidl_message_type_support_t * type_support_introspection = - get_type_support_introspection(type_support); - if (!type_support_introspection) { - throw std::runtime_error("failed to get type support introspection"); - } - - if (type_support_introspection->typesupport_identifier == - rosidl_typesupport_introspection_c__identifier) - { - add_access_path( - identifier_state, n, type_support_introspection); - } else { - add_access_path( - identifier_state, n, type_support_introspection); - } - } - - static FilterValue::ValueKind get_value_kind( - uint8_t type_id, - const position & pos) - { - switch (type_id) { - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: - return FilterValue::ValueKind::BOOLEAN; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_CHAR: - return FilterValue::ValueKind::CHAR; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: - return FilterValue::ValueKind::STRING; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT8: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT16: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT32: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT64: - return FilterValue::ValueKind::SIGNED_INTEGER; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_OCTET: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT8: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT16: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT32: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT64: - return FilterValue::ValueKind::UNSIGNED_INTEGER; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: - return FilterValue::ValueKind::FLOAT_FIELD; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_DOUBLE: - return FilterValue::ValueKind::DOUBLE_FIELD; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_LONG_DOUBLE: - return FilterValue::ValueKind::LONG_DOUBLE_FIELD; - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: - case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: - break; - } - - throw parse_error("type is not primitive", pos); - } - - template - static void transform( - std::unique_ptr & n, - CurrentIdentifierState & state, - States &&... /*st*/) - { - if (n->is()) { - // Set data for fieldname node - n->field_kind = get_value_kind(state.current_type, n->end()); - n->field_access_path = state.access_path; - n->type_id = state.current_type; - - // Reset parser state - state.access_path.clear(); - state.current_type = 0; - state.current_type_support = nullptr; - } else { - if (0 == state.current_type) { - add_member_access(n, state, state.type_support); - } else { - add_member_access(n, state, state.current_type_support); - } - } - - n->children.clear(); - } -}; - -#endif // FILTEREXPRESSIONPARSERIMPL__IDENTIFIERS_HPP_ diff --git a/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp b/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp deleted file mode 100644 index c4d63a0..0000000 --- a/common_content_filter/src/FilterExpressionParserImpl/literal_values.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Group Corporation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file literal_values.hpp - * - * Note: this is an implementation file, designed to be included inside the - * FilterExpressionParser.hpp file of the parent folder. - */ - -#ifndef FILTEREXPRESSIONPARSERIMPL__LITERAL_VALUES_HPP_ -#define FILTEREXPRESSIONPARSERIMPL__LITERAL_VALUES_HPP_ - -#include -struct literal_value_processor - : parse_tree::apply -{ - template - static void transform( - std::unique_ptr & n, - States &&... /*st*/) - { - n->value.reset(new FilterValue()); - if (n->is()) { - n->value->kind = FilterValue::ValueKind::BOOLEAN; - n->value->boolean_value = true; - } else if (n->is()) { - n->value->kind = FilterValue::ValueKind::BOOLEAN; - n->value->boolean_value = false; - } else if (n->is() || n->is()) { - if (n->m_begin.data[0] == '-') { - n->value->kind = FilterValue::ValueKind::SIGNED_INTEGER; - n->value->signed_integer_value = std::stoll(n->content(), nullptr, 0); - } else { - n->value->kind = FilterValue::ValueKind::UNSIGNED_INTEGER; - n->value->unsigned_integer_value = std::stoull(n->content(), nullptr, 0); - } - } else if (n->is()) { - n->value->kind = FilterValue::ValueKind::FLOAT_CONST; - n->value->float_value = std::stold(n->content()); - } else if (n->is()) { - n->value->kind = FilterValue::ValueKind::CHAR; - n->value->char_value = n->m_begin.data[1]; - } else if (n->is()) { - const ParseNode & content_node = n->left(); - size_t str_len = content_node.m_end.byte - content_node.m_begin.byte; - if (sizeof(n->value->string_value) < str_len) { - throw parse_error("string constant has more than 255 characters", n->end()); - } - n->value->kind = FilterValue::ValueKind::STRING; - strncpy(n->value->string_value, content_node.m_begin.data, str_len); - } - - n->children.clear(); - } -}; - -#endif // FILTEREXPRESSIONPARSERIMPL__LITERAL_VALUES_HPP_ diff --git a/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp b/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp deleted file mode 100644 index cfdf584..0000000 --- a/common_content_filter/src/FilterExpressionParserImpl/parameters.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Group Corporation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file parameters.hpp - * - * Note: this is an implementation file, designed to be included inside the - * FilterExpressionParser.hpp file of the parent folder. - */ - -#ifndef FILTEREXPRESSIONPARSERIMPL__PARAMETERS_HPP_ -#define FILTEREXPRESSIONPARSERIMPL__PARAMETERS_HPP_ - -#include -struct parameter_processor - : parse_tree::apply -{ - template - static void transform( - std::unique_ptr & n, - States &&... /*st*/) - { - n->parameter_index = static_cast(n->m_begin.data[1] - '0'); - if (n->m_end.byte - n->m_begin.byte == 3) { - n->parameter_index *= 10; - n->parameter_index += static_cast(n->m_begin.data[2] - '0'); - } - } -}; - -#endif // FILTEREXPRESSIONPARSERIMPL__PARAMETERS_HPP_ diff --git a/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp b/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp deleted file mode 100644 index 686c170..0000000 --- a/common_content_filter/src/FilterExpressionParserImpl/rearrange.hpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// Copyright 2022 Sony Group Corporation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file rearrange.hpp - * - * Note: this is an implementation file, designed to be included inside the - * FilterExpressionParser.hpp file of the parent folder. - */ - -#ifndef FILTEREXPRESSIONPARSERIMPL__REARRANGE_HPP_ -#define FILTEREXPRESSIONPARSERIMPL__REARRANGE_HPP_ - -#include -#include -#include - -// after a node is stored successfully, you can add an optional transformer like this: -struct rearrange - : parse_tree::apply // allows bulk selection, see selector<...> -{ - // recursively rearrange nodes. the basic principle is: - // - // from: SEQ_BASED_RULE - // / | \ (LHS... may be one or more children, followed by OP,) - // LHS... OP RHS (which is one operator, and RHS, which is a single child) - // - // to: OP - // / \ (OP now has two children, the original PROD/EXPR and RHS) - // SEQ_BASED_RULE RHS (Note that PROD/EXPR has two fewer children now) - // | - // LHS... - // - // if only one child is left for LHS..., replace the SEQ_BASED_RULE with the child directly. - // otherwise, perform the above transformation, then apply it recursively until LHS... - // becomes a single child, which then replaces the parent node and the recursion ends. - template - static void transform( - std::unique_ptr & n, - States &&... st) - { - if (n->children.size() == 1) { - n = std::move(n->children.back()); - } else { - n->remove_content(); - auto & c = n->children; - auto r = std::move(c.back()); - c.pop_back(); - auto o = std::move(c.back()); - c.pop_back(); - if (c.empty()) { - o->children.emplace_back(std::move(r)); - n = std::move(o); - } else { - o->children.emplace_back(std::move(n)); - o->children.emplace_back(std::move(r)); - n = std::move(o); - transform(n->children.front(), st ...); - } - } - } -}; - -#endif // FILTEREXPRESSIONPARSERIMPL__REARRANGE_HPP_ From dbd5a02c1fa27063a441d2dc3226e96df5bc0b3f Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 10 Oct 2022 10:08:06 +0800 Subject: [PATCH 51/51] add missing files Signed-off-by: Chen Lihui --- .../identifiers.inc | 180 ++++++++++++++++++ .../literal_values.inc | 64 +++++++ .../FilterExpressionParserImpl/parameters.inc | 37 ++++ .../FilterExpressionParserImpl/rearrange.inc | 67 +++++++ 4 files changed, 348 insertions(+) create mode 100644 common_content_filter/src/FilterExpressionParserImpl/identifiers.inc create mode 100644 common_content_filter/src/FilterExpressionParserImpl/literal_values.inc create mode 100644 common_content_filter/src/FilterExpressionParserImpl/parameters.inc create mode 100644 common_content_filter/src/FilterExpressionParserImpl/rearrange.inc diff --git a/common_content_filter/src/FilterExpressionParserImpl/identifiers.inc b/common_content_filter/src/FilterExpressionParserImpl/identifiers.inc new file mode 100644 index 0000000..f9ad017 --- /dev/null +++ b/common_content_filter/src/FilterExpressionParserImpl/identifiers.inc @@ -0,0 +1,180 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Group Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file identifiers.inc + * + * Note: this is an implementation file, designed to be included inside the + * FilterExpressionParser.hpp file of the parent folder. + */ + +struct CurrentIdentifierState +{ + const rosidl_message_type_support_t * type_support; + + const rosidl_message_type_support_t * current_type_support; + + uint8_t current_type; + + std::vector access_path; +}; + +struct identifier_processor + : parse_tree::apply +{ + template + static void + add_access_path( + CurrentIdentifierState & identifier_state, + std::unique_ptr & n, + const rosidl_message_type_support_t * type_support_introspection) + { + const MembersType * members = + static_cast(type_support_introspection->data); + if (!members) { + throw std::runtime_error("The data in the type support introspection is invalid."); + } + + size_t member_index = 0; + size_t array_index = std::numeric_limits::max(); + + const ParseNode & name_node = n->left(); + std::string parse_node_name = name_node.content(); + + for (uint32_t i = 0; i < members->member_count_; ++i) { + const auto member = members->members_ + i; + + if (member->name_ == parse_node_name) { + member_index = i; + bool has_index = n->children.size() > 1; + if (member->is_array_) { + if (!has_index) { + throw parse_error("field should have an index (i.e. [n])", n->left().end()); + } + + array_index = static_cast(std::stoul(n->right().left().content())); + + if (member->array_size_ && !member->is_upper_bound_) { + if (member->array_size_ <= array_index) { + throw parse_error("index is greater than maximum size", n->right().end()); + } + } + } else { + if (has_index) { + throw parse_error("field is not an array or sequence", n->right().begin()); + } + } + + identifier_state.current_type = member->type_id_; + + if (member->type_id_ == ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE) { + identifier_state.current_type_support = member->members_; + } + + identifier_state.access_path.emplace_back( + FilterField::FieldAccessor{member_index, array_index, type_support_introspection}); + + return; + } + } + throw parse_error("field not found", name_node.begin()); + } + + static void add_member_access( + std::unique_ptr & n, + CurrentIdentifierState & identifier_state, + const rosidl_message_type_support_t * type_support) + { + const rosidl_message_type_support_t * type_support_introspection = + get_type_support_introspection(type_support); + if (!type_support_introspection) { + throw std::runtime_error("failed to get type support introspection"); + } + + if (type_support_introspection->typesupport_identifier == + rosidl_typesupport_introspection_c__identifier) + { + add_access_path( + identifier_state, n, type_support_introspection); + } else { + add_access_path( + identifier_state, n, type_support_introspection); + } + } + + static FilterValue::ValueKind get_value_kind( + uint8_t type_id, + const position & pos) + { + switch (type_id) { + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOLEAN: + return FilterValue::ValueKind::BOOLEAN; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_CHAR: + return FilterValue::ValueKind::CHAR; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: + return FilterValue::ValueKind::STRING; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT8: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT16: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT32: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_INT64: + return FilterValue::ValueKind::SIGNED_INTEGER; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_OCTET: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT8: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT16: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT32: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_UINT64: + return FilterValue::ValueKind::UNSIGNED_INTEGER; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_FLOAT: + return FilterValue::ValueKind::FLOAT_FIELD; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_DOUBLE: + return FilterValue::ValueKind::DOUBLE_FIELD; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_LONG_DOUBLE: + return FilterValue::ValueKind::LONG_DOUBLE_FIELD; + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WCHAR: + case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING: + break; + } + + throw parse_error("type is not primitive", pos); + } + + template + static void transform( + std::unique_ptr & n, + CurrentIdentifierState & state, + States &&... /*st*/) + { + if (n->is()) { + // Set data for fieldname node + n->field_kind = get_value_kind(state.current_type, n->end()); + n->field_access_path = state.access_path; + n->type_id = state.current_type; + + // Reset parser state + state.access_path.clear(); + state.current_type = 0; + state.current_type_support = nullptr; + } else { + if (0 == state.current_type) { + add_member_access(n, state, state.type_support); + } else { + add_member_access(n, state, state.current_type_support); + } + } + + n->children.clear(); + } +}; diff --git a/common_content_filter/src/FilterExpressionParserImpl/literal_values.inc b/common_content_filter/src/FilterExpressionParserImpl/literal_values.inc new file mode 100644 index 0000000..45c57d0 --- /dev/null +++ b/common_content_filter/src/FilterExpressionParserImpl/literal_values.inc @@ -0,0 +1,64 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Group Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file literal_values.inc + * + * Note: this is an implementation file, designed to be included inside the + * FilterExpressionParser.hpp file of the parent folder. + */ + +struct literal_value_processor + : parse_tree::apply +{ + template + static void transform( + std::unique_ptr & n, + States &&... /*st*/) + { + n->value.reset(new FilterValue()); + if (n->is()) { + n->value->kind = FilterValue::ValueKind::BOOLEAN; + n->value->boolean_value = true; + } else if (n->is()) { + n->value->kind = FilterValue::ValueKind::BOOLEAN; + n->value->boolean_value = false; + } else if (n->is() || n->is()) { + if (n->m_begin.data[0] == '-') { + n->value->kind = FilterValue::ValueKind::SIGNED_INTEGER; + n->value->signed_integer_value = std::stoll(n->content(), nullptr, 0); + } else { + n->value->kind = FilterValue::ValueKind::UNSIGNED_INTEGER; + n->value->unsigned_integer_value = std::stoull(n->content(), nullptr, 0); + } + } else if (n->is()) { + n->value->kind = FilterValue::ValueKind::FLOAT_CONST; + n->value->float_value = std::stold(n->content()); + } else if (n->is()) { + n->value->kind = FilterValue::ValueKind::CHAR; + n->value->char_value = n->m_begin.data[1]; + } else if (n->is()) { + const ParseNode & content_node = n->left(); + size_t str_len = content_node.m_end.byte - content_node.m_begin.byte; + if (sizeof(n->value->string_value) < str_len) { + throw parse_error("string constant has more than 255 characters", n->end()); + } + n->value->kind = FilterValue::ValueKind::STRING; + strncpy(n->value->string_value, content_node.m_begin.data, str_len); + } + + n->children.clear(); + } +}; diff --git a/common_content_filter/src/FilterExpressionParserImpl/parameters.inc b/common_content_filter/src/FilterExpressionParserImpl/parameters.inc new file mode 100644 index 0000000..2caece9 --- /dev/null +++ b/common_content_filter/src/FilterExpressionParserImpl/parameters.inc @@ -0,0 +1,37 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Group Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file parameters.inc + * + * Note: this is an implementation file, designed to be included inside the + * FilterExpressionParser.hpp file of the parent folder. + */ + +struct parameter_processor + : parse_tree::apply +{ + template + static void transform( + std::unique_ptr & n, + States &&... /*st*/) + { + n->parameter_index = static_cast(n->m_begin.data[1] - '0'); + if (n->m_end.byte - n->m_begin.byte == 3) { + n->parameter_index *= 10; + n->parameter_index += static_cast(n->m_begin.data[2] - '0'); + } + } +}; diff --git a/common_content_filter/src/FilterExpressionParserImpl/rearrange.inc b/common_content_filter/src/FilterExpressionParserImpl/rearrange.inc new file mode 100644 index 0000000..50c4ada --- /dev/null +++ b/common_content_filter/src/FilterExpressionParserImpl/rearrange.inc @@ -0,0 +1,67 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2022 Sony Group Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file rearrange.inc + * + * Note: this is an implementation file, designed to be included inside the + * FilterExpressionParser.hpp file of the parent folder. + */ + +// after a node is stored successfully, you can add an optional transformer like this: +struct rearrange + : parse_tree::apply // allows bulk selection, see selector<...> +{ + // recursively rearrange nodes. the basic principle is: + // + // from: SEQ_BASED_RULE + // / | \ (LHS... may be one or more children, followed by OP,) + // LHS... OP RHS (which is one operator, and RHS, which is a single child) + // + // to: OP + // / \ (OP now has two children, the original PROD/EXPR and RHS) + // SEQ_BASED_RULE RHS (Note that PROD/EXPR has two fewer children now) + // | + // LHS... + // + // if only one child is left for LHS..., replace the SEQ_BASED_RULE with the child directly. + // otherwise, perform the above transformation, then apply it recursively until LHS... + // becomes a single child, which then replaces the parent node and the recursion ends. + template + static void transform( + std::unique_ptr & n, + States &&... st) + { + if (n->children.size() == 1) { + n = std::move(n->children.back()); + } else { + n->remove_content(); + auto & c = n->children; + auto r = std::move(c.back()); + c.pop_back(); + auto o = std::move(c.back()); + c.pop_back(); + if (c.empty()) { + o->children.emplace_back(std::move(r)); + n = std::move(o); + } else { + o->children.emplace_back(std::move(n)); + o->children.emplace_back(std::move(r)); + n = std::move(o); + transform(n->children.front(), st ...); + } + } + } +};