16 extern src::severity_logger<severity_level>
lg;
26 template <
typename T,
typename Compare>
29 std::vector<int> p(vec.size());
30 std::iota(p.begin(), p.end(), 0);
31 std::sort(p.begin(), p.end(),[&](
unsigned int i,
unsigned int j){
return compare(vec[i], vec[j]); });
39 if (str1[0] ==
'\\' && str1[1] ==
'n')
86 for(
int i=0; i<str1.size(); i++)
90 words.push_back(str1.substr(start, len));
97 words.push_back(str1.substr(start, len));
101 for(
auto& word:
words)
102 word.erase(remove_if(word.begin(), word.end(), isspace), word.end());
109 BOOST_LOG_SEV(
lg, debug)<<
log_spacer<<
"--> milliSleep::"<<msec;
111 for(
int i=0; i<(msec/20); i++)
116 BOOST_LOG_SEV(
lg, error)<<
log_spacer<<
"usleep: "<<strerror(errno);
118 throw std::runtime_error(
"usleep: ");
122 BOOST_LOG_SEV(
lg, debug)<<
log_spacer<<
"milliSleep::rcvd EXIT, "<<msec-(i+1)*20<<
" msec remaining";
126 r = usleep((msec%20 )*1000);
129 BOOST_LOG_SEV(
lg, error)<<
log_spacer<<
"usleep: "<<strerror(errno);
131 throw std::runtime_error(
"usleep: ");
133 BOOST_LOG_SEV(
lg, debug)<<
log_spacer<<
"<-- milliSleep::with "<<0<<
" msec remaining";
140 unsigned long sec = msec/1000;
141 int msec_remainder = msec%1000;
142 unsigned long minutes = sec/60;
143 int sec_remainder = sec%60;
144 std::stringstream ss{
""};
145 ss<<minutes<<
":"<<sec_remainder<<
"."<<msec_remainder;
165 std::stringstream ss;
173 void swap(std::vector<T>& v,
int i,
int j)
190 std::map<std::string, int>
color_map{{
"BLACK", COLOR_BLACK}, {
"RED", COLOR_RED}, {
"GREEN", COLOR_GREEN}, {
"YELLOW", COLOR_YELLOW}, {
"BLUE", COLOR_BLUE}, {
"MAGENTA", COLOR_MAGENTA}, {
"CYAN", COLOR_CYAN}, {
"WHITE", COLOR_WHITE}};
194 #endif // RTOP_UTILS_H_ responsible for parsing strings in a line, specfied by some character separator
void setSeparator(char c)
sets separator character
void milliSleep(int msec)
makes calling thread sleep for specified milliseconds
char toChar(std::string str1)
converts string to its equivalent char value.
void operator<<(std::string)
reads in a line and stores parsed string into StringParser::words
void clear()
clears StringParser::words vector
std::string msecToTimeStr(unsigned long msec)
converts msec to TimerStr for display as min:sec.secs_fraction
char sep
character separator
StringParser(char c)
StringParser constructor. Instantiates a StringParser object with provided separator character.
void delSpace()
deletes one white-space from white-space string corresponding to invoking thread
std::vector< std::string > Words() const
returns a vector of parsed strings stored in StringParser::words
std::ostream & operator<<(std::ostream &ofs, const InfoProc< T > &obj)
overloaded << operator for printing InfoProc contents
std::vector< int > sort_permutation(const std::vector< T > &vec, Compare compare)
returns permutation vector after sorting the given vector based on the provided compare function
void addSpace()
adds one white-space to white-space string corresponding to invoking thread
src::severity_logger< severity_level > lg
enables indentation of logs for easy viewing
data structure that defines type of entry from which panel menu entries obtain their c-string data
std::vector< std::string > words
stores the parsed strings
std::string vec_to_string(std::vector< T > &vec)
concatenates a vectors entries into a string
void swap(std::vector< T > &v, int i, int j)
swaps supplied vectors' element corresponding to indices i and j
std::map< std::string, int > color_map
dictionary containing color_pair number corresponding to each color_name
int size() const
returns size of StringParser::words vector