diff --git a/examples/cpp/dds/IdlParserExample/CMakeLists.txt b/examples/cpp/dds/IdlParserExample/CMakeLists.txt deleted file mode 100644 index ff3e23004ee..00000000000 --- a/examples/cpp/dds/IdlParserExample/CMakeLists.txt +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright 2024 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. - -cmake_minimum_required(VERSION 3.20) - -project(IdlParserExample VERSION 1 LANGUAGES CXX) - -# Find requirements -if(NOT fastcdr_FOUND) -find_package(fastcdr 2 REQUIRED) -endif() - -if(NOT fastdds_FOUND) -find_package(fastdds 3 REQUIRED) -endif() - -# Check C++11 -include(CheckCXXCompilerFlag) -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - check_cxx_compiler_flag(-std=c++11 SUPPORTS_CXX11) - check_cxx_compiler_flag(-std=c++11 SUPPORTS_CXX11) - if(NOT SUPPORTS_CXX11) - message(FATAL_ERROR "Compiler doesn't support C++11") - endif() -endif() - -message(STATUS "Configuring IDL parser example...") -file(GLOB DDS_IDL_PARSER_EXAMPLE_SOURCES_CPP "*.cpp") - -include_directories( - ../../../../thirdparty/taocpp-pegtl/ - ../../../../src/cpp/fastdds/xtypes/dynamic_types/ -) - -add_executable(IdlParserExample - ${DDS_IDL_PARSER_EXAMPLE_SOURCES_CPP}) - -target_compile_definitions(IdlParserExample PRIVATE - $<$>,$>:__DEBUG> - $<$:__INTERNALDEBUG> # Internal debug activated. -) - -# Put executable in directory where CMake files are being generated -if(MSVC) - set_target_properties(IdlParserExample PROPERTIES - RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}) -endif() - -# Copy IDL files -configure_file( - ${PROJECT_SOURCE_DIR}/idl/test01.idl - ${PROJECT_BINARY_DIR}/idl/test01.idl - COPYONLY) -configure_file( - ${PROJECT_SOURCE_DIR}/idl/test02.idl - ${PROJECT_BINARY_DIR}/idl/test02.idl - COPYONLY) -configure_file( - ${PROJECT_SOURCE_DIR}/idl/test03.idl - ${PROJECT_BINARY_DIR}/idl/test03.idl - COPYONLY) -configure_file( - ${PROJECT_SOURCE_DIR}/idl/test04.idl - ${PROJECT_BINARY_DIR}/idl/test04.idl - COPYONLY) -configure_file( - ${PROJECT_SOURCE_DIR}/idl/include/test_include.idl - ${PROJECT_BINARY_DIR}/idl/include/test_include.idl - COPYONLY) - -target_link_libraries(IdlParserExample fastdds fastcdr) -install(TARGETS IdlParserExample - RUNTIME DESTINATION examples/cpp/dds/IdlParserExample/${BIN_INSTALL_DIR}) diff --git a/examples/cpp/dds/IdlParserExample/IdlParser_main.cpp b/examples/cpp/dds/IdlParserExample/IdlParser_main.cpp deleted file mode 100644 index e6215b91aab..00000000000 --- a/examples/cpp/dds/IdlParserExample/IdlParser_main.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2024 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 IdlParser_main.cpp - * - */ - -#define FASTDDS_ENFORCE_LOG_INFO - -#include -#include - -#include - -using namespace eprosima::fastdds::dds; -using eprosima::fastdds::dds::Log; - -int main( - int argc, - char** argv) -{ - Log::SetVerbosity(Log::Kind::Info); - Log::SetCategoryFilter(std::regex("IDLPARSER")); - - std::cout << "Processing forward declarations:" << std::endl; - std::string test00 = - R"( - struct StructDcl; - union UnionDcl; - )"; - DynamicType::_ref_type fwd_dcl_type = DynamicTypeBuilderFactory::get_instance()->create_type_w_idl(test00)->build(); - if (nullptr != fwd_dcl_type) - { - EPROSIMA_LOG_INFO(IDLPARSER, "Succeeded to create DynamicType from IDL: " << test00); - } - else - { - EPROSIMA_LOG_ERROR(IDLPARSER, "Failed to create DynamicType from IDL: " << test00); - } - - std::cout << "Processing literals, expressions, and consts:" << std::endl; - std::string test01 = - R"( - // boolean literals in IDL are case sensitive and should be exactly TRUE or FALSE - const boolean C_BOOL = TRUE; - const string<100> C_STR = "hello"; - const int32 C_LITERALS1 = (0x5 | (4 + 3)) + (4 << 1) * 2; // 23 - const int32 C_LITERALS2 = (02 + 0x1) * 2; // 6 - const int32 C_LITERALS3 = 4 / ( 07 & 0x2 ); // 2 - const int32 C_LITERALS4 = -(5 * ( 03 + 0xF )); // -90 - const int32 C_LITERALS5 = 0xf0 & ~(4 * ( 0x7 - 02 )); // 224 - const int32 C_LITERALS6 = (0x7 | 0x9) & ~(6 * ( 024 - 5 )); // 5 - const float C_LITERALS7 = (2 + 4) / 3.0d; /* 2.0 */ - const float C_LITERALS8 = (2e0 + 4) / 3.0d; /* 2.0 */ - )"; - DynamicTypeBuilder::_ref_type null_builder = DynamicTypeBuilderFactory::get_instance()->create_type_w_idl(test01); - - std::string test02 = - R"( - struct Test02 - { - long my_long; - short my_short; - long long my_llong; - int32 my_int; - unsigned short my_ushort; - unsigned long my_ulong; - long double my_ldouble; - float my_float; - double my_double; - }; - )"; - DynamicType::_ref_type struct_type = DynamicTypeBuilderFactory::get_instance()->create_type_w_idl(test02)->build(); - if (nullptr != struct_type) - { - EPROSIMA_LOG_INFO(IDLPARSER, "Succeeded to create DynamicType from IDL: " << test02); - } - else - { - EPROSIMA_LOG_ERROR(IDLPARSER, "Failed to create DynamicType from IDL: " << test02); - } - - std::string test03 = - R"( - enum e_test { a, b, c }; - )"; - DynamicType::_ref_type enum_type = DynamicTypeBuilderFactory::get_instance()->create_type_w_idl(test03)->build(); - if (nullptr != enum_type) - { - EPROSIMA_LOG_INFO(IDLPARSER, "Succeeded to create DynamicType from IDL: " << test03); - } - else - { - EPROSIMA_LOG_ERROR(IDLPARSER, "Failed to create DynamicType from IDL: " << test03); - } - - std::string test04 = - R"( - struct Point { - float x; - float y; - float z; - }; - typedef Point PointAlias; - typedef Point PointArrayOf10[ 10 /**/]; - typedef PointAlias TwoDimPointArray[5][3]; - )"; - DynamicType::_ref_type alias_type = DynamicTypeBuilderFactory::get_instance()->create_type_w_idl(test04)->build(); - if (nullptr != alias_type) - { - EPROSIMA_LOG_INFO(IDLPARSER, "Succeeded to create DynamicType from IDL: " << test04); - } - else - { - EPROSIMA_LOG_ERROR(IDLPARSER, "Failed to create DynamicType from IDL: " << test04); - } - - std::string test05 = - R"( - union MyUnion switch (int32) { - case 0: - case 1: - long myLong; - case 2: - double myDouble; - default: - char myChar; - }; - )"; - DynamicType::_ref_type union_type = DynamicTypeBuilderFactory::get_instance()->create_type_w_idl(test05)->build(); - if (nullptr != union_type) - { - EPROSIMA_LOG_INFO(IDLPARSER, "Succeeded to create DynamicType from IDL: " << test05); - } - else - { - EPROSIMA_LOG_ERROR(IDLPARSER, "Failed to create DynamicType from IDL: " << test05); - } - - Log::Flush(); - Log::Reset(); - - return 0; -} diff --git a/examples/cpp/dds/IdlParserExample/idl/include/test_include.idl b/examples/cpp/dds/IdlParserExample/idl/include/test_include.idl deleted file mode 100644 index 3ee354959be..00000000000 --- a/examples/cpp/dds/IdlParserExample/idl/include/test_include.idl +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -module include -{ - struct TestInclude - { - string my_string; - }; -}; diff --git a/examples/cpp/dds/IdlParserExample/idl/test01.idl b/examples/cpp/dds/IdlParserExample/idl/test01.idl deleted file mode 100644 index 8402fa48c83..00000000000 --- a/examples/cpp/dds/IdlParserExample/idl/test01.idl +++ /dev/null @@ -1,8 +0,0 @@ -const float C_FLOAT = 3.141592; - -struct Test01 -{ - long my_long; - short my_short; - long long my_long_long; -}; diff --git a/examples/cpp/dds/IdlParserExample/idl/test02.idl b/examples/cpp/dds/IdlParserExample/idl/test02.idl deleted file mode 100644 index 0768d6b9e13..00000000000 --- a/examples/cpp/dds/IdlParserExample/idl/test02.idl +++ /dev/null @@ -1,6 +0,0 @@ -#include "include/test_include.idl" - -struct Test02 -{ - include::TestInclude my_include; -}; diff --git a/examples/cpp/dds/IdlParserExample/idl/test03.idl b/examples/cpp/dds/IdlParserExample/idl/test03.idl deleted file mode 100644 index c4fddec539c..00000000000 --- a/examples/cpp/dds/IdlParserExample/idl/test03.idl +++ /dev/null @@ -1,6 +0,0 @@ -#include - -struct Test03 -{ - include::TestInclude my_include; -}; diff --git a/examples/cpp/dds/IdlParserExample/idl/test04.idl b/examples/cpp/dds/IdlParserExample/idl/test04.idl deleted file mode 100644 index abcb6144273..00000000000 --- a/examples/cpp/dds/IdlParserExample/idl/test04.idl +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include "test03.idl" - -struct Test04 -{ - include::TestInclude my_include; - Test03 my_test03; -};