schema_wrapper_utils.cc 646 B

12345678910111213141516171819202122
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #include "schema_wrapper_utils.h"
  3. void set_google_timestamp_from_timeval(struct timeval tv, google::protobuf::Timestamp *ts)
  4. {
  5. ts->set_nanos(tv.tv_usec*1000);
  6. ts->set_seconds(tv.tv_sec);
  7. }
  8. void set_timeval_from_google_timestamp(const google::protobuf::Timestamp &ts, struct timeval *tv)
  9. {
  10. tv->tv_sec = ts.seconds();
  11. tv->tv_usec = ts.nanos()/1000;
  12. }
  13. int label_add_to_map_callback(const char *name, const char *value, RRDLABEL_SRC ls, void *data) {
  14. (void)ls;
  15. auto map = (google::protobuf::Map<std::string, std::string> *)data;
  16. map->insert({name, value});
  17. return 1;
  18. }