ifw-daq  3.0.0-pre2
IFW Data Acquisition modules
parsing.cpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup daq_ocm_libdaqif_suppport
4  * @copyright 2022 ESO - European Southern Observatory
5  *
6  * @brief Contains parse functions for daqif
7  */
8 
9 #include <daqif/parsing.hpp>
10 
11 #include <fmt/format.h>
12 #include <fmt/ostream.h>
13 #include <boost/algorithm/string/predicate.hpp>
14 
15 using namespace std::string_view_literals;
16 
17 namespace daqif {
18 
19 template<>
20 DaqState FromString<DaqState>(std::string_view state) {
21  if (boost::iequals(state, "StateAcquiring"sv)) {
22  return DaqState::StateAcquiring;
23  }
24  if (boost::iequals(state, "StateMerging"sv)) {
25  return DaqState::StateMerging;
26  }
27  if (boost::iequals(state, "StateCompleted"sv)) {
28  return DaqState::StateCompleted;
29  }
30  throw std::invalid_argument(fmt::format("Invalid DaqState '{}'", state));
31 }
32 
33 template<>
34 DaqSubState FromString<DaqSubState>(std::string_view state) {
35  if (boost::iequals(state, "NotStarted"sv)) {
36  return DaqSubState::NotStarted;
37  }
38  if (boost::iequals(state, "Starting"sv)) {
39  return DaqSubState::Starting;
40  }
41  if (boost::iequals(state, "Acquiring"sv)) {
42  return DaqSubState::Acquiring;
43  }
44  if (boost::iequals(state, "Stopping"sv)) {
45  return DaqSubState::Stopping;
46  }
47  if (boost::iequals(state, "Stopped"sv)) {
48  return DaqSubState::Stopped;
49  }
50  if (boost::iequals(state, "Aborting"sv)) {
51  return DaqSubState::Aborting;
52  }
53  if (boost::iequals(state, "NotScheduled"sv)) {
54  return DaqSubState::NotScheduled;
55  }
56  if (boost::iequals(state, "Scheduled"sv)) {
57  return DaqSubState::Scheduled;
58  }
59  if (boost::iequals(state, "Transferring"sv)) {
60  return DaqSubState::Transferring;
61  }
62  if (boost::iequals(state, "Merging"sv)) {
63  return DaqSubState::Merging;
64  }
65  if (boost::iequals(state, "Releasing"sv)) {
66  return DaqSubState::Releasing;
67  }
68  if (boost::iequals(state, "Completed"sv)) {
69  return DaqSubState::Completed;
70  }
71  if (boost::iequals(state, "Aborted"sv)) {
72  return DaqSubState::Aborted;
73  }
74  throw std::invalid_argument(fmt::format("Invalid DaqSubState '{}'", state));
75 }
76 
77 } //namespace daqif
DaqState FromString< DaqState >(std::string_view state)
Parse state name.
Definition: parsing.cpp:20
DaqSubState FromString< DaqSubState >(std::string_view state)
Parse sub-state name.
Definition: parsing.cpp:34
Contains parse functions for daqif.