BPNGClientLib
Library for accessing the Telemotive data logger devices
Functions
clientUtil.hh File Reference

Helper functions. More...

#include <chrono>
#include <iosfwd>
#include <iostream>
#include <sstream>
#include <time.h>
#include <string.h>
#include <vector>
#include <sys/stat.h>

Go to the source code of this file.

Functions

const char * progname (const char *path)
 Get the program name, similar to basename.
 
template<class Duration >
constexpr std::chrono::hours toHours (const Duration &d)
 
template<class Duration >
constexpr std::chrono::minutes toMinutes (const Duration &d)
 
template<class Duration >
constexpr std::chrono::seconds toSeconds (const Duration &d)
 
template<class Duration >
constexpr std::chrono::milliseconds toMilliseconds (const Duration &d)
 
template<class Duration >
constexpr std::chrono::microseconds toMicroseconds (const Duration &d)
 
template<class Duration >
constexpr std::chrono::nanoseconds toNanoseconds (const Duration &d)
 
template<typename Rep , typename Period >
timespec toTimespec (const std::chrono::duration< Rep, Period > &d)
 Convert a chrono duration into a POSIX timespec.
 
std::ostream & operator<< (std::ostream &os, const tm &_t)
 
std::ostream & operator<< (std::ostream &os, const timespec &_t)
 Output operator for struct timespec as used e.g. by pselect or nanosleep. More...
 
template<typename Rep , typename Period >
std::ostream & operator<< (std::ostream &os, const std::chrono::duration< Rep, Period > &d)
 Output operator for a chrono duration. More...
 
template<typename Rep >
std::ostream & operator<< (std::ostream &os, const std::chrono::duration< Rep, std::ratio< 1 >> &d)
 Output operator for a chrono duration with period one. More...
 
template<typename Rep >
std::ostream & operator<< (std::ostream &os, const std::chrono::duration< Rep, std::milli > &d)
 Output operator for a chrono duration with Period milli. More...
 
template<typename Rep >
std::ostream & operator<< (std::ostream &os, const std::chrono::duration< Rep, std::micro > &d)
 Output operator for a chrono duration with Period micro. More...
 
template<typename Rep >
std::ostream & operator<< (std::ostream &os, const std::chrono::duration< Rep, std::nano > &d)
 Output operator for a chrono duration with Period nano. More...
 
template<typename Clock , typename Duration >
std::ostream & operator<< (std::ostream &os, const std::chrono::time_point< Clock, Duration > &tp)
 
int mkdirPath (const std::string &_dirpath, int _mode=S_IRWXU|S_IRWXG|S_IRWXO)
 

Detailed Description

Helper functions.

Function Documentation

◆ operator<<() [1/7]

std::ostream& operator<< ( std::ostream &  os,
const timespec &  _t 
)

Output operator for struct timespec as used e.g. by pselect or nanosleep.

Prints out the time specified in _t in seconds.

◆ operator<<() [2/7]

template<typename Rep , typename Period >
std::ostream& operator<< ( std::ostream &  os,
const std::chrono::duration< Rep, Period > &  d 
)
inline

Output operator for a chrono duration.

If the duration has to be printed in a hh:mm:ss.ms notation you have to use e.g.

cout << toTimespec(d)

◆ operator<<() [3/7]

template<typename Rep >
std::ostream& operator<< ( std::ostream &  os,
const std::chrono::duration< Rep, std::ratio< 1 >> &  d 
)

Output operator for a chrono duration with period one.

Formatting:

  • std::ios::showbase: the unit "s" will be printed
  • std::ios::skipws: no space between the time and the unit

◆ operator<<() [4/7]

template<typename Rep >
std::ostream& operator<< ( std::ostream &  os,
const std::chrono::duration< Rep, std::milli > &  d 
)

Output operator for a chrono duration with Period milli.

Formatting:

  • std::ios::showbase: the unit "ms" will be printed
  • std::ios::skipws: no space between the time and the unit

◆ operator<<() [5/7]

template<typename Rep >
std::ostream& operator<< ( std::ostream &  os,
const std::chrono::duration< Rep, std::micro > &  d 
)

Output operator for a chrono duration with Period micro.

Formatting:

  • std::ios::showbase: the unit "µs" will be printed
  • std::ios::skipws: no space between the time and the unit

◆ operator<<() [6/7]

template<typename Rep >
std::ostream& operator<< ( std::ostream &  os,
const std::chrono::duration< Rep, std::nano > &  d 
)

Output operator for a chrono duration with Period nano.

Formatting:

  • std::ios::showbase: the unit "ns" will be printed
  • std::ios::skipws: no space between the time and the unit

◆ operator<<() [7/7]

template<typename Clock , typename Duration >
std::ostream& operator<< ( std::ostream &  os,
const std::chrono::time_point< Clock, Duration > &  tp 
)
inline

Output operator for a chrono time point. Prints the date and time since the epoch. The following adjustments can be done:

  • If std::ios_base::scientific is set in the flags the duration will be printed seconds plus fractions of a second, otherwise it will be printed in a readable format.
  • If the precision is set to a value of 9 or larger nanosecond precision is printed.