SRS-control 0.1.4
Loading...
Searching...
No Matches
DataWriterOptions.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <cstdint>
6#include <filesystem>
7#include <string>
8#include <string_view>
9#include <tuple>
10
11namespace srs
12{
13 enum class DataWriterOption : uint8_t
14 {
15 no_output = 0x00,
16 root = 0x01,
17 json = 0x02,
18 bin = 0x04,
19 udp = 0x10,
20 };
21
22 inline auto get_filetype_from_filename(std::string_view filename)
23 -> std::tuple<DataWriterOption, process::DataConvertOptions>
24 {
25 using enum DataWriterOption;
27 namespace fs = std::filesystem;
28
29 if (auto pos = filename.find(':'); pos != std::string::npos)
30 {
31 if (auto pos = filename.find('?'); pos != std::string::npos)
32 {
33 return { udp, raw };
34 }
35 return { udp, proto };
36 }
37
38 const auto file_ext = fs::path{ filename }.extension().string();
39 if (file_ext == ".bin" or file_ext == ".lmd")
40 {
41 return { bin, raw_frame };
42 }
43 if (file_ext == ".binpb")
44 {
45 return { bin, proto_frame };
46 }
47 if (file_ext == ".root")
48 {
49 return { root, structure };
50 }
51 if (file_ext == ".json")
52 {
53 return { json, structure };
54 }
55
56 return { no_output, none };
57 }
58
59} // namespace srs
asio::ip::udp udp
Definition main.cpp:9
auto get_filetype_from_filename(std::string_view filename) -> std::tuple< DataWriterOption, process::DataConvertOptions >