Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions src/bindings/python/src/pyopenvino/utils/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,37 @@ class MemoryBuffer : public std::streambuf {
pos_type seekoff(off_type off,
std::ios_base::seekdir dir,
std::ios_base::openmode which = std::ios_base::in) override {
if (!(which & std::ios_base::in)) {
return pos_type(off_type(-1));
}

const auto size = static_cast<off_type>(egptr() - eback());
off_type new_pos = 0;

switch (dir) {
case std::ios_base::beg:
setg(eback(), eback() + off, egptr());
break;
case std::ios_base::end:
setg(eback(), egptr() + off, egptr());
new_pos = off;
break;
case std::ios_base::cur:
setg(eback(), gptr() + off, egptr());
new_pos = static_cast<off_type>(gptr() - eback()) + off;
break;
case std::ios_base::end:
new_pos = size + off;
break;
default:
return pos_type(off_type(-1));
}
return (gptr() < eback() || gptr() > egptr()) ? pos_type(off_type(-1)) : pos_type(gptr() - eback());
}
if (new_pos < 0 || new_pos > size) {
return pos_type(off_type(-1));
}
char* const base = eback();
setg(base, base + new_pos, base + size);
return pos_type(new_pos);
}

pos_type seekpos(pos_type pos, std::ios_base::openmode which) override {
return seekoff(pos, std::ios_base::beg, which);
return seekoff(static_cast<off_type>(pos), std::ios_base::beg, which);
}

};

enum class PY_TYPE : int { UNKNOWN = 0, STR, INT, FLOAT, BOOL, PARTIAL_SHAPE, MODEL_DISTRIBUTION_POLICY };
Expand Down
Loading