![]() |
【转帖】odstring = operator
odstring "+" operator
odstring "+" operator it lools like that, in dd2.0.3 this syntax does not work : timestring = timestring + "," + tostring(precord->dashlengthat(i)); i use this loop, and the string does not cumulate : odstring timestring; ddblinetypetableptr plintypetable = pdb->getlinetypetableid().safeopenobject(); oddbsymboltableiteratorptr piter = plintypetable->newiterator(); // iterate in the table contents for (piter->start(); !piter->done(); piter->step()) oddblinetypetablerecordptr precord = piter->getrecordid().safeopenobject(); if (precord->numdashes()) { timestring = (precord->isscaledtofit() ? " , s" : " , a"); for (int i=0; i < precord->numdashes(); i++) { timestring = timestring + "," + tostring(precord->dashlengthat(i)); printf("%s\n",(const char*)timestring, );fflush(stdout); } what is wrong with this ? thanks jp hi, the problem is inside odstring tostring(const double val). code: odstring tostring(const double val) { odstring temp; if (fabs(val) < 1e6) { temp.format(dd_t("%.4f"), val); /***********************************************************************/ /* strip all but one trailing zero from buffer */ /***********************************************************************/ for (int n = temp.getlength(); ((temp[n-2] != '.') && (temp[n-1] == '0')); n--) { temp.setat(n-1, '\0'); } } else { temp.format(dd_t("%.4e"), val); } return temp; } temp.setat(n-1, '\0'); generates invalid string. it can be fixed by changing to code: temp = temp.left(temp.getlength() - 1); oups ! tostring() was taken from the sample dbdumper.cpp ! should be corrected there ! rgds jp yes, of course. i have fixed it already. |
所有的时间均为北京时间。 现在的时间是 10:20 AM. |