version 2.2.0
remove deprecated members PIVariantTypes::File add "is_save" flag PIBinaryLog clear
This commit is contained in:
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
|
||||
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
||||
project(pip)
|
||||
set(_PIP_MAJOR 2)
|
||||
set(_PIP_MINOR 1)
|
||||
set(_PIP_MINOR 2)
|
||||
set(_PIP_REVISION 0)
|
||||
set(_PIP_SUFFIX _alpha)
|
||||
set(_PIP_COMPANY SHS)
|
||||
|
||||
@@ -454,19 +454,6 @@ template<> inline float piLetobe(const float & v) {
|
||||
return a.f;
|
||||
}
|
||||
|
||||
DEPRECATED inline ushort letobe_s(const ushort & v) {return (v << 8) | (v >> 8);}
|
||||
DEPRECATED inline uint letobe_i(const uint & v) {return (v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | ((v << 24) & 0xFF000000);}
|
||||
|
||||
#ifdef DOXYGEN
|
||||
|
||||
/// \deprecated \brief Use \a piLetobe() instead of this function
|
||||
ushort letobe_s(ushort v) {return (v << 8) | (v >> 8);}
|
||||
|
||||
/// \deprecated \brief Use \a piLetobe() instead of this function
|
||||
uint letobe_i(uint v) {return (v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | ((v << 24) & 0xFF000000);}
|
||||
|
||||
#endif
|
||||
|
||||
/// \brief Generic hash function, implements murmur3/32 algorithm
|
||||
inline uint piHashData(const uchar * data, uint len, uint seed = 0) {
|
||||
if (!data || len <= 0) return 0u;
|
||||
|
||||
@@ -48,7 +48,6 @@ struct PIP_EXPORT Enumerator {
|
||||
*/
|
||||
struct PIP_EXPORT Enum {
|
||||
Enum(const PIString & n = PIString()): enum_name(n) {}
|
||||
PIString toString() const {return selected;} // obsolete
|
||||
|
||||
/**
|
||||
* @brief Find selected value.
|
||||
@@ -123,15 +122,18 @@ struct PIP_EXPORT Enum {
|
||||
};
|
||||
|
||||
struct PIP_EXPORT File {
|
||||
File(const PIString & p = PIString(), const PIString & f = PIString(), bool abs = false): file(p), filter(f), is_abs(abs) {}
|
||||
File(const PIString & p = PIString(), const PIString & f = PIString(), bool abs = false, bool save_mode = false):
|
||||
file(p), filter(f), is_abs(abs), is_save(save_mode) {}
|
||||
PIString toString() const {return file;}
|
||||
PIString file;
|
||||
PIString filter;
|
||||
bool is_abs;
|
||||
bool is_save;
|
||||
};
|
||||
|
||||
struct PIP_EXPORT Dir {
|
||||
Dir(const PIString & d = PIString(), bool abs = false): dir(d), is_abs(abs) {}
|
||||
Dir(const PIString & d = PIString(), bool abs = false):
|
||||
dir(d), is_abs(abs) {}
|
||||
PIString toString() const {return dir;}
|
||||
PIString dir;
|
||||
bool is_abs;
|
||||
@@ -156,27 +158,27 @@ struct PIP_EXPORT IODevice {
|
||||
}
|
||||
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIVariantTypes::Enumerator & v) {s << v.value << v.name; return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVariantTypes::Enumerator & v) {s >> v.value >> v.name; return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVariantTypes::Enumerator & v) {s >> v.value >> v.name; return s;}
|
||||
inline PICout operator <<(PICout s, const PIVariantTypes::Enumerator & v) {s << v.name << "(" << v.value << ")"; return s;}
|
||||
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIVariantTypes::Enum & v) {s << v.enum_name << v.selected << v.enum_list; return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVariantTypes::Enum & v) {s >> v.enum_name >> v.selected >> v.enum_list; return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVariantTypes::Enum & v) {s >> v.enum_name >> v.selected >> v.enum_list; return s;}
|
||||
inline PICout operator <<(PICout s, const PIVariantTypes::Enum & v) {s << "Enum(" << v.selectedValue() << "=" << v.selectedName() << ")"; return s;}
|
||||
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIVariantTypes::File & v) {s << v.file << v.filter << v.is_abs; return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVariantTypes::File & v) {s >> v.file >> v.filter >> v.is_abs; return s;}
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIVariantTypes::File & v) {s << v.file << v.filter << uchar((v.is_abs ? 1 : 0) + (v.is_save ? 2 : 0)); return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVariantTypes::File & v) {uchar f(0); s >> v.file >> v.filter >> f; v.is_abs = ((f & 1) == 1); v.is_save = ((f & 2) == 2); return s;}
|
||||
inline PICout operator <<(PICout s, const PIVariantTypes::File & v) {s << "File(\"" << v.file << "\")"; return s;}
|
||||
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIVariantTypes::Dir & v) {s << v.dir << v.is_abs; return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVariantTypes::Dir & v) {s >> v.dir >> v.is_abs; return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVariantTypes::Dir & v) {s >> v.dir >> v.is_abs; return s;}
|
||||
inline PICout operator <<(PICout s, const PIVariantTypes::Dir & v) {s << "Dir(\"" << v.dir << "\")"; return s;}
|
||||
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIVariantTypes::Color & v) {s << v.rgba; return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVariantTypes::Color & v) {s >> v.rgba; return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVariantTypes::Color & v) {s >> v.rgba; return s;}
|
||||
inline PICout operator <<(PICout s, const PIVariantTypes::Color & v) {s.saveControl(); s << PICoutManipulators::Hex << "Color(#" << v.rgba << ")"; s.restoreControl(); return s;}
|
||||
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIVariantTypes::IODevice & v) {s << v.prefix << v.mode << v.options << v.props; return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVariantTypes::IODevice & v) {s >> v.prefix >> v.mode >> v.options >> v.props; return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVariantTypes::IODevice & v) {s >> v.prefix >> v.mode >> v.options >> v.props; return s;}
|
||||
inline PICout operator <<(PICout s, const PIVariantTypes::IODevice & v) {s << v.toPICout(); return s;}
|
||||
|
||||
#endif // PIVARIANTYPES_H
|
||||
|
||||
@@ -45,6 +45,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
static const uchar binlog_sig[] = {'B','I','N','L','O','G'};
|
||||
|
||||
#define PIBINARYLOG_VERSION 0x32
|
||||
#define PIBINARYLOG_SIGNATURE_SIZE sizeof(binlog_sig)
|
||||
|
||||
REGISTER_DEVICE(PIBinaryLog)
|
||||
|
||||
PIBinaryLog::PIBinaryLog() {
|
||||
@@ -358,6 +363,11 @@ int PIBinaryLog::readBinLog(int id, void *read_to, int max_size, PISystemTime *
|
||||
}
|
||||
|
||||
|
||||
bool PIBinaryLog::isEmpty() const {
|
||||
return (log_size <= llong(PIBINARYLOG_SIGNATURE_SIZE + 1));
|
||||
}
|
||||
|
||||
|
||||
void PIBinaryLog::setHeader(const PIByteArray & header) {
|
||||
user_header = header;
|
||||
}
|
||||
@@ -414,7 +424,7 @@ void PIBinaryLog::restart() {
|
||||
|
||||
|
||||
bool PIBinaryLog::writeFileHeader() {
|
||||
if (file.write(&__S__PIBinaryLog::binlog_sig, PIBINARYLOG_SIGNATURE_SIZE) <= 0) return false;
|
||||
if (file.write(binlog_sig, PIBINARYLOG_SIGNATURE_SIZE) <= 0) return false;
|
||||
uchar version = PIBINARYLOG_VERSION;
|
||||
if (file.write(&version, 1) <= 0) return false;
|
||||
uint32_t sz = user_header.size();
|
||||
@@ -432,7 +442,7 @@ bool PIBinaryLog::checkFileHeader() {
|
||||
if (file.read(read_sig, PIBINARYLOG_SIGNATURE_SIZE) < 0) return false;
|
||||
bool correct = true;
|
||||
for (uint i=0; i<PIBINARYLOG_SIGNATURE_SIZE; i++)
|
||||
if (read_sig[i] != __S__PIBinaryLog::binlog_sig[i]) correct = false;
|
||||
if (read_sig[i] != binlog_sig[i]) correct = false;
|
||||
if (!correct) {
|
||||
piCoutObj << "BinLogFile signature is corrupted or invalid file";
|
||||
return false;
|
||||
@@ -516,7 +526,7 @@ void PIBinaryLog::parseLog(PIFile * f, PIBinaryLog::BinLogInfo * info, PIVector<
|
||||
bool ok = true;
|
||||
if (f->read(read_sig, PIBINARYLOG_SIGNATURE_SIZE) < 0) {if (ginfo) bi->records_count = -1; ok = false;}
|
||||
for (uint i=0; i<PIBINARYLOG_SIGNATURE_SIZE; i++)
|
||||
if (read_sig[i] != __S__PIBinaryLog::binlog_sig[i]) {if (ginfo) bi->records_count = -2; ok = false;}
|
||||
if (read_sig[i] != binlog_sig[i]) {if (ginfo) bi->records_count = -2; ok = false;}
|
||||
uchar read_version = 0;
|
||||
if (f->read(&read_version, 1) < 0) {if (ginfo) bi->records_count = -3; ok = false;}
|
||||
if (read_version == 0) {if (ginfo) bi->records_count = -4; ok = false;}
|
||||
|
||||
@@ -25,14 +25,7 @@
|
||||
|
||||
#include "pifile.h"
|
||||
|
||||
#define PIBINARYLOG_VERSION 0x32
|
||||
namespace __S__PIBinaryLog {
|
||||
static const uchar binlog_sig[] = {'B','I','N','L','O','G'};
|
||||
}
|
||||
#define PIBINARYLOG_SIGNATURE_SIZE sizeof(__S__PIBinaryLog::binlog_sig)
|
||||
|
||||
/// TODO: Create static functions to join binlog files
|
||||
/// TODO: Create functions to insert and delete records
|
||||
class PIP_EXPORT PIBinaryLog: public PIIODevice
|
||||
{
|
||||
PIIODEVICE(PIBinaryLog)
|
||||
@@ -196,7 +189,7 @@ public:
|
||||
bool isEnd() const {if (isClosed()) return true; return file.isEnd();}
|
||||
|
||||
//! Returns if BinLog file is empty
|
||||
bool isEmpty() const {return (log_size <= llong(PIBINARYLOG_SIGNATURE_SIZE + 1));}
|
||||
bool isEmpty() const;
|
||||
|
||||
//! Returns BinLog pause status
|
||||
bool isPause() const {return is_pause;}
|
||||
|
||||
Reference in New Issue
Block a user