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"
95 readInto(reinterpret_cast<uint8_t*>(&val),
sizeof(T));
105 void readInto(uint8_t* buffer,
size_t len);
144 void read(std::string& outbuffer,
int size=-1);
151 bool getLine(std::string& buffer);
155 size_t m_index_current;
157 template <
typename T> T littleToHost(T value)
const {
161 return revert(value);
164 template <
typename T> T bigToHost(T value)
const {
168 return revert(value);
171 template <
typename T> T revert(T value)
const {
173 for (
unsigned int i = 0; i <
sizeof(T); ++i)
174 reinterpret_cast<uint8_t*>(&retval)[i] =
reinterpret_cast<uint8_t*
>(&value)[
sizeof(T)-1-i];
179 RawData(
const RawData&);
180 RawData& operator=(
const RawData&) {
return *
this; };
182 static bool littleEndian();
184 typedef boost::shared_ptr<RawData> RawDataPtr;
188 IndexSaver(RawData* d) : m_rd(d), m_index(m_rd->getCurrentIndex()) {}
191 m_rd->setIndex(m_index);
196 unsigned int m_index;
198 IndexSaver(
const IndexSaver&);
199 IndexSaver& operator=(
const IndexSaver&) {
return *
this; }