Introduce time units
[pulseview.git] / pv / util.hpp
index 5466322b738aec51d60904be5df765de45a389d2..f13516508aa45da7050a1aef0b9dd14f803e98af 100644 (file)
@@ -18,8 +18,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-#ifndef PULSEVIEW_UTIL_H
-#define PULSEVIEW_UTIL_H
+#ifndef PULSEVIEW_UTIL_HPP
+#define PULSEVIEW_UTIL_HPP
 
 #include <cmath>
 
 namespace pv {
 namespace util {
 
+enum TimeUnit {
+       Time = 1,
+       Samples = 2
+};
+
 extern const int FirstSIPrefixPower;
 
 /**
@@ -57,7 +62,8 @@ QString format_si_value(
  * @return The formated value.
  */
 QString format_time(
-       double t, int prefix = -1, unsigned precision = 0, bool sign = true);
+       double t, int prefix = -1, TimeUnit unit = Time, unsigned precision = 0,
+       bool sign = true);
 
 /**
  * Formats a given time value with a SI prefix so that the
@@ -71,4 +77,4 @@ QString format_second(double second);
 } // namespace util
 } // namespace pv
 
-#endif // PULSEVIEW_UTIL_H
+#endif // PULSEVIEW_UTIL_HPP