mirror of
https://github.com/fraillt/bitsery.git
synced 2026-06-08 08:13:56 +00:00
cleanup
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
|
||||
#ifndef BITSERY_ADAPTER_STREAM_H
|
||||
#define BITSERY_ADAPTER_STREAM_H
|
||||
|
||||
@@ -28,7 +27,6 @@
|
||||
#include "../traits/array.h"
|
||||
#include <ios>
|
||||
|
||||
|
||||
namespace bitsery {
|
||||
|
||||
template <typename TChar, typename CharTraits>
|
||||
@@ -40,11 +38,6 @@ namespace bitsery {
|
||||
BasicInputStreamAdapter(std::basic_ios<TChar, CharTraits>& istream)
|
||||
:_ios{std::addressof(istream)} {}
|
||||
|
||||
template <typename T>
|
||||
void read(T& data) {
|
||||
read(reinterpret_cast<TValue*>(&data), sizeof(T));
|
||||
}
|
||||
|
||||
void read(TValue* data, size_t size) {
|
||||
if (static_cast<size_t>(_ios->rdbuf()->sgetn( data , size )) != size) {
|
||||
*data = {};
|
||||
@@ -85,11 +78,6 @@ namespace bitsery {
|
||||
BasicOutputStreamAdapter(std::basic_ios<TChar, CharTraits>& ostream)
|
||||
:_ios{std::addressof(ostream)} {}
|
||||
|
||||
template <typename T>
|
||||
void write(const T& data) {
|
||||
write(reinterpret_cast<const TValue*>(&data), sizeof(T));
|
||||
}
|
||||
|
||||
void write(const TValue* data, size_t size) {
|
||||
//for optimization
|
||||
_ios->rdbuf()->sputn( data , size );
|
||||
@@ -159,28 +147,6 @@ namespace bitsery {
|
||||
|
||||
~BasicBufferedOutputStreamAdapter() = default;
|
||||
|
||||
template <typename T>
|
||||
void write(const T& data) {
|
||||
auto tmp = _outIt;
|
||||
|
||||
#if defined(_MSC_VER) && (_ITERATOR_DEBUG_LEVEL > 0)
|
||||
using TDistance = typename std::iterator_traits<BufferIt>::difference_type;
|
||||
if (std::distance(_outIt , std::end(_buf)) >= static_cast<TDistance>(size)) {
|
||||
*reinterpret_cast<T*>(std::addressof(*tmp)) = data;
|
||||
_outIt += sizeof(T);
|
||||
#else
|
||||
_outIt += sizeof(T);
|
||||
if (std::distance(_outIt , std::end(_buf)) >= 0) {
|
||||
*reinterpret_cast<T*>(std::addressof(*tmp)) = data;
|
||||
#endif
|
||||
} else {
|
||||
//when buffer is full write out to stream
|
||||
_outIt = std::begin(_buf);
|
||||
_adapter.write(std::addressof(*_outIt), static_cast<size_t>(std::distance(_outIt, tmp)));
|
||||
_adapter.write(reinterpret_cast<const TValue*>(&data), sizeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
void write(const TValue* data, size_t size) {
|
||||
auto tmp = _outIt;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user