git-svn-id: svn://db.shs.com.ru/pip@316 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -63,13 +63,9 @@ int main(int argc, char *argv[]) {
|
|||||||
c.start();
|
c.start();
|
||||||
piMSleep(3000);*/
|
piMSleep(3000);*/
|
||||||
|
|
||||||
PIStringList sl;
|
PISystemTime st = PISystemTime::current();
|
||||||
sl << "one" << "two" << "three";
|
piCout << PIDateTime::current();
|
||||||
PIVariantTypes::Enum e;
|
piCout << PIDateTime::fromSystemTime(st);
|
||||||
e << sl;
|
|
||||||
e.selectValue(1);
|
|
||||||
PIVariant v = e;
|
|
||||||
piCout << v.value<PIVariantTypes::Enum>();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -118,7 +118,7 @@ PIInit::PIInit() {
|
|||||||
WSAStartup(MAKEWORD(2, 2), &wsaData);
|
WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||||
|
|
||||||
// Timers init
|
// Timers init
|
||||||
SYSTEMTIME jan1970 = {1970, 1, 4, 1, 0, 14, 15, 0};
|
SYSTEMTIME jan1970 = {1970, 1, 4, 1, 0, 0, 0, 0};
|
||||||
SystemTimeToFileTime(&jan1970, &__pi_ftjan1970);
|
SystemTimeToFileTime(&jan1970, &__pi_ftjan1970);
|
||||||
LARGE_INTEGER pf;
|
LARGE_INTEGER pf;
|
||||||
pf.QuadPart = -1;
|
pf.QuadPart = -1;
|
||||||
|
|||||||
@@ -463,3 +463,42 @@ double PITimeMeasurer::elapsed_s() const {
|
|||||||
PISystemTime PITimeMeasurer::elapsed() const {
|
PISystemTime PITimeMeasurer::elapsed() const {
|
||||||
return (PISystemTime::current(true) - t_st);
|
return (PISystemTime::current(true) - t_st);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PICout operator <<(PICout s, const PITime & v) {
|
||||||
|
s.space();
|
||||||
|
s.setControl(0, true);
|
||||||
|
s << "PITime(" << v.hours << ":";
|
||||||
|
s << PIString::fromNumber(v.minutes).expandLeftTo(2, '0') << ":";
|
||||||
|
s << PIString::fromNumber(v.seconds).expandLeftTo(2, '0') << ":";
|
||||||
|
s << PIString::fromNumber(v.milliseconds).expandLeftTo(3, '0') << ")";
|
||||||
|
s.restoreControl();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PICout operator <<(PICout s, const PIDate & v) {
|
||||||
|
s.space();
|
||||||
|
s.setControl(0, true);
|
||||||
|
s << "PIDate(" << v.day << "-";
|
||||||
|
s << PIString::fromNumber(v.month).expandLeftTo(2, '0') << "-";
|
||||||
|
s << v.year << ")";
|
||||||
|
s.restoreControl();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PICout operator <<(PICout s, const PIDateTime & v) {
|
||||||
|
s.space();
|
||||||
|
s.setControl(0, true);
|
||||||
|
s << "PIDateTime(";
|
||||||
|
s << v.day << "-";
|
||||||
|
s << PIString::fromNumber(v.month).expandLeftTo(2, '0') << "-";
|
||||||
|
s << v.year << " ";
|
||||||
|
s << v.hours << ":";
|
||||||
|
s << PIString::fromNumber(v.minutes).expandLeftTo(2, '0') << ":";
|
||||||
|
s << PIString::fromNumber(v.seconds).expandLeftTo(2, '0') << ":";
|
||||||
|
s << PIString::fromNumber(v.milliseconds).expandLeftTo(3, '0') << ")";
|
||||||
|
s.restoreControl();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|||||||
+29
-1
@@ -29,6 +29,7 @@
|
|||||||
# include <time.h>
|
# include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef DOXYGEN
|
#ifdef DOXYGEN
|
||||||
//! \brief Sleep for "msecs" milliseconds
|
//! \brief Sleep for "msecs" milliseconds
|
||||||
void msleep(int msecs);
|
void msleep(int msecs);
|
||||||
@@ -56,6 +57,9 @@ inline void piMSleep(double msecs) {piUSleep(int(msecs * 1000.));} // on !Window
|
|||||||
* \details This function exec \a piUSleep (msecs * 1000000). */
|
* \details This function exec \a piUSleep (msecs * 1000000). */
|
||||||
inline void piSleep(double secs) {piUSleep(int(secs * 1000000.));} // on !Windows consider constant "usleep" offset
|
inline void piSleep(double secs) {piUSleep(int(secs * 1000000.));} // on !Windows consider constant "usleep" offset
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PIP_EXPORT PISystemTime {
|
class PIP_EXPORT PISystemTime {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -176,7 +180,7 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \relatesalso PICout \relatesalso PIByteArray \brief Output operator to PICout
|
//! \relatesalso PICout \relatesalso PICout \brief Output operator to PICout
|
||||||
inline PICout operator <<(PICout s, const PISystemTime & v) {s.space(); s.setControl(0, true); s << "(" << v.seconds << " s, " << v.nanoseconds << " ns)"; s.restoreControl(); return s;}
|
inline PICout operator <<(PICout s, const PISystemTime & v) {s.space(); s.setControl(0, true); s << "(" << v.seconds << " s, " << v.nanoseconds << " ns)"; s.restoreControl(); return s;}
|
||||||
|
|
||||||
//! \relatesalso PISystemTime \relatesalso PIByteArray \brief Output operator to PIByteArray
|
//! \relatesalso PISystemTime \relatesalso PIByteArray \brief Output operator to PIByteArray
|
||||||
@@ -185,6 +189,9 @@ inline PIByteArray & operator <<(PIByteArray & s, const PISystemTime & v) {s <<
|
|||||||
//! \relatesalso PISystemTime \relatesalso PIByteArray \brief Input operator from PIByteArray
|
//! \relatesalso PISystemTime \relatesalso PIByteArray \brief Input operator from PIByteArray
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, PISystemTime & v) {s >> v.seconds >> v.nanoseconds; return s;}
|
inline PIByteArray & operator >>(PIByteArray & s, PISystemTime & v) {s >> v.seconds >> v.nanoseconds; return s;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct PIP_EXPORT PITime {
|
struct PIP_EXPORT PITime {
|
||||||
PITime(int hours_ = 0, int minutes_ = 0, int seconds_ = 0, int milliseconds_ = 0): hours(hours_), minutes(minutes_), seconds(seconds_), milliseconds(milliseconds_) {;}
|
PITime(int hours_ = 0, int minutes_ = 0, int seconds_ = 0, int milliseconds_ = 0): hours(hours_), minutes(minutes_), seconds(seconds_), milliseconds(milliseconds_) {;}
|
||||||
int hours;
|
int hours;
|
||||||
@@ -196,6 +203,7 @@ struct PIP_EXPORT PITime {
|
|||||||
static PITime current();
|
static PITime current();
|
||||||
static PITime fromSystemTime(const PISystemTime & st);
|
static PITime fromSystemTime(const PISystemTime & st);
|
||||||
};
|
};
|
||||||
|
|
||||||
PIP_EXPORT bool operator ==(const PITime & t0, const PITime & t1);
|
PIP_EXPORT bool operator ==(const PITime & t0, const PITime & t1);
|
||||||
PIP_EXPORT bool operator <(const PITime & t0, const PITime & t1);
|
PIP_EXPORT bool operator <(const PITime & t0, const PITime & t1);
|
||||||
PIP_EXPORT bool operator >(const PITime & t0, const PITime & t1);
|
PIP_EXPORT bool operator >(const PITime & t0, const PITime & t1);
|
||||||
@@ -205,6 +213,12 @@ inline bool operator >=(const PITime & t0, const PITime & t1) {return !(t0 < t1)
|
|||||||
inline PIByteArray & operator <<(PIByteArray & s, const PITime & v) {s << v.hours << v.minutes << v.seconds << v.milliseconds; return s;}
|
inline PIByteArray & operator <<(PIByteArray & s, const PITime & v) {s << v.hours << v.minutes << v.seconds << v.milliseconds; return s;}
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, PITime & v) {s >> v.hours >> v.minutes >> v.seconds >> v.milliseconds; return s;}
|
inline PIByteArray & operator >>(PIByteArray & s, PITime & v) {s >> v.hours >> v.minutes >> v.seconds >> v.milliseconds; return s;}
|
||||||
|
|
||||||
|
//! \relatesalso PICout \relatesalso PICout \brief Output operator to PICout
|
||||||
|
PICout operator <<(PICout s, const PITime & v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct PIP_EXPORT PIDate {
|
struct PIP_EXPORT PIDate {
|
||||||
PIDate(int year_ = 0, int month_ = 0, int day_ = 0): year(year_), month(month_), day(day_) {;}
|
PIDate(int year_ = 0, int month_ = 0, int day_ = 0): year(year_), month(month_), day(day_) {;}
|
||||||
int year;
|
int year;
|
||||||
@@ -213,6 +227,7 @@ struct PIP_EXPORT PIDate {
|
|||||||
PIString toString(const PIString & format = "d.MM.yyyy") const;
|
PIString toString(const PIString & format = "d.MM.yyyy") const;
|
||||||
static PIDate current();
|
static PIDate current();
|
||||||
};
|
};
|
||||||
|
|
||||||
PIP_EXPORT bool operator ==(const PIDate & t0, const PIDate & t1);
|
PIP_EXPORT bool operator ==(const PIDate & t0, const PIDate & t1);
|
||||||
PIP_EXPORT bool operator <(const PIDate & t0, const PIDate & t1);
|
PIP_EXPORT bool operator <(const PIDate & t0, const PIDate & t1);
|
||||||
PIP_EXPORT bool operator >(const PIDate & t0, const PIDate & t1);
|
PIP_EXPORT bool operator >(const PIDate & t0, const PIDate & t1);
|
||||||
@@ -222,6 +237,12 @@ inline bool operator >=(const PIDate & t0, const PIDate & t1) {return !(t0 < t1)
|
|||||||
inline PIByteArray & operator <<(PIByteArray & s, const PIDate & v) {s << v.year << v.month << v.day; return s;}
|
inline PIByteArray & operator <<(PIByteArray & s, const PIDate & v) {s << v.year << v.month << v.day; return s;}
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, PIDate & v) {s >> v.year >> v.month >> v.day; return s;}
|
inline PIByteArray & operator >>(PIByteArray & s, PIDate & v) {s >> v.year >> v.month >> v.day; return s;}
|
||||||
|
|
||||||
|
//! \relatesalso PICout \relatesalso PICout \brief Output operator to PICout
|
||||||
|
PICout operator <<(PICout s, const PIDate & v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct PIP_EXPORT PIDateTime {
|
struct PIP_EXPORT PIDateTime {
|
||||||
PIDateTime() {year = month = day = hours = minutes = seconds = milliseconds = 0;}
|
PIDateTime() {year = month = day = hours = minutes = seconds = milliseconds = 0;}
|
||||||
PIDateTime(const PITime & time) {year = month = day = 0; hours = time.hours; minutes = time.minutes; seconds = time.seconds; milliseconds = time.milliseconds;}
|
PIDateTime(const PITime & time) {year = month = day = 0; hours = time.hours; minutes = time.minutes; seconds = time.seconds; milliseconds = time.milliseconds;}
|
||||||
@@ -255,6 +276,7 @@ struct PIP_EXPORT PIDateTime {
|
|||||||
static PIDateTime fromSystemTime(const PISystemTime & st) {PIDateTime dt = fromSecondSinceEpoch(st.seconds); dt.milliseconds = piClampi(st.nanoseconds / 1000000, 0, 999); return dt;}
|
static PIDateTime fromSystemTime(const PISystemTime & st) {PIDateTime dt = fromSecondSinceEpoch(st.seconds); dt.milliseconds = piClampi(st.nanoseconds / 1000000, 0, 999); return dt;}
|
||||||
static PIDateTime current();
|
static PIDateTime current();
|
||||||
};
|
};
|
||||||
|
|
||||||
inline PIDateTime operator +(const PIDateTime & d0, const PIDateTime & d1) {PIDateTime td = d0; td += d1; return td.normalized();}
|
inline PIDateTime operator +(const PIDateTime & d0, const PIDateTime & d1) {PIDateTime td = d0; td += d1; return td.normalized();}
|
||||||
inline PIDateTime operator -(const PIDateTime & d0, const PIDateTime & d1) {PIDateTime td = d0; td -= d1; return td.normalized();}
|
inline PIDateTime operator -(const PIDateTime & d0, const PIDateTime & d1) {PIDateTime td = d0; td -= d1; return td.normalized();}
|
||||||
PIP_EXPORT bool operator ==(const PIDateTime & t0, const PIDateTime & t1);
|
PIP_EXPORT bool operator ==(const PIDateTime & t0, const PIDateTime & t1);
|
||||||
@@ -266,6 +288,12 @@ inline bool operator >=(const PIDateTime & t0, const PIDateTime & t1) {return !(
|
|||||||
inline PIByteArray & operator <<(PIByteArray & s, const PIDateTime & v) {s << v.year << v.month << v.day << v.hours << v.minutes << v.seconds << v.milliseconds; return s;}
|
inline PIByteArray & operator <<(PIByteArray & s, const PIDateTime & v) {s << v.year << v.month << v.day << v.hours << v.minutes << v.seconds << v.milliseconds; return s;}
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, PIDateTime & v) {s >> v.year >> v.month >> v.day >> v.hours >> v.minutes >> v.seconds >> v.milliseconds; return s;}
|
inline PIByteArray & operator >>(PIByteArray & s, PIDateTime & v) {s >> v.year >> v.month >> v.day >> v.hours >> v.minutes >> v.seconds >> v.milliseconds; return s;}
|
||||||
|
|
||||||
|
//! \relatesalso PICout \relatesalso PICout \brief Output operator to PICout
|
||||||
|
PICout operator <<(PICout s, const PIDateTime & v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DEPRECATED inline PITime currentTime() {return PITime::current();} // obsolete, use PITime::current() instead
|
DEPRECATED inline PITime currentTime() {return PITime::current();} // obsolete, use PITime::current() instead
|
||||||
DEPRECATED inline PIDate currentDate() {return PIDate::current();} // obsolete, use PIDate::current() instead
|
DEPRECATED inline PIDate currentDate() {return PIDate::current();} // obsolete, use PIDate::current() instead
|
||||||
DEPRECATED inline PIDateTime currentDateTime() {return PIDateTime::current();} // obsolete, use PIDateTime::current() instead
|
DEPRECATED inline PIDateTime currentDateTime() {return PIDateTime::current();} // obsolete, use PIDateTime::current() instead
|
||||||
|
|||||||
@@ -503,6 +503,9 @@ PIString PIVariant::toString() const {
|
|||||||
case PIVariant::pivLDouble: {ldouble r; ba >> r; return PIString::fromNumber(r);}
|
case PIVariant::pivLDouble: {ldouble r; ba >> r; return PIString::fromNumber(r);}
|
||||||
case PIVariant::pivComplexd: {complexd r; ba >> r; return PIString::fromNumber(r.real());}
|
case PIVariant::pivComplexd: {complexd r; ba >> r; return PIString::fromNumber(r.real());}
|
||||||
case PIVariant::pivComplexld: {complexld r; ba >> r; return PIString::fromNumber(r.real());}
|
case PIVariant::pivComplexld: {complexld r; ba >> r; return PIString::fromNumber(r.real());}
|
||||||
|
case PIVariant::pivTime: {PITime r; ba >> r; return r.toString();}
|
||||||
|
case PIVariant::pivDate: {PIDate r; ba >> r; return r.toString();}
|
||||||
|
case PIVariant::pivDateTime: {PIDateTime r; ba >> r; return r.toString();}
|
||||||
case PIVariant::pivString: {PIString r; ba >> r; return r;}
|
case PIVariant::pivString: {PIString r; ba >> r; return r;}
|
||||||
case PIVariant::pivStringList: {PIStringList r; ba >> r; if (r.isEmpty()) return PIString(); return r.front();}
|
case PIVariant::pivStringList: {PIStringList r; ba >> r; if (r.isEmpty()) return PIString(); return r.front();}
|
||||||
case PIVariant::pivEnum: {PIVariantTypes::Enum r; ba >> r; return r.selectedName();}
|
case PIVariant::pivEnum: {PIVariantTypes::Enum r; ba >> r; return r.selectedName();}
|
||||||
|
|||||||
Reference in New Issue
Block a user