### Compile and Run Basic Example Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Demonstrates how to compile and run a basic C++ program using string-view-lite. Ensure you have g++ installed and the library header is accessible. ```bash prompt> g++ -Wall -std=c++14 -I../include/ -o 01-basic.exe 01-basic.cpp && 01-basic.exe hello, world! ``` -------------------------------- ### Installation Rules Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/clsocket/CMakeLists.txt Configures installation rules for the library and headers when not building as a dependency. ```cmake # install into configured prefix if(NOT CLSOCKET_DEP_ONLY) install(TARGETS clsocket ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) install(FILES ${CLSOCKET_HEADERS} DESTINATION include) else() endif() ``` -------------------------------- ### Install Libraries and Archives Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/main/CMakeLists.txt Configures the installation paths for libraries and archives based on the detected platform and build configuration. ```cmake ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBS}/Linux/${PLATFORM}/$/" RUNTIME DESTINATION "${CMAKE_INSTALL_LIBS}/Linux/${PLATFORM}/$/" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBS}/Linux/${PLATFORM}/$/" ) ``` -------------------------------- ### Install Export Header Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/main/CMakeLists.txt Installs the generated rd_framework_export.h header file to the public header installation path. ```cmake install(FILES ${CMAKE_CURRENT_BINARY_DIR}/rd_framework_export.h DESTINATION "${CMAKE_INSTALL_PUBLIC_HEADER}/rd_framework_cpp" ) ``` -------------------------------- ### Install Headers Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/clsocket/CMakeLists.txt Installs header files to a specified destination. ```cmake install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION "${CMAKE_INSTALL_PUBLIC_HEADER_THIRDPARTY}/clsocket" CONFIGURATIONS Release FILES_MATCHING PATTERN *.h PATTERN *.hpp ) ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/CMakeLists.txt Initializes CMake version, names the project, and defines build options for tests and documentation. ```cmake cmake_minimum_required(VERSION 3.5) project(optional) option(OPTIONAL_ENABLE_TESTS "Enable tests." OFF) option(OPTIONAL_ENABLE_DOCS "Enable documentation." OFF) ``` -------------------------------- ### Install Public Headers Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/main/CMakeLists.txt Installs header files from the source directory to the public header installation path. ```cmake install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION "${CMAKE_INSTALL_PUBLIC_HEADER}/rd_framework_cpp" CONFIGURATIONS Debug Release FILES_MATCHING PATTERN *.h PATTERN *.hpp ) ``` -------------------------------- ### Platform-Specific Installation (Windows) Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/main/CMakeLists.txt Installs the rd_framework_cpp, rd_core_cpp, and spdlog targets to specific directories on Windows, differentiating between 32-bit and 64-bit platforms and Release/Debug configurations. ```cmake if (WIN32) if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") SET(PLATFORM "x86") elseif ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8") SET(PLATFORM "x64") endif () install(TARGETS rd_framework_cpp rd_core_cpp spdlog CONFIGURATIONS Release Debug ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBS}/Win/${PLATFORM}/$/" RUNTIME DESTINATION "${CMAKE_INSTALL_LIBS}/Win/${PLATFORM}/$/" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBS}/Win/${PLATFORM}/$/" ) elseif (APPLE) SET(PLATFORM "x64") install(TARGETS rd_framework_cpp rd_core_cpp spdlog CONFIGURATIONS Release Debug ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBS}/Mac/${PLATFORM}/$/" RUNTIME DESTINATION "${CMAKE_INSTALL_LIBS}/Mac/${PLATFORM}/$/" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBS}/Mac/${PLATFORM}/$/" ) elseif (UNIX) SET(PLATFORM "x64") install(TARGETS rd_framework_cpp rd_core_cpp spdlog CONFIGURATIONS Release Debug ``` -------------------------------- ### Installing Optional Library Headers Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/CMakeLists.txt Installs the header files for the optional library to a public header directory for release configurations. ```cmake install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION "${CMAKE_INSTALL_PUBLIC_HEADER_THIRDPARTY}/optional" CONFIGURATIONS Release FILES_MATCHING PATTERN *.h PATTERN *.hpp ) ``` -------------------------------- ### Example Executable Definitions (Unix) Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/clsocket/CMakeLists.txt Defines example executables if the option is enabled, linking them against clsocket and other necessary libraries. ```cmake if(UNIX) OPTION(CLSOCKET_EXAMPLES "Build the examples" OFF) if(CLSOCKET_EXAMPLES) ADD_EXECUTABLE(clsocket-example examples/RecvAsync.cpp) TARGET_LINK_LIBRARIES(clsocket-example clsocket pthread) if(NOT CLSOCKET_DEP_ONLY) install(TARGETS clsocket-example DESTINATION bin) endif() ADD_EXECUTABLE(querydaytime-example examples/QueryDayTime.cpp) TARGET_LINK_LIBRARIES(querydaytime-example clsocket) ADD_EXECUTABLE(echoserver-example examples/EchoServer.cpp) TARGET_LINK_LIBRARIES(echoserver-example clsocket) endif() endif() ``` -------------------------------- ### UTF-8/16/32 Conversion Example Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/utf-cpp/README.md Demonstrates converting between UTF-8, UTF-16, UTF-32, and wide character strings using the library's conversion functions. Includes examples of direct conversion and conversion via intermediate types. ```cpp // यूनिकोड static char const u8s[] = "\xE0\xA4\xAF\xE0\xA5\x82\xE0\xA4\xA8\xE0\xA4\xBF\xE0\xA4\x95\xE0\xA5\x8B\xE0\xA4\xA1"; using namespace ww898::utf; std::u16string u16; convz, utf16>(u8s, std::back_inserter(u16)); std::u32string u32; conv>(u16.begin(), u16.end(), std::back_inserter(u32)); std::vector u8; convz(u32.data(), std::back_inserter(u8)); std::wstring uw; conv(u8s, u8s + sizeof(u8s), std::back_inserter(uw)); auto u8r = conv(uw); auto u16r = conv(u16); auto uwr = convz(u8s); auto u32r = conv(std::string_view(u8r.data(), u8r.size())); // C++17 only static_assert(std::is_same, utf_selector>::value, "Fail"); static_assert( std::is_same, utf_selector_t>::value != std::is_same, utf_selector_t>::value, "Fail"); ``` -------------------------------- ### C++ CountdownLatch Example Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/countdownlatch/README.md Demonstrates how to use the CountdownLatch library in C++ for thread synchronization. It shows threads waiting for a set of operations to complete. ```c++ #include #include #include #include #include void fun(clatch::countdownlatch *cl) { cl->await(); std::cout << "Wait is over " << std::endl; } int main() { auto cl = new clatch::countdownlatch(10); int i = 0; std::vector ts; while (i++ < 2) { std::thread *t = new std::thread(fun, cl); ts.push_back(t); } i = 0; while (i++ < 10) { sleep(1); cl->count_down(); } i = 0; while (i < 2) { ts[i++]->join(); } i = 0; while (i < 2) { delete ts[i++]; } delete cl; return 0; } ``` -------------------------------- ### Using map_or_else with a default function Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/README.md Demonstrates 'map_or_else', which applies a function if a value exists, otherwise returns the result of a provided default function. This example gets the size of an optional string or calls a 'get_default' function. ```C++ std::size_t get_default(); tl::optional s = opt_string.map_or(&std::string::size, get_default); ``` -------------------------------- ### Configure Maven Central Repository in settings.gradle.kts Source: https://github.com/jetbrains/rd/blob/master/docs/rd-gen.md Add the Maven Central repository to your `settings.gradle.kts` to allow installation of plugins from Maven Central. ```kotlin // settings.gradle.kts pluginManagement { repositories { gradlePluginPortal() mavenCentral() } resolutionStrategy { eachPlugin { if (requested.id.id == "com.jetbrains.rdgen") { useModule("com.jetbrains.rd:rd-gen:${requested.version}") } } } } ``` -------------------------------- ### Using take to extract value and empty optional Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/README.md Demonstrates the 'take' function, which returns the contained value and leaves the optional empty. This example shows taking the value and then mapping its size. ```C++ opt_string.take().map(&std::string::size); //opt_string now empty; ``` -------------------------------- ### Install Variant for CMake find_package Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/variant/README.md Install MPark.Variant to a custom location using CMake and CMAKE_INSTALL_PREFIX. This allows CMake's find_package to locate the library. ```bash git clone https://github.com/mpark/variant.git mkdir variant/build && cd variant/build cmake .. cmake --build . --target install ``` -------------------------------- ### Using and_then for optional-returning functions Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/README.md Demonstrates the 'and_then' function, suitable for operations that themselves return an optional. This example uses a hypothetical 'stoi' function that converts a string to an optional integer. ```C++ tl::optional stoi (const std::string& s); tl::optional i = opt_string.and_then(stoi); ``` -------------------------------- ### Show Template Tree in Diagnostics Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/main/CMakeLists.txt Sets a public link option to display the template tree in diagnostics. This is a commented-out example. ```cmake #target_link_options(rd_framework_cpp PUBLIC -fdiagnostics-show-template-tree) ``` -------------------------------- ### Define a Root Model in RdGen Source: https://github.com/jetbrains/rd/blob/master/docs/rd-gen.md This snippet shows the basic structure for defining a root model, which serves as the starting point for protocol definitions in RdGen. ```kotlin object ExampleRoot : Root() ``` -------------------------------- ### Using or_else to provide fallback behavior Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/README.md Shows the 'or_else' function, which executes a provided function only if the optional object is empty. This example demonstrates throwing an exception when no value is present. ```C++ opt.or_else([] { throw std::runtime_error{"oh no"}; }); ``` -------------------------------- ### Using disjunction with tl::optional Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/README.md Illustrates the 'disjunction' function, which returns the optional's value if present, otherwise returns its argument. Examples show behavior with and without a value. ```C++ tl::make_optional(42).disjunction(13); //42 tl::optional{}.disjunction(13); //13 ``` -------------------------------- ### Using conjunction with tl::optional Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/README.md Shows the 'conjunction' function, which returns its argument if the optional has a value, otherwise returns an empty optional. Examples demonstrate behavior with and without a value. ```C++ tl::make_optional(42).conjunction(13); //13 tl::optional){}.conjunction(13); //empty ``` -------------------------------- ### Rebinding optional reference assignment Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/README.md Illustrates the assignment behavior for optional references, where assignment rebinds the reference to a new object rather than assigning through the existing reference. This example shows rebinding to a different integer. ```C++ int j = 8; o = j; &*o == &j; //true ``` -------------------------------- ### Using map_or with a default value Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/README.md Illustrates 'map_or', which applies a function if a value exists, otherwise returns a specified default value. This example gets the size of an optional string or returns 0. ```C++ tl::optional s = opt_string.map_or(&std::string::size, 0); ``` -------------------------------- ### Using map to transform optional value Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/README.md Illustrates the 'map' function, which applies a given function to the contained value if the optional object holds one. This example shows getting the size of an optional string. ```C++ tl::optional s = opt_string.map(&std::string::size); ``` -------------------------------- ### Build .NET Solution Source: https://github.com/jetbrains/rd/blob/master/README.md Builds the .NET solution for the RD framework. Requires .NET Framework >= 3.5. ```bash dotnet build rd-net/Rd.sln ``` -------------------------------- ### Basic string_view Usage Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Demonstrates how to use string_view with different string types like C-strings, std::string, and string_view literals. ```C++ #include "nonstd/string_view.hpp" #include using namespace std::literals; using namespace nonstd::literals; using namespace nonstd; void write( string_view sv ) { std::cout << sv; } int main() { write( "hello" ); // C-string write( ", "s ); // std::string write( "world!"_sv ); // nonstd::string_view } ``` -------------------------------- ### Build All Projects Source: https://github.com/jetbrains/rd/blob/master/README.md Builds all projects in the RD framework using Gradle. ```bash ./gradlew build ``` -------------------------------- ### Generating Documentation with Standardese Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/CMakeLists.txt Finds the Standardese tool and generates documentation for the optional library if documentation is enabled. ```cmake if(OPTIONAL_ENABLE_DOCS) find_package(standardese) # find standardese after installation # generates a custom target that will run standardese to generate the documentation if(standardese_FOUND) standardese_generate(optional INCLUDE_DIRECTORY tl CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/standardese.config INPUT tl/optional.hpp) endif() endif() ``` -------------------------------- ### Find First Character Not Of (C-String) Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Searches for the first character not equal to any character in a C-string, starting from a given position. ```cpp string_view: Allows to search for the first character not equal to any of the characters specified in a C-string, starting at position pos via find_first_not_of(), (4) ``` -------------------------------- ### Find Last Character Not Of (C-String) Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Searches backwards for the first character not equal to any character in a C-string, starting from a given position. ```cpp string_view: Allows to search backwards for the first character not equal to any of the characters specified in a C-string, starting at position pos via find_last_not_of(), (4) ``` -------------------------------- ### Basic CMake Configuration Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/clsocket/CMakeLists.txt Sets the minimum CMake version and project name. Includes policy settings for compatibility. ```cmake cmake_minimum_required(VERSION 3.5 FATAL_ERROR) if (POLICY CMP0048) # cmake warns if loaded from a min-3.0-required parent dir, so silence the warning: cmake_policy(SET CMP0048 NEW) endif() project(clsocket) ``` -------------------------------- ### Find First Character Not Of (Specific Character) Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Searches for the first character not equal to a specified character, starting from a given position. ```cpp string_view: Allows to search for the first character not equal to the specified character, starting at position pos (default: 0) via find_first_not_of(), (2) ``` -------------------------------- ### Building and Running tsl::ordered_map Tests Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/ordered-map/README.md Provides the command-line steps to clone the ordered-map repository, navigate to the tests directory, configure with CMake, build the tests, and run them. ```bash git clone https://github.com/Tessil/ordered-map.git cd ordered-map/tests mkdir build cd build cmake .. cmake --build . ./tsl_ordered_map_tests ``` -------------------------------- ### Configuring Tests with Catch2 Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/CMakeLists.txt Sets up the Catch2 testing framework and compiles the test executable if tests are enabled. ```cmake if(OPTIONAL_ENABLE_TESTS) # Prepare "Catch" library for other executables set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test) add_library(Catch INTERFACE) target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR}) # Make test executable set(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tests/main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/noexcept.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/make_optional.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/in_place.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/relops.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/observers.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/extensions.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/emplace.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/constexpr.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/constructors.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/assignment.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/issues.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/bases.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/nullopt.cpp) add_executable(tests ${TEST_SOURCES}) target_link_libraries(tests Catch optional) set(CXXSTD 14 CACHE STRING "C++ standard to use, default C++14") set_property(TARGET tests PROPERTY CXX_STANDARD ${CXXSTD}) endif() ``` -------------------------------- ### Build C++ Project (Windows) Source: https://github.com/jetbrains/rd/blob/master/README.md Builds the experimental C++ part of the RD framework on Windows using a build script. Requires git, cmake, and Visual Studio 2015+. ```bash cd rd-cpp ./build.cmd ``` -------------------------------- ### Define Executable and Link Libraries Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/test/kotlin_interaction/CMakeLists.txt Configures the build system to create an executable from 'test.cpp' and links it against the necessary RD Framework and testing utility libraries. ```cmake add_executable(kotlin_interaction_test test.cpp) target_link_libraries(kotlin_interaction_test rd_framework_cpp rd_core_cpp_test_util) ``` -------------------------------- ### Define an Enum Type Source: https://github.com/jetbrains/rd/blob/master/docs/rd-gen.md Example of defining an enumeration with several string values. Enums are used for a fixed set of named constants. ```kotlin val MyEnum = enum { +"zero" +"two" +"three" +"five" +"six" } ``` -------------------------------- ### Set Template Backtrace Limit Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/main/CMakeLists.txt Sets a public compile option to limit the depth of template backtraces during compilation. This is a commented-out example. ```cmake #target_compile_options(rd_framework_cpp PUBLIC -ftemplate-backtrace-limit=100) ``` -------------------------------- ### Build C++ Project (Unix-like) Source: https://github.com/jetbrains/rd/blob/master/README.md Builds the experimental C++ part of the RD framework using CMake. Requires git, cmake, and clang 6.0+. ```bash cd rd-cpp cmake .. make ``` -------------------------------- ### Find Last Character Not Of (Specific Character) Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Searches backwards for the first character not equal to a specified character, starting from a given position. ```cpp string_view: Allows to search backwards for the first character not equal to the specified character, starting at position pos (default: npos) via find_last_not_of(), (2) ``` -------------------------------- ### Find First Character Not Of (String View) Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Searches for the first character not present in a specified string view, starting from a given position. ```cpp string_view: Allows to search for the first character not specified in a string view, starting at position pos (default: 0) via find_first_not_of(), (1) ``` -------------------------------- ### Source and Header Files Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/clsocket/CMakeLists.txt Lists the header and source files for the clsocket library. ```cmake SET(CLSOCKET_HEADERS src/ActiveSocket.h src/Host.h src/PassiveSocket.h src/SimpleSocket.h src/StatTimer.h src/SimpleSocketSender.h ) SET(CLSOCKET_SOURCES src/SimpleSocket.cpp src/ActiveSocket.cpp src/PassiveSocket.cpp src/SimpleSocketSender.cpp ) ``` -------------------------------- ### Create string_view via "_sv" literal with namespace Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Creates a string_view using the "_sv" literal, with specific namespace usage. ```cpp string_view: Allows to create a string_view via literal "_sv", using namespace nonstd::literals::string_view_literals ``` ```cpp string_view: Allows to create a string_view via literal "_sv", using namespace nonstd::string_view_literals ``` ```cpp string_view: Allows to create a string_view via literal "_sv", using namespace nonstd::literals ``` -------------------------------- ### Build Visual Studio 2017 Project Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/README.md Clones the repository, checks out the rd-cpp branch, and sets up the build environment for Visual Studio 2017 using CMake. Includes cloning external dependencies. ```bash git clone https://github.com/JetBrains/rd.git cd rd git checkout --track origin/rd-cpp cd rd-cpp git clone https://github.com/TartanLlama/optional.git git clone https://github.com/mpark/variant.git git clone https://github.com/google/googletest.git mkdir build cd build cmake -G "Visual Studio 15 2017" .. cmake --build . --config Release ``` -------------------------------- ### Find Last Character Not Of (String View) Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Searches backwards for the first character not present in a specified string view, starting from a given position. ```cpp string_view: Allows to search backwards for the first character not specified in a string view, starting at position pos (default: npos) via find_last_not_of(), (1) ``` -------------------------------- ### Define Base and Derived Structs Source: https://github.com/jetbrains/rd/blob/master/docs/rd-gen.md Demonstrates how to define a base struct and a derived struct that inherits from it. Use structs for simple data objects. ```kotlin val BaseStruct = basestruct { field("baseField", PredefinedType.int) } val DerivedStruct = structdef extends BaseStruct { field("derivedField", PredefinedType.bool) } ``` -------------------------------- ### Find First Character Not Of (C-String, Length) Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Searches for the first character not equal to any character in a C-string of a specified length, starting from a given position. ```cpp string_view: Allows to search for the first character not equal to any of the characters specified in a C-string, starting at position pos and of length n via find_first_not_of(), (3) ``` -------------------------------- ### Find Last Character Not Of (C-String, Length) Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Searches backwards for the first character not equal to any character in a C-string of a specified length, starting from a given position. ```cpp string_view: Allows to search backwards for the first character not equal to any of the characters specified in a C-string, starting at position pos and of length n via find_last_not_of(), (3) ``` -------------------------------- ### Build NuGet Packages Source: https://github.com/jetbrains/rd/blob/master/README.md Builds NuGet packages for the RD framework. This script currently works only on Linux. ```bash rd-kt/rd-gen/pack.sh ``` -------------------------------- ### Create Build Directory Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Create a directory for build outputs. This step is part of the CMake build process for string-view-lite. ```shell cd c:\string-view-lite md build-win-x86-vc10 cd build-win-x86-vc10 ``` -------------------------------- ### Select nonstd::string_view as nonstd::string_view Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Define `nssv_CONFIG_SELECT_STRING_VIEW` to `nssv_STRING_VIEW_NONSTD` to use string-view lite's `nonstd::string_view` as `nonstd::string_view`. ```c++ #define nssv_CONFIG_SELECT_STRING_VIEW nssv_STRING_VIEW_NONSTD ``` -------------------------------- ### Find Variant with CMake find_package Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/variant/README.md Use CMake's find_package command to locate and link MPark.Variant in your project. Specify CMAKE_PREFIX_PATH if the library is installed in a custom location. ```cmake cmake_minimum_required(VERSION 3.6.3) project(HelloWorld CXX) find_package(mpark_variant 1.3.0 REQUIRED) add_executable(hello-world hello_world.cpp) target_link_libraries(hello-world mpark_variant) ``` -------------------------------- ### Build Options Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/clsocket/CMakeLists.txt Defines options for building a shared library and for use as a dependency. ```cmake OPTION(CLSOCKET_SHARED "Build clsocket lib as shared." OFF) OPTION(CLSOCKET_DEP_ONLY "Build for use inside other CMake projects as dependency." ON) ``` -------------------------------- ### Interning Strings within a Struct for Protocol Lifetime Source: https://github.com/jetbrains/rd/blob/master/docs/rd-gen.md Example of defining a struct where string fields are interned for the lifetime of the entire protocol. This reduces traffic by sending values only once. ```kotlin map("issues", PredefinedType.int, structdef("ProtocolWrappedStringModel") { // These strings will be interned for the lifetime of the whole protocol: field("text", PredefinedType.string.interned(ProtocolInternScope)) }) ``` -------------------------------- ### Configure RdGenTask Classpath and Outputs Source: https://github.com/jetbrains/rd/blob/master/docs/rd-gen.md Configure the `RdGenTask` to include the runtime classpath and specify the output directories for generated code. ```kotlin tasks.withType { val classPath = sourceSets["main"].runtimeClasspath inputs.files(classPath) outputs.dirs(csOutput, ktOutput) classpath(classPath) } ``` -------------------------------- ### Create string_view via "_sv" literal Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Creates string_view, wstring_view, u16string_view, and u32string_view using the "_sv" literal. ```cpp string_view: Allows to create a string_view, wstring_view, u16string_view, u32string_view via literal "_sv" ``` -------------------------------- ### Create string_view via "sv" literal with namespace Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Creates a string_view using the "sv" literal, with specific namespace usage. ```cpp string_view: Allows to create a string_view via literal "sv", using namespace nonstd::literals::string_view_literals ``` ```cpp string_view: Allows to create a string_view via literal "sv", using namespace nonstd::string_view_literals ``` ```cpp string_view: Allows to create a string_view via literal "sv", using namespace nonstd::literals ``` -------------------------------- ### Define Static Library and Source Files Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_core_cpp/src/test/util/CMakeLists.txt Defines a static library named 'rd_core_cpp_test_util' and lists its source and header files. ```cmake add_library(rd_core_cpp_test_util STATIC filesystem.cpp filesystem.h) ``` -------------------------------- ### Handle Unsupported OS Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/main/CMakeLists.txt Exits the build process with a fatal error if the operating system is not supported. ```cmake else () message(FATAL_ERROR "OS not supported") endif () ``` -------------------------------- ### Create string_view via "sv" literal Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Creates string_view, wstring_view, u16string_view, and u32string_view using the "sv" literal. ```cpp string_view: Allows to create a string_view, wstring_view, u16string_view, u32string_view via literal "sv" ``` -------------------------------- ### Define Base and Derived Classes Source: https://github.com/jetbrains/rd/blob/master/docs/rd-gen.md Illustrates the definition of a base class and a derived class, showcasing inheritance. Classes can contain reactive members and support inheritance. ```kotlin val BaseClass = baseclass { field("baseField", PredefinedType.int) } val DerivedClass = classdef extends BaseClass { field("derivedField", PredefinedType.bool) } ``` -------------------------------- ### Defining the Optional Library Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/CMakeLists.txt Creates an interface library for 'optional' and specifies its source files and include directories. ```cmake add_library(optional INTERFACE) target_sources(optional INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/tl/optional.hpp) target_include_directories(optional INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/tl) ``` -------------------------------- ### Basic Operations with tsl::ordered_map and tsl::ordered_set Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/ordered-map/README.md Demonstrates fundamental operations like insertion, deletion, iteration, and lookup in tsl::ordered_map. Also shows basic usage of tsl::ordered_set. ```c++ #include #include #include #include #include int main() { tsl::ordered_map map = {{'d', 1}, {'a', 2}, {'g', 3}}; map.insert({'b', 4}); map['h'] = 5; map['e'] = 6; map.erase('a'); // {d, 1} {g, 3} {b, 4} {h, 5} {e, 6} for(const auto& key_value : map) { std::cout << "{" << key_value.first << ", " << key_value.second << "}" << std::endl; } map.unordered_erase('b'); // Break order: {d, 1} {g, 3} {e, 6} {h, 5} for(const auto& key_value : map) { std::cout << "{" << key_value.first << ", " << key_value.second << "}" << std::endl; } for(auto it = map.begin(); it != map.end(); ++it) { //it->second += 2; // Not valid. it.value() += 2; } if(map.find('d') != map.end()) { std::cout << "Found 'd'." << std::endl; } const std::size_t precalculated_hash = std::hash()('d'); // If we already know the hash beforehand, we can pass it as argument to speed-up the lookup. if(map.find('d', precalculated_hash) != map.end()) { std::cout << "Found 'd' with hash " << precalculated_hash << "." << std::endl; } tsl::ordered_set, std::equal_to, std::allocator, std::vector> set; set.reserve(6); set = {'3', '4', '9', '2'}; set.erase('2'); set.insert('1'); set.insert('\0'); set.pop_back(); set.insert({'0', '\0'}); // Get raw buffer for C API: 34910 std::cout << atoi(set.data()) << std::endl; } ``` -------------------------------- ### Convert to std::string via to_string() Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Illustrates converting to a std::string using the to_string() function. ```cpp to_string(): convert to std::string via to_string() [extension] ``` -------------------------------- ### Verbose empty-checking with std::optional Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/README.md Demonstrates the traditional approach to handling sequential operations that might fail, requiring explicit checks for nullopt at each step. ```C++ std::optional get_cute_cat (const image& img) { auto cropped = crop_to_cat(img); if (!cropped) { return std::nullopt; } auto with_tie = add_bow_tie(*cropped); if (!with_tie) { return std::nullopt; } auto with_sparkles = make_eyes_sparkle(*with_tie); if (!with_sparkles) { return std::nullopt; } return add_rainbow(make_smaller(*with_sparkles)); } ``` -------------------------------- ### Use Default string_view Selection Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Leaving `nssv_CONFIG_SELECT_STRING_VIEW` undefined defaults to `nssv_STRING_VIEW_DEFAULT`, which selects `std::string_view` if available. ```c++ // Default behavior: use std::string_view if available ``` -------------------------------- ### Define Interface and Implementations Source: https://github.com/jetbrains/rd/blob/master/docs/rd-gen.md Shows how to declare an interface and then implement it in both a base class and a base struct. Multiple interfaces can be implemented by chaining 'implements' calls. ```kotlin val Interface = interfacedef { method("foo", PredefinedType.void, PredefinedType.void) } val BaseClassWithInterface = baseclass implements Interface with { } val BaseStructWithInterface = basestruct implements Interface with { } ``` ```kotlin val DerivedClassWith2Interfaces = baseclass extends BaseClass implements Interface implements Interface2 with { field("derivedField", PredefinedType.bool) } ``` -------------------------------- ### Construct string_view from std::string Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Demonstrates the extension for constructing a string_view from a std::string. ```cpp string_view: construct from std::string [extension] ``` -------------------------------- ### Convert from std::string via to_string_view() Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Shows how to convert from a std::string to a string_view using the to_string_view() function. ```cpp to_string_view(): convert from std::string via to_string_view() [extension] ``` -------------------------------- ### Create Shared or Static Library Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/main/CMakeLists.txt Adds the rd_framework_cpp library, creating it as either a SHARED or STATIC library based on the RD_STATIC build option. ```cmake if (RD_STATIC) add_library(rd_framework_cpp STATIC ${RD_FRAMEWORK_CPP_SOURCES}) target_compile_definitions(rd_core_cpp PUBLIC RD_FRAMEWORK_STATIC_DEFINE) else () add_library(rd_framework_cpp SHARED ${RD_FRAMEWORK_CPP_SOURCES}) endif () ``` -------------------------------- ### Add Subdirectories for Entities and Interning Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/test/util/CMakeLists.txt Includes subdirectories for 'entities' and 'interning' to incorporate their CMake configurations. ```cmake add_subdirectory(entities) add_subdirectory(interning) ``` -------------------------------- ### Set Include Directories Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/main/CMakeLists.txt Configures the include paths for the rd_framework_cpp target, including the current source and binary directories. ```cmake target_include_directories(rd_framework_cpp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) ``` -------------------------------- ### Configure string-view-lite for std::string Class Methods Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Define nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS to 1 to enable std::string and nonstd::string_view interoperability via class methods. Define to 0 to omit them. Default is undefined. ```c++ #define nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS 1 ``` -------------------------------- ### Build Test Suite with CMake Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Build the test suite using CMake. This command can be used for either Debug or Release configurations. ```shell cmake --build . --config Debug ``` -------------------------------- ### Define Executable and Source Files Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_core_cpp/src/test/CMakeLists.txt Defines the main executable target 'rd_core_cpp_test' and lists its source files, including test cases and precompiled header options. ```cmake add_executable(rd_core_cpp_test cases/SignalTest.cpp cases/ViewableMapTest.cpp cases/PropertyTest.cpp cases/ViewableSetTest.cpp cases/AdviseVsViewTest.cpp cases/ViewableListTest.cpp cases/GeneratorUtilTest.cpp #pch ${PCH_CPP_OPT} ) ``` -------------------------------- ### RD-Gen Settings Configuration Source: https://github.com/jetbrains/rd/blob/master/docs/rd-gen.md Demonstrates how to customize code generation using settings within RD model constructors. Settings are specific to generators, such as defining namespaces for Kotlin and C#. ```kotlin object MyModel : Ext(SolutionModel.Solution) { init { setting(Kotlin11Generator.Namespace, "my.plugin.model") setting(CSharp50Generator.Namespace, "MyPlugin.Model") } } ``` -------------------------------- ### Select std::string_view as nonstd::string_view Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Define `nssv_CONFIG_SELECT_STRING_VIEW` to `nssv_STRING_VIEW_STD` to use `std::string_view` as `nonstd::string_view`. ```c++ #define nssv_CONFIG_SELECT_STRING_VIEW nssv_STRING_VIEW_STD ``` -------------------------------- ### Build Docker Image for Tests Source: https://github.com/jetbrains/rd/blob/master/README.md Builds a Docker image for running RD tests. This command also removes any existing container with the name 'rd'. ```bash docker build . -t rd && docker rm rd && docker run -it --name rd rd ``` -------------------------------- ### Build Kotlin Project Source: https://github.com/jetbrains/rd/blob/master/README.md Builds the Kotlin project for the RD framework using Gradle. Requires Gradle 6.2.2 and Kotlin 1.3.61. ```bash ./gradlew :build -x test ``` -------------------------------- ### Run Test Suite with CTest Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Run the test suite using CTest. The -V flag provides verbose output, and -C specifies the configuration (e.g., Debug). ```shell ctest -V -C Debug ``` -------------------------------- ### Run Specific Kotlin Test in Docker Source: https://github.com/jetbrains/rd/blob/master/README.md Builds a Docker image and runs a specific Kotlin test suite (e.g., :rd-gen:test) within a container. This command also removes any existing container with the name 'rd'. ```bash docker build . -t rd && docker rm rd && docker run -it --name rd rd --entrypoint ./gradlew :rd-gen:test ``` -------------------------------- ### Include Directories Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/clsocket/CMakeLists.txt Specifies public include directories for the clsocket target. ```cmake target_include_directories(clsocket PUBLIC src) ``` -------------------------------- ### Optional references in C++ Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/README.md Shows how to use tl::optional with references, allowing an optional to hold a reference to an object. Demonstrates assignment and checking the address of the referenced object. ```C++ int i = 42; tl::optional o = i; *o == 42; //true i = 12; *o = 12; //true &*o == &i; //true ``` -------------------------------- ### Define rd_framework_cpp Sources Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/main/CMakeLists.txt Lists all source and header files for the rd_framework_cpp library, categorized by module. ```cmake set(RD_FRAMEWORK_CPP_SOURCES #base base/IRdBindable.h base/IRdReactive.h base/IRdDynamic.h base/IWire.h base/IProtocol.cpp base/IProtocol.h base/RdReactiveBase.cpp base/RdReactiveBase.h base/RdBindableBase.cpp base/RdBindableBase.h base/WireBase.cpp base/WireBase.h base/RdPropertyBase.h base/ISerializersOwner.cpp base/IUnknownInstance.cpp base/IUnknownInstance.h base/IRdWireable.cpp base/IRdWireable.h #impl impl/RdSignal.h impl/RdProperty.h impl/RdList.h impl/RdMap.h impl/RName.cpp impl/RName.h impl/RdSet.h #ext ext/RdExtBase.cpp ext/RdExtBase.h ext/ExtWire.cpp ext/ExtWire.h #scheduler scheduler/base/IScheduler.cpp scheduler/base/IScheduler.h scheduler/base/SingleThreadSchedulerBase.cpp scheduler/base/SingleThreadSchedulerBase.h scheduler/SingleThreadScheduler.cpp scheduler/SingleThreadScheduler.h scheduler/SimpleScheduler.cpp scheduler/SimpleScheduler.h scheduler/SynchronousScheduler.cpp scheduler/SynchronousScheduler.h #serialization serialization/SerializationCtx.cpp serialization/SerializationCtx.h serialization/Serializers.cpp serialization/Serializers.h serialization/Polymorphic.h serialization/NullableSerializer.h serialization/ArraySerializer.h serialization/ISerializable.cpp serialization/ISerializable.h serialization/InternedSerializer.h serialization/AbstractPolymorphic.h serialization/RdAny.cpp serialization/RdAny.h serialization/InternedAnySerializer.h serialization/DefaultAbstractDeclaration.cpp serialization/DefaultAbstractDeclaration.h #task task/RdCall.h task/RdTask.h task/RdTaskResult.h task/RdEndpoint.h task/RdTaskImpl.h task/WiredRdTask.h task/WiredRdTaskImpl.h task/RdSymmetricCall.h #wire wire/SocketWire.cpp wire/SocketWire.h wire/PumpScheduler.cpp wire/PumpScheduler.h wire/ByteBufferAsyncProcessor.cpp wire/ByteBufferAsyncProcessor.h wire/WireUtil.cpp wire/WireUtil.h wire/PkgInputStream.cpp wire/PkgInputStream.h #intern intern/InternRoot.cpp intern/InternRoot.h intern/InternScheduler.cpp intern/InternScheduler.h #protocol protocol/Identities.cpp protocol/Identities.h protocol/Buffer.cpp protocol/Buffer.h protocol/RdId.cpp protocol/RdId.h protocol/Protocol.cpp protocol/Protocol.h protocol/MessageBroker.cpp protocol/MessageBroker.h #pch ${PCH_CPP_OPT} ) ``` -------------------------------- ### Main function demonstrating thread pool usage Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/CTPL/README.md This is the main function demonstrating how to create and use the CTPL thread pool. It shows pushing various types of callable objects, including functions, lambdas, and functors, with and without additional parameters. ```cpp int main () { ctpl::thread_pool p(2 /* two threads in the pool */); p.push(first); // function p.push(third, "additional_param"); p.push( [] (int id){ std::cout << "hello from " << id << '\n'; }); // lambda p.push(std::ref(second)); // functor, reference p.push(const_cast(second)); // functor, copy ctor p.push(std::move(second)); // functor, move ctor } ``` -------------------------------- ### Set Include Directories for Test Utilities Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/test/util/CMakeLists.txt Configures public include directories for the rd_framework_cpp_test_util library, making headers accessible during compilation. ```cmake target_include_directories(rd_framework_cpp_test_util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} entities models test_fixture others scheduler) ``` -------------------------------- ### Configure string-view-lite for std::string Interoperability Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Define nssv_CONFIG_CONVERSION_STD_STRING to 1 to enable std::string and nonstd::string_view interoperability via methods and free functions. Define to 0 to omit them. Default is undefined. ```c++ #define nssv_CONFIG_CONVERSION_STD_STRING 1 ``` -------------------------------- ### Convert string_view to std::string via to_string() Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/string-view-lite/README.md Demonstrates converting a string_view to a std::string using the to_string() method. ```cpp string_view: convert to std::string via to_string() [extension] ``` -------------------------------- ### Define rd_framework_cpp_test_util Library Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/test/util/CMakeLists.txt Defines the C++ test utility library, listing its source files and headers. ```cmake add_library(rd_framework_cpp_test_util #others others/entities_util.cpp others/entities_util.h others/ExtProperty.h #scheduler scheduler/TestSingleThreadScheduler.cpp scheduler/TestSingleThreadScheduler.h #test_fixture test_fixture/SocketWireTestBase.cpp test_fixture/SocketWireTestBase.h test_fixture/RdFrameworkTestBase.cpp test_fixture/RdFrameworkTestBase.h test_fixture/RdFrameworkDynamicPolymorphicTestBase.cpp test_fixture/RdFrameworkDynamicPolymorphicTestBase.h test_fixture/InterningTestBase.cpp test_fixture/InterningTestBase.h test_fixture/RdAsyncTestBase.cpp test_fixture/RdAsyncTestBase.h #wire wire/SocketProxy.cpp wire/SocketProxy.h Linearization.cpp Linearization.h PropertyHolderWithInternRoot.cpp PropertyHolderWithInternRoot.h SimpleWire.cpp SimpleWire.h ) ``` -------------------------------- ### Set Include Directories for Test Utilities Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_core_cpp/src/test/util/CMakeLists.txt Sets the public include directories for the 'rd_core_cpp_test_util' library to the current source directory. ```cmake target_include_directories(rd_core_cpp_test_util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) ``` -------------------------------- ### Configure Include Directories Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_core_cpp/src/test/CMakeLists.txt Specifies the directories from which the 'rd_core_cpp_test' executable can include header files. This ensures that source files can find necessary definitions. ```cmake target_include_directories(rd_core_cpp_test PUBLIC cases) target_include_directories(rd_core_cpp_test PUBLIC util) ``` -------------------------------- ### Header File Properties and Source List Append Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/clsocket/CMakeLists.txt Marks header files and appends them to the source list for dependency checks. ```cmake # mark headers as headers... SET_SOURCE_FILES_PROPERTIES( ${CLSOCKET_HEADERS} PROPERTIES HEADER_FILE_ONLY TRUE ) # append to sources so that dependency checks work on headers LIST(APPEND CLSOCKET_SOURCES ${CLSOCKET_HEADERS}) ``` -------------------------------- ### Link Libraries for Test Utilities Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_core_cpp/src/test/util/CMakeLists.txt Links the 'rd_core_cpp_test_util' library against the 'rd_core_cpp' library. ```cmake target_link_libraries(rd_core_cpp_test_util rd_core_cpp) ``` -------------------------------- ### Set Include Directories for Test Executable Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/test/CMakeLists.txt Configures public include directories for the rd_framework_cpp_test target, making 'cases' and 'util' headers accessible during compilation. ```cmake target_include_directories(rd_framework_cpp_test PUBLIC cases) target_include_directories(rd_framework_cpp_test PUBLIC util) ``` -------------------------------- ### Chaining operations with tl::optional Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/optional/README.md Shows how to use the monadic functions (and_then, map) provided by the tl::optional library to chain operations in a more concise, functional style. ```C++ tl::optional get_cute_cat (const image& img) { return crop_to_cat(img) .and_then(add_bow_tie) .and_then(make_eyes_sparkle) .map(make_smaller) .map(add_rainbow); } ``` -------------------------------- ### Apply rd-gen Plugin in build.gradle.kts Source: https://github.com/jetbrains/rd/blob/master/docs/rd-gen.md Apply the `com.jetbrains.rd.generator.nova` plugin to your `build.gradle.kts` file. ```kotlin plugins { id("com.jetbrains.rdgen") version "2025.1.1" } ``` -------------------------------- ### Configure rdgen Extension Source: https://github.com/jetbrains/rd/blob/master/docs/rd-gen.md Configure the `rdgen` extension in your `build.gradle.kts` to specify generator settings, including output directories and package names. ```kotlin rdgen { verbose = true packages = "model.rider" generator { language = "kotlin" transform = "asis" root = "com.jetbrains.rider.model.nova.ide.IdeRoot" directory = "$ktOutput" } generator { language = "csharp" transform = "reversed" root = "com.jetbrains.rider.model.nova.ide.IdeRoot" directory = "$csOutput" } } ``` -------------------------------- ### Add Subdirectory for Utilities Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_core_cpp/src/test/CMakeLists.txt Includes the 'util' subdirectory, which likely contains utility source files and their own CMake configurations. ```cmake add_subdirectory(util) ``` -------------------------------- ### Add Utility and Kotlin Interaction Subdirectories Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/test/CMakeLists.txt Includes build configurations from 'util' and 'kotlin_interaction' subdirectories, likely containing shared utilities and Kotlin-specific code. ```cmake add_subdirectory(util) add_subdirectory(kotlin_interaction) ``` -------------------------------- ### Link Libraries for Test Utilities Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/src/rd_framework_cpp/src/test/util/CMakeLists.txt Links necessary libraries for the rd_framework_cpp_test_util target, including testing frameworks and other Rd libraries. ```cmake target_link_libraries(rd_framework_cpp_test_util PUBLIC gtest gtest_main rd_framework_cpp rd_core_cpp_test_util entities interning_test_model) ``` -------------------------------- ### Version Definition Source: https://github.com/jetbrains/rd/blob/master/rd-cpp/thirdparty/clsocket/CMakeLists.txt Defines the build version for the clsocket library. ```cmake # set up versioning. set(BUILD_MAJOR "1") set(BUILD_MINOR "4") set(BUILD_VERSION "3") set(BUILD_VERSION ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_VERSION}) ```