Files
Webcam/include/platform/filesystem/io_handle_endian.h
2026-06-22 11:49:35 +02:00

51 lines
1.0 KiB
C++

/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NIOHANDLE_ENDIAN__
#define __NIOHANDLE_ENDIAN__
#include "filesystem/io_handle.h"
#include "memory/endian.h"
namespace GS {
namespace IO {
/// IO Handle endian wrapper.
class HandleEndian
{
AutoPtr <Handle> h;
Endian::Config config;
public:
bool IsNull() const { return h.IsNull(); }
bool IsValid() const { return h.IsValid(); }
Handle &GetIOHandle() const { return *h; }
template <class T> const HandleEndian &operator << (const T &v)
{
*h << Endian::ToHost(v, config);
return *this;
}
template <class T> const HandleEndian &operator >> (T &v)
{
*h >> v;
Endian::ToHost(&v, sizeof(T), config);
return *this;
}
HandleEndian(Handle *in_h, Endian::Config in_config = Endian::Little) : h(in_h), config(in_config) {}
};
} // IO
} // GS
#endif // __NIOHANDLE_ENDIAN__