40 #ifndef STRING_MANIPULATION_HPP 41 #define STRING_MANIPULATION_HPP 43 #include <boost/lexical_cast.hpp> 45 #include <type_traits> 52 #define STR(s) boost::lexical_cast<std::string>(s) 61 const std::vector<std::string>
SplitString(
const std::string&
input,
const std::string& separators);
68 void add_escape(std::string& ioString,
const std::string& to_be_escaped);
80 std::string
cxa_rename_mangled(
const std::string& signature,
const std::string& new_fname);
82 std::string
cxa_prefix_mangled(
const std::string& signature,
const std::string& prefix);
90 return str.find(pattern) == 0;
93 inline bool ends_with(
const std::string&
str,
const std::string& pattern)
95 const auto pos = str.rfind(pattern);
96 return pos != std::string::npos && (pos + pattern.size()) == str.size();
106 inline std::string
NumberToString(
const T number,
const size_t precision,
const size_t size)
108 std::stringstream return_stream;
109 return_stream.width(static_cast<std::streamsize>(size));
110 return_stream.fill(
' ');
111 return_stream.setf(std::ios::fixed, std::ios::floatfield);
112 return_stream.precision(static_cast<std::streamsize>(precision));
113 return_stream << static_cast<long double>(number);
114 return return_stream.str();
125 std::stringstream return_stream;
126 return_stream.setf(std::ios::fixed, std::ios::floatfield);
127 return_stream.precision(static_cast<std::streamsize>(precision));
128 return_stream << static_cast<long double>(number);
129 return return_stream.str();
141 auto temp_number = number;
142 while(temp_number > 0)
144 auto bit = temp_number % 2;
153 temp_number = temp_number / 2;
157 while(ret.size() < precision)
178 #define GET_CLASS(obj) cxa_demangle(typeid(obj).name()) 192 unsigned long long ac_type_bitwidth(
const std::string& intType,
bool& is_signed,
bool& is_fixed);
std::string capitalize(const std::string &str)
unsigned long long convert_fp_to_bits(std::string num, unsigned long long precision)
convert a real number stored in a string into bits with a given precision
struct definition of the real_type tree node.
std::string cxa_rename_mangled(const std::string &signature, const std::string &new_fname)
std::string NumberToString(const T number, const size_t precision, const size_t size)
Function with print number in desired format.
std::string NumberToBinaryString(const T number, const size_t precision=0)
Function which print number in binary format.
bool starts_with(const std::string &str, const std::string &pattern)
std::string cxa_prefix_mangled(const std::string &signature, const std::string &prefix)
void remove_escaped(std::string &ioString)
Function converting all the escaped characters in the associated character.
std::string convert_fp_to_string(std::string num, unsigned long long precision)
convert a real number stored in a string into a string of bits with a given precision ...
bool ends_with(const std::string &str, const std::string &pattern)
std::string TrimSpaces(const std::string &value)
const std::vector< std::string > SplitString(const std::string &input, const std::string &separators)
Function which splits a string into tokens.
void add_escape(std::string &ioString, const std::string &to_be_escaped)
Function which adds escape to selected characters.
unsigned long long ac_type_bitwidth(const std::string &intType, bool &is_signed, bool &is_fixed)
std::string ConvertInBinary(const std::string &C_value, unsigned long long precision, const bool real_type, bool unsigned_type)
Convert a string storing a number in decimal format into a string in binary format.
std::string cxa_demangle(const std::string &input)
std::string FixedPointReinterpret(const std::string &FP_vector, const std::string &fp_typename)