replace typedef function ptr by std::function
start PIMap refactoring
This commit is contained in:
@@ -1,8 +1,17 @@
|
|||||||
/*! \file pimap.h
|
//! \addtogroup Containers
|
||||||
* \brief Associative array with custom types of key and value
|
//! \{
|
||||||
*
|
//! \file pideque.h
|
||||||
* This file declares PIMap
|
//! \brief
|
||||||
*/
|
//! \~english Declares \a PIMap
|
||||||
|
//! \~russian Объявление \a PIMap
|
||||||
|
//! \~\authors
|
||||||
|
//! \~english
|
||||||
|
//! Ivan Pelipenko peri4ko@yandex.ru;
|
||||||
|
//! Andrey Bychkov work.a.b@yandex.ru;
|
||||||
|
//! \~russian
|
||||||
|
//! Иван Пелипенко peri4ko@yandex.ru;
|
||||||
|
//! Андрей Бычков work.a.b@yandex.ru;
|
||||||
|
//! \~\}
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Associative array with custom types of key and value
|
Associative array with custom types of key and value
|
||||||
@@ -30,41 +39,6 @@
|
|||||||
#include "pipair.h"
|
#include "pipair.h"
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void piQuickSort(T * a, ssize_t N) {
|
|
||||||
if (N < 1) return;
|
|
||||||
if (N < 46) {
|
|
||||||
T tmp;
|
|
||||||
ssize_t i,j;
|
|
||||||
for(i=1; i<=N; i++) {
|
|
||||||
tmp = a[i];
|
|
||||||
j = i-1;
|
|
||||||
while(tmp<a[j] && j>=0) {
|
|
||||||
a[j+1] = a[j];
|
|
||||||
j = j-1;
|
|
||||||
}
|
|
||||||
a[j+1] = tmp;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ssize_t i = 0, j = N;
|
|
||||||
T & p(a[N >> 1]);
|
|
||||||
do {
|
|
||||||
while (a[i] < p) i++;
|
|
||||||
while (a[j] > p) j--;
|
|
||||||
if (i <= j) {
|
|
||||||
if (i != j) {
|
|
||||||
//piCout << "swap" << i << j << a[i] << a[j];
|
|
||||||
piSwap<T>(a[i], a[j]);
|
|
||||||
}
|
|
||||||
i++; j--;
|
|
||||||
}
|
|
||||||
} while (i <= j);
|
|
||||||
if (j > 0) piQuickSort(a, j);
|
|
||||||
if (N > i) piQuickSort(a + i, N - i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <typename Key, typename T>
|
template <typename Key, typename T>
|
||||||
class PIMapIterator;
|
class PIMapIterator;
|
||||||
|
|
||||||
@@ -81,8 +55,9 @@ public:
|
|||||||
PIMap(const PIMap<Key, T> & other) {*this = other;}
|
PIMap(const PIMap<Key, T> & other) {*this = other;}
|
||||||
PIMap(PIMap<Key, T> && other) : pim_content(std::move(other.pim_content)), pim_index(std::move(other.pim_index)) {}
|
PIMap(PIMap<Key, T> && other) : pim_content(std::move(other.pim_content)), pim_index(std::move(other.pim_index)) {}
|
||||||
PIMap(std::initializer_list<std::pair<Key, T>> init_list) {
|
PIMap(std::initializer_list<std::pair<Key, T>> init_list) {
|
||||||
for (auto i: init_list)
|
for (auto i: init_list) {
|
||||||
insert(std::get<0>(i), std::get<1>(i));
|
insert(std::get<0>(i), std::get<1>(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
virtual ~PIMap() {;}
|
virtual ~PIMap() {;}
|
||||||
|
|
||||||
@@ -150,7 +125,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
const_iterator(): parent(0), pos(0) {}
|
const_iterator(): parent(0), pos(0) {}
|
||||||
const value_type operator *() const {return parent->_pair(pos);}
|
const value_type operator *() const {return parent->_pair(pos);}
|
||||||
const value_type* operator ->() const {cval = parent->_pair(pos); return &cval;}
|
//const value_type* operator ->() const {cval = parent->_pair(pos); return &cval;}
|
||||||
const Key & key() const {return const_cast<PIMap<Key, T> * >(parent)->_key(pos);}
|
const Key & key() const {return const_cast<PIMap<Key, T> * >(parent)->_key(pos);}
|
||||||
const T & value() const {return const_cast<PIMap<Key, T> * >(parent)->_value(pos);}
|
const T & value() const {return const_cast<PIMap<Key, T> * >(parent)->_value(pos);}
|
||||||
void operator ++() {++pos;}
|
void operator ++() {++pos;}
|
||||||
@@ -159,7 +134,7 @@ public:
|
|||||||
void operator --(int) {--pos;}
|
void operator --(int) {--pos;}
|
||||||
bool operator ==(const const_iterator & it) const {return (pos == it.pos);}
|
bool operator ==(const const_iterator & it) const {return (pos == it.pos);}
|
||||||
bool operator !=(const const_iterator & it) const {return (pos != it.pos);}
|
bool operator !=(const const_iterator & it) const {return (pos != it.pos);}
|
||||||
mutable value_type cval;
|
//mutable value_type cval;
|
||||||
};
|
};
|
||||||
|
|
||||||
class const_reverse_iterator {
|
class const_reverse_iterator {
|
||||||
@@ -171,14 +146,14 @@ public:
|
|||||||
public:
|
public:
|
||||||
const_reverse_iterator(): parent(0), pos(0) {}
|
const_reverse_iterator(): parent(0), pos(0) {}
|
||||||
const value_type operator *() const {return parent->_pair(pos);}
|
const value_type operator *() const {return parent->_pair(pos);}
|
||||||
const value_type* operator ->() const {cval = parent->_pair(pos); return &cval;}
|
//const value_type* operator ->() const {cval = parent->_pair(pos); return &cval;}
|
||||||
void operator ++() {--pos;}
|
void operator ++() {--pos;}
|
||||||
void operator ++(int) {--pos;}
|
void operator ++(int) {--pos;}
|
||||||
void operator --() {++pos;}
|
void operator --() {++pos;}
|
||||||
void operator --(int) {++pos;}
|
void operator --(int) {++pos;}
|
||||||
bool operator ==(const const_reverse_iterator & it) const {return (pos == it.pos);}
|
bool operator ==(const const_reverse_iterator & it) const {return (pos == it.pos);}
|
||||||
bool operator !=(const const_reverse_iterator & it) const {return (pos != it.pos);}
|
bool operator !=(const const_reverse_iterator & it) const {return (pos != it.pos);}
|
||||||
mutable value_type cval;
|
//mutable value_type cval;
|
||||||
};
|
};
|
||||||
|
|
||||||
iterator begin() {return iterator(this, 0);}
|
iterator begin() {return iterator(this, 0);}
|
||||||
@@ -201,6 +176,7 @@ public:
|
|||||||
int size_s() const {return pim_content.size_s();}
|
int size_s() const {return pim_content.size_s();}
|
||||||
size_t length() const {return pim_content.size();}
|
size_t length() const {return pim_content.size();}
|
||||||
bool isEmpty() const {return (pim_content.size() == 0);}
|
bool isEmpty() const {return (pim_content.size() == 0);}
|
||||||
|
bool isNotEmpty() const {return (pim_content.size() > 0);}
|
||||||
|
|
||||||
T & operator [](const Key & key) {
|
T & operator [](const Key & key) {
|
||||||
bool f(false);
|
bool f(false);
|
||||||
@@ -210,8 +186,7 @@ public:
|
|||||||
pim_index.insert(i, MapIndex(key, pim_content.size() - 1));
|
pim_index.insert(i, MapIndex(key, pim_content.size() - 1));
|
||||||
return pim_content.back();
|
return pim_content.back();
|
||||||
}
|
}
|
||||||
const T operator [](const Key & key) const {bool f(false); ssize_t i = _find(key, f); if (f) return pim_content[pim_index[i].index]; return T();}
|
T at(const Key & key) const {return value(key);}
|
||||||
const T at(const Key & key) const {return (*this)[key];}
|
|
||||||
|
|
||||||
PIMap<Key, T> & operator <<(const PIMap<Key, T> & other) {
|
PIMap<Key, T> & operator <<(const PIMap<Key, T> & other) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@@ -268,7 +243,7 @@ public:
|
|||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
const T value(const Key & key, const T & default_ = T()) const {bool f(false); ssize_t i = _find(key, f); if (!f) return default_; return pim_content[pim_index[i].index];}
|
T value(const Key & key, const T & default_ = T()) const {bool f(false); ssize_t i = _find(key, f); if (!f) return default_; return pim_content[pim_index[i].index];}
|
||||||
PIVector<T> values() const {return pim_content;}
|
PIVector<T> values() const {return pim_content;}
|
||||||
Key key(const T & value_, const Key & default_ = Key()) const {for (int i = 0; i < pim_index.size_s(); ++i) if (pim_content[pim_index[i].index] == value_) return pim_index[i].key; return default_;}
|
Key key(const T & value_, const Key & default_ = Key()) const {for (int i = 0; i < pim_index.size_s(); ++i) if (pim_content[pim_index[i].index] == value_) return pim_index[i].key; return default_;}
|
||||||
PIVector<Key> keys() const {
|
PIVector<Key> keys() const {
|
||||||
@@ -278,16 +253,16 @@ public:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump() {
|
// void dump() {
|
||||||
piCout << "PIMap" << size() << "entries" << PICoutManipulators::NewLine << "content:";
|
// piCout << "PIMap" << size() << "entries" << PICoutManipulators::NewLine << "content:";
|
||||||
for (size_t i = 0; i < pim_content.size(); ++i)
|
// for (size_t i = 0; i < pim_content.size(); ++i)
|
||||||
piCout << PICoutManipulators::Tab << i << ":" << pim_content[i];
|
// piCout << PICoutManipulators::Tab << i << ":" << pim_content[i];
|
||||||
piCout << "index:";
|
// piCout << "index:";
|
||||||
for (size_t i = 0; i < pim_index.size(); ++i)
|
// for (size_t i = 0; i < pim_index.size(); ++i)
|
||||||
piCout << PICoutManipulators::Tab << i << ":" << pim_index[i].key << "->" << pim_index[i].index;
|
// piCout << PICoutManipulators::Tab << i << ":" << pim_index[i].key << "->" << pim_index[i].index;
|
||||||
}
|
// }
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
struct MapIndex {
|
struct MapIndex {
|
||||||
MapIndex(Key k = Key(), size_t i = 0): key(k), index(i) {;}
|
MapIndex(Key k = Key(), size_t i = 0): key(k), index(i) {;}
|
||||||
Key key;
|
Key key;
|
||||||
@@ -302,7 +277,7 @@ protected:
|
|||||||
template <typename P, typename Key1, typename T1>
|
template <typename P, typename Key1, typename T1>
|
||||||
friend PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIDeque<typename PIMap<Key1, T1>::MapIndex> & v);
|
friend PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIDeque<typename PIMap<Key1, T1>::MapIndex> & v);
|
||||||
|
|
||||||
ssize_t binarySearch(ssize_t first, ssize_t last, const Key & key, bool & found) const {
|
ssize_t _binarySearch(ssize_t first, ssize_t last, const Key & key, bool & found) const {
|
||||||
ssize_t mid;
|
ssize_t mid;
|
||||||
while (first <= last) {
|
while (first <= last) {
|
||||||
mid = (first + last) / 2;
|
mid = (first + last) / 2;
|
||||||
@@ -313,13 +288,12 @@ protected:
|
|||||||
found = false;
|
found = false;
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
void _sort() {piQuickSort<MapIndex>(pim_index.data(), pim_index.size_s() - 1);}
|
|
||||||
ssize_t _find(const Key & k, bool & found) const {
|
ssize_t _find(const Key & k, bool & found) const {
|
||||||
if (pim_index.isEmpty()) {
|
if (pim_index.isEmpty()) {
|
||||||
found = false;
|
found = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return binarySearch(0, pim_index.size_s() - 1, k, found);
|
return _binarySearch(0, pim_index.size_s() - 1, k, found);
|
||||||
}
|
}
|
||||||
void _remove(ssize_t index) {
|
void _remove(ssize_t index) {
|
||||||
//if (index >= pim_index.size()) return;
|
//if (index >= pim_index.size()) return;
|
||||||
@@ -415,7 +389,7 @@ inline PICout operator <<(PICout s, const PIMap<Key, Type> & v) {
|
|||||||
if (!first)
|
if (!first)
|
||||||
s << ", ";
|
s << ", ";
|
||||||
first = false;
|
first = false;
|
||||||
s << i->first << ": " << i->second;
|
s << i.key() << ": " << i.value();
|
||||||
}
|
}
|
||||||
s << "}";
|
s << "}";
|
||||||
s.restoreControl();
|
s.restoreControl();
|
||||||
|
|||||||
@@ -34,8 +34,6 @@
|
|||||||
#include "piqueue.h"
|
#include "piqueue.h"
|
||||||
#include "piobject_macros.h"
|
#include "piobject_macros.h"
|
||||||
|
|
||||||
typedef void (*Handler)(void * );
|
|
||||||
|
|
||||||
//! \ingroup Core
|
//! \ingroup Core
|
||||||
//! \~\brief
|
//! \~\brief
|
||||||
//! \~english This is base class for any classes which use events -> handlers mechanism.
|
//! \~english This is base class for any classes which use events -> handlers mechanism.
|
||||||
|
|||||||
@@ -374,8 +374,8 @@ inline PICout operator <<(PICout s, const PIBinaryLog::BinLogInfo & bi) {
|
|||||||
s << "read records " << bi.records_count << " in " << bi.records.size() << " types, log size " << bi.log_size;
|
s << "read records " << bi.records_count << " in " << bi.records.size() << " types, log size " << bi.log_size;
|
||||||
s << "\nlog start " << bi.start_time << " , log end " << bi.end_time;
|
s << "\nlog start " << bi.start_time << " , log end " << bi.end_time;
|
||||||
PIVector<int> keys = bi.records.keys();
|
PIVector<int> keys = bi.records.keys();
|
||||||
piForeachC(int i, keys) {
|
for (int i : keys) {
|
||||||
const PIBinaryLog::BinLogRecordInfo &bri(bi.records[i]);
|
PIBinaryLog::BinLogRecordInfo bri = bi.records.at(i);
|
||||||
s << "\n record id " << bri.id << " , count " << bri.count;
|
s << "\n record id " << bri.id << " , count " << bri.count;
|
||||||
s << "\n record start " << bri.start_time << " , end " << bri.end_time;
|
s << "\n record start " << bri.start_time << " , end " << bri.end_time;
|
||||||
s << "\n record size " << bri.minimum_size << " - " << bri.maximum_size;
|
s << "\n record size " << bri.minimum_size << " - " << bri.maximum_size;
|
||||||
|
|||||||
@@ -32,8 +32,7 @@
|
|||||||
|
|
||||||
/// TODO: написать документацию, тут ничего не понятно
|
/// TODO: написать документацию, тут ничего не понятно
|
||||||
// function executed from threaded read, pass readedData, sizeOfData, ThreadedReadData
|
// function executed from threaded read, pass readedData, sizeOfData, ThreadedReadData
|
||||||
typedef bool (*ReadRetFunc)(const uchar *, int, void *);
|
typedef std::function<bool(const uchar *, int, void *)> ReadRetFunc;
|
||||||
|
|
||||||
|
|
||||||
#ifdef DOXYGEN
|
#ifdef DOXYGEN
|
||||||
|
|
||||||
|
|||||||
@@ -29,10 +29,17 @@
|
|||||||
#include "piiodevice.h"
|
#include "piiodevice.h"
|
||||||
|
|
||||||
/// TODO: написать документацию, тут ничего не понятно
|
/// TODO: написать документацию, тут ничего не понятно
|
||||||
// Pass data, recHeaderPtr, received_data, recHeaderSize. Return true if packet is correct nor return false.
|
/// Pass SourceHeaderPtr, ReceivedHeaderPtr, HeaderSize.
|
||||||
typedef int (*PacketExtractorHeaderFunc)(const uchar *, const uchar *, int);
|
/// Return size of payload if packet is correct, or -1 if incorrect.
|
||||||
typedef bool (*PacketExtractorPayloadFunc)(const uchar *, int);
|
typedef std::function<int(const uchar *, const uchar *, int)> PacketExtractorHeaderFunc;
|
||||||
typedef bool (*PacketExtractorFooterFunc)(const uchar *, const uchar *, int);
|
|
||||||
|
/// Pass ReceivedDataPtr, DataSize.
|
||||||
|
/// Return true if packet is correct, false otherwise.
|
||||||
|
typedef std::function<bool(const uchar *, int)> PacketExtractorPayloadFunc;
|
||||||
|
|
||||||
|
/// Pass SourceFooterPtr, ReceivedFooterPtr, FooterSize.
|
||||||
|
/// Return true if packet is correct, false otherwise.
|
||||||
|
typedef std::function<bool(const uchar *, const uchar *, int)> PacketExtractorFooterFunc;
|
||||||
|
|
||||||
class PIP_EXPORT PIPacketExtractor: public PIIODevice
|
class PIP_EXPORT PIPacketExtractor: public PIIODevice
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ int PIEvaluatorContent::addVariable(const PIString & name, const complexd & val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIEvaluatorContent::addCustomFunction(const PIString & name, int args_count, FuncFunc func) {
|
void PIEvaluatorContent::addCustomFunction(const PIString & name, int args_count, PIEvaluatorTypes::FuncHanlder func) {
|
||||||
functions << PIEvaluatorTypes::Function(name, args_count, func);
|
functions << PIEvaluatorTypes::Function(name, args_count, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,10 +29,11 @@
|
|||||||
#include "pistringlist.h"
|
#include "pistringlist.h"
|
||||||
#include "pimathcomplex.h"
|
#include "pimathcomplex.h"
|
||||||
|
|
||||||
typedef complexd (*FuncFunc)(void * , int, complexd * );
|
|
||||||
|
|
||||||
namespace PIEvaluatorTypes {
|
namespace PIEvaluatorTypes {
|
||||||
|
|
||||||
|
typedef std::function<complexd(void * , int, complexd * )> FuncHanlder;
|
||||||
|
|
||||||
enum eType {etNumber, etOperator, etVariable, etFunction};
|
enum eType {etNumber, etOperator, etVariable, etFunction};
|
||||||
enum Operation {oNone, oAdd, oSubtract, oMultiply, oDivide, oResidue, oPower,
|
enum Operation {oNone, oAdd, oSubtract, oMultiply, oDivide, oResidue, oPower,
|
||||||
oEqual, oNotEqual, oGreater, oSmaller, oGreaterEqual, oSmallerEqual,
|
oEqual, oNotEqual, oGreater, oSmaller, oGreaterEqual, oSmallerEqual,
|
||||||
@@ -70,12 +71,12 @@ namespace PIEvaluatorTypes {
|
|||||||
short var_num;
|
short var_num;
|
||||||
};
|
};
|
||||||
struct PIP_EXPORT Function {
|
struct PIP_EXPORT Function {
|
||||||
Function() {arguments = 0; type = bfUnknown; handler = 0;}
|
Function() {arguments = 0; type = bfUnknown; handler = nullptr;}
|
||||||
Function(const PIString & name, short args, BaseFunctions ftype) {identifier = name; arguments = args; type = ftype; handler = 0;}
|
Function(const PIString & name, short args, BaseFunctions ftype) {identifier = name; arguments = args; type = ftype; handler = nullptr;}
|
||||||
Function(const PIString & name, short args, FuncFunc h) {identifier = name; arguments = args; type = bfCustom; handler = h;}
|
Function(const PIString & name, short args, FuncHanlder h) {identifier = name; arguments = args; type = bfCustom; handler = h;}
|
||||||
PIString identifier;
|
PIString identifier;
|
||||||
BaseFunctions type;
|
BaseFunctions type;
|
||||||
FuncFunc handler;
|
FuncHanlder handler;
|
||||||
short arguments;
|
short arguments;
|
||||||
};
|
};
|
||||||
struct PIP_EXPORT Variable {
|
struct PIP_EXPORT Variable {
|
||||||
@@ -103,7 +104,7 @@ public:
|
|||||||
|
|
||||||
void addFunction(const PIString & name, int args = 1);
|
void addFunction(const PIString & name, int args = 1);
|
||||||
int addVariable(const PIString & name, const complexd & val = 0.);
|
int addVariable(const PIString & name, const complexd & val = 0.);
|
||||||
void addCustomFunction(const PIString & name, int args_count, FuncFunc func);
|
void addCustomFunction(const PIString & name, int args_count, PIEvaluatorTypes::FuncHanlder func);
|
||||||
int functionsCount() const {return functions.size();}
|
int functionsCount() const {return functions.size();}
|
||||||
int variablesCount() const {return variables.size();}
|
int variablesCount() const {return variables.size();}
|
||||||
int customVariablesCount() const;
|
int customVariablesCount() const;
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ public:
|
|||||||
All = 0xFFFFF
|
All = 0xFFFFF
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (*SignalEvent)(PISignals::Signal);
|
typedef std::function<void(PISignals::Signal)> SignalEvent;
|
||||||
// slot is any function format "void <func>(PISignals::Signal)"
|
// slot is any function format "void(PISignals::Signal)"
|
||||||
static void setSlot(SignalEvent slot) {ret_func = slot;}
|
static void setSlot(SignalEvent slot) {ret_func = slot;}
|
||||||
static void grabSignals(PIFlags<PISignals::Signal> signals_);
|
static void grabSignals(PIFlags<PISignals::Signal> signals_);
|
||||||
static void raiseSignal(PISignals::Signal signal);
|
static void raiseSignal(PISignals::Signal signal);
|
||||||
|
|||||||
13
main.cpp
13
main.cpp
@@ -4,22 +4,21 @@ using namespace PICoutManipulators;
|
|||||||
|
|
||||||
|
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
PIByteArray ba = PIByteArray::fromHex("AA11FFAA22EEAA33FF");
|
PIByteArray ba = PIByteArray::fromHex("AA1122BB11233AA4455");
|
||||||
PIIOByteArray b;
|
PIIOByteArray b;
|
||||||
b.open(ba);
|
b.open(ba);
|
||||||
PIPacketExtractor p(&b);
|
PIPacketExtractor p(&b);
|
||||||
p.setSplitMode(PIPacketExtractor::Header);
|
p.setSplitMode(PIPacketExtractor::Header);
|
||||||
p.setHeader(PIByteArray::fromHex("AABB"));
|
p.setHeader(PIByteArray::fromHex("00"));
|
||||||
// p.setFooter(PIByteArray::fromHex("AA"));
|
p.setFooter(PIByteArray::fromHex("AA"));
|
||||||
p.setPayloadSize(2);
|
p.setPayloadSize(2);
|
||||||
p.setThreadedReadSlot([](const uchar * data, int size, void * d) {
|
p.setThreadedReadSlot([](const uchar * data, int size, void * d) {
|
||||||
piCout << size;
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
p.setHeaderCheckSlot([](const uchar * src, const uchar * rec, int size) {
|
p.setHeaderCheckSlot([](const uchar * src, const uchar * rec, int size)->int {
|
||||||
if (*src == *rec) {
|
if (*src == *rec) {
|
||||||
if (rec[1] == 0x11) return 1;
|
if (rec[0] == 0xAA) return 2;
|
||||||
if (rec[1] == 0x22) return 3;
|
if (rec[0] == 0xBB) return 3;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user