|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
Demonstrates usage of C++20 concepts in network_system. More...
#include <kcenon/network/concepts/concepts.h>#include <functional>#include <iostream>#include <memory>#include <string>#include <system_error>#include <vector>
Go to the source code of this file.
Classes | |
| class | ConceptClient |
| A client class demonstrating concept-constrained callbacks. More... | |
| class | MockNetworkClient |
| A mock client satisfying NetworkClient concept. More... | |
| class | XorTransformer |
| A simple XOR "encryption" transformer. More... | |
Functions | |
| template<ByteBuffer Buffer> | |
| void | send_buffer (const Buffer &buffer) |
| Send data from any buffer type satisfying ByteBuffer concept. | |
| void | demonstrate_byte_buffer () |
| template<MutableByteBuffer Buffer> | |
| void | receive_into (Buffer &buffer, std::size_t expected_size) |
| Receive data into a resizable buffer. | |
| void | demonstrate_mutable_buffer () |
| void | demonstrate_callbacks () |
| template<NetworkClient Client> | |
| void | use_client (Client &client, const std::string &message) |
| Generic function that works with any NetworkClient. | |
| void | demonstrate_network_client () |
| template<ReversibleDataTransformer T> | |
| void | process_bidirectional (T &transformer, std::vector< uint8_t > &data) |
| Apply a reversible transformer to data. | |
| void | demonstrate_transformer () |
| template<Duration D> | |
| void | set_timeout (D duration) |
| Set a timeout using any duration type. | |
| void | demonstrate_duration () |
| int | main () |
Demonstrates usage of C++20 concepts in network_system.
BSD 3-Clause License Copyright (c) 2024, Network System Project
This example shows how to use network_system concepts for:
Requirements:
Definition in file concepts_example.cpp.
| void demonstrate_byte_buffer | ( | ) |
Definition at line 44 of file concepts_example.cpp.
References send_buffer().
Referenced by main().


| void demonstrate_callbacks | ( | ) |
Definition at line 180 of file concepts_example.cpp.
Referenced by main().

| void demonstrate_duration | ( | ) |
Definition at line 347 of file concepts_example.cpp.
References set_timeout().
Referenced by main().


| void demonstrate_mutable_buffer | ( | ) |
Definition at line 84 of file concepts_example.cpp.
References receive_into().
Referenced by main().


| void demonstrate_network_client | ( | ) |
Definition at line 256 of file concepts_example.cpp.
References use_client().
Referenced by main().


| void demonstrate_transformer | ( | ) |
Definition at line 322 of file concepts_example.cpp.
References process_bidirectional().
Referenced by main().


| int main | ( | ) |
Definition at line 392 of file concepts_example.cpp.
References demonstrate_byte_buffer(), demonstrate_callbacks(), demonstrate_duration(), demonstrate_mutable_buffer(), demonstrate_network_client(), and demonstrate_transformer().

| void process_bidirectional | ( | T & | transformer, |
| std::vector< uint8_t > & | data ) |
Apply a reversible transformer to data.
| T | Must satisfy ReversibleDataTransformer |
Definition at line 306 of file concepts_example.cpp.
Referenced by demonstrate_transformer().

| void receive_into | ( | Buffer & | buffer, |
| std::size_t | expected_size ) |
Receive data into a resizable buffer.
| Buffer | Must satisfy MutableByteBuffer (ByteBuffer + resize) |
Definition at line 75 of file concepts_example.cpp.
Referenced by demonstrate_mutable_buffer().

| void send_buffer | ( | const Buffer & | buffer | ) |
Send data from any buffer type satisfying ByteBuffer concept.
| Buffer | Must satisfy ByteBuffer (has data() and size()) |
Definition at line 37 of file concepts_example.cpp.
Referenced by demonstrate_byte_buffer().

| void set_timeout | ( | D | duration | ) |
Set a timeout using any duration type.
| D | Must satisfy Duration concept |
Definition at line 342 of file concepts_example.cpp.
Referenced by demonstrate_duration().

| void use_client | ( | Client & | client, |
| const std::string & | message ) |
Generic function that works with any NetworkClient.
| Client | Must satisfy NetworkClient concept |
Definition at line 246 of file concepts_example.cpp.
Referenced by demonstrate_network_client().
