MADARA  3.2.3
Utility.cpp File Reference
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <ios>
#include <iostream>
#include <sstream>
#include <fstream>
#include <thread>
#include "madara/logger/GlobalLogger.h"
#include "madara/utility/Utility.h"
#include "madara/utility/EpochEnforcer.h"
#include "madara/knowledge/KnowledgeBase.h"
#include "Timer.h"
#include "madara/Version.h"

Go to the source code of this file.

Namespaces

 madara
 Copyright (c) 2015 Carnegie Mellon University.
 
 madara::utility
 Provides utility functions and classes for common tasks and needs.
 

Macros

#define REPLACE_THIS   '\\'
 
#define REPLACE_WITH   '/'
 

Functions

std::string madara::utility::clean_dir_name (const std::string &target)
 Substitutes the appropriate directory delimiter, which may help with portability between operating systems. More...
 
std::string madara::utility::expand_envs (const std::string &source)
 Expand any environment variables in a string. More...
 
std::string madara::utility::extract_filename (const std::string &name)
 Extracts the file name of an absolute or relative path. More...
 
std::string madara::utility::extract_path (const std::string &name)
 Extracts the path of a filename. More...
 
std::string madara::utility::file_to_string (const std::string &filename)
 Reads a file into a string. More...
 
uint32_t madara::utility::get_uint_version (void)
 Gets the MADARA version number. More...
 
char * madara::utility::get_var (const std::string &source, size_t cur, size_t &end)
 grab an environment variable value ( More...
 
std::string madara::utility::get_version (void)
 Gets the MADARA version number. More...
 
int madara::utility::merge_hostport_identifier (std::string &key, const std::string &host, const std::string &port)
 Merges a host and port into a host:port key. More...
 
int madara::utility::merge_hostport_identifier (std::string &key, const std::string &host, unsigned short u_port)
 Merges a host and port into a host:port key. More...
 
int64_t madara::utility::nearest_int (double input)
 Rounds a double to the nearest integer. More...
 
std::pair< std::string, uint16_t > madara::utility::parse_address (std::string addr)
 
double madara::utility::rand_double (double floor=0.0, double ceiling=1.0, bool set_seed_to_time=true)
 Returns a random double between floor and ceiling. More...
 
int64_t madara::utility::rand_int (int64_t floor=0, int64_t ceiling=RAND_MAX, bool set_seed_to_time=true)
 Returns a random integer between a floor and ceiling. More...
 
int madara::utility::read_file (const std::string &filename, void *&buffer, size_t &size, bool add_zero_char=false)
 Reads a file into a provided void pointer. More...
 
double madara::utility::sleep (double sleep_time)
 Sleeps for a certain amount of time. More...
 
SecondsDuration madara::utility::sleep (const SecondsDuration &sleep_time)
 Sleeps for a certain amount of time. More...
 
int madara::utility::split_hostport_identifier (const std::string &key, std::string &host, std::string &port)
 Splits a key of host:port into a corresponding host and port. More...
 
std::string & madara::utility::string_remove (std::string &input, char unwanted)
 Strips an unwanted character. More...
 
size_t madara::utility::string_replace (std::string &source, const std::string &old_phrase, const std::string &new_phrase, bool replace_all=true)
 Replaces an old phrase with a new phrase within a string. More...
 
std::string & madara::utility::strip_comments (std::string &input)
 Strips all comments (single-line and multi-line). More...
 
std::string & madara::utility::strip_extra_white_space (std::string &input)
 Strip whitespace from front and end of string and also condense multiple whitespace into a single space. More...
 
std::string & madara::utility::strip_white_space (std::string &input)
 Strip all whitespace. More...
 
std::string madara::utility::to_string_version (uint32_t version)
 Converts a MADARA uint32_t version number to human-readable. More...
 
void madara::utility::tokenizer (const std::string &input, const ::std::vector< std::string > &splitters,::std::vector< std::string > &tokens,::std::vector< std::string > &pivots)
 Split a string into tokens. More...
 
bool madara::utility::wait_false (knowledge::KnowledgeBase &knowledge, const std::string &variable, const knowledge::WaitSettings &settings=knowledge::WaitSettings())
 Waits on a knowledge record to be false without needing KaRL language. More...
 
bool madara::utility::wait_true (knowledge::KnowledgeBase &knowledge, const std::string &variable, const knowledge::WaitSettings &settings=knowledge::WaitSettings())
 Waits on a knowledge record to be true without needing KaRL language. More...
 
ssize_t madara::utility::write_file (const std::string &filename, void *buffer, size_t size)
 Writes a file with provided contents. More...
 

Macro Definition Documentation

#define REPLACE_THIS   '\\'
#define REPLACE_WITH   '/'