Myra Canyon  v0.0.1-768
network control
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tools.hpp File Reference

Common tools and functions for Myra Canyon. More...

#include "Types.hpp"
#include <string>
#include <ctime>
#include <cstdio>
Include dependency graph for Tools.hpp:
This graph shows which files directly or indirectly include this file:

Namespaces

 Myra
 Namespace declaration for all of the Myra Canyon helper functions.
 

Functions

std::size_t Myra::number_of_processing_units (void)
 Get the number of processing units available. This returns the sum of CPUs, cores, hyperthreads, etc. More...
 
VStr Myra::run_command_and_get_vector (const std::string &cmd)
 Run a command and get all of the output from STDOUT. More...
 
std::string Myra::run_command_and_get_string (const std::string &cmd)
 Run a command and get all of the output from STDOUT. More...
 
std::string Myra::read_text_file (const std::string &filename)
 Read an entire text file. More...
 
void Myra::write_file (const std::string &filename, const std::string &text)
 Write a text file. This writes the file to a temporary location, then renames it to the requested name. More...
 
bool Myra::is_root (void)
 Determine if we're running with root-level access. More...
 
std::string Myra::approximate_time (const time_t tt)
 Build a text string that tells us approximately when a specific event took place. More...
 
std::string Myra::approximate_time (const TP &when)
 Similar to the other approximate_time() function, but takes a TP reference. More...
 
std::string Myra::cpp_demangle (const std::string &str)
 Demangle the given C++ name. This is compiler-specific. More...
 
FD Myra::create_pid_lockfile (const std::string &name)
 Create a PID lock file. This creates and places an exclusive lock on a PID file in /var/run/. More...
 
void Myra::release_pid_lockfile (FD &pid_fd)
 Release the PID lock file. This unlocks the file in /var/run/ created by create_pid_lockfile(). More...
 
std::string Myra::hex_out (const std::string &str, const int number_of_rows_to_display=4)
 Produce hex output for the given data. More...
 
std::string Myra::hex_out (const uint8_t *data, const size_t len, const int number_of_rows_to_display=4)
 
std::string Myra::format_SI_or_IEC (const long double &bytes, std::string &postfix, const int divider)
 } More...
 
std::string Myra::format_bytes_SI (const uint64_t &bytes)
 
std::string Myra::format_bytes_IEC (const uint64_t &bytes)
 
std::string Myra::format_bps (const uint64_t &bytes, std::size_t seconds)
 
std::string & Myra::ltrim (std::string &str)
 Trim whitespace from string. More...
 
std::string & Myra::rtrim (std::string &str)
 
std::string Myra::ltrim (const std::string &str)
 
std::string Myra::rtrim (const std::string &str)
 
std::string Myra::trim (const std::string &str)
 Trim whitespace from string. More...
 
std::string & Myra::trim (std::string &str)
 Trim whitespace from string. More...
 

Detailed Description

Common tools and functions for Myra Canyon.