JayBeams  0.1
Another project to have fun coding.
as_hhmmss.hpp
Go to the documentation of this file.
1 #ifndef jb_as_hhmmss_hpp
2 #define jb_as_hhmmss_hpp
3 
4 #include <chrono>
5 #include <iosfwd>
6 
7 namespace jb {
8 
9 /**
10  * Helper class to print time durations in a HHMMSS.UUUUUU format.
11  */
12 struct as_hhmmssu {
13  /**
14  * Constructor
15  *
16  * @param x a time duration in the units specified by the type
17  *
18  * @tparam time_duration_t an instance of std::chrono::duration, or
19  * any type compatible with std::chrono::duration_cast<>
20  */
21  template <typename time_duration_t>
22  explicit as_hhmmssu(time_duration_t const& x)
23  : t(std::chrono::duration_cast<std::chrono::microseconds>(x)) {
24  }
25 
26  std::chrono::microseconds t;
27 };
28 
29 /// Format as_hhmmssu into an iostream
30 std::ostream& operator<<(std::ostream& os, as_hhmmssu const& x);
31 
32 /**
33  * Helper class to print time durations s in HHMMSS format.
34  */
35 struct as_hhmmss {
36  /**
37  * Constructor
38  *
39  * @param x a time duration in the units specified by the type
40  *
41  * @tparam time_duration_t an instance of std::chrono::duration, or
42  * any type compatible with std::chrono::duration_cast<>
43  */
44  template <typename time_duration_t>
45  explicit as_hhmmss(time_duration_t const& x)
46  : t(std::chrono::duration_cast<std::chrono::microseconds>(x)) {
47  }
48 
49  std::chrono::microseconds t;
50 };
51 
52 /// Format as_hhmmss into an iostream
53 std::ostream& operator<<(std::ostream& os, as_hhmmss const& x);
54 
55 /**
56  * Helper class to print time durations in HH:MM:SS.UUUUUU format.
57  */
58 struct as_hh_mm_ss_u {
59  /**
60  * Constructor
61  *
62  * @param x a time duration in the units specified by the type
63  *
64  * @tparam time_duration_t an instance of std::chrono::duration, or
65  * any type compatible with std::chrono::duration_cast<>
66  */
67  template <typename time_duration_t>
68  explicit as_hh_mm_ss_u(time_duration_t const& x)
69  : t(std::chrono::duration_cast<std::chrono::microseconds>(x)) {
70  }
71 
72  std::chrono::microseconds t;
73 };
74 
75 /// Format as_hh_mm_ss_u into an iostream
76 std::ostream& operator<<(std::ostream& os, as_hh_mm_ss_u const& x);
77 
78 } // namespace jb
79 
80 #endif // jb_as_hhmmss_hpp
as_hh_mm_ss_u(time_duration_t const &x)
Constructor.
Definition: as_hhmmss.hpp:68
as_hhmmssu(time_duration_t const &x)
Constructor.
Definition: as_hhmmss.hpp:22
std::chrono::microseconds t
Definition: as_hhmmss.hpp:72
std::chrono::microseconds t
Definition: as_hhmmss.hpp:26
std::ostream & operator<<(std::ostream &os, as_hhmmssu const &x)
Format as_hhmmssu into an iostream.
Definition: as_hhmmss.cpp:8
STL namespace.
std::chrono::microseconds t
Definition: as_hhmmss.hpp:49
Helper class to print time durations s in HHMMSS format.
Definition: as_hhmmss.hpp:35
Helper class to print time durations in a HHMMSS.UUUUUU format.
Definition: as_hhmmss.hpp:12
Helper class to print time durations in HH:MM:SS.UUUUUU format.
Definition: as_hhmmss.hpp:58
as_hhmmss(time_duration_t const &x)
Constructor.
Definition: as_hhmmss.hpp:45
The top-level namespace for the JayBeams library.
Definition: as_hhmmss.hpp:7