[Kst] branches/work/kst/portto4/kst/src/datasources/ascii
Peter Kümmel
syntheticpp at gmx.net
Wed Oct 24 21:13:56 UTC 2012
SVN commit 1322266 by kuemmel:
accept one space in time string (use two columns)
M +11 -2 kst_atof.cpp
M +1 -0 kst_atof.h
--- branches/work/kst/portto4/kst/src/datasources/ascii/kst_atof.cpp #1322265:1322266
@@ -188,20 +188,29 @@
//-------------------------------------------------------------------------------------------
void LexicalCast::setTimeFormat(const QString& format)
{
- _timeFormat = format;
+ _timeFormat = format.trimmed(); // remove space at start/end
_isTime = !format.isEmpty();
_timeWithDate = format.contains("d") || format.contains("M") || format.contains("y");
+ if (_timeWithDate) {
+ _timeInTwoColumns = _timeFormat.contains(' ');
}
+}
//-------------------------------------------------------------------------------------------
double LexicalCast::fromTime(const char* p) const
{
int maxScan = 100;
int end = 0;
- for (; *(p + end) != ' ' && *(p + end) != '\t'; end++) {
+ int columnEnd = _timeInTwoColumns ? 2 : 1;
+ int inCol = 0;
+ for (; inCol != columnEnd; end++) {
+ if (*(p + end) == ' ' || *(p + end) == '\t') {
+ inCol++;
+ }
if (end > maxScan)
return Kst::NOPOINT;
}
+ end--;
const QString time = QString::fromLatin1(p, end);
double sec = Kst::NOPOINT;
--- branches/work/kst/portto4/kst/src/datasources/ascii/kst_atof.h #1322265:1322266
@@ -52,6 +52,7 @@
QString _timeFormat;
bool _isTime;
bool _timeWithDate;
+ bool _timeInTwoColumns;
void resetLocal();
More information about the Kst
mailing list