87 const string myname =
"StandardAdcChannelStringTool::build: ";
109 string smat =
m_reps[irep] +
"%";
110 string::size_type ipos = 1;
112 while ( (ipos = sout.find(smat, ipos)) != string::npos ) {
114 string::size_type iposRep = ipos;
115 string::size_type wOld = 0;
116 if ( sout[--iposRep] ==
'%' ) {
117 wOld = smat.size() + 1;
119 }
else if ( iposRep > 0 && sout[--iposRep] ==
'%' ) {
120 istringstream sswid(sout.substr(iposRep+1, 1));
123 if ( wNew == 0 ) wNew =
m_wids[irep];
124 if ( wNew == 999 ) wNew = 0;
125 wOld = smat.size() + 2;
136 Index ival = vals[irep];
140 while ( wNew > sval.size() ) sval =
"0" + sval;
142 sout.replace(iposRep, wOld, sval);
143 ipos = iposRep + sval.size();
150 string sunitSpaced = sunit.size() ?
" " + sunit :
"";
151 string sunitWrapped = sunit.size() ?
"(" + sunit +
")" :
"";
152 string sunitSpWrapped = sunit.size() ?
" " + sunitWrapped :
"";
153 string sunitOptWrapped = sunit.find(
" ") != string::npos ? sunitWrapped :
"";
154 string sunitSpOptWrapped = sunitOptWrapped.size() ?
" " + sunitOptWrapped :
"";
155 string sunitBarred = sunit.size() ?
"[" + sunit +
"]" :
"";
156 string sunitSpBarred = sunit.size() ?
" " + sunitBarred :
"";
157 sman.replace(
"%SUNIT%", sunit);
158 sman.replace(
"% SUNIT%", sunitSpaced);
159 sman.replace(
"%(SUNIT)%", sunitWrapped);
160 sman.replace(
"% (SUNIT)%", sunitSpWrapped);
161 sman.replace(
"%((SUNIT))%", sunitOptWrapped);
162 sman.replace(
"% ((SUNIT))%", sunitSpOptWrapped);
163 sman.replace(
"%[SUNIT]%", sunitBarred);
164 sman.replace(
"% [SUNIT]%", sunitSpBarred);
166 string asunit = sunit +
"-tick";
167 string::size_type ipos = sunit.find(
"/tick");
168 if ( ipos != string::npos ) {
169 asunit = sunit.substr(0, ipos) + sunit.substr(ipos + 5);
171 string asunitSpaced = asunit.size() ?
" " + asunit :
"";
172 string asunitWrapped = asunit.size() ?
"(" + asunit +
")" :
"";
173 string asunitSpWrapped = asunit.size() ?
" " + asunitWrapped :
"";
174 string asunitOptWrapped = asunit.find(
" ") != string::npos ? asunitWrapped :
"";
175 string asunitSpOptWrapped = asunitOptWrapped.size() ?
" " + asunitOptWrapped :
"";
176 string asunitBarred = asunit.size() ?
"[" + asunit +
"]" :
"";
177 string asunitSpBarred = asunit.size() ?
" " + asunitBarred :
"";
178 sman.replace(
"%ASUNIT%", asunit);
179 sman.replace(
"% ASUNIT%", asunitSpaced);
180 sman.replace(
"%(ASUNIT)%", asunitWrapped);
181 sman.replace(
"% (ASUNIT)%", asunitSpWrapped);
182 sman.replace(
"%((ASUNIT))%", asunitOptWrapped);
183 sman.replace(
"% ((ASUNIT))%", asunitSpOptWrapped);
184 sman.replace(
"%[ASUNIT]%", asunitBarred);
185 sman.replace(
"% [ASUNIT]%", asunitSpBarred);
187 if ( sout.find(
"%TRIGNAME") != string::npos ) {
189 Name strig =
"undefined";
191 Index itrn = itrig < ntrn ? itrig : ntrn - 1;
194 sman.replace(
"%TRIGNAME%", strig);
195 if ( strig.size() ) strig[0] = std::toupper(strig[0]);
196 sman.replace(
"%TRIGNAMECAP%", strig);
199 string spatpre =
"%UTCTIME";
200 ipos = sout.find(spatpre);
201 if ( ipos != string::npos ) {
202 time_t tim = acd.
time();
204 int remMax = 1000000000;
205 if (
std::abs(rem) >= remMax ) rem = 0;
211 TTimeStamp ts(tim, rem);
212 string stimpre = ts.AsString(
"s");
213 sman.replace(spatpre +
"%", stimpre);
215 while ( srem.size() < 9 ) srem =
"0" + srem;
216 for (
Index ndig=0; ndig<10; ++ndig ) {
219 string stim = stimpre;
220 if ( ndig ) stim +=
"." + srem.substr(0, ndig);
221 sman.replace(spat, stim);
224 if (
m_LogLevel >= 2 ) cout << myname << spat <<
" --> " << sout <<
endl;
ChannelGroupService::Name Name
bool haveInt(Name name) const
int getInt(Name name, int def=0) const
static Index badChannel()
std::string to_string(ModuleType const mt)
QTextStream & endl(QTextStream &s)