diff --git a/main.cpp b/main.cpp index df93d5c9..9e8db8cb 100644 --- a/main.cpp +++ b/main.cpp @@ -1,4 +1,4 @@ -#include "pip.h" +#include "piobject.h" /* struct __S__ { PIString text; diff --git a/src/core/piincludes.cpp b/src/core/piincludes.cpp index 5beeec50..6cb66f7b 100755 --- a/src/core/piincludes.cpp +++ b/src/core/piincludes.cpp @@ -254,6 +254,12 @@ void piqsort(void * base, size_t num, size_t size, int (*compar)(const void *, c } +void randomize() { + srand(PISystemTime::current(true).nanoseconds); +} + + int randomi() { return rand(); } + diff --git a/src/core/piincludes.h b/src/core/piincludes.h index a3ef6131..f6720329 100755 --- a/src/core/piincludes.h +++ b/src/core/piincludes.h @@ -48,6 +48,7 @@ void errorClear(); void piqsort(void* base, size_t num, size_t size, int (*compar)(const void*,const void*)); +void randomize(); int randomi(); /// Return readable version of PIP diff --git a/src/core/pivariant.cpp b/src/core/pivariant.cpp index 72279f37..a98ac201 100755 --- a/src/core/pivariant.cpp +++ b/src/core/pivariant.cpp @@ -99,8 +99,6 @@ PIVariant::Type PIVariant::typeFromName(const PIString & tname) { if (s == "float") return PIVariant::pivFloat; if (s == "double" || s == "real") return PIVariant::pivDouble; if (s == "ldouble" || s == "longdouble") return PIVariant::pivLDouble; - if (s == "complexd" || s == "complex") return PIVariant::pivComplexd; - if (s == "complexld" || s == "complex" || s == "complex") return PIVariant::pivComplexld; if (s == "pibitarray" || s == "bitarray") return PIVariant::pivBitArray; if (s == "pibytearray" || s == "bytearray" || s == "vector" || s == "pivector" || s == "vector" || s == "pivector" || s == "vector" || s == "pivector") return PIVariant::pivByteArray; @@ -140,8 +138,6 @@ PIString PIVariant::typeName(PIVariant::Type type) { case PIVariant::pivFloat: return "Float"; case PIVariant::pivDouble: return "Double"; case PIVariant::pivLDouble: return "LDouble"; - case PIVariant::pivComplexd: return "Complexd"; - case PIVariant::pivComplexld: return "Complexld"; case PIVariant::pivBitArray: return "BitArray"; case PIVariant::pivByteArray: return "ByteArray"; case PIVariant::pivString: return "String"; @@ -181,8 +177,6 @@ bool PIVariant::toBool() const { case PIVariant::pivFloat: {float r; ba >> r; return r > 0.f;} case PIVariant::pivDouble: {double r; ba >> r; return r > 0.;} case PIVariant::pivLDouble: {ldouble r; ba >> r; return r > 0.;} - case PIVariant::pivComplexd: {complexd r; ba >> r; return r.real() != 0;} - case PIVariant::pivComplexld: {complexld r; ba >> r; return r.real() != 0;} case PIVariant::pivString: {PIString r; ba >> r; return r.toBool();} case PIVariant::pivStringList: {PIStringList r; ba >> r; if (r.isEmpty()) return false; return r.front().toBool();} case PIVariant::pivCustom: return getAsValue(*this); @@ -214,8 +208,6 @@ int PIVariant::toInt() const { case PIVariant::pivFloat: {float r; ba >> r; return r;} case PIVariant::pivDouble: {double r; ba >> r; return r;} case PIVariant::pivLDouble: {ldouble r; ba >> r; return r;} - case PIVariant::pivComplexd: {complexd r; ba >> r; return r.real();} - case PIVariant::pivComplexld: {complexld r; ba >> r; return r.real();} case PIVariant::pivString: {PIString r; ba >> r; return r.toInt();} case PIVariant::pivStringList: {PIStringList r; ba >> r; if (r.isEmpty()) return 0; return r.front().toInt();} case PIVariant::pivEnum: {PIVariantTypes::Enum r; ba >> r; return r.selectedValue();} @@ -247,8 +239,6 @@ llong PIVariant::toLLong() const { case PIVariant::pivFloat: {float r; ba >> r; return r;} case PIVariant::pivDouble: {double r; ba >> r; return r;} case PIVariant::pivLDouble: {ldouble r; ba >> r; return r;} - case PIVariant::pivComplexd: {complexd r; ba >> r; return r.real();} - case PIVariant::pivComplexld: {complexld r; ba >> r; return r.real();} case PIVariant::pivString: {PIString r; ba >> r; return r.toLLong();} case PIVariant::pivStringList: {PIStringList r; ba >> r; if (r.isEmpty()) return 0L; return r.front().toLLong();} case PIVariant::pivEnum: {PIVariantTypes::Enum r; ba >> r; return llong(r.selectedValue());} @@ -280,8 +270,6 @@ float PIVariant::toFloat() const { case PIVariant::pivFloat: {float r; ba >> r; return r;} case PIVariant::pivDouble: {double r; ba >> r; return r;} case PIVariant::pivLDouble: {ldouble r; ba >> r; return r;} - case PIVariant::pivComplexd: {complexd r; ba >> r; return r.real();} - case PIVariant::pivComplexld: {complexld r; ba >> r; return r.real();} case PIVariant::pivString: {PIString r; ba >> r; return r.toFloat();} case PIVariant::pivStringList: {PIStringList r; ba >> r; if (r.isEmpty()) return 0.f; return r.front().toFloat();} case PIVariant::pivEnum: {PIVariantTypes::Enum r; ba >> r; return float(r.selectedValue());} @@ -313,8 +301,6 @@ double PIVariant::toDouble() const { case PIVariant::pivFloat: {float r; ba >> r; return r;} case PIVariant::pivDouble: {double r; ba >> r; return r;} case PIVariant::pivLDouble: {ldouble r; ba >> r; return r;} - case PIVariant::pivComplexd: {complexd r; ba >> r; return r.real();} - case PIVariant::pivComplexld: {complexld r; ba >> r; return r.real();} case PIVariant::pivString: {PIString r; ba >> r; return r.toDouble();} case PIVariant::pivStringList: {PIStringList r; ba >> r; if (r.isEmpty()) return 0.; return r.front().toDouble();} case PIVariant::pivEnum: {PIVariantTypes::Enum r; ba >> r; return double(r.selectedValue());} @@ -346,8 +332,6 @@ ldouble PIVariant::toLDouble() const { case PIVariant::pivFloat: {float r; ba >> r; return r;} case PIVariant::pivDouble: {double r; ba >> r; return r;} case PIVariant::pivLDouble: {ldouble r; ba >> r; return r;} - case PIVariant::pivComplexd: {complexd r; ba >> r; return r.real();} - case PIVariant::pivComplexld: {complexld r; ba >> r; return r.real();} case PIVariant::pivString: {PIString r; ba >> r; return r.toLDouble();} case PIVariant::pivStringList: {PIStringList r; ba >> r; if (r.isEmpty()) return 0.; return r.front().toLDouble();} case PIVariant::pivEnum: {PIVariantTypes::Enum r; ba >> r; return ldouble(r.selectedValue());} @@ -358,72 +342,6 @@ ldouble PIVariant::toLDouble() const { } -/** \brief Returns variant content as complex - * \details In case of numeric types returns complex value. \n - * In case of String type returns \a PIString::toDouble(). \n - * In case of StringList type returns \b 0. if string list is empty, - * otherwise returns \a PIString::toDouble() of first string. \n - * In case of other types returns \b 0.. */ -complexd PIVariant::toComplexd() const { - PIByteArray ba(_content); - switch (_type) { - case PIVariant::pivBool: {bool r; ba >> r; return r;} - case PIVariant::pivChar: {char r; ba >> r; return r;} - case PIVariant::pivUChar: {uchar r; ba >> r; return r;} - case PIVariant::pivShort: {short r; ba >> r; return r;} - case PIVariant::pivUShort: {ushort r; ba >> r; return r;} - case PIVariant::pivInt: {int r; ba >> r; return r;} - case PIVariant::pivUInt: {uint r; ba >> r; return r;} - case PIVariant::pivLLong: {llong r; ba >> r; return r;} - case PIVariant::pivULLong: {ullong r; ba >> r; return r;} - case PIVariant::pivFloat: {float r; ba >> r; return r;} - case PIVariant::pivDouble: {double r; ba >> r; return r;} - case PIVariant::pivLDouble: {ldouble r; ba >> r; return r;} - case PIVariant::pivComplexd: {complexd r; ba >> r; return r.real();} - case PIVariant::pivComplexld: {complexld r; ba >> r; return r.real();} - case PIVariant::pivString: {PIString r; ba >> r; return r.toDouble();} - case PIVariant::pivStringList: {PIStringList r; ba >> r; if (r.isEmpty()) return complexd_0; return r.front().toDouble();} - case PIVariant::pivEnum: {PIVariantTypes::Enum r; ba >> r; return complexd(r.selectedValue());} - case PIVariant::pivCustom: return getAsValue(*this); - default: break; - } - return complexd_0; -} - - -/** \brief Returns variant content as long complex - * \details In case of numeric types returns long complex value. \n - * In case of String type returns \a PIString::toLDouble(). \n - * In case of StringList type returns \b 0. if string list is empty, - * otherwise returns \a PIString::toLDouble() of first string. \n - * In case of other types returns \b 0.. */ -complexld PIVariant::toComplexld() const { - PIByteArray ba(_content); - switch (_type) { - case PIVariant::pivBool: {bool r; ba >> r; return r;} - case PIVariant::pivChar: {char r; ba >> r; return r;} - case PIVariant::pivUChar: {uchar r; ba >> r; return r;} - case PIVariant::pivShort: {short r; ba >> r; return r;} - case PIVariant::pivUShort: {ushort r; ba >> r; return r;} - case PIVariant::pivInt: {int r; ba >> r; return r;} - case PIVariant::pivUInt: {uint r; ba >> r; return r;} - case PIVariant::pivLLong: {llong r; ba >> r; return r;} - case PIVariant::pivULLong: {ullong r; ba >> r; return r;} - case PIVariant::pivFloat: {float r; ba >> r; return r;} - case PIVariant::pivDouble: {double r; ba >> r; return r;} - case PIVariant::pivLDouble: {ldouble r; ba >> r; return r;} - case PIVariant::pivComplexd: {complexd r; ba >> r; return r.real();} - case PIVariant::pivComplexld: {complexld r; ba >> r; return r.real();} - case PIVariant::pivString: {PIString r; ba >> r; return r.toLDouble();} - case PIVariant::pivStringList: {PIStringList r; ba >> r; if (r.isEmpty()) return complexld_0; return r.front().toLDouble();} - case PIVariant::pivEnum: {PIVariantTypes::Enum r; ba >> r; return complexld(r.selectedValue());} - case PIVariant::pivCustom: return getAsValue(*this); - default: break; - } - return complexld_0; -} - - /** \brief Returns variant content as time * \details In case of Time type returns time value. \n * In case of DateTime type returns time part of value. \n @@ -501,8 +419,6 @@ PIString PIVariant::toString() const { case PIVariant::pivFloat: {float r; ba >> r; return PIString::fromNumber(r);} case PIVariant::pivDouble: {double 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::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();} diff --git a/src/core/pivariant.h b/src/core/pivariant.h index 3cb73709..9494a2f9 100755 --- a/src/core/pivariant.h +++ b/src/core/pivariant.h @@ -27,7 +27,6 @@ #include "pivarianttypes.h" #include "pitime.h" -#include "pimathbase.h" #ifndef QNX # define CUSTOM_PIVARIANT @@ -188,8 +187,6 @@ public: pivFloat /** float */ , pivDouble /** double */ , pivLDouble /** ldouble */ , - pivComplexd /** complexd */ , - pivComplexld /** complexld */ , pivBitArray /** PIBitArray */ , pivByteArray /** PIByteArray */ , pivString /** PIString */ , @@ -248,12 +245,6 @@ public: //! Constructs variant from long double PIVariant(const ldouble & v) {initType(v);} - //! Constructs variant from complex - PIVariant(const complexd & v) {initType(v);} - - //! Constructs variant from complex - PIVariant(const complexld & v) {initType(v);} - //! Constructs variant from bit array PIVariant(const PIBitArray & v) {initType(v);} @@ -327,12 +318,6 @@ public: //! Set variant content and type to long double void setValue(const ldouble & v) {initType(v);} - //! Set variant content and type to complex - void setValue(const complexd & v) {initType(v);} - - //! Set variant content and type to complex - void setValue(const complexld & v) {initType(v);} - //! Set variant content and type to bit array void setValue(const PIBitArray & v) {initType(v);} @@ -373,8 +358,6 @@ public: float toFloat() const; double toDouble() const; ldouble toLDouble() const; - complexd toComplexd() const; - complexld toComplexld() const; PITime toTime() const; PIDate toDate() const; PIDateTime toDateTime() const; @@ -408,8 +391,6 @@ public: operator float() const {return toFloat();} operator double() const {return toDouble();} operator ldouble() const {return toLDouble();} - operator complexd() const {return toComplexd();} - operator complexld() const {return toComplexld();} operator PITime() const {return toTime();} operator PIDate() const {return toDate();} operator PIDateTime() const {return toDateTime();} @@ -450,10 +431,6 @@ public: //! Assign operator PIVariant & operator =(const ldouble & v) {setValue(v); return *this;} //! Assign operator - PIVariant & operator =(const complexd & v) {setValue(v); return *this;} - //! Assign operator - PIVariant & operator =(const complexld & v) {setValue(v); return *this;} - //! Assign operator PIVariant & operator =(const PIBitArray & v) {setValue(v); return *this;} //! Assign operator PIVariant & operator =(const PIByteArray & v) {setValue(v); return *this;} @@ -588,8 +565,6 @@ template<> inline ullong PIVariant::value() const {return (ullong)toLLong();} template<> inline float PIVariant::value() const {return toFloat();} template<> inline double PIVariant::value() const {return toDouble();} template<> inline ldouble PIVariant::value() const {return toLDouble();} -template<> inline complexd PIVariant::value() const {return toComplexd();} -template<> inline complexld PIVariant::value() const {return toComplexld();} template<> inline void* PIVariant::value() const {return (void*)toLLong();} template<> inline const char* PIVariant::value() const {return toString().data();} template<> inline PITime PIVariant::value() const {return toTime();} @@ -616,8 +591,6 @@ template<> inline PIVariant PIVariant::fromValue(const ullong & v) {return PIVar template<> inline PIVariant PIVariant::fromValue(const float & v) {return PIVariant(v);} template<> inline PIVariant PIVariant::fromValue(const double & v) {return PIVariant(v);} template<> inline PIVariant PIVariant::fromValue(const ldouble & v) {return PIVariant(v);} -template<> inline PIVariant PIVariant::fromValue(const complexd & v) {return PIVariant(v);} -template<> inline PIVariant PIVariant::fromValue(const complexld & v) {return PIVariant(v);} template<> inline PIVariant PIVariant::fromValue(const PIBitArray & v) {return PIVariant(v);} template<> inline PIVariant PIVariant::fromValue(const PIByteArray & v) {return PIVariant(v);} template<> inline PIVariant PIVariant::fromValue(const PIString & v) {return PIVariant(v);} @@ -642,8 +615,6 @@ template<> inline PIVariant::Type PIVariant::getType() {return PIVariant template<> inline PIVariant::Type PIVariant::getType() {return PIVariant::pivFloat;} template<> inline PIVariant::Type PIVariant::getType() {return PIVariant::pivDouble;} template<> inline PIVariant::Type PIVariant::getType() {return PIVariant::pivLDouble;} -template<> inline PIVariant::Type PIVariant::getType() {return PIVariant::pivComplexd;} -template<> inline PIVariant::Type PIVariant::getType() {return PIVariant::pivComplexld;} template<> inline PIVariant::Type PIVariant::getType() {return PIVariant::pivBitArray;} template<> inline PIVariant::Type PIVariant::getType() {return PIVariant::pivByteArray;} template<> inline PIVariant::Type PIVariant::getType() {return PIVariant::pivString;} @@ -668,8 +639,6 @@ REGISTER_VARIANT(ullong) REGISTER_VARIANT(float) REGISTER_VARIANT(double) REGISTER_VARIANT(ldouble) -REGISTER_VARIANT(complexd) -REGISTER_VARIANT(complexld) REGISTER_VARIANT(PIBitArray) REGISTER_VARIANT(PIByteArray) REGISTER_VARIANT(PIString) diff --git a/src/io/pifile.cpp b/src/io/pifile.cpp index a06a9936..bf945ac5 100755 --- a/src/io/pifile.cpp +++ b/src/io/pifile.cpp @@ -139,6 +139,11 @@ PIFile::PIFile(const PIString & path, PIIODevice::DeviceMode mode): PIIODevice(p } +bool PIFile::openTemporary(PIIODevice::DeviceMode mode) { + return open(PIString(tmpnam(0)), mode); +} + + //PIFile::PIFile(const PIFile & other) { // fd = 0; // fdi = -1; @@ -283,6 +288,11 @@ bool PIFile::remove(const PIString & path) { } +bool PIFile::rename(const PIString & from, const PIString & to) { + return ::rename(from.data(), to.data()) == 0; +} + + PIString PIFile::constructFullPathDevice() const { return path(); } @@ -367,6 +377,156 @@ void PIFile::setPrecision(int prec) { } +PIFile &PIFile::operator <<(double v) { + if (canWrite() && fd != 0) ret = fprintf(fd, ("%" + prec_str + "lf").data(), v); + return *this; +} + + +PIFile &PIFile::operator >>(double & v) { + if (canRead() && fd != 0) ret = fscanf(fd, "%lf", &v); + return *this; +} + + +PIFile &PIFile::operator >>(float & v) { + if (canRead() && fd != 0) ret = fscanf(fd, "%f", &v); + return *this; +} + + +PIFile &PIFile::operator >>(ullong & v) { + if (canRead() && fd != 0) ret = fscanf(fd, "%lln", &v); + return *this; +} + + +PIFile &PIFile::operator >>(ulong & v) { + if (canRead() && fd != 0) ret = fscanf(fd, "%ln", &v); + return *this; +} + + +PIFile &PIFile::operator >>(uint & v) { + if (canRead() && fd != 0) ret = fscanf(fd, "%n", &v); + return *this; +} + + +PIFile &PIFile::operator >>(ushort & v) { + if (canRead() && fd != 0) ret = fscanf(fd, "%hn", &v); + return *this; +} + + +PIFile &PIFile::operator >>(uchar & v) { + if (canRead() && fd != 0) ret = fscanf(fd, "%hhn", &v); + return *this; +} + + +PIFile &PIFile::operator >>(llong & v) { + if (canRead() && fd != 0) ret = fscanf(fd, "%lln", &v); + return *this; +} + + +PIFile &PIFile::operator >>(long & v) { + if (canRead() && fd != 0) ret = fscanf(fd, "%ln", &v); + return *this; +} + + +PIFile &PIFile::operator >>(int & v) { + if (canRead() && fd != 0) ret = fscanf(fd, "%n", &v); + return *this; +} + + +PIFile &PIFile::operator >>(short & v) { + if (canRead() && fd != 0) ret = fscanf(fd, "%hn", &v); + return *this; +} + + +PIFile &PIFile::operator >>(char & v) { + if (canRead() && fd != 0) ret = fscanf(fd, "%hhn", &v); + return *this; +} + + +PIFile &PIFile::operator <<(float v) { + if (canWrite() && fd != 0) ret = fprintf(fd, ("%" + prec_str + "f").data(), v); + return *this; +} + + +PIFile &PIFile::operator <<(ullong v) { + if (canWrite() && fd != 0) ret = fprintf(fd, "%llu", v); + return *this; +} + + +PIFile &PIFile::operator <<(ulong v) { + if (canWrite() && fd != 0) ret = fprintf(fd, "%lu", v); + return *this; +} + + +PIFile &PIFile::operator <<(uint v) { + if (canWrite() && fd != 0) ret = fprintf(fd, "%u", v); + return *this; +} + + +PIFile &PIFile::operator <<(ushort v) { + if (canWrite() && fd != 0) ret = fprintf(fd, "%hu", v); + return *this; +} + + +PIFile &PIFile::operator <<(uchar v) { + if (canWrite() && fd != 0) ret = fprintf(fd, "%u", int(v)); + return *this; +} + + +PIFile &PIFile::operator <<(llong v) { + if (canWrite() && fd != 0) ret = fprintf(fd, "%lld", v); + return *this; +} + + +PIFile &PIFile::operator <<(long v) { + if (canWrite() && fd != 0) ret = fprintf(fd, "%ld", v); + return *this; +} + + +PIFile &PIFile::operator <<(int v) { + if (canWrite() && fd != 0) ret = fprintf(fd, "%d", v); + return *this; +} + + +PIFile &PIFile::operator <<(short v) { + if (canWrite() && fd != 0) ret = fprintf(fd, "%hd", v); + return *this; +} + + +PIFile &PIFile::operator <<(const PIByteArray & v) { + if (canWrite() && fd != 0) write(v.data(), v.size()); + return *this; +} + + +PIFile &PIFile::operator <<(const char v) { + if (canWrite() && fd != 0) write(&v, 1); + return *this; +} + + int PIFile::readDevice(void * read_to, int max_size) { if (!canRead() || fd == 0) return -1; return fread(read_to, 1, max_size, fd); diff --git a/src/io/pifile.h b/src/io/pifile.h index 88870480..d0ce9703 100755 --- a/src/io/pifile.h +++ b/src/io/pifile.h @@ -88,7 +88,7 @@ public: //! Open temporary file with open mode "mode" - bool openTemporary(PIIODevice::DeviceMode mode = PIIODevice::ReadWrite) {return open(PIString(tmpnam(0)), mode);} + bool openTemporary(PIIODevice::DeviceMode mode = PIIODevice::ReadWrite); // PIFile(const PIFile & other); @@ -180,60 +180,59 @@ public: //PIFile & operator =(const PIFile & f) {PIIODevice::setPath(f.path()); mode_ = f.mode_; return *this;} //! Write to file text representation of "v" - PIFile & operator <<(const char v) {if (canWrite() && fd != 0) write(&v, 1); return *this;} - //PIFile & operator <<(const string & v) {write(v.c_str(), v.size()); return *this;} + PIFile & operator <<(const char v); //! Write to file string "v" PIFile & operator <<(const PIString & v); //! Write to file text representation of "v" - PIFile & operator <<(const PIByteArray & v) {if (canWrite() && fd != 0) write(v.data(), v.size()); return *this;} + PIFile & operator <<(const PIByteArray & v); //! Write to file text representation of "v" - PIFile & operator <<(short v) {if (canWrite() && fd != 0) ret = fprintf(fd, "%hd", v); return *this;} + PIFile & operator <<(short v); //! Write to file text representation of "v" - PIFile & operator <<(int v) {if (canWrite() && fd != 0) ret = fprintf(fd, "%d", v); return *this;} + PIFile & operator <<(int v); //! Write to file text representation of "v" - PIFile & operator <<(long v) {if (canWrite() && fd != 0) ret = fprintf(fd, "%ld", v); return *this;} + PIFile & operator <<(long v); //! Write to file text representation of "v" - PIFile & operator <<(llong v) {if (canWrite() && fd != 0) ret = fprintf(fd, "%lld", v); return *this;} + PIFile & operator <<(llong v); //! Write to file text representation of "v" - PIFile & operator <<(uchar v) {if (canWrite() && fd != 0) ret = fprintf(fd, "%u", int(v)); return *this;} + PIFile & operator <<(uchar v); //! Write to file text representation of "v" - PIFile & operator <<(ushort v) {if (canWrite() && fd != 0) ret = fprintf(fd, "%hu", v); return *this;} + PIFile & operator <<(ushort v); //! Write to file text representation of "v" - PIFile & operator <<(uint v) {if (canWrite() && fd != 0) ret = fprintf(fd, "%u", v); return *this;} + PIFile & operator <<(uint v); //! Write to file text representation of "v" - PIFile & operator <<(ulong v) {if (canWrite() && fd != 0) ret = fprintf(fd, "%lu", v); return *this;} + PIFile & operator <<(ulong v); //! Write to file text representation of "v" - PIFile & operator <<(ullong v) {if (canWrite() && fd != 0) ret = fprintf(fd, "%llu", v); return *this;} + PIFile & operator <<(ullong v); //! Write to file text representation of "v" with precision \a precision() - PIFile & operator <<(float v) {if (canWrite() && fd != 0) ret = fprintf(fd, ("%" + prec_str + "f").data(), v); return *this;} + PIFile & operator <<(float v); //! Write to file text representation of "v" with precision \a precision() - PIFile & operator <<(double v) {if (canWrite() && fd != 0) ret = fprintf(fd, ("%" + prec_str + "lf").data(), v); return *this;} + PIFile & operator <<(double v); //! Read from file text representation of "v" - PIFile & operator >>(char & v) {if (canRead() && fd != 0) ret = fscanf(fd, "%hhn", &v); return *this;} + PIFile & operator >>(char & v); //! Read from file text representation of "v" - PIFile & operator >>(short & v) {if (canRead() && fd != 0) ret = fscanf(fd, "%hn", &v); return *this;} + PIFile & operator >>(short & v); //! Read from file text representation of "v" - PIFile & operator >>(int & v) {if (canRead() && fd != 0) ret = fscanf(fd, "%n", &v); return *this;} + PIFile & operator >>(int & v); //! Read from file text representation of "v" - PIFile & operator >>(long & v) {if (canRead() && fd != 0) ret = fscanf(fd, "%ln", &v); return *this;} + PIFile & operator >>(long & v); //! Read from file text representation of "v" - PIFile & operator >>(llong & v) {if (canRead() && fd != 0) ret = fscanf(fd, "%lln", &v); return *this;} + PIFile & operator >>(llong & v); //! Read from file text representation of "v" - PIFile & operator >>(uchar & v) {if (canRead() && fd != 0) ret = fscanf(fd, "%hhn", &v); return *this;} + PIFile & operator >>(uchar & v); //! Read from file text representation of "v" - PIFile & operator >>(ushort & v) {if (canRead() && fd != 0) ret = fscanf(fd, "%hn", &v); return *this;} + PIFile & operator >>(ushort & v); //! Read from file text representation of "v" - PIFile & operator >>(uint & v) {if (canRead() && fd != 0) ret = fscanf(fd, "%n", &v); return *this;} + PIFile & operator >>(uint & v); //! Read from file text representation of "v" - PIFile & operator >>(ulong & v) {if (canRead() && fd != 0) ret = fscanf(fd, "%ln", &v); return *this;} + PIFile & operator >>(ulong & v); //! Read from file text representation of "v" - PIFile & operator >>(ullong & v) {if (canRead() && fd != 0) ret = fscanf(fd, "%lln", &v); return *this;} + PIFile & operator >>(ullong & v); //! Read from file text representation of "v" - PIFile & operator >>(float & v) {if (canRead() && fd != 0) ret = fscanf(fd, "%f", &v); return *this;} + PIFile & operator >>(float & v); //! Read from file text representation of "v" - PIFile & operator >>(double & v) {if (canRead() && fd != 0) ret = fscanf(fd, "%lf", &v); return *this;} + PIFile & operator >>(double & v); EVENT_HANDLER(void, clear); EVENT_HANDLER(void, remove); @@ -253,7 +252,7 @@ public: static bool remove(const PIString & path); //! Rename file with path "from" to path "to" and returns if rename was successful - static bool rename(const PIString & from, const PIString & to) {return ::rename(from.data(), to.data()) == 0;} + static bool rename(const PIString & from, const PIString & to); //! Returns FileInfo of file or dir with path "path" static FileInfo fileInfo(const PIString & path); diff --git a/src/io/piprotocol.cpp b/src/io/piprotocol.cpp index 69deaedf..7871219a 100755 --- a/src/io/piprotocol.cpp +++ b/src/io/piprotocol.cpp @@ -19,7 +19,6 @@ #include "piprotocol.h" - /** \class PIProtocol * \brief * \details @@ -517,7 +516,7 @@ void PIProtocol::setExpectedFrequency(float frequency) { void PIProtocol::changeDisconnectTimeout() { - pckt_cnt_max = int(round(timeout_ * exp_freq)); + pckt_cnt_max = int(piRound(timeout_ * exp_freq)); if (pckt_cnt_max < 3) pckt_cnt_max = 3; last_packets.resize(pckt_cnt_max); } diff --git a/src/math/pimathbase.cpp b/src/math/pimathbase.cpp index cc501b64..b5a1a204 100644 --- a/src/math/pimathbase.cpp +++ b/src/math/pimathbase.cpp @@ -452,11 +452,6 @@ double piYn(int n, const double & v) { } -void randomize() { - srand(PISystemTime::current(true).nanoseconds); -} - - double randomn(double dv, double sv) { static bool agen = false; double s = 2., v0 = 0., v1 = 0.; diff --git a/src/math/pimathbase.h b/src/math/pimathbase.h index 735f4f1d..1ba05368 100644 --- a/src/math/pimathbase.h +++ b/src/math/pimathbase.h @@ -162,7 +162,6 @@ inline PIByteArray & operator >>(PIByteArray & s, complexd & v) {double t0, t1; //! \relatesalso PIByteArray \brief Restore operator inline PIByteArray & operator >>(PIByteArray & s, complexld & v) {ldouble t0, t1; s >> t0; s >> t1; v = complexld(t0, t1); return s;} -void randomize(); // [-1 ; 1] double randomd(); // [-1 ; 1] normal diff --git a/src/system/piintrospection.cpp b/src/system/piintrospection.cpp index 6257966c..ccd61efb 100644 --- a/src/system/piintrospection.cpp +++ b/src/system/piintrospection.cpp @@ -18,6 +18,7 @@ */ #include "piintrospection.h" +#include "piincludes.h" #include "pisysteminfo.h"