From 6434d824dc80a04342ffeb52a02ddf8cd623a63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Thu, 18 Apr 2019 17:07:24 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/pip@782 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- src_main/core/pibytearray.cpp | 16 ++++++++++++++++ src_main/core/pibytearray.h | 12 +----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src_main/core/pibytearray.cpp b/src_main/core/pibytearray.cpp index 0549d4fd..e7a6c489 100755 --- a/src_main/core/pibytearray.cpp +++ b/src_main/core/pibytearray.cpp @@ -372,3 +372,19 @@ std::ostream &operator <<(std::ostream & s, const PIByteArray & ba) { return s; } #endif + + +PIByteArray & operator >>(PIByteArray & s, PIByteArray & v) { + assert(s.size_s() >= 4); + int sz; s >> sz; + if (sz > s.size_s()) { + piCout << "[PIByteArray] Warning: operator >> wants too much data, discard!"; + s.clear(); + v.clear(); + return s; + } + v.resize(sz); + if (sz > 0) memcpy(v.data(), s.data(), v.size()); + s.remove(0, v.size()); + return s; +} diff --git a/src_main/core/pibytearray.h b/src_main/core/pibytearray.h index c00fd650..d8047884 100755 --- a/src_main/core/pibytearray.h +++ b/src_main/core/pibytearray.h @@ -209,17 +209,7 @@ inline PIByteArray & operator >>(PIByteArray & s, ldouble & v) {assert(s.size() //! \relatesalso PIByteArray \brief Restore operator template inline PIByteArray & operator >>(PIByteArray & s, PIFlags & v) {PBA_OPERATOR_FROM return s;} //! \relatesalso PIByteArray \brief Restore operator, see \ref PIByteArray_sec1 for details -inline PIByteArray & operator >>(PIByteArray & s, PIByteArray & v) { - assert(s.size_s() >= 4); - int sz; s >> sz; - if (sz > s.size_s()) { - piCout << "[PIByteArray] Warning: operator >> want too much data!"; - sz = s.size_s(); - } - v.resize(sz); - if (sz > 0) memcpy(v.data(), s.data(), v.size()); - s.remove(0, v.size()); - return s;} +PIByteArray & operator >>(PIByteArray & s, PIByteArray & v); //! \relatesalso PIByteArray \brief Restore operator, see \ref PIByteArray_sec1 for details inline PIByteArray & operator >>(PIByteArray & s, PIByteArray::RawData v) {assert(s.size_s() >= v.s); if (v.s > 0) memcpy((void*)(v.d), s.data(), v.s); s.remove(0, v.s); return s;}