mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 10:37:01 +00:00
[8384] Restore build mangos at Unix/Linux.
* Also fixed wrong read_skip<char*>() code. * Also fixed some warnings in related code.
This commit is contained in:
parent
55a56ad71e
commit
2372623a5b
2 changed files with 36 additions and 23 deletions
|
|
@ -27,15 +27,16 @@
|
|||
class ByteBufferException
|
||||
{
|
||||
public:
|
||||
ByteBufferException(bool add, size_t pos, size_t esize, size_t size):add(add), pos(pos), esize(esize), size(size)
|
||||
ByteBufferException(bool _add, size_t _pos, size_t _esize, size_t _size)
|
||||
: add(_add), pos(_pos), esize(_esize), size(_size)
|
||||
{
|
||||
PrintPosError();
|
||||
}
|
||||
|
||||
void PrintPosError() const
|
||||
{
|
||||
sLog.outError("ERROR: Attempted to %s in ByteBuffer (pos: %lu size: %lu) value with size: %lu",(add ? "put" : "get"),(unsigned long)pos, (unsigned long)size, (unsigned long)esize);
|
||||
|
||||
sLog.outError("ERROR: Attempted to %s in ByteBuffer (pos: " SIZEFMTD " size: "SIZEFMTD") value with size: " SIZEFMTD,
|
||||
(add ? "put" : "get"), pos, size, esize);
|
||||
}
|
||||
private:
|
||||
bool add;
|
||||
|
|
@ -265,19 +266,6 @@ class ByteBuffer
|
|||
template<typename T1, typename T2>
|
||||
void read_skip2() { read_skip(sizeof(T1)+sizeof(T2)); }
|
||||
|
||||
template<>
|
||||
void read_skip<char*>()
|
||||
{
|
||||
uint8 size = read<uint8>();
|
||||
read_skip(size);
|
||||
}
|
||||
|
||||
template<>
|
||||
void read_skip<char const*>() { read_skip<char*>(); }
|
||||
|
||||
template<>
|
||||
void read_skip<std::string>() { read_skip<char*>(); }
|
||||
|
||||
void read_skip(size_t skip)
|
||||
{
|
||||
if(_rpos + skip > size())
|
||||
|
|
@ -512,7 +500,8 @@ class ByteBuffer
|
|||
std::vector<uint8> _storage;
|
||||
};
|
||||
|
||||
template <typename T> ByteBuffer &operator<<(ByteBuffer &b, std::vector<T> v)
|
||||
template <typename T>
|
||||
inline ByteBuffer &operator<<(ByteBuffer &b, std::vector<T> v)
|
||||
{
|
||||
b << (uint32)v.size();
|
||||
for (typename std::vector<T>::iterator i = v.begin(); i != v.end(); ++i)
|
||||
|
|
@ -522,7 +511,8 @@ template <typename T> ByteBuffer &operator<<(ByteBuffer &b, std::vector<T> v)
|
|||
return b;
|
||||
}
|
||||
|
||||
template <typename T> ByteBuffer &operator>>(ByteBuffer &b, std::vector<T> &v)
|
||||
template <typename T>
|
||||
inline ByteBuffer &operator>>(ByteBuffer &b, std::vector<T> &v)
|
||||
{
|
||||
uint32 vsize;
|
||||
b >> vsize;
|
||||
|
|
@ -536,7 +526,8 @@ template <typename T> ByteBuffer &operator>>(ByteBuffer &b, std::vector<T> &v)
|
|||
return b;
|
||||
}
|
||||
|
||||
template <typename T> ByteBuffer &operator<<(ByteBuffer &b, std::list<T> v)
|
||||
template <typename T>
|
||||
inline ByteBuffer &operator<<(ByteBuffer &b, std::list<T> v)
|
||||
{
|
||||
b << (uint32)v.size();
|
||||
for (typename std::list<T>::iterator i = v.begin(); i != v.end(); ++i)
|
||||
|
|
@ -546,7 +537,8 @@ template <typename T> ByteBuffer &operator<<(ByteBuffer &b, std::list<T> v)
|
|||
return b;
|
||||
}
|
||||
|
||||
template <typename T> ByteBuffer &operator>>(ByteBuffer &b, std::list<T> &v)
|
||||
template <typename T>
|
||||
inline ByteBuffer &operator>>(ByteBuffer &b, std::list<T> &v)
|
||||
{
|
||||
uint32 vsize;
|
||||
b >> vsize;
|
||||
|
|
@ -560,7 +552,8 @@ template <typename T> ByteBuffer &operator>>(ByteBuffer &b, std::list<T> &v)
|
|||
return b;
|
||||
}
|
||||
|
||||
template <typename K, typename V> ByteBuffer &operator<<(ByteBuffer &b, std::map<K, V> &m)
|
||||
template <typename K, typename V>
|
||||
inline ByteBuffer &operator<<(ByteBuffer &b, std::map<K, V> &m)
|
||||
{
|
||||
b << (uint32)m.size();
|
||||
for (typename std::map<K, V>::iterator i = m.begin(); i != m.end(); ++i)
|
||||
|
|
@ -570,7 +563,8 @@ template <typename K, typename V> ByteBuffer &operator<<(ByteBuffer &b, std::map
|
|||
return b;
|
||||
}
|
||||
|
||||
template <typename K, typename V> ByteBuffer &operator>>(ByteBuffer &b, std::map<K, V> &m)
|
||||
template <typename K, typename V>
|
||||
inline ByteBuffer &operator>>(ByteBuffer &b, std::map<K, V> &m)
|
||||
{
|
||||
uint32 msize;
|
||||
b >> msize;
|
||||
|
|
@ -584,4 +578,23 @@ template <typename K, typename V> ByteBuffer &operator>>(ByteBuffer &b, std::map
|
|||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void ByteBuffer::read_skip<char*>()
|
||||
{
|
||||
std::string temp;
|
||||
*this >> temp;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void ByteBuffer::read_skip<char const*>()
|
||||
{
|
||||
read_skip<char*>();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void ByteBuffer::read_skip<std::string>()
|
||||
{
|
||||
read_skip<char*>();
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "8383"
|
||||
#define REVISION_NR "8384"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue