dodo  0.0.1
A C++ library to create containerized Linux services
util.cpp File Reference
#include <common/exception.hpp>
#include <common/util.hpp>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <ios>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
#include <unistd.h>
Include dependency graph for util.cpp:

Go to the source code of this file.

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::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...
 
std::string dodo::common::getSSLErrors (char terminator)
 Get all OpenSSL errors as a single string, and clear their error state. More...
 
std::string dodo::common::strASCII (char c)
 Return ASCII representation of char. 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 bool dodo::common::YAML_read_key< bool > (const YAML::Node &, const std::string &)
 Instantiate template YAML_read_key for bool. More...
 
template double dodo::common::YAML_read_key< double > (const YAML::Node &, const std::string &)
 Instantiate template YAML_read_key for double. More...
 
template int dodo::common::YAML_read_key< int > (const YAML::Node &, const std::string &)
 Instantiate template YAML_read_key for int. More...
 
template long dodo::common::YAML_read_key< long > (const YAML::Node &, const std::string &)
 Instantiate template YAML_read_key for long. More...
 
template size_t dodo::common::YAML_read_key< size_t > (const YAML::Node &, const std::string &)
 Instantiate template YAML_read_key for size_t. More...
 
template std::string dodo::common::YAML_read_key< std::string > (const YAML::Node &, const std::string &)
 Instantiate template YAML_read_key for std::string. More...
 
template uint16_t dodo::common::YAML_read_key< uint16_t > (const YAML::Node &, const std::string &)
 Instantiate template YAML_read_key for uint16_t. More...
 
template unsigned int dodo::common::YAML_read_key< unsigned int > (const YAML::Node &, const std::string &)
 Instantiate template YAML_read_key for unsigned int. 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...
 
template bool dodo::common::YAML_read_key_default< bool > (const YAML::Node &, const std::string &, const bool &)
 Instantiate template YAML_read_key for bool. More...
 
template double dodo::common::YAML_read_key_default< double > (const YAML::Node &, const std::string &, const double &)
 Instantiate template YAML_read_key for double. More...
 
template int dodo::common::YAML_read_key_default< int > (const YAML::Node &, const std::string &, const int &)
 Instantiate template YAML_read_key for int. More...
 
template long dodo::common::YAML_read_key_default< long > (const YAML::Node &, const std::string &, const long &)
 Instantiate template YAML_read_key for long. More...
 
template size_t dodo::common::YAML_read_key_default< size_t > (const YAML::Node &, const std::string &, const size_t &)
 Instantiate template YAML_read_key for size_t. More...
 
template std::string dodo::common::YAML_read_key_default< std::string > (const YAML::Node &, const std::string &, const std::string &)
 Instantiate template YAML_read_key for std::string. More...
 
template unsigned int dodo::common::YAML_read_key_default< unsigned int > (const YAML::Node &, const std::string &, const unsigned int &)
 Instantiate template YAML_read_key for unsigned int. More...
 

Detailed Description

Implement utility things.

Definition in file util.cpp.