subsecond_time_c.h 900 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef __SUBSECOND_TIME_C_H
  2. #define __SUBSECOND_TIME_C_H
  3. // POD and c-linkage subsecond-time header
  4. #ifdef __cplusplus
  5. #include <iostream>
  6. #include <cstdint>
  7. #else
  8. #include <stdint.h>
  9. #endif
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. // This subsecond_time_t struct is used for c-linkage cases
  14. struct subsecond_time_s {
  15. #ifdef __cplusplus
  16. // Remove all constructors to make this data structure POD
  17. // Conversion to/from SubsecondTime is defined by the SubsecondTime class
  18. // From http://www.stackoverflow.com/questions/4421706
  19. subsecond_time_s& operator+=(const subsecond_time_s &rhs)
  20. {
  21. m_time += rhs.m_time;
  22. return *this;
  23. }
  24. #endif
  25. uint64_t m_time;
  26. };
  27. typedef struct subsecond_time_s subsecond_time_t;
  28. #ifdef __cplusplus
  29. }
  30. #endif
  31. #ifdef __cplusplus
  32. std::ostream &operator<<(std::ostream &os, const subsecond_time_t &time);
  33. #endif
  34. #endif /* __SUBSECOND_TIME_C_H */