jle_cpp_tk  0.0 2015-04-03 sh1:"d699093732dd5f321606d0ff7a6b63b229f1922c"
A small, safe, selft contained, soft-realtime C++ toolkit
string.h
1 #ifndef JLE_STRING_H
2 #define JLE_STRING_H
3 
4 
5 #include <sstream>
6 #include "cont/vector.hpp"
7 
8 #include "core/chrono.h"
9 
10 
11 
14 
15 
16 #define JLE_SS(__EXPR__) ((dynamic_cast<std::ostringstream &>(std::ostringstream().seekp(0, std::ios_base::cur) << __EXPR__ )).str())
17 
18 
19 
20 namespace jle
21 {
22 
23 
24 
26  std::tuple<double, bool>
27  s_try_s2d (const std::string& s, double def_val );
28 
30  std::tuple<int, bool>
31  s_try_s2i (const std::string& s, int def_val );
32 
33 
34 
35 
47  std::tuple<chrono::duration, bool>
48  s_try_s2dur (const std::string& s, const chrono::duration& def_val );
49 
50 
56  std::tuple<jle::chrono::time_point, bool>
57  s_try_s2tp (const std::string& s, const chrono::time_point& defVal );
58 
59 
60 
61 
62 
64  std::string s_trim (const std::string& s , char char2remove);
65 
67  std::string s_trim (const std::string& s , const std::string& chars2remove);
68 
69 
78  const std::string& s,
79  const std::string& separator,
80  bool remove_empty = false
81  );
82 
83 
84  std::string s_2lower(const std::string& s);
85  std::string s_2upper(const std::string& s);
86 
87 
88  std::string s_align_left (const std::string& s, int size, char char_fill=' ');
89  std::string s_align_right(const std::string& s, int size, char char_fill=' ');
90 
94  std::string align_cols (const std::string& text);
95 
96 
100  std::string s_normalize_utf8(const std::string& s);
101 
102 }
103 
104 #endif // JLE_STRING_H
std::string align_cols(const std::string &text)
format in columns separated by spaces align_cols("aa, b, cccc, dd, eee\n. . . ............ .")
Definition: string.cpp:383
std::tuple< int, bool > s_try_s2i(const std::string &_s, int def_val)
try to convert from string to integer
Definition: string.cpp:260
std::tuple< double, bool > s_try_s2d(const std::string &_s, double def_val)
try to convert from string to double
Definition: string.cpp:242
std::tuple< chrono::time_point, bool > s_try_s2tp(const std::string &s, const chrono::time_point &def_val)
try to convert from string to jle::time_point possible formats...
Definition: string.cpp:150
std::string s_trim(const std::string &s, char char2remove)
remove from left and right char2remove from string s
Definition: string.cpp:17
jle::vector< std::string > s_split(const std::string &s, const std::string &separator, bool remove_empty)
divide string s with separator s_split("a b c") -> ["a", "b", "c"] s_split("a b c") -> ["a"...
Definition: string.cpp:207
std::string s_normalize_utf8(const std::string &source_string)
return a valid utf8 string from a raw one If char is "special" as á, é, í, ó, ú, ñ, ü (and uppercases) it will be converted to utf8. Other weird values will be replaced by "_"
Definition: string.cpp:303
std::tuple< chrono::duration, bool > s_try_s2dur(const std::string &_s, const chrono::duration &def_val)
try to convert from string to jle::duration possible formats...
Definition: string.cpp:65
Definition: vector.hpp:17
generic namespace
Definition: alarm.cpp:12