14 #define TRG_SHORT_NAMES
20 #include "trg/trg/Utilities.h"
31 TRGUtil::dateString(
void)
38 strftime(ts1,
sizeof(ts1),
"%Y/%m/%d %H:%M %Z", tl);
43 TRGUtil::dateStringF(
void)
50 strftime(ts0,
sizeof(ts0),
"%Y%m%d_%H%M", tl);
55 TRGUtil::itostring(
int i)
61 return std::to_string(i);
65 TRGUtil::dtostring(
double d,
unsigned int precision)
68 s << std::setprecision(precision) << d;
73 TRGUtil::carstring(
const std::string& s)
81 for (i = 0; i < len; i++) {
82 if (!isspace(s[i]))
break;
84 for (; i < len; i++) {
93 TRGUtil::cdrstring(
const std::string& s)
100 int len = s.length();
101 for (i = 0; i < len; i++) {
102 if (!isspace(s[i]))
break;
104 for (; i < len; i++) {
105 if (isspace(s[i]))
break;
107 for (; i < len; i++) {
108 if (!isspace(s[i]))
break;
114 TRGUtil::bitDisplay(
unsigned val)
116 bitDisplay(val, 31, 0);
120 TRGUtil::bitDisplay(
unsigned val,
unsigned f,
unsigned l)
123 for (i = 0; i < f - l; i++) {
124 if ((i % 8) == 0) cout <<
" ";
125 cout << (val >> (f - i)) % 2;
130 TRGUtil::streamDisplay(
unsigned val,
unsigned f,
unsigned l)
133 for (
unsigned i = f; i < l + 1; i++) {
134 if ((i % 8) == 0) s +=
" ";
135 s += itostring((val >> i) % 2);
141 TRGUtil::streamDisplay(
unsigned val)
143 return streamDisplay(val, 0, 63);