first commit
This commit is contained in:
50
include/platform/filesystem/io_handle_endian.h
Normal file
50
include/platform/filesystem/io_handle_endian.h
Normal file
@ -0,0 +1,50 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
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__
|
||||
Reference in New Issue
Block a user