mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Move packet into callback to avoid unnecessary clone, fix forward_iterator value type, and update comments
This commit is contained in:
@@ -223,7 +223,7 @@ struct accepts_type<T, P, enable_if_t<
|
|||||||
// use enable_if to invoke the Packet& version of the sniff_loop handler if possible - otherwise fail to old behavior
|
// use enable_if to invoke the Packet& version of the sniff_loop handler if possible - otherwise fail to old behavior
|
||||||
template <class Functor, class Packet>
|
template <class Functor, class Packet>
|
||||||
bool invoke_loop_cb(Functor& f, Packet& p, typename std::enable_if<accepts_type<Functor, Packet>::value, bool>::type* = 0) {
|
bool invoke_loop_cb(Functor& f, Packet& p, typename std::enable_if<accepts_type<Functor, Packet>::value, bool>::type* = 0) {
|
||||||
return f(p);
|
return f(std::move(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Functor, class Packet>
|
template <class Functor, class Packet>
|
||||||
|
|||||||
@@ -139,6 +139,9 @@ namespace Tins {
|
|||||||
* \code
|
* \code
|
||||||
* bool(PDU&);
|
* bool(PDU&);
|
||||||
* bool(const PDU&);
|
* bool(const PDU&);
|
||||||
|
* bool(const Packet&);
|
||||||
|
* bool(Packet&&);
|
||||||
|
* bool(Packet);
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* This functor will be called using the each of the sniffed packets
|
* This functor will be called using the each of the sniffed packets
|
||||||
@@ -391,7 +394,7 @@ namespace Tins {
|
|||||||
/**
|
/**
|
||||||
* \brief Iterates over packets sniffed by a BaseSniffer.
|
* \brief Iterates over packets sniffed by a BaseSniffer.
|
||||||
*/
|
*/
|
||||||
class SnifferIterator : public std::iterator<std::forward_iterator_tag, PDU> {
|
class SnifferIterator : public std::iterator<std::forward_iterator_tag, Packet> {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructs a SnifferIterator.
|
* Constructs a SnifferIterator.
|
||||||
|
|||||||
Reference in New Issue
Block a user