A library for working with phylogenetic and population genetic data.
v0.32.0
convert.hpp File Reference
#include "genesis/utils/text/string.hpp"
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <typeinfo>
#include <vector>

Go to the source code of this file.

Namespaces

 genesis
 Container namespace for all symbols of genesis in order to keep them separate when used as a library.
 
 genesis::utils
 

Functions

template<typename T >
convert_from_string (std::string const &str, bool trim=false)
 Generic conversion from string to any data type that is supported by std::stringsteam operator >>. More...
 
template<>
double convert_from_string< double > (std::string const &str, bool trim)
 Specialization of the generic conversion function for double, which also takes nan and inf into account. More...
 
template<>
std::string convert_from_string< std::string > (std::string const &str, bool trim)
 Specialization of the generic conversion function for std::string. More...
 
template<typename ForwardIterator >
std::vector< bool > convert_to_bool (ForwardIterator first, ForwardIterator last, size_t size=0)
 
bool convert_to_bool (std::string const &str)
 Convert a string to bool, return the result, and throw an exception when the conversion was not successful. More...
 
bool convert_to_bool (std::string const &str, bool &result)
 Convert a string to bool, store the result in result, and return whether the conversion as successful. More...
 
template<typename ForwardIterator >
std::vector< double > convert_to_bool_double (ForwardIterator first, ForwardIterator last, size_t size=0)
 
double convert_to_bool_double (std::string const &str)
 Convert a string to bool, but return it as a double, and throw an exception when the conversion was not successful. More...
 
bool convert_to_bool_double (std::string const &str, double &result)
 Convert a string to bool, but store the result as a double in result, and return whether the conversion as successful. More...
 
template<typename ForwardIterator >
std::vector< double > convert_to_double (ForwardIterator first, ForwardIterator last, size_t size=0)
 
double convert_to_double (std::string const &str)
 Convert a string to double, return the result, and throw an exception when the conversion was not successful. More...
 
bool convert_to_double (std::string const &str, double &result)
 Convert a string to double, store the result in result, and return whether the conversion as successful. More...
 
template<typename ForwardIterator >
std::vector< long long > convert_to_signed_integer (ForwardIterator first, ForwardIterator last, size_t size=0)
 
long long convert_to_signed_integer (std::string const &str)
 Convert a string to signed integer, return the result, and throw an exception when the conversion was not successful. More...
 
bool convert_to_signed_integer (std::string const &str, long long &result)
 Convert a string to signed integer, store the result in result, and return whether the conversion as successful. More...
 
template<typename ForwardIterator >
std::vector< unsigned long long > convert_to_unsigned_integer (ForwardIterator first, ForwardIterator last, size_t size=0)
 
unsigned long long convert_to_unsigned_integer (std::string const &str)
 Convert a string to unsigned integer, return the result, and throw an exception when the conversion was not successful. More...
 
bool convert_to_unsigned_integer (std::string const &str, unsigned long long &result)
 Convert a string to unsigned integer, store the result in result, and return whether the conversion as successful. More...
 
template<typename ForwardIterator >
bool is_convertible_to_bool (ForwardIterator first, ForwardIterator last)
 
bool is_convertible_to_bool (std::string const &str)
 Return whether a string can be converted to bool. More...
 
template<typename ForwardIterator >
bool is_convertible_to_bool_double (ForwardIterator first, ForwardIterator last)
 
bool is_convertible_to_bool_double (std::string const &str)
 Return whether a string can be converted to bool (and stored as a double). More...
 
template<typename ForwardIterator >
bool is_convertible_to_double (ForwardIterator first, ForwardIterator last)
 
bool is_convertible_to_double (std::string const &str)
 Return whether a string can be converted to double. More...
 
template<typename ForwardIterator >
bool is_convertible_to_signed_integer (ForwardIterator first, ForwardIterator last)
 
bool is_convertible_to_signed_integer (std::string const &str)
 Return whether a string can be converted to signed integer. More...
 
template<typename ForwardIterator >
bool is_convertible_to_unsigned_integer (ForwardIterator first, ForwardIterator last)
 
bool is_convertible_to_unsigned_integer (std::string const &str)
 Return whether a string can be converted to unsigned integer. More...