Fast map matching  0.1.0
Typedefs | Functions | Variables
FMM::UTIL Namespace Reference

Utility functions. More...

Typedefs

typedef std::chrono::steady_clock::time_point TimePoint
 Time point.
 

Functions

bool file_exists (const char *filename)
 Check if file exist or not. More...
 
bool file_exists (const std::string &filename)
 Check if file exist or not. More...
 
std::vector< std::string > split_string (const std::string &str)
 Split a string containing string separated by , into a vector of string. More...
 
bool string2bool (const std::string &str)
 Convert string to bool. More...
 
std::chrono::time_point< std::chrono::system_clock > get_current_time ()
 Get current timestamp. More...
 
void print_time (const std::chrono::time_point< std::chrono::system_clock > &start_time)
 Print a timestamp. More...
 
double get_duration (const std::chrono::time_point< std::chrono::system_clock > &start_time, const std::chrono::time_point< std::chrono::system_clock > &end_time)
 Calculate the duration between two time points. More...
 
bool check_file_extension (const std::string &filename, const std::string &extension_list_str)
 Check if the filename has an extension in the list. More...
 
bool folder_exist (const std::string &folder_name)
 Check if folder exists or not. More...
 
std::string get_file_directory (const std::string &fn)
 Get folder path from file path. More...
 
std::string bool2string (bool value)
 Convert bool to string. More...
 
template<typename T >
std::string vec2string (const std::vector< T > &vec)
 Convert a vector of type into a string with delimiter of ,. More...
 
template<typename T >
std::vector< T > string2vec (const std::string &str)
 Convert string to vector. More...
 

Variables

static const std::vector< std::string > LOG_LEVESLS
 Log level strings for printing the log level information. More...
 

Detailed Description

Utility functions.

Function Documentation

◆ bool2string()

std::string FMM::UTIL::bool2string ( bool  value)
inline

Convert bool to string.

Parameters
valuebool value
Returns
"true" if value is true

Definition at line 127 of file util.hpp.

◆ check_file_extension()

bool FMM::UTIL::check_file_extension ( const std::string &  filename,
const std::string &  extension_list_str 
)

Check if the filename has an extension in the list.

Parameters
filename
extension_list_stra list of string separated by ,
Returns
true if file extension is in the list

Definition at line 105 of file util.cpp.

◆ file_exists() [1/2]

bool FMM::UTIL::file_exists ( const char *  filename)

Check if file exist or not.

Parameters
filenamefile name
Returns
true if file exists

Definition at line 61 of file util.cpp.

◆ file_exists() [2/2]

bool FMM::UTIL::file_exists ( const std::string &  filename)

Check if file exist or not.

Parameters
filenamefile name
Returns
true if file exists

Definition at line 69 of file util.cpp.

◆ folder_exist()

bool FMM::UTIL::folder_exist ( const std::string &  folder_name)

Check if folder exists or not.

Parameters
folder_namefolder name
Returns
true if folder exists

Definition at line 120 of file util.cpp.

◆ get_current_time()

std::chrono::time_point< std::chrono::system_clock > FMM::UTIL::get_current_time ( )

Get current timestamp.

Returns
a timestamp point

Definition at line 88 of file util.cpp.

◆ get_duration()

double FMM::UTIL::get_duration ( const std::chrono::time_point< std::chrono::system_clock > &  start_time,
const std::chrono::time_point< std::chrono::system_clock > &  end_time 
)

Calculate the duration between two time points.

Parameters
start_timestart time point
end_timeend time point
Returns
the duration between two time points

Definition at line 99 of file util.cpp.

◆ get_file_directory()

std::string FMM::UTIL::get_file_directory ( const std::string &  fn)

Get folder path from file path.

Parameters
fnFile path
Returns
Folder path to a file

Definition at line 129 of file util.cpp.

◆ print_time()

void FMM::UTIL::print_time ( const std::chrono::time_point< std::chrono::system_clock > &  start_time)

Print a timestamp.

Parameters
start_timetimestamp point

Definition at line 93 of file util.cpp.

◆ split_string()

std::vector< std::string > FMM::UTIL::split_string ( const std::string &  str)

Split a string containing string separated by , into a vector of string.

Parameters
strinput string
Returns
a vector of strings

Definition at line 73 of file util.cpp.

◆ string2bool()

bool FMM::UTIL::string2bool ( const std::string &  str)

Convert string to bool.

Parameters
strinput string
Returns
true if str equals "true", "t" or "1";

Definition at line 84 of file util.cpp.

◆ string2vec()

template<typename T >
std::vector<T> FMM::UTIL::string2vec ( const std::string &  str)

Convert string to vector.

Parameters
stra string containing a list of values separated by ,
Returns
a vector of values

Definition at line 163 of file util.hpp.

◆ vec2string()

template<typename T >
std::string FMM::UTIL::vec2string ( const std::vector< T > &  vec)

Convert a vector of type into a string with delimiter of ,.

Parameters
vecinput vector
Returns
a string of values in the vector delimited by ,

Definition at line 146 of file util.hpp.

Variable Documentation

◆ LOG_LEVESLS

const std::vector<std::string> FMM::UTIL::LOG_LEVESLS
static
Initial value:
{"0-trace","1-debug","2-info",
"3-warn","4-err","5-critical","6-off"}

Log level strings for printing the log level information.

Definition at line 28 of file debug.hpp.