summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/.keep0
-rw-r--r--examples/fix_tag_example/CMakeLists.txt15
-rw-r--r--examples/fix_tag_example/example.cc30
-rw-r--r--examples/hash_crc32_example/CMakeLists.txt15
-rw-r--r--examples/hash_crc32_example/example.cc14
-rw-r--r--examples/simple_unique_socket/CMakeLists.txt15
-rw-r--r--examples/simple_unique_socket/example.cc22
7 files changed, 111 insertions, 0 deletions
diff --git a/examples/.keep b/examples/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/.keep
diff --git a/examples/fix_tag_example/CMakeLists.txt b/examples/fix_tag_example/CMakeLists.txt
new file mode 100644
index 0000000..b9a80db
--- /dev/null
+++ b/examples/fix_tag_example/CMakeLists.txt
@@ -0,0 +1,15 @@
+
+cmake_minimum_required(VERSION 3.15...3.31)
+
+project(
+ FixExample
+ VERSION 1.0
+ LANGUAGES CXX)
+
+find_package(Boost REQUIRED COMPONENTS container)
+
+add_executable(FixExample example.cc)
+
+set_property(TARGET FixExample PROPERTY CXX_STANDARD 20)
+target_include_directories(FixExample PUBLIC ../../include/ocl)
+target_link_libraries(FixExample PRIVATE Boost::container)
diff --git a/examples/fix_tag_example/example.cc b/examples/fix_tag_example/example.cc
new file mode 100644
index 0000000..37376d0
--- /dev/null
+++ b/examples/fix_tag_example/example.cc
@@ -0,0 +1,30 @@
+#include <ocl/fix/parser.hpp>
+
+constexpr const char default_fix[] = {
+ '8', '=', 'F', 'I', 'X', '.', '4', '.', '2', 0x01,
+ '9', '=', '6', '3', 0x01, // BodyLength = 63
+ '3', '5', '=', 'A', 0x01,
+ '4', '9', '=', 'S', 'E', 'R', 'V', 'E', 'R', 0x01,
+ '5', '6', '=', 'C', 'L', 'I', 'E', 'N', 'T', 0x01,
+ '3', '4', '=', '1', '7', '7', 0x01,
+ '5', '2', '=', '2', '0', '0', '9', '0', '1', '0', '7', '-', '1', '8', ':', '1', '5', ':', '1', '6', 0x01,
+ '9', '8', '=', '0', 0x01,
+ '1', '0', '8', '=', '3', '0', 0x01,
+ '1', '0', '=', '1', '4', '3', 0x01, 0x00 // CheckSum = 143
+};
+
+int main(int argc, char** argv)
+{
+ ocl::fix::visitor basic_visitor;
+ ocl::fix::range_buffer fix = basic_visitor.visit(default_fix);
+
+ ocl::io::enable_stdio_sync(false);
+
+ ocl::io::print(":key=35\n");
+ ocl::io::print(":value=", fix["35"], "\n");
+
+ ocl::io::print(":key=49\n");
+ ocl::io::print(":value=", fix["49"], "\n");
+
+ return 0;
+}
diff --git a/examples/hash_crc32_example/CMakeLists.txt b/examples/hash_crc32_example/CMakeLists.txt
new file mode 100644
index 0000000..9758bfa
--- /dev/null
+++ b/examples/hash_crc32_example/CMakeLists.txt
@@ -0,0 +1,15 @@
+
+cmake_minimum_required(VERSION 3.15...3.31)
+
+project(
+ HashExample
+ VERSION 1.0
+ LANGUAGES CXX)
+
+find_package(Boost REQUIRED COMPONENTS container)
+
+add_executable(HashExample example.cc)
+
+set_property(TARGET HashExample PROPERTY CXX_STANDARD 20)
+target_include_directories(HashExample PUBLIC ../../include/ocl)
+target_link_libraries(HashExample PRIVATE Boost::container)
diff --git a/examples/hash_crc32_example/example.cc b/examples/hash_crc32_example/example.cc
new file mode 100644
index 0000000..bd27662
--- /dev/null
+++ b/examples/hash_crc32_example/example.cc
@@ -0,0 +1,14 @@
+#include <ocl/crc_hash.hpp>
+#include <ocl/print.hpp>
+
+int main(int argc, char** argv)
+{
+ if (argc != 2) return 1;
+
+ std::hash<ocl::crc_hash_trait> hash{};
+
+ ocl::io::enable_stdio_sync(false);
+ ocl::io::print(hash(argv[1]));
+
+ return 0;
+}
diff --git a/examples/simple_unique_socket/CMakeLists.txt b/examples/simple_unique_socket/CMakeLists.txt
new file mode 100644
index 0000000..2cf3648
--- /dev/null
+++ b/examples/simple_unique_socket/CMakeLists.txt
@@ -0,0 +1,15 @@
+
+cmake_minimum_required(VERSION 3.15...3.31)
+
+project(
+ NetworkExample
+ VERSION 1.0
+ LANGUAGES CXX)
+
+find_package(Boost REQUIRED COMPONENTS container)
+
+add_executable(NetworkExample example.cc)
+
+set_property(TARGET NetworkExample PROPERTY CXX_STANDARD 20)
+target_include_directories(NetworkExample PUBLIC ../../include/ocl)
+target_link_libraries(NetworkExample PRIVATE Boost::container)
diff --git a/examples/simple_unique_socket/example.cc b/examples/simple_unique_socket/example.cc
new file mode 100644
index 0000000..b5bd34f
--- /dev/null
+++ b/examples/simple_unique_socket/example.cc
@@ -0,0 +1,22 @@
+#include <ocl/unique_socket.hpp>
+#include <ocl/print.hpp>
+
+/// @brief Basic Send test
+int main()
+{
+ ocl::unique_socket sock = ocl::unique_socket::make_socket<8005>(ocl::unique_socket::any_address, true);
+
+ char buf_dst[512] = {"HELLO, WORLD\0"};
+
+ ocl::unique_socket sock2 = ocl::unique_socket::make_socket<8005>(ocl::unique_socket::any_address, false);
+
+ char buf_dst2[512] = {0};
+
+ auto new_sock = sock.accept();
+ new_sock.write_from_buffer(buf_dst, strlen(buf_dst));
+ sock2.read_client_buffer(buf_dst2, strlen(buf_dst));
+ std::cout << "result:" << buf_dst2 << "\n";
+
+
+ return EXIT_SUCCESS;
+}