NeTrainSim 0.1.1 beta
The Open-Source Network Trains Simulator
 
Loading...
Searching...
No Matches
utils.h File Reference
#include <iostream>
#include <iomanip>
#include <locale>
#include <sstream>
#include "vector.h"
#include <fstream>
#include <string>
#include <regex>
#include <chrono>
#include <cmath>
#include <tuple>
#include <type_traits>
#include <QVector>

Go to the source code of this file.

Namespaces

namespace  Utils
 

Functions

std::pair< double, double > Utils::dot (Vector< Vector< double > > matrix, std::pair< double, double > &v)
 Compute the dot product of a 2x2 matrix and a 2D vector.
 
double Utils::dot (std::pair< double, double > &u, std::pair< double, double > &v)
 Compute the dot product of two 2D vectors.
 
double Utils::cross (std::pair< double, double > &u, std::pair< double, double > &v)
 Compute the cross product of two 2D vectors.
 
double Utils::getDistanceByTwoCoordinates (const std::pair< double, double > &position1, const std::pair< double, double > &position2)
 Computes the Euclidean distance between two coordinates.
 
double Utils::power (double base, int exponent)
 Powers.
 
template<typename T >
requires std::is_arithmetic<T>
::value std::string Utils::thousandSeparator (T n, int decimals=3)
 Convert a plain numeric value to thousand separated value.
 
template<typename T >
std::string Utils::formatDuration (T seconds)
 Format duration.
 
std::string Utils::getFilenameWithoutExtension (std::string path)
 
std::string Utils::getPrefix (std::string str)
 
Vector< double > Utils::splitStringToDoubleVector (const std::string &input, char delimiter=',')
 Splits string to double vector.
 
Vector< int > Utils::splitStringToIntVector (const std::string &str)
 The function stringToIntVector takes a string as input and converts it into a Vector<int> by parsing the string for comma-separated integers and pushing each one onto the vector.
 
Vector< std::string > Utils::split (const std::string &s, char delimiter)
 This function is splitting a given string "s" into substrings using a delimiter "delimiter" and returning the resulting substrings as a vector of strings.
 
Vector< int > Utils::convertStringVectorToIntVector (const std::vector< std::string > &stringVector)
 
std::string Utils::trim (const std::string &str)
 This function trim takes in a string str and returns a copy of it with leading and trailing white spaces removed.
 
bool Utils::writeToFile (std::stringstream &s, std::string filename)
 
template<typename... Args>
std::stringstream Utils::convertTupleToStringStream (const std::tuple< Args... > &t, int limit, std::string delim="\t")
 
template<typename Tuple , size_t... Indices>
void Utils::addTupleValuesToStreamImpl (const Tuple &t, std::stringstream &ss, std::index_sequence< Indices... >, int limit, std::string delim)
 
template<typename T >
void Utils::writeToStream (const T &value, std::stringstream &ss, std::string delim)
 
std::string Utils::removeLastWord (const std::string &originalString)
 
QVector< double > Utils::convertQStringVectorToDouble (const QVector< QString > &stringVector)
 
QVector< double > Utils::subtractQVector (const QVector< double > l1, const QVector< double > l2)
 
QVector< double > Utils::factorQVector (const QVector< double > l1, const double factor)
 
Vector< std::pair< std::string, std::string > > Utils::splitStringStream (std::stringstream &ss, const std::string &delimiter=":")
 
std::string Utils::replaceAll (std::string str, const std::string &from, const std::string &to)