Commit bee3cc3d authored by David Schulz's avatar David Schulz

cdbext: Generate values for QDate, QTime, QDateTime

... in the watchdata via flags.

Change-Id: I4664807713cc7747216de5abaabf30011921ab4c
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@digia.com>
parent c172a128
......@@ -364,7 +364,10 @@ enum DumpEncoding // WatchData encoding of GDBMI values
DumpEncodingHex_Ucs4_LittleEndian_WithQuotes = 3,
DumpEncodingBase64_Utf16 = 4,
DumpEncodingHex_Latin1_WithQuotes = 6,
DumpEncodingHex_Utf8_LittleEndian_WithQuotes = 9
DumpEncodingHex_Utf8_LittleEndian_WithQuotes = 9,
DumpEncodingJulianDate = 14,
DumpEncodingMillisecondsSinceMidnight = 15,
DumpEncodingJulianDateAndMillisecondsSinceMidnight = 16
};
/* Recode arrays/pointers of char*, wchar_t according to users
......@@ -1110,7 +1113,20 @@ int SymbolGroupNode::dumpNode(std::ostream &str,
// Shall it be recoded?
int encoding = 0;
if (dumpParameters.recode(t, aFullIName, ctx, addr, &value, &encoding)) {
switch (knownType(t, 0)) {
case KT_QDate:
encoding = DumpEncodingJulianDate;
break;
case KT_QTime:
encoding = DumpEncodingMillisecondsSinceMidnight;
break;
case KT_QDateTime:
encoding = DumpEncodingJulianDateAndMillisecondsSinceMidnight;
break;
}
if (encoding) {
str << ",valueencoded=\"" << encoding << "\",value=\"" << gdbmiWStringFormat(value) <<'"';
} else if (dumpParameters.recode(t, aFullIName, ctx, addr, &value, &encoding)) {
str << ",valueencoded=\"" << encoding
<< "\",value=\"" << gdbmiWStringFormat(value) <<'"';
} else { // As is: ASCII or base64?
......
......@@ -972,31 +972,6 @@ static inline void getDateFromJulianDay(unsigned julianDay, int *year, int *mont
*day = d;
}
// Convert and format Julian Date as used in QDate
static inline void formatJulianDate(std::wostream &str, unsigned julianDate)
{
int y, m, d;
getDateFromJulianDay(julianDate, &y, &m, &d);
str << d << '.' << m << '.' << y;
}
// Format time in milliseconds as "hh:dd:ss:mmm"
static inline void formatMilliSeconds(std::wostream &str, int milliSecs)
{
const int hourFactor = 1000 * 3600;
const int hours = milliSecs / hourFactor;
milliSecs = milliSecs % hourFactor;
const int minFactor = 1000 * 60;
const int minutes = milliSecs / minFactor;
milliSecs = milliSecs % minFactor;
const int secs = milliSecs / 1000;
milliSecs = milliSecs % 1000;
str.fill('0');
str << std::setw(2) << hours << ':' << std::setw(2)
<< minutes << ':' << std::setw(2) << secs
<< '.' << std::setw(3) << milliSecs;
}
const char *stdStringTypeC = "std::basic_string<char,std::char_traits<char>,std::allocator<char> >";
const char *stdWStringTypeC = "std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >";
// Compiler option: -Zc:wchar_t-:
......@@ -2042,21 +2017,13 @@ static inline bool dumpQFlags(const SymbolGroupValue &v, std::wostream &str)
return false;
}
static bool dumpJulianDate(int julianDay, std::wostream &str)
{
if (julianDay < 0)
return false;
else if (!julianDay)
str << L"<null>";
else
formatJulianDate(str, julianDay);
return true;
}
static bool dumpQDate(const SymbolGroupValue &v, std::wostream &str)
{
if (const SymbolGroupValue julianDayV = v["jd"])
return dumpJulianDate(julianDayV.intValue(), str);
if (const SymbolGroupValue julianDayV = v["jd"]) {
if (julianDayV.intValue() > 0)
str << julianDayV.intValue();
return true;
}
return false;
}
......@@ -2064,10 +2031,8 @@ static bool dumpQTime(const SymbolGroupValue &v, std::wostream &str)
{
if (const SymbolGroupValue milliSecsV = v["mds"]) {
const int milliSecs = milliSecsV.intValue();
if (milliSecs >= 0) {
formatMilliSeconds(str, milliSecs);
return true;
}
str << milliSecs;
return true;
}
return false;
}
......@@ -2090,14 +2055,11 @@ static bool dumpQDateTime(const SymbolGroupValue &v, std::wostream &str)
str << L"<null>";
return true;
}
if (!dumpJulianDate(date, str))
return false;
const ULONG64 timeAddr = dateAddr + (qtVersion < 5 ? SymbolGroupValue::intSize() : 8);
const int time =
SymbolGroupValue::readIntValue(v.context().dataspaces,
timeAddr, SymbolGroupValue::intSize(), 0);
str << L' ';
formatMilliSeconds(str, time);
str << date << '/' << time;
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment