diff options
Diffstat (limited to 'examples/fix')
| -rw-r--r-- | examples/fix/CMakeLists.txt | 15 | ||||
| -rw-r--r-- | examples/fix/fix.cc | 37 |
2 files changed, 52 insertions, 0 deletions
diff --git a/examples/fix/CMakeLists.txt b/examples/fix/CMakeLists.txt new file mode 100644 index 0000000..4c0a432 --- /dev/null +++ b/examples/fix/CMakeLists.txt @@ -0,0 +1,15 @@ + +cmake_minimum_required(VERSION 3.15...3.31) + +project( + Fix + VERSION 1.0 + LANGUAGES CXX) + +find_package(Boost REQUIRED COMPONENTS container) + +add_executable(Fix fix.cc) + +target_link_libraries(Fix PRIVATE Boost::container) +set_property(TARGET Fix PROPERTY CXX_STANDARD 20) +target_include_directories(Fix PUBLIC ../../include/ocl) diff --git a/examples/fix/fix.cc b/examples/fix/fix.cc new file mode 100644 index 0000000..eabe3ac --- /dev/null +++ b/examples/fix/fix.cc @@ -0,0 +1,37 @@ +/* + fix example + written by Amlal El Mahrouss. + licensed under the Boost Software License + */ + +#include <core/error_handler.hpp> +#include <net/modem.hpp> +#include <fix/fix.hpp> +#include <iostream> +#include <unistd.h> +#include <io/print.hpp> +#include <sys/socket.h> + +/* finally test it */ +int main(int argc, char** argv) +{ + constexpr auto default_fix = "8=FIX.4.2|9=65|35=A|49=SERVER|56=CLIENT|34=177|52=20090107-18:15:16|98=0|108=30|10=062|"; + + ocl::fix::basic_visitor<char> basic_visitor; + ocl::fix::basic_range_data<char> fix = basic_visitor.visit(default_fix); + + std::cout << "magic=" << fix.magic_ << std::endl; + std::cout << "magic_len=" << fix.magic_len_ << std::endl; + std::cout << "is_valid=" << std::boolalpha << fix.is_valid() << std::endl; + + ocl::basic_error_handler handler; + ocl::fix::must_pass<char, ocl::basic_error_handler>(fix, handler); + + for (auto fields : fix.body_) + { + ocl::io::print("key=", fields.first); + ocl::io::print(", value=", fields.second); + } + + return 0; +} |
