dodo  0.0.1
A C++ library to create containerized Linux services
util.hpp File Reference
#include <chrono>
#include <string>
#include <ostream>
#include <regex>
#include <set>
#include <sstream>
#include <vector>
#include "buildenv.hpp"
#include <sys/time.h>
#include <yaml-cpp/yaml.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
Include dependency graph for util.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  dodo::common::StopWatch
 StopWatch timing class. More...
 

Namespaces

 dodo
 A C++ platform interface to lean Linux services tailored for containerized deployment.
 
 dodo::common
 Common and utility interfaces.
 

Functions

bool dodo::common::availableFileSpace (const std::string &path, size_t &avail)
 Return true when the free space could be determined, and set in avail. More...
 
std::string dodo::common::bio2String (BIO *bio)
 Convert the data contents of an OpenSSL BIO to a std::string. More...
 
bool dodo::common::directoryExists (const std::string &path)
 Return true when the directory exists. More...
 
bool dodo::common::directoryWritable (const std::string &path)
 Return true when the directory exists and is writable to the caller. More...
 
void dodo::common::dumpBinaryData (std::ostream &out, const std::string &s, size_t width)
 Dump binary data to a std::ostream. More...
 
std::vector< std::string > dodo::common::escapedSplit (const std::string &src, std::set< char > escape, char delimiter=' ')
 Split a string into substrings by delimiter - unless the delimiter is escaped. More...
 
std::string dodo::common::escapeJSON (const std::string &s)
 Escape a JSOn string. More...
 
bool dodo::common::fileReadAccess (const std::string &path)
 Return true when the file exists and the calling user has read access. More...
 
bool dodo::common::fileReadInt (const std::string &file, int &i)
 Read from a file, expecting it to contain a (signed) int. More...
 
std::string dodo::common::fileReadString (const std::string &filename)
 Read the file as a single string. More...
 
std::vector< std::string > dodo::common::fileReadStrings (const std::string &filename)
 Read the file as vector of strings. More...
 
std::vector< std::string > dodo::common::fileReadStrings (const std::string &filename, const std::regex &exp)
 Read the file as vector of strings, return only regexp matches. More...
 
std::string dodo::common::formatDateTimeUTC (const struct timeval &tv)
 Return a datetime string in UTC (2020-07-01T20:14:36.442929Z) More...
 
size_t dodo::common::getFileSize (const std::string &path)
 Return the size of the file. More...
 
double dodo::common::getSecondDiff (struct timeval &t1, struct timeval &t2)
 Return difference in seconds as a double. More...
 
std::string dodo::common::getSSLErrors (char terminator)
 Get all OpenSSL errors as a single string, and clear their error state. More...
 
std::vector< std::string > dodo::common::split (const std::string &src, char delimiter=' ')
 Split a string into substrings. More...
 
size_t dodo::common::writeSSLErrors (std::ostream &out, char terminator)
 Write OpenSSL errors occurred in this thread to ostream, and clear their error state. More...
 
template<typename T >
dodo::common::YAML_read_key (const YAML::Node &node, const std::string &key)
 Template function to check existence and read YAML values of arbitrary type. More...
 
template<typename T >
dodo::common::YAML_read_key_default (const YAML::Node &node, const std::string &key, const T &default_value)
 Template function to check existence and read YAML values of arbitrary type. More...
 

Detailed Description

Defines utilities.

Definition in file util.hpp.