c@90: c@90: #ifndef CAPNP_MESSAGE_COMPLETENESS_CHECKER_H c@90: #define CAPNP_MESSAGE_COMPLETENESS_CHECKER_H c@90: c@90: #include "SynchronousTransport.h" //!!! c@90: c@90: #include c@90: c@90: #include c@90: c@90: namespace piper { //!!! change c@90: c@90: class CapnpMessageCompletenessChecker : public MessageCompletenessChecker c@90: { c@90: public: c@90: bool isComplete(const std::vector &message) const override { c@90: c@90: // a bit liberal with the copies here c@90: size_t wordSize = sizeof(capnp::word); c@90: size_t words = message.size() / wordSize; c@90: kj::Array karr(kj::heapArray(words)); c@90: memcpy(karr.begin(), message.data(), words * wordSize); c@90: c@90: size_t expected = capnp::expectedSizeInWordsFromPrefix(karr); c@90: c@90: if (words > expected) { c@90: std::cerr << "WARNING: obtained more data than expected (" c@90: << words << " " << wordSize << "-byte words, expected " c@90: << expected << ")" << std::endl; c@90: } c@90: c@90: return words >= expected; c@90: } c@90: }; c@90: c@90: } c@90: c@90: #endif