Fleet  0.0.9
Inference in the LOT
Classes | Functions
str.h File Reference
#include <sstream>
#include <queue>
#include <array>
#include <map>
#include <set>
#include <atomic>
#include <string>
Include dependency graph for str.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  has_string< T >
 

Functions

std::deque< std::string > split (const std::string &s, const char delimiter)
 Split is returns a deque of s split up at the character delimiter. It handles these special cases: split("a:", ':') -> ["a", ""] split(":", ':') -> [""] split(":a", ':') -> ["", "a"]. More...
 
template<typename T >
std::string str (T x)
 A pythonesque string function. This gets specialized in many ways. More...
 
std::string str (const std::string &x)
 
template<typename... T, size_t... I>
std::string str (const std::tuple< T... > &x, std::index_sequence< I... > idx)
 
template<typename... T>
std::string str (const std::tuple< T... > &x)
 
template<typename A , typename B >
std::string str (const std::pair< A, B > x)
 
template<typename T , size_t N>
std::string str (const std::array< T, N > &a)
 
template<typename T >
std::string str (const std::vector< T > &a, const std::string _sep=",")
 
template<typename T , typename U >
std::string str (const std::map< T, U > &a)
 
template<typename T >
std::string str (const std::set< T > &a)
 
template<typename T >
std::string str (const std::atomic< T > &a)
 
template<typename... Args>
std::string str (std::string _sep, Args... args)
 
template<typename T >
string_to (const std::string s)
 Fleet includes this templated function to allow us to convert strings to a variety of formats. This is mostly used for reading data from text files. This recursively will unpack containers with some standard delimiters. Since it can handle Fleet types (e.g. defaultdata_t) it can be used to unpack data stored in strings (see e.g. Models/Sorting) More...
 
template<>
std::string string_to (const std::string s)
 
template<>
int string_to (const std::string s)
 
template<>
long string_to (const std::string s)
 
template<>
unsigned long string_to (const std::string s)
 
template<>
double string_to (const std::string s)
 
template<>
float string_to (const std::string s)
 
template<>
bool string_to (const std::string s)
 

Function Documentation

◆ split()

std::array< std::string, N > split ( const std::string &  s,
const char  delimiter 
)

Split is returns a deque of s split up at the character delimiter. It handles these special cases: split("a:", ':') -> ["a", ""] split(":", ':') -> [""] split(":a", ':') -> ["", "a"].

Split with a fixed return size, useful in parsing csv.

Parameters
s
delimiter
Returns

◆ str() [1/11]

template<typename T >
std::string str ( x)

A pythonesque string function. This gets specialized in many ways.

c

Parameters
x
Returns

◆ str() [2/11]

std::string str ( const std::string &  x)

◆ str() [3/11]

template<typename... T, size_t... I>
std::string str ( const std::tuple< T... > &  x,
std::index_sequence< I... >  idx 
)

A pythonesque string function

Parameters
x
Returns

◆ str() [4/11]

template<typename... T>
std::string str ( const std::tuple< T... > &  x)

A pythonesque string function

Parameters
x
Returns

◆ str() [5/11]

template<typename A , typename B >
std::string str ( const std::pair< A, B >  x)

A pythonesque string function

Parameters
x
Returns

◆ str() [6/11]

template<typename T , size_t N>
std::string str ( const std::array< T, N > &  a)

A pythonesque string function

Parameters
x
Returns

◆ str() [7/11]

template<typename T >
std::string str ( const std::vector< T > &  a,
const std::string  _sep = "," 
)

A pythonesque string function

Parameters
x
Returns

◆ str() [8/11]

template<typename T , typename U >
std::string str ( const std::map< T, U > &  a)

A pythonesque string function

Parameters
x
Returns

◆ str() [9/11]

template<typename T >
std::string str ( const std::set< T > &  a)

A pythonesque string function

Parameters
x
Returns

◆ str() [10/11]

template<typename T >
std::string str ( const std::atomic< T > &  a)

A pythonesque string function

Parameters
x
Returns

◆ str() [11/11]

template<typename... Args>
std::string str ( std::string  _sep,
Args...  args 
)

◆ string_to() [1/8]

template<typename T >
T string_to ( const std::string  s)

Fleet includes this templated function to allow us to convert strings to a variety of formats. This is mostly used for reading data from text files. This recursively will unpack containers with some standard delimiters. Since it can handle Fleet types (e.g. defaultdata_t) it can be used to unpack data stored in strings (see e.g. Models/Sorting)

Parameters
s
Returns

◆ string_to() [2/8]

template<>
std::string string_to ( const std::string  s)

◆ string_to() [3/8]

template<>
int string_to ( const std::string  s)

◆ string_to() [4/8]

template<>
long string_to ( const std::string  s)

◆ string_to() [5/8]

template<>
unsigned long string_to ( const std::string  s)

◆ string_to() [6/8]

template<>
double string_to ( const std::string  s)

◆ string_to() [7/8]

template<>
float string_to ( const std::string  s)

◆ string_to() [8/8]

template<>
bool string_to ( const std::string  s)