22 #ifndef FIFE_VFS_RAW_RAWDATA_H
23 #define FIFE_VFS_RAW_RAWDATA_H
29 #include "util/base/fife_stdint.h"
32 #include <boost/shared_ptr.hpp>
39 #include "rawdatasource.h"
96 readInto(reinterpret_cast<uint8_t*>(&val),
sizeof(T));
106 void readInto(uint8_t* buffer,
size_t len);
147 void read(std::string& outbuffer, int32_t size=-1);
154 bool getLine(std::string& buffer);
158 size_t m_index_current;
160 template <
typename T> T littleToHost(T value)
const {
164 return revert(value);
167 template <
typename T> T bigToHost(T value)
const {
171 return revert(value);
174 template <
typename T> T revert(T value)
const {
176 for (uint32_t i = 0; i <
sizeof(T); ++i)
177 reinterpret_cast<uint8_t*>(&retval)[i] =
reinterpret_cast<uint8_t*
>(&value)[
sizeof(T)-1-i];
182 RawData(
const RawData&);
183 RawData& operator=(
const RawData&) {
return *
this; };
185 static bool littleEndian();
187 typedef boost::shared_ptr<RawData> RawDataPtr;
191 IndexSaver(RawData* d) : m_rd(d), m_index(m_rd->getCurrentIndex()) {}
194 m_rd->setIndex(m_index);
201 IndexSaver(
const IndexSaver&);
202 IndexSaver& operator=(
const IndexSaver&) {
return *
this; }