diag_file::size() was setting the m_state and returning 0 on error,
which violated original size() convention not to change stream state and
to return fsize_max on error.
Changing m_state prevented declaring size() method as const before.
cache::seek() was missing size() return value check.
Signed-off-by: Simon Rozman <simon@rozman.si>
Like with stdex::locale_t, this frees us from using Windowsizms on other
platforms. Sockets came from Unix to Windows and not the other way
around in the first place.
Signed-off-by: Simon Rozman <simon@rozman.si>
Where we need to read from/write to m_source and immediately apply its
state to our converter, we already have methods for this.
Signed-off-by: Simon Rozman <simon@rozman.si>
While runtime asserts also served as MSVC Code Analysis hints, the lack
of asserts in Release builds provides no hints to Code Analysis which
rises a lot of warnings then.
Maybe I should learn how to use SAL to annotate <ptr, len> parameter
pairs to allow ptr==nullptr when and only when len==0? 😇
Signed-off-by: Simon Rozman <simon@rozman.si>
When deriving, C++ might believe the derived class is still movable. But
it's not and rather than deleting move constructor and operator, this
approach made simpler code.
Signed-off-by: Simon Rozman <simon@rozman.si>
On non-Windows, wchar_t is UTF-32. This adds preliminary support for UTF-32
and changes readln and write_array members to use charset_encoder for better
performance on non-Windows platforms.
Signed-off-by: Simon Rozman <simon@rozman.si>
"sys_char" sticks out of "wchar_t", "char32_t", "uint32_t"...
Likewise, "sys_string" out of "string", "wstring", "u16string",
"u32string"...
Signed-off-by: Simon Rozman <simon@rozman.si>
We had to introduce out-of-order construction for those classes, but we
forgot to implement out-of-order destruction. File gets closed first
by cached_file::m_source destructor, then inherited destructor
cache::~cache() which flushes the cache is called.
Signed-off-by: Simon Rozman <simon@rozman.si>
Reusing same class instance for different files reused cache content
as well.
Reported-by: Peter Holozan <peter.holozan@amebis.si>
Signed-off-by: Simon Rozman <simon@rozman.si>
Our test program runs 15 minutes using our streams vs. 25 minutes using
std::iostream derived streams.
Streams were ported from Amebis AOsn project.
Signed-off-by: Simon Rozman <simon@rozman.si>