### Post-installation Instructions Source: https://github.com/pocoproject/poco/wiki/Creating-a-RPM-Package-for-a-POCO-Application Provides instructions for starting and checking the status of the POCO service after installation. ```shell echo "1) Execute systemctl start pocoServiceExample.service" echo "2) Execute systemctl status pocoServiceExample.service" ``` -------------------------------- ### Write Benchmark - Basic Operation Source: https://github.com/pocoproject/poco/blob/main/Benchmark/README.md Example of a basic benchmark for a component's operation. Includes setup and the benchmark loop. ```cpp // src/MyComponentBench.cpp #include #include "Poco/MyComponent.h" using Poco::MyComponent; static void BM_MyOperation(benchmark::State& state) { MyComponent component; for (auto _ : state) { // Code to benchmark - runs many iterations auto result = component.doSomething(); benchmark::DoNotOptimize(result); } // Optional: report throughput state.SetBytesProcessed(state.iterations() * sizeof(result)); } BENCHMARK(BM_MyOperation); ``` -------------------------------- ### Install Google Benchmark Source: https://github.com/pocoproject/poco/blob/main/Data/SQLParser/benchmark/README.md Steps to install Google Benchmark for running parser benchmarks. This involves CMake configuration, building, and installation. ```bash cmake -DCMAKE_BUILD_TYPE=Release make make install ``` -------------------------------- ### Run Basic ReplicaSet Example Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md Execute the basic ReplicaSet example to demonstrate core functionality. ```bash ./bin/ReplicaSet basic ``` -------------------------------- ### Install Google Benchmark (Windows vcpkg) Source: https://github.com/pocoproject/poco/blob/main/Benchmark/README.md Install Google Benchmark on Windows using vcpkg. ```bash vcpkg install benchmark:x64-windows ``` -------------------------------- ### Install Util Library Source: https://github.com/pocoproject/poco/blob/main/Util/CMakeLists.txt Installs the Util library using POCO_INSTALL macro. ```cmake POCO_INSTALL(Util) ``` -------------------------------- ### Installing the Library Source: https://github.com/pocoproject/poco/blob/main/CppParser/CMakeLists.txt Installs the CppParser library using the POCO_INSTALL macro. ```cmake POCO_INSTALL(CppParser) ``` -------------------------------- ### Install Net Library Source: https://github.com/pocoproject/poco/blob/main/Net/CMakeLists.txt Installs the Net library using the POCO_INSTALL macro. ```cmake POCO_INSTALL(Net) ``` -------------------------------- ### Install Google Benchmark (Fedora/RHEL) Source: https://github.com/pocoproject/poco/blob/main/Benchmark/README.md Install Google Benchmark on Fedora/RHEL systems using dnf. ```bash dnf install google-benchmark-devel ``` -------------------------------- ### Install Google Benchmark (macOS) Source: https://github.com/pocoproject/poco/blob/main/Benchmark/README.md Install Google Benchmark on macOS using Homebrew. ```bash brew install google-benchmark ``` -------------------------------- ### Show Connection Pooling Example Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md Executes the 'pool' command for the ReplicaSet example to demonstrate connection pooling. ```bash ./ReplicaSet pool ``` -------------------------------- ### Install Google Benchmark (Debian/Ubuntu) Source: https://github.com/pocoproject/poco/blob/main/Benchmark/README.md Install Google Benchmark on Debian/Ubuntu systems using apt. ```bash apt install libbenchmark-dev ``` -------------------------------- ### Run Read Preference Example Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md Executes the 'readpref' command for the ReplicaSet example to showcase different read preference settings. ```bash ./ReplicaSet readpref ``` -------------------------------- ### Linux Dynamic Library Examples Source: https://github.com/pocoproject/poco/wiki/Library-Naming-Conventions Examples of release and debug 64-bit dynamic library names on Linux. ```text libPocoFoundation.so.41 ``` ```text libPocoFoundationd64.so.41 ``` -------------------------------- ### Install DNSSD Library Source: https://github.com/pocoproject/poco/blob/main/DNSSD/CMakeLists.txt Installs the configured DNSSD library using Poco's installation macro. ```cmake POCO_INSTALL("${LIBNAME}") ``` -------------------------------- ### Full ReplicaSetMonitor Example with Traditional Options Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md A comprehensive example using traditional options to specify replica set name, hosts, interval, target database and collection, and enabling verbose output. ```bash ./ReplicaSetMonitor \ --set rs0 \ --hosts mongo1:27017,mongo2:27017,mongo3:27017 \ --interval 5 \ --database test \ --collection health_check \ --verbose ``` -------------------------------- ### Deployment Verification Example Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md Run the ReplicaSetMonitor for a production replica set to verify its deployment and health. This example runs for 60 iterations with a 5-second interval. ```bash # Run for 60 iterations (5 minutes with 5-second intervals) ./ReplicaSetMonitor -s production-rs -H prod1:27017,prod2:27017,prod3:27017 -n 60 ``` -------------------------------- ### Start Oracle DB Container Source: https://github.com/pocoproject/poco/wiki/How-to-connect-to-Oracle-DB-and-SQL-Server-using-ODBC Start the previously created Oracle Database container. ```bash docker start oracle-demo ``` -------------------------------- ### Full ReplicaSetMonitor Example with URI and Options Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md A comprehensive example using a MongoDB URI, specifying a 5-second interval, target database and collection, and enabling verbose output. ```bash ./ReplicaSetMonitor \ --uri 'mongodb://mongo1:27017,mongo2:27017,mongo3:27017/?replicaSet=rs0&readPreference=primaryPreferred' \ --interval 5 \ --database test \ --collection health_check \ --verbose ``` -------------------------------- ### Install POCO using vcpkg Package Manager Source: https://github.com/pocoproject/poco/blob/main/README.md Install POCO using the vcpkg dependency manager. This involves cloning vcpkg, bootstrapping it, integrating it with your system, and then installing the POCO package. ```bash $ git clone https://github.com/Microsoft/vcpkg.git $ cd vcpkg $ ./bootstrap-vcpkg.sh $ ./vcpkg integrate install $ ./vcpkg install poco ``` -------------------------------- ### Test Oracle DB Connection with SQL*Plus Source: https://github.com/pocoproject/poco/wiki/How-to-connect-to-Oracle-DB-and-SQL-Server-using-ODBC Verify the Oracle database installation and user setup by connecting using SQL*Plus. ```bash sqlplus poco/poco@localhost:1521/ORCLCDB ``` -------------------------------- ### Install Prerequisites for Debian/Ubuntu Source: https://github.com/pocoproject/poco/wiki/How-to-connect-to-Oracle-DB-and-SQL-Server-using-ODBC Installs curl and gnupg2 packages required for downloading files from Microsoft. ```bash $ sudo apt install curl $ sudo apt-get install -y gnupg2 ``` -------------------------------- ### Installing and Packaging SevenZip Source: https://github.com/pocoproject/poco/blob/main/SevenZip/CMakeLists.txt Uses POCO_INSTALL and POCO_GENERATE_PACKAGE macros to handle the installation and packaging of the SevenZip library. ```cmake POCO_INSTALL(SevenZip) POCO_GENERATE_PACKAGE(SevenZip) ``` -------------------------------- ### Install libaio1 for SQL*Plus Source: https://github.com/pocoproject/poco/wiki/How-to-connect-to-Oracle-DB-and-SQL-Server-using-ODBC Install the libaio1 library to resolve missing library errors when using SQL*Plus. ```bash sudo apt-get install libaio1 ``` -------------------------------- ### Installing and Packaging DataPostgreSQL Source: https://github.com/pocoproject/poco/blob/main/Data/PostgreSQL/CMakeLists.txt Installs the DataPostgreSQL library and generates its package configuration files. ```cmake POCO_INSTALL(DataPostgreSQL) POCO_GENERATE_PACKAGE(DataPostgreSQL) ``` -------------------------------- ### Installing and Packaging Redis Library Source: https://github.com/pocoproject/poco/blob/main/Redis/CMakeLists.txt Installs the Redis library and generates its package configuration files. ```cmake POCO_INSTALL(Redis) POCO_GENERATE_PACKAGE(Redis) ``` -------------------------------- ### Installing PocoDoc Executable and Libraries Source: https://github.com/pocoproject/poco/blob/main/PocoDoc/CMakeLists.txt This install command specifies the destinations for the PocoDoc executable and related files when the project is installed. It defines paths for libraries, archives, runtime binaries, and include files. ```cmake install( TARGETS PocoDoc EXPORT PocoDocTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) ``` -------------------------------- ### Poco Installation and Packaging Source: https://github.com/pocoproject/poco/blob/main/Encodings/CMakeLists.txt Installs the Encodings library and generates its package configuration files. ```cmake POCO_INSTALL(Encodings) POCO_GENERATE_PACKAGE(Encodings) ``` -------------------------------- ### Install Oracle Instant Client DEB packages Source: https://github.com/pocoproject/poco/wiki/How-to-connect-to-Oracle-DB-and-SQL-Server-using-ODBC Install the converted Oracle Instant Client packages on a Debian-based system. ```bash sudo apt install ./oracle-instantclient19.19-odbc_19.19.0.0.0-2_arm64.deb ``` ```bash sudo apt install ./oracle-instantclient19.19-basic_19.19.0.0.0-2_arm64.deb ``` ```bash sudo apt install ./oracle-instantclient19.19-sqlplus_19.19.0.0.0-2_arm64.deb ``` -------------------------------- ### Run URI Example with Replica Set Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md Connect to a MongoDB replica set using a connection string URI. ```bash ./bin/URIExample 'mongodb://localhost:27017/?replicaSet=rs0' ``` -------------------------------- ### Install POCO using Conan Package Manager Source: https://github.com/pocoproject/poco/blob/main/README.md Install POCO using the Conan package manager. You can either install directly from Conan Center or download the recipe and build locally. ```bash $ conan install --requires=poco/1.15.3 ``` ```bash $ conan install --requires=poco/1.15.3 --build=poco ``` -------------------------------- ### Install unixODBC Development Files Source: https://github.com/pocoproject/poco/wiki/How-to-connect-to-Oracle-DB-and-SQL-Server-using-ODBC Installs the unixODBC development package, which is a prerequisite for using ODBC. ```bash sudo apt-get install -y unixodbc-dev ``` -------------------------------- ### Verify Docker Installation Source: https://github.com/pocoproject/poco/wiki/How-to-connect-to-Oracle-DB-and-SQL-Server-using-ODBC Check if Docker is installed and its version. ```bash docker -v ``` -------------------------------- ### Installing the Executable Source: https://github.com/pocoproject/poco/blob/main/ActiveRecord/Compiler/CMakeLists.txt Installs the ActiveRecordCompiler target to the appropriate directories based on CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_BINDIR, and CMAKE_INSTALL_INCLUDEDIR. ```cmake install( TARGETS ActiveRecordCompiler EXPORT "ActiveRecordCompiler" LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) ``` -------------------------------- ### Windows Cygwin Shared Library Example Source: https://github.com/pocoproject/poco/wiki/Library-Naming-Conventions Example of a shared library name on Windows using Cygwin. ```text cygPocoFoundation-41.dll ``` -------------------------------- ### Installing the Executable and Related Files Source: https://github.com/pocoproject/poco/blob/main/PageCompiler/File2Page/CMakeLists.txt Configures installation rules for the File2Page target. Specifies destinations for libraries, archives, runtime binaries, and includes based on standard CMake variables. ```cmake install( TARGETS File2Page EXPORT File2PageTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) ``` -------------------------------- ### Windows MSVC Static Library Examples Source: https://github.com/pocoproject/poco/wiki/Library-Naming-Conventions Examples of MD debug and MT release static library names on Windows. ```text PocoFoundationmdd.lib ``` ```text PocoFoundationmd.lib ``` -------------------------------- ### Install OpenSSL 32-bit Static Libraries Source: https://github.com/pocoproject/poco/wiki/How-to-Build-OpenSSL-1.0-on-Windows Installs the built static OpenSSL libraries, executables, and header files to the directory specified during the configuration step. ```bash > nmake -f ms\nt.mak install ``` -------------------------------- ### Installing and Packaging ActiveRecord Source: https://github.com/pocoproject/poco/blob/main/ActiveRecord/CMakeLists.txt Uses POCO_INSTALL and POCO_GENERATE_PACKAGE macros to handle the installation and packaging of the ActiveRecord library. ```cmake POCO_INSTALL(ActiveRecord) POCO_GENERATE_PACKAGE(ActiveRecord) ``` -------------------------------- ### Install OpenSSL 32-bit DLL Libraries Source: https://github.com/pocoproject/poco/wiki/How-to-Build-OpenSSL-1.0-on-Windows Installs the built OpenSSL DLL libraries, executables, and header files to the directory specified during the configuration step. ```bash > nmake -f ms\ntdll.mak install ``` -------------------------------- ### Run Basic Replica Set Command Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md Executes the 'basic' command for the ReplicaSet example, demonstrating fundamental replica set operations. ```bash ./ReplicaSet basic ``` -------------------------------- ### Install and Package JWT Source: https://github.com/pocoproject/poco/blob/main/JWT/CMakeLists.txt Uses POCO_INSTALL and POCO_GENERATE_PACKAGE macros to handle installation and packaging of the JWT library. ```cmake POCO_INSTALL(JWT) POCO_GENERATE_PACKAGE(JWT) ``` -------------------------------- ### Windows MSVC Dynamic DLL Examples Source: https://github.com/pocoproject/poco/wiki/Library-Naming-Conventions Examples of debug and release dynamic DLL names on Windows. ```text PocoFoundationd.dll ``` ```text PocoFoundation.dll ``` -------------------------------- ### POCO Installation and Packaging Source: https://github.com/pocoproject/poco/blob/main/MongoDB/CMakeLists.txt Installs the MongoDB library and generates its package configuration using POCO-specific CMake macros. ```cmake POCO_INSTALL(MongoDB) POCO_GENERATE_PACKAGE(MongoDB) ``` -------------------------------- ### Install OpenSSL on Windows with WinGet Source: https://github.com/pocoproject/poco/blob/main/README.md Installs OpenSSL development package on Windows using the WinGet package manager. ```bash $ winget install --id -e ShiningLight.OpenSSL.Dev ``` -------------------------------- ### Install CppUnit Library and Headers Source: https://github.com/pocoproject/poco/blob/main/CppUnit/CMakeLists.txt Installs the CppUnit headers and the library targets if ENABLE_INSTALL_CPPUNIT is set. This includes header directories, library files, archives, and runtime binaries. ```cmake if(ENABLE_INSTALL_CPPUNIT) install( DIRECTORY include/CppUnit DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT Devel ) install( TARGETS CppUnit LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) endif() ``` -------------------------------- ### Demonstrate Automatic Failover Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md Executes the 'failover' command for the ReplicaSet example to demonstrate automatic failover. ```bash ./ReplicaSet failover ``` -------------------------------- ### Install POCO Dependencies on Windows with WinGet Source: https://github.com/pocoproject/poco/blob/main/README.md Installs essential dependencies for building POCO on Windows using WinGet. ```bash $ winget install --id -e Git.Git LLVM.LLVM Kitware.CMake ShiningLight.OpenSSL.Dev PostgreSQL.PostgreSQL Oracle.MySQL Microsoft.msodbcsql ``` -------------------------------- ### Configuring Include Directories Source: https://github.com/pocoproject/poco/blob/main/SevenZip/CMakeLists.txt Sets up public and private include directories for the SevenZip target. $ and $ ensure correct paths during build and installation. ```cmake target_include_directories(SevenZip PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) ``` -------------------------------- ### Install Targets Source: https://github.com/pocoproject/poco/blob/main/PageCompiler/CMakeLists.txt Defines installation rules for the PageCompiler executable and its associated files. This specifies where the runtime, library, and include files should be placed on the target system. ```cmake install( TARGETS PageCompiler EXPORT PageCompilerTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) ``` -------------------------------- ### CppUnit Fixture Setup and Teardown Source: https://github.com/pocoproject/poco/blob/main/CppUnit/doc/cookbook.htm Illustrates how to set up a fixture for CppUnit tests by overriding setUp and tearDown methods. This is used to initialize and release resources for multiple test cases. ```cpp class ComplexNumberTest : public TestCase { private: Complex m_10_1, *m_1_1; *m_11_2; protected: void setUp () { m_10_1 = new Complex (10, 1); m_1_1 = new Complex (1, 1); m_11_2 = new Complex (11, 2); } void tearDown () { delete m_10_1, delete m_1_1, delete m_11_2; } }; ``` -------------------------------- ### POCO Installation and Packaging Source: https://github.com/pocoproject/poco/blob/main/Prometheus/CMakeLists.txt Installs the Prometheus library using POCO_INSTALL and generates its package configuration using POCO_GENERATE_PACKAGE. ```cmake POCO_INSTALL(Prometheus) POCO_GENERATE_PACKAGE(Prometheus) ``` -------------------------------- ### Install and Generate Package for Data Library Source: https://github.com/pocoproject/poco/blob/main/Data/CMakeLists.txt Installs the 'Data' library and generates its package configuration files using POCO_INSTALL and POCO_GENERATE_PACKAGE macros. ```cmake POCO_INSTALL(Data) POCO_GENERATE_PACKAGE(Data) ``` -------------------------------- ### Install OpenSSL on Debian Linux Source: https://github.com/pocoproject/poco/blob/main/README.md Installs OpenSSL development headers and libraries on Debian-based systems using apt-get. ```bash $ sudo apt-get install openssl libssl-dev ``` -------------------------------- ### Display Topology Information Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md Executes the 'topology' command for the ReplicaSet example to display replica set topology information. ```bash ./ReplicaSet topology ``` -------------------------------- ### Mac OS X Dynamic Library Example Source: https://github.com/pocoproject/poco/wiki/Library-Naming-Conventions Example of a dynamic library name on Mac OS X. ```text libPocoFoundation.41.dylib ``` -------------------------------- ### Setup PID Directory and Permissions Source: https://github.com/pocoproject/poco/wiki/Creating-a-RPM-Package-for-a-POCO-Application This script creates a directory for PID files and sets appropriate ownership and permissions. It ensures the directory exists and is accessible by the specified user and group. ```shell echo "Creating pid directory and setting permisssions on pid directory" if ! test -e "/var/run/THEPRODUCT" then mkdir -p "/var/run/THEPRODUCT" >/dev/null 2>&1 || : fi chown THEUSER:THEGROUP "/var/run/THEPRODUCT" >/dev/null 2>&1 || : chmod 0770 "/var/run/THEPRODUCT" >/dev/null 2>&1 || : ``` -------------------------------- ### Enable POCO Service on System Start Source: https://github.com/pocoproject/poco/wiki/Creating-a-RPM-Package-for-a-POCO-Application This command enables the POCO service to start automatically when the system boots up. It uses systemctl to manage the service. ```shell systemctl enable pocoServiceExample.service >/dev/null 2>&1 || : ``` -------------------------------- ### Install Target Source: https://github.com/pocoproject/poco/blob/main/Encodings/Compiler/CMakeLists.txt This snippet defines the installation rules for the 'EncodingsCompiler' target, specifying destinations for libraries, archives, runtime binaries, and includes. ```cmake install( TARGETS EncodingsCompiler EXPORT "EncodingsCompilerTargets" LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) ``` -------------------------------- ### Configuring Include Directories Source: https://github.com/pocoproject/poco/blob/main/CppParser/CMakeLists.txt Sets public build and install interface include directories, and private source include directory. ```cmake target_include_directories(CppParser PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) ``` -------------------------------- ### Build TextConverter Executable Source: https://github.com/pocoproject/poco/blob/main/Encodings/samples/TextConverter/CMakeLists.txt Defines the TextConverter executable and links it with the Poco::Encodings library. This setup is necessary for the TextConverter example to utilize Poco's encoding functionalities. ```cmake add_executable(TextConverter src/TextConverter.cpp) target_link_libraries(TextConverter PUBLIC Poco::Encodings) ``` -------------------------------- ### ODBC Driver Configuration (/etc/odbcinst.ini) Source: https://github.com/pocoproject/poco/wiki/How-to-connect-to-Oracle-DB-and-SQL-Server-using-ODBC This example shows the content of the `/etc/odbcinst.ini` file, specifying the drivers for SQL Server and Oracle. Ensure the 'Driver' path points to your actual driver file. ```ini [ODBC Driver 18 for SQL Server] Description=Microsoft ODBC Driver 18 for SQL Server Driver=/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.2.so.1.1 [Oracle 19 ODBC driver] Description = Oracle ODBC driver for Oracle 19 Driver = /usr/lib/oracle/19.19/client64/lib/libsqora.so.19.1 ``` -------------------------------- ### Install POCO Libraries using CMake Build Target Source: https://github.com/pocoproject/poco/blob/main/README.md Install the POCO C++ Libraries headers and libraries by building the 'install' target with CMake. The default installation location can be overridden using CMAKE_INSTALL_PREFIX. ```bash $ sudo cmake --build . --target install ``` -------------------------------- ### Add Benchmark to CMakeLists.txt Source: https://github.com/pocoproject/poco/blob/main/Benchmark/README.md Example of how to add a new benchmark source file to the CMakeLists.txt file. ```cmake set( SRCS src/BenchmarkApp.cpp src/PatternFormatterBench.cpp src/MyComponentBench.cpp # Add this ) ``` -------------------------------- ### Build and Run Replica Set Monitor Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md Navigate to the sample directory and build the ReplicaSetMonitor executable using make. ```bash cd MongoDB/samples/ReplicaSet make ./ReplicaSetMonitor --help ``` -------------------------------- ### Add Subdirectories for Examples, Benchmarks, Tests, and Fuzzing Source: https://github.com/pocoproject/poco/blob/main/dependencies/quill/CMakeLists.txt Conditionally adds subdirectories for examples, benchmarks, tests, and fuzzing based on build flags. Ensures only relevant components are included in the build. ```cmake if (QUILL_BUILD_EXAMPLES) add_subdirectory(examples) add_subdirectory(docs/examples) endif () if (QUILL_BUILD_BENCHMARKS) add_subdirectory(benchmarks) endif () if (QUILL_BUILD_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test) add_subdirectory(test) endif () if (QUILL_BUILD_FUZZING) if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") message(FATAL_ERROR "QUILL_BUILD_FUZZING requires Clang compiler") endif () add_subdirectory(fuzz) endif () ``` -------------------------------- ### Failover Testing with ReplicaSetMonitor Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md Starts the monitor and then simulates a primary step down to test automatic failover. ```bash # Start monitor ./ReplicaSetMonitor -v # In another terminal, step down the primary: # mongo --eval "rs.stepDown()" # Monitor will automatically failover and continue operations ``` -------------------------------- ### Basic Single Server Connection Source: https://github.com/pocoproject/poco/blob/main/MongoDB/README-ReplicaSet.md Example of connecting to a single MongoDB server using the basic Connection class. ```cpp Connection::Ptr conn = new Connection("localhost", 27017); conn->sendRequest(request, response); ``` -------------------------------- ### Build Documentation Package Source: https://github.com/pocoproject/poco/wiki/How-to-Create-a-Release Use the mkdoc script with the 'all' argument to build the documentation for the Complete Edition. This generates HTML reference documentation and packages it into archives. ```shell mkdoc all ``` -------------------------------- ### Setting Include Directories for DataPostgreSQL Source: https://github.com/pocoproject/poco/blob/main/Data/PostgreSQL/CMakeLists.txt Configures public include directories for build time and installation time. ```cmake target_include_directories(DataPostgreSQL PUBLIC $ $ ) ``` -------------------------------- ### Build MongoDB Library Only Source: https://github.com/pocoproject/poco/blob/main/MongoDB/README-ReplicaSet.md Builds only the MongoDB library without examples or tests. ```bash cmake --build . --target MongoDB # Creates lib/libPocoMongoDB.dylib (or .so on Linux) ``` -------------------------------- ### Build MongoDB with CMake Source: https://github.com/pocoproject/poco/blob/main/MongoDB/README-ReplicaSet.md Builds the MongoDB library and related examples using CMake. Ensure you are in the 'poco' directory. ```bash cd poco mkdir build && cd build cmake .. -DENABLE_MONGODB=ON -DENABLE_SAMPLES=ON -DENABLE_TESTS=OFF cmake --build . --target MongoDB cmake --build . --target ReplicaSetMonitor cmake --build . --target ReplicaSet cmake --build . --target URIExample ``` -------------------------------- ### Write Benchmark - Parameterized Benchmark Source: https://github.com/pocoproject/poco/blob/main/Benchmark/README.md Example of a parameterized benchmark that tests with different input sizes. The Range() method specifies the input range. ```cpp // Parameterized benchmark static void BM_MyOperationSized(benchmark::State& state) { int size = state.range(0); std::vector data(size); for (auto _ : state) { // Benchmark with different sizes processData(data); } } BENCHMARK(BM_MyOperationSized)->Range(8, 8<<10); ``` -------------------------------- ### Run ReplicaSetMonitor Help Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md Execute the ReplicaSetMonitor executable with the --help flag to view its command-line options. ```bash ./bin/ReplicaSetMonitor --help ``` -------------------------------- ### Configuring Include Directories for Redis Library Source: https://github.com/pocoproject/poco/blob/main/Redis/CMakeLists.txt Sets public include directories for build and install interfaces, and private include directory for sources. ```cmake target_include_directories(Redis PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) ``` -------------------------------- ### Configure OpenSSL for 64-bit Static Libraries Source: https://github.com/pocoproject/poco/wiki/How-to-Build-OpenSSL-1.0-on-Windows Configures OpenSSL for a 64-bit build, specifying the installation prefix. This command is run from the OpenSSL source directory in a VS2015 x64 Native Tools Command Prompt. ```bash > perl Configure VC-WIN64A no-asm --prefix=C:\OpenSSL-Win64 > ms\do_win64a ``` -------------------------------- ### Configure ReplicaSetURI Programmatically Source: https://github.com/pocoproject/poco/blob/main/MongoDB/README-ReplicaSet.md Demonstrates the correct way to configure a ReplicaSetURI using its methods and constants. ```cpp // Good - type-safe and validated ReplicaSetURI uri; uri.setHeartbeatFrequencyMS(ReplicaSetURI::DEFAULT_HEARTBEAT_FREQUENCY_MS); uri.addServer("mongo1:27017"); // Bad - manual string construction is error-prone std::string uri = "mongodb://mongo1:27017/?heartbeatFrequency=10000"; // Wrong parameter name! ``` -------------------------------- ### Define SampleApp Executable and Link Libraries Source: https://github.com/pocoproject/poco/blob/main/Util/samples/SampleApp/CMakeLists.txt Defines the SampleApp executable using source files and links it with Poco Util, JSON, and XML libraries. Ensure Poco is correctly installed and discoverable by CMake. ```cmake add_executable(SampleApp src/SampleApp.cpp) target_link_libraries(SampleApp PUBLIC Poco::Util Poco::JSON Poco::XML) ``` -------------------------------- ### Install OpenSSL on macOS with Homebrew Source: https://github.com/pocoproject/poco/blob/main/README.md Installs OpenSSL using the Homebrew package manager on macOS. ```bash $ brew install openssl ``` -------------------------------- ### Configure URIExample Sample Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/CMakeLists.txt Sets up the URIExample sample application for demonstrating URI parsing, linking against Poco libraries. ```cmake set(URI_NAME "URIExample") set(URI_SRCS src/URIExample.cpp) add_executable(${URI_NAME} ${URI_SRCS}) target_link_libraries(${URI_NAME} Poco::MongoDB Poco::Net Poco::Foundation) ``` -------------------------------- ### DSN Configuration (/etc/odbc.ini) Source: https://github.com/pocoproject/poco/wiki/How-to-connect-to-Oracle-DB-and-SQL-Server-using-ODBC This is an example of the `/etc/odbc.ini` file, which configures a Data Source Name (DSN) for an Oracle database. It includes connection details like ServerName, Port, ServiceName, UserID, and Password. ```ini [OracleDB] Description = Oracle ODBC DSN Driver = Oracle 19 ODBC driver ServerName = localhost Port = 1521 ServiceName = ORCLCDB UserID = poco Password = poco ``` -------------------------------- ### Configure ReplicaSet Sample Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/CMakeLists.txt Sets up the ReplicaSet sample application, linking against Poco MongoDB, Net, and Foundation libraries. ```cmake set(SAMPLE_NAME "ReplicaSet") set(SRCS src/ReplicaSet.cpp) add_executable(${SAMPLE_NAME} ${SRCS}) target_link_libraries(${SAMPLE_NAME} Poco::MongoDB Poco::Net Poco::Foundation) ``` -------------------------------- ### Configure OpenSSL for 32-bit Static Libraries Source: https://github.com/pocoproject/poco/wiki/How-to-Build-OpenSSL-1.0-on-Windows Configures OpenSSL for a 32-bit build, specifying the installation prefix. This command is run from the OpenSSL source directory in a VS2015 x86 Native Tools Command Prompt. ```bash > perl Configure VC-WIN32 no-asm --prefix=C:\OpenSSL-Win32 > ms\do_ms ``` -------------------------------- ### Run Benchmark - List all benchmarks Source: https://github.com/pocoproject/poco/blob/main/Benchmark/README.md Command to list all available benchmarks. ```bash ./Benchmark/bin/$(uname)/$(arch)/benchmark --list ``` -------------------------------- ### Run ReplicaSetMonitor with Defaults Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md Execute the ReplicaSetMonitor tool with its default configuration settings. ```bash ./ReplicaSetMonitor ``` -------------------------------- ### Build Google Benchmark from Source (Linux/macOS) Source: https://github.com/pocoproject/poco/blob/main/Benchmark/README.md Build Google Benchmark from source on Linux or macOS. ```bash git clone https://github.com/google/benchmark.git cd benchmark cmake -DBENCHMARK_DOWNLOAD_DEPENDENCIES=on -DCMAKE_BUILD_TYPE=Release -S . -B build cmake --build build --config Release sudo cmake --install build ``` -------------------------------- ### Build Google Benchmark from Source (Windows) Source: https://github.com/pocoproject/poco/blob/main/Benchmark/README.md Build Google Benchmark from source on Windows. ```powershell git clone https://github.com/google/benchmark.git cd benchmark cmake -DBENCHMARK_DOWNLOAD_DEPENDENCIES=on -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:\local -S . -B build cmake --build build --config Release cmake --install build --config Release ``` -------------------------------- ### Install POCO Dependencies on macOS with Homebrew Source: https://github.com/pocoproject/poco/blob/main/README.md Installs essential dependencies for building POCO on macOS using Homebrew. ```bash $ brew install cmake openssl mysql-client libpq ``` -------------------------------- ### Configure ReplicaSetMonitor Sample Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/CMakeLists.txt Sets up the ReplicaSetMonitor sample application for monitoring and health checks, linking against Poco libraries. ```cmake set(MONITOR_NAME "ReplicaSetMonitor") set(MONITOR_SRCS src/ReplicaSetMonitor.cpp) add_executable(${MONITOR_NAME} ${MONITOR_SRCS}) target_link_libraries(${MONITOR_NAME} Poco::MongoDB Poco::Net Poco::Foundation) ``` -------------------------------- ### Build with Make on Linux/OS X Source: https://github.com/pocoproject/poco/blob/main/DNSSD/README.md Build the POCO DNS-SD library on Linux or OS X using the make command, setting the POCO_BASE environment variable. ```bash $ export POCO_BASE=`pwd` $ cd DNSSD $ make -s -j8 $ make -s -j8 -C Default ``` -------------------------------- ### Install POCO Dependencies on Arch Linux Source: https://github.com/pocoproject/poco/blob/main/README.md Installs essential dependencies for building POCO on Arch Linux using pacman. ```bash $ sudo pacman -Syu --noconfirm git gcc make cmake openssl mariadb-libs postgresql-libs ``` -------------------------------- ### Install POCO Dependencies on RedHat Linux Source: https://github.com/pocoproject/poco/blob/main/README.md Installs essential dependencies for building POCO on RedHat-based systems using dnf. ```bash $ sudo dnf install -y git gcc-c++ cmake openssl-devel mysql-devel postgresql-devel ``` -------------------------------- ### CMakeLists.txt Configuration Source: https://github.com/pocoproject/poco/blob/main/DNSSD/samples/HTTPTimeServer/CMakeLists.txt Defines the sample name, collects source files, creates an executable, and links required libraries for the DNSSD HTTP Time Server sample. ```cmake set(SAMPLE_NAME "DNSSDHTTPTimeServer") set(LOCAL_SRCS "") aux_source_directory(src LOCAL_SRCS) add_executable( ${SAMPLE_NAME} ${LOCAL_SRCS} ) target_link_libraries( ${SAMPLE_NAME} Foundation Net Util XML DNSSD ${DNSSD_IMPLEMENTATION_LIBRARY} ) ``` -------------------------------- ### Replica Set Connection (Basic) Source: https://github.com/pocoproject/poco/blob/main/MongoDB/README-ReplicaSet.md Initializes a ReplicaSet object with seed addresses and retrieves a connection to the primary server. ```cpp ReplicaSet::Config config; config.seeds = {Net::SocketAddress("localhost", 27017)}; ReplicaSet rs(config); Connection::Ptr conn = rs.getPrimaryConnection(); conn->sendRequest(request, response); ``` -------------------------------- ### Build with CMake on Linux Source: https://github.com/pocoproject/poco/blob/main/DNSSD/README.md Build the POCO DNS-SD library on Linux using CMake and a build script. ```bash $ git apply DNSSD/CMakeLists.diff $ sudo ./build_cmake.sh ``` -------------------------------- ### Install Microsoft ODBC Driver for SQL Server on Ubuntu Source: https://github.com/pocoproject/poco/wiki/How-to-connect-to-Oracle-DB-and-SQL-Server-using-ODBC Installs the msodbcsql17 package and optionally mssql-tools for bcp and sqlcmd. Updates the PATH environment variable. ```bash if ! [[ "16.04 18.04 20.04 22.04" == *"$(lsb_release -rs)"* ]] then echo "Ubuntu $(lsb_release -rs) is not currently supported." exit fi curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list sudo apt-get update sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17 # optional: for bcp and sqlcmd sudo ACCEPT_EULA=Y apt-get install -y mssql-tools echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc ``` -------------------------------- ### Install Microsoft ODBC Driver for SQL Server on Debian Source: https://github.com/pocoproject/poco/wiki/How-to-connect-to-Oracle-DB-and-SQL-Server-using-ODBC Installs the msodbcsql18 package and optionally mssql-tools for bcp and sqlcmd. Updates the PATH environment variable. ```bash sudo apt-get update sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 # optional: for bcp and sqlcmd sudo ACCEPT_EULA=Y apt-get install -y mssql-tools echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc ``` -------------------------------- ### Install POCO Dependencies on Debian Linux Source: https://github.com/pocoproject/poco/blob/main/README.md Installs essential dependencies for building POCO on Debian-based systems, including git, g++, cmake, OpenSSL, and database connectors. ```bash $ sudo apt-get -y update && sudo apt-get -y install git g++ cmake libssl-dev libmysqlclient-dev libpq-dev ``` -------------------------------- ### Build with CMake on Windows/OS X Source: https://github.com/pocoproject/poco/blob/main/DNSSD/README.md Build the POCO DNS-SD library on Windows or OS X using CMake. ```bash $ git apply DNSSD/CMakeLists.diff $ mkdir build $ cd build $ cmake .. $ make -j8 ``` -------------------------------- ### Use Constants for Configuration Source: https://github.com/pocoproject/poco/blob/main/MongoDB/README-ReplicaSet.md Illustrates using defined constants for configuration values instead of magic numbers. ```cpp // Good - use defined constants uri.setHeartbeatFrequencyMS(ReplicaSetURI::DEFAULT_HEARTBEAT_FREQUENCY_MS); uri.setHeartbeatFrequencyMS(ReplicaSetURI::MIN_HEARTBEAT_FREQUENCY_MS); // Bad - magic numbers uri.setHeartbeatFrequencyMS(10000); uri.setHeartbeatFrequencyMS(500); ``` -------------------------------- ### MongoDB ReplicaSet Initialization with URI Source: https://github.com/pocoproject/poco/blob/main/MongoDB/README-ReplicaSet.md Shows how to initialize a MongoDB ReplicaSet object directly using various connection URI strings, including options for read preference, timeouts, and heartbeat frequency. ```cpp // Basic URI with replica set name ReplicaSet rs("mongodb://mongo1:27017,mongo2:27017,mongo3:27017/?replicaSet=rs0"); // URI with read preference ReplicaSet rs("mongodb://host1:27017,host2:27017/?replicaSet=rs0&readPreference=primaryPreferred"); // URI with timeouts ReplicaSet rs("mongodb://host1:27017,host2:27017/?replicaSet=rs0&connectTimeoutMS=5000&socketTimeoutMS=30000"); // URI with heartbeat frequency ReplicaSet rs("mongodb://host1:27017,host2:27017/?replicaSet=rs0&heartbeatFrequencyMS=5000"); // Complete URI with all options ReplicaSet rs("mongodb://host1:27017,host2:27017,host3:27017/" "?replicaSet=rs0" "&readPreference=secondaryPreferred" "&connectTimeoutMS=10000" "&socketTimeoutMS=30000" "&heartbeatFrequencyMS=10000" "&reconnectRetries=5" "&reconnectDelay=2"); ``` -------------------------------- ### Add Benchmark to Makefile Source: https://github.com/pocoproject/poco/blob/main/Benchmark/README.md Example of how to add a new benchmark object to the Makefile. ```makefile objects = BenchmarkApp PatternFormatterBench MyComponentBench ``` -------------------------------- ### Set up Release Script Environment Source: https://github.com/pocoproject/poco/wiki/How-to-Create-a-Release Set the POCO_BASE environment variable and add the release script directory to the PATH. This is necessary before running the mkrel script. ```shell export POCO_BASE=`pwd` export PATH=$POCO_BASE/release/script:$PATH ``` -------------------------------- ### Run ReplicaSetMonitor with Replica Set Name and Hosts Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md Specify the replica set name and a comma-separated list of host:port for connection. ```bash ./ReplicaSetMonitor -s rs0 -H mongo1:27017,mongo2:27017,mongo3:27017 ``` -------------------------------- ### Configure OpenSSL on Unix Source: https://github.com/pocoproject/poco/blob/main/NetSSL_OpenSSL/doc/howtobuild.txt Configure OpenSSL for installation on Unix systems. Ensure the prefix is set to /usr for compatibility. ```bash ./configure --prefix=/usr --openssldir/usr/openssl make make install (with superuser rights) ``` -------------------------------- ### Create a Test Suite with Other Test Suites Source: https://github.com/pocoproject/poco/blob/main/CppUnit/doc/cookbook.htm Illustrates how to combine different TestSuite objects into a larger suite. ```cpp TestSuite suite; suite.addTest (ComplexNumberTest.suite ()); suite.addTest (SurrealNumberTest.suite ()); suite.run (&result); ``` -------------------------------- ### Initialize Encryption Keys Source: https://github.com/pocoproject/poco/blob/main/Zip/doc/ZIP Spec.txt Sets the initial values for the three 32-bit encryption keys. ```pseudocode Key(0) <- 305419896 Key(1) <- 591751049 Key(2) <- 878082192 loop for i <- 0 to length(password)-1 update_keys(password(i)) end loop ``` -------------------------------- ### Docker Compose Configuration for Replica Set Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md Defines a Docker Compose setup for a 3-node MongoDB replica set. ```yaml # docker-compose.yml version: '3' services: mongo1: image: mongo:7.0 command: ["--replSet", "rs0", "--bind_ip_all", "--port", "27017"] ports: ["27017:27017"] mongo2: image: mongo:7.0 command: ["--replSet", "rs0", "--bind_ip_all", "--port", "27017"] ports: ["27018:27017"] mongo3: image: mongo:7.0 command: ["--replSet", "rs0", "--bind_ip_all", "--port", "27017"] ports: ["27019:27017"] ``` -------------------------------- ### Proof-of-Concept: Custom Thread Pool for Async Events Source: https://github.com/pocoproject/poco/wiki/Customizing-Poco::AbstractEvent::notifyAsync()-Threading This complete example demonstrates the custom ActiveStarter specialization. It includes the necessary includes, the custom thread pool function, the specialization, an event source class, a callback, and the main function to trigger the async event. ```c++ #include "Poco/ActiveStarter.h" #include "Poco/BasicEvent.h" #include "Poco/Delegate.h" #include "Poco/ThreadPool.h" #include Poco::ThreadPool& eventThreadPool() { static Poco::ThreadPool pool(2, 16, 30); return pool; } namespace Poco { template class ActiveStarter > { public: static void start(AbstractEvent* pOwner, ActiveRunnableBase::Ptr pRunnable) { std::cout << "ActiveStarter" << std::endl; eventThreadPool().start(*pRunnable); pRunnable->duplicate(); // The runnable will release itself. } }; }; class EventSource { public: Poco::BasicEvent event; }; void callback() { std::cout << "CALLBACK!" << std::endl; } int main(int argc, char** argv) { EventSource src; src.event += Poco::delegate(callback); src.event.notifyAsync(0); Poco::Thread::sleep(1000); return 0; } ``` -------------------------------- ### Setting Include Directories Source: https://github.com/pocoproject/poco/blob/main/Encodings/CMakeLists.txt Configures public and private include directories for the Encodings library, including build and install interfaces. ```cmake target_include_directories(Encodings PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) ``` -------------------------------- ### Advanced MongoDB URI Parsing with Credentials and Database Source: https://github.com/pocoproject/poco/blob/main/MongoDB/README-ReplicaSet.md Demonstrates parsing a MongoDB URI that includes username, password, and a specific database. Shows how to extract these components and use the URI string to initialize a ReplicaSet. ```cpp // Parse URI with credentials and database ReplicaSetURI uri("mongodb://user:pass@mongo1:27017,mongo2:27017/mydb?replicaSet=rs0"); std::string username = uri.username(); // "user" std::string password = uri.password(); // "pass" std::string database = uri.database(); // "mydb" // Use with ReplicaSet ReplicaSet rs(uri.toString()); ``` -------------------------------- ### Run Multiple Replica Set Monitors Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md Starts multiple instances of the ReplicaSetMonitor in parallel to monitor replica set members. ```bash # Run 10 monitors in parallel for i in {1..10}; do ./ReplicaSetMonitor -i 1 & done ``` -------------------------------- ### Build Poco Benchmark with Make Source: https://github.com/pocoproject/poco/blob/main/Benchmark/README.md Build the Poco Benchmark component using Make on Linux/macOS. ```bash cd poco make -C Benchmark ``` -------------------------------- ### Define a Static Test Suite Method Source: https://github.com/pocoproject/poco/blob/main/CppUnit/doc/cookbook.htm Provides an example of a static method that returns a TestSuite, making it accessible to TestRunner. ```cpp public: static Test *suite () { TestSuite *suiteOfTests = new TestSuite; suiteOfTests->addTest (new TestCaller("testEquality", testEquality)); suiteOfTests->addTest (new TestCaller("testAddition", testAddition)); return suiteOfTests; } ``` -------------------------------- ### Find External Expat Package Source: https://github.com/pocoproject/poco/blob/main/dependencies/expat/CMakeLists.txt Locates and imports an already installed Expat package. Ensures the imported target is globally available. ```cmake if(POCO_UNBUNDLED) if (ENABLE_XML) find_package(EXPAT REQUIRED) set_target_properties(EXPAT::EXPAT PROPERTIES IMPORTED_GLOBAL TRUE) endif() endif() ``` -------------------------------- ### Set Net Include Directories Source: https://github.com/pocoproject/poco/blob/main/Net/CMakeLists.txt Configures public and private include directories for the Net library, including build and install interfaces. ```cmake target_include_directories(Net PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) ``` -------------------------------- ### Initialize Replica Set with Docker Compose Source: https://github.com/pocoproject/poco/blob/main/MongoDB/samples/ReplicaSet/README.md Initializes a replica set named 'rs0' using mongosh after starting MongoDB containers. ```bash docker-compose up -d docker exec -it $(docker ps -q -f name=mongo1) mongosh --eval " rs.initiate({ _id: 'rs0', members: [ { _id: 0, host: 'localhost:27017' }, { _id: 1, host: 'localhost:27018' }, { _id: 2, host: 'localhost:27019' } ] })" # Wait a few seconds for election sleep 5 # Run the monitor ./ReplicaSetMonitor -s rs0 -H localhost:27017,localhost:27018,localhost:27019 ``` -------------------------------- ### Basic SQL Parsing in C++ Source: https://github.com/pocoproject/poco/blob/main/Data/SQLParser/README.md Demonstrates how to parse a SQL query string into C++ objects using the SQLParser library. Includes checking for validity and statement type. ```cpp #include "hsql/SQLParser.h" /* ... */ { // Basic Usage Example const std::string query = "..."; hsql::SQLParserResult result; hsql::SQLParser::parse(query, &result); if (result.isValid() && result.size() > 0) { const hsql::SQLStatement* statement = result.getStatement(0); if (statement->isType(hsql::kStmtSelect)) { const auto* select = static_cast(statement); /* ... */ } } } ``` -------------------------------- ### Bit Reversal Example Source: https://github.com/pocoproject/poco/blob/main/Zip/doc/ZIP Spec.txt Illustrates the process of reversing the order of bits within a value, transforming a hexadecimal number into its bit-reversed equivalent. ```hexadecimal 0x1234 (hex) would become 0x2C48 (hex) ``` -------------------------------- ### CMakeLists.txt for NetSSL Download Sample Source: https://github.com/pocoproject/poco/blob/main/NetSSL_OpenSSL/samples/download/CMakeLists.txt Defines the executable and links the necessary Poco and OpenSSL libraries for the NetSSL download sample. ```cmake add_executable(download-ssl src/download.cpp) target_link_libraries(download-ssl PUBLIC Poco::NetSSL Poco::Util Poco::XML) if(MSVC) target_link_libraries(download-ssl PRIVATE OpenSSL::applink) endif() ```