mirror of https://github.com/libAthena/athena.git
added Little/Big suffix method for at[U]Int8 types for consistency
This commit is contained in:
parent
4ffce2dbc3
commit
9535778932
|
@ -82,6 +82,12 @@ public:
|
|||
template <class T>
|
||||
inline atInt8 readVal(typename std::enable_if<std::is_same<T, atInt8>::value>::type* = 0)
|
||||
{return readByte();}
|
||||
template <class T>
|
||||
inline atInt8 readValLittle(typename std::enable_if<std::is_same<T, atInt8>::value>::type* = 0)
|
||||
{return readByte();}
|
||||
template <class T>
|
||||
inline atInt8 readValBig(typename std::enable_if<std::is_same<T, atInt8>::value>::type* = 0)
|
||||
{return readByte();}
|
||||
|
||||
/*! \brief Reads a byte at the current position and advances the current position
|
||||
*
|
||||
|
@ -91,6 +97,12 @@ public:
|
|||
template <class T>
|
||||
inline atUint8 readVal(typename std::enable_if<std::is_same<T, atUint8>::value>::type* = 0)
|
||||
{return readUByte();}
|
||||
template <class T>
|
||||
inline atUint8 readValLittle(typename std::enable_if<std::is_same<T, atUint8>::value>::type* = 0)
|
||||
{return readUByte();}
|
||||
template <class T>
|
||||
inline atUint8 readValBig(typename std::enable_if<std::is_same<T, atUint8>::value>::type* = 0)
|
||||
{return readUByte();}
|
||||
|
||||
/*! \brief Reads a byte at the current position and advances the current position.
|
||||
*
|
||||
|
|
|
@ -73,14 +73,18 @@ public:
|
|||
* \param byte The value to write
|
||||
*/
|
||||
inline void writeUByte(atUint8 val) {writeUBytes(&val, 1);}
|
||||
inline void writeVal(atUint8 val) {return writeUByte(val);}
|
||||
inline void writeVal(atUint8 val) {writeUByte(val);}
|
||||
inline void writeValLittle(atUint8 val) {writeUByte(val);}
|
||||
inline void writeValBig(atUint8 val) {writeUByte(val);}
|
||||
|
||||
/*! \brief Writes a byte at the current position and advances the position by one byte.
|
||||
* \param byte The value to write
|
||||
* \throw IOException
|
||||
*/
|
||||
inline void writeByte(atInt8 val) {writeUByte(val);}
|
||||
inline void writeVal(atInt8 val) {return writeByte(val);}
|
||||
inline void writeVal(atInt8 val) {writeByte(val);}
|
||||
inline void writeValLittle(atInt8 val) {writeByte(val);}
|
||||
inline void writeValBig(atInt8 val) {writeByte(val);}
|
||||
|
||||
/*! \brief Writes the given buffer with the specified length, buffers can be bigger than the length
|
||||
* however it's undefined behavior to try and write a buffer which is smaller than the given length.
|
||||
|
@ -112,21 +116,21 @@ public:
|
|||
utility::LittleInt16(val);
|
||||
writeUBytes((atUint8*)&val, 2);
|
||||
}
|
||||
inline void writeVal(atInt16 val) {return writeInt16(val);}
|
||||
inline void writeVal(atInt16 val) {writeInt16(val);}
|
||||
|
||||
inline void writeInt16Little(atInt16 val)
|
||||
{
|
||||
utility::LittleInt16(val);
|
||||
writeUBytes((atUint8*)&val, 2);
|
||||
}
|
||||
inline void writeValLittle(atInt16 val) {return writeInt16Little(val);}
|
||||
inline void writeValLittle(atInt16 val) {writeInt16Little(val);}
|
||||
|
||||
inline void writeInt16Big(atInt16 val)
|
||||
{
|
||||
utility::BigInt16(val);
|
||||
writeUBytes((atUint8*)&val, 2);
|
||||
}
|
||||
inline void writeValBig(atInt16 val) {return writeInt16Big(val);}
|
||||
inline void writeValBig(atInt16 val) {writeInt16Big(val);}
|
||||
|
||||
/*! \brief Writes an Uint16 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings
|
||||
|
@ -135,13 +139,13 @@ public:
|
|||
* \param val The value to write to the buffer
|
||||
*/
|
||||
inline void writeUint16(atUint16 val) {writeInt16(val);}
|
||||
inline void writeVal(atUint16 val) {return writeUint16(val);}
|
||||
inline void writeVal(atUint16 val) {writeUint16(val);}
|
||||
|
||||
inline void writeUint16Little(atUint16 val) {writeInt16Little(val);}
|
||||
inline void writeValLittle(atUint16 val) {return writeUint16Little(val);}
|
||||
inline void writeValLittle(atUint16 val) {writeUint16Little(val);}
|
||||
|
||||
inline void writeUint16Big(atUint16 val) {writeInt16Big(val);}
|
||||
inline void writeValBig(atUint16 val) {return writeUint16Big(val);}
|
||||
inline void writeValBig(atUint16 val) {writeUint16Big(val);}
|
||||
|
||||
/*! \brief Writes an Int32 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
|
@ -157,21 +161,21 @@ public:
|
|||
utility::LittleInt32(val);
|
||||
writeUBytes((atUint8*)&val, 4);
|
||||
}
|
||||
inline void writeVal(atInt32 val) {return writeInt32(val);}
|
||||
inline void writeVal(atInt32 val) {writeInt32(val);}
|
||||
|
||||
inline void writeInt32Little(atInt32 val)
|
||||
{
|
||||
utility::LittleInt32(val);
|
||||
writeUBytes((atUint8*)&val, 4);
|
||||
}
|
||||
inline void writeValLittle(atInt32 val) {return writeInt32Little(val);}
|
||||
inline void writeValLittle(atInt32 val) {writeInt32Little(val);}
|
||||
|
||||
inline void writeInt32Big(atInt32 val)
|
||||
{
|
||||
utility::BigInt32(val);
|
||||
writeUBytes((atUint8*)&val, 4);
|
||||
}
|
||||
inline void writeValBig(atInt32 val) {return writeInt32Big(val);}
|
||||
inline void writeValBig(atInt32 val) {writeInt32Big(val);}
|
||||
|
||||
/*! \brief Writes an Uint32 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
|
@ -180,13 +184,13 @@ public:
|
|||
* \param val The value to write to the buffer
|
||||
*/
|
||||
inline void writeUint32(atUint32 val) {writeInt32(val);}
|
||||
inline void writeVal(atUint32 val) {return writeUint32(val);}
|
||||
inline void writeVal(atUint32 val) {writeUint32(val);}
|
||||
|
||||
inline void writeUint32Little(atUint32 val) {writeInt32Little(val);}
|
||||
inline void writeValLittle(atUint32 val) {return writeUint32Little(val);}
|
||||
inline void writeValLittle(atUint32 val) {writeUint32Little(val);}
|
||||
|
||||
inline void writeUint32Big(atUint32 val) {writeInt32Big(val);}
|
||||
inline void writeValBig(atUint32 val) {return writeUint32Big(val);}
|
||||
inline void writeValBig(atUint32 val) {writeUint32Big(val);}
|
||||
|
||||
/*! \brief Writes an Int64 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
|
@ -202,21 +206,21 @@ public:
|
|||
utility::LittleInt64(val);
|
||||
writeUBytes((atUint8*)&val, 8);
|
||||
}
|
||||
inline void writeVal(atInt64 val) {return writeInt64(val);}
|
||||
inline void writeVal(atInt64 val) {writeInt64(val);}
|
||||
|
||||
inline void writeInt64Little(atInt64 val)
|
||||
{
|
||||
utility::LittleInt64(val);
|
||||
writeUBytes((atUint8*)&val, 8);
|
||||
}
|
||||
inline void writeValLittle(atInt64 val) {return writeInt64Little(val);}
|
||||
inline void writeValLittle(atInt64 val) {writeInt64Little(val);}
|
||||
|
||||
inline void writeInt64Big(atInt64 val)
|
||||
{
|
||||
utility::BigInt64(val);
|
||||
writeUBytes((atUint8*)&val, 8);
|
||||
}
|
||||
inline void writeValBig(atInt64 val) {return writeInt64Big(val);}
|
||||
inline void writeValBig(atInt64 val) {writeInt64Big(val);}
|
||||
|
||||
/*! \brief Writes an Uint64 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
|
@ -225,13 +229,13 @@ public:
|
|||
* \param val The value to write to the buffer
|
||||
*/
|
||||
inline void writeUint64(atUint64 val) {writeInt64(val);}
|
||||
inline void writeVal(atUint64 val) {return writeUint64(val);}
|
||||
inline void writeVal(atUint64 val) {writeUint64(val);}
|
||||
|
||||
inline void writeUint64Little(atUint64 val) {writeInt64Little(val);}
|
||||
inline void writeValLittle(atUint64 val) {return writeUint64Little(val);}
|
||||
inline void writeValLittle(atUint64 val) {writeUint64Little(val);}
|
||||
|
||||
inline void writeUint64Big(atUint64 val) {writeInt64Big(val);}
|
||||
inline void writeValBig(atUint64 val) {return writeUint64Big(val);}
|
||||
inline void writeValBig(atUint64 val) {writeUint64Big(val);}
|
||||
|
||||
/*! \brief Writes an float to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
|
@ -247,21 +251,21 @@ public:
|
|||
utility::LittleFloat(val);
|
||||
writeUBytes((atUint8*)&val, 4);
|
||||
}
|
||||
inline void writeVal(float val) {return writeFloat(val);}
|
||||
inline void writeVal(float val) {writeFloat(val);}
|
||||
|
||||
inline void writeFloatLittle(float val)
|
||||
{
|
||||
utility::LittleFloat(val);
|
||||
writeUBytes((atUint8*)&val, 4);
|
||||
}
|
||||
inline void writeValLittle(float val) {return writeFloatLittle(val);}
|
||||
inline void writeValLittle(float val) {writeFloatLittle(val);}
|
||||
|
||||
inline void writeFloatBig(float val)
|
||||
{
|
||||
utility::BigFloat(val);
|
||||
writeUBytes((atUint8*)&val, 4);
|
||||
}
|
||||
inline void writeValBig(float val) {return writeFloatBig(val);}
|
||||
inline void writeValBig(float val) {writeFloatBig(val);}
|
||||
|
||||
/*! \brief Writes an double to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
|
@ -277,21 +281,21 @@ public:
|
|||
utility::LittleDouble(val);
|
||||
writeUBytes((atUint8*)&val, 8);
|
||||
}
|
||||
inline void writeVal(double val) {return writeDouble(val);}
|
||||
inline void writeVal(double val) {writeDouble(val);}
|
||||
|
||||
inline void writeDoubleLittle(double val)
|
||||
{
|
||||
utility::LittleDouble(val);
|
||||
writeUBytes((atUint8*)&val, 8);
|
||||
}
|
||||
inline void writeValLittle(double val) {return writeDoubleLittle(val);}
|
||||
inline void writeValLittle(double val) {writeDoubleLittle(val);}
|
||||
|
||||
inline void writeDoubleBig(double val)
|
||||
{
|
||||
utility::BigDouble(val);
|
||||
writeUBytes((atUint8*)&val, 8);
|
||||
}
|
||||
inline void writeValBig(double val) {return writeDoubleBig(val);}
|
||||
inline void writeValBig(double val) {writeDoubleBig(val);}
|
||||
|
||||
/*! \brief Writes an bool to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
|
@ -300,7 +304,7 @@ public:
|
|||
* \param val The value to write to the buffer
|
||||
*/
|
||||
inline void writeBool(bool val) {writeUBytes((atUint8*)&val, 1);}
|
||||
inline void writeVal(bool val) {return writeBool(val);}
|
||||
inline void writeVal(bool val) {writeBool(val);}
|
||||
|
||||
/*! \brief Writes an atVec2f (8 bytes) to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
|
@ -322,7 +326,7 @@ public:
|
|||
}
|
||||
writeUBytes((atUint8*)&vec, 8);
|
||||
}
|
||||
inline void writeVal(atVec2f val) {return writeVec2f(val);}
|
||||
inline void writeVal(atVec2f val) {writeVec2f(val);}
|
||||
|
||||
inline void writeVec2fLittle(atVec2f vec)
|
||||
{
|
||||
|
@ -330,7 +334,7 @@ public:
|
|||
utility::LittleFloat(vec.vec[1]);
|
||||
writeUBytes((atUint8*)&vec, 8);
|
||||
}
|
||||
inline void writeValLittle(atVec2f val) {return writeVec2fLittle(val);}
|
||||
inline void writeValLittle(atVec2f val) {writeVec2fLittle(val);}
|
||||
|
||||
inline void writeVec2fBig(atVec2f vec)
|
||||
{
|
||||
|
@ -338,7 +342,7 @@ public:
|
|||
utility::BigFloat(vec.vec[1]);
|
||||
writeUBytes((atUint8*)&vec, 8);
|
||||
}
|
||||
inline void writeValBig(atVec2f val) {return writeVec2fBig(val);}
|
||||
inline void writeValBig(atVec2f val) {writeVec2fBig(val);}
|
||||
|
||||
/*! \brief Writes an atVec3f (12 bytes) to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
|
@ -362,7 +366,7 @@ public:
|
|||
}
|
||||
writeUBytes((atUint8*)&vec, 12);
|
||||
}
|
||||
inline void writeVal(atVec3f val) {return writeVec3f(val);}
|
||||
inline void writeVal(atVec3f val) {writeVec3f(val);}
|
||||
|
||||
inline void writeVec3fLittle(atVec3f vec)
|
||||
{
|
||||
|
@ -371,7 +375,7 @@ public:
|
|||
utility::LittleFloat(vec.vec[2]);
|
||||
writeUBytes((atUint8*)&vec, 12);
|
||||
}
|
||||
inline void writeValLittle(atVec3f val) {return writeVec3fLittle(val);}
|
||||
inline void writeValLittle(atVec3f val) {writeVec3fLittle(val);}
|
||||
|
||||
inline void writeVec3fBig(atVec3f vec)
|
||||
{
|
||||
|
@ -380,7 +384,7 @@ public:
|
|||
utility::BigFloat(vec.vec[2]);
|
||||
writeUBytes((atUint8*)&vec, 12);
|
||||
}
|
||||
inline void writeValBig(atVec3f val) {return writeVec3fBig(val);}
|
||||
inline void writeValBig(atVec3f val) {writeVec3fBig(val);}
|
||||
|
||||
/*! \brief Writes an atVec4f (16 bytes) to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
|
@ -406,7 +410,7 @@ public:
|
|||
}
|
||||
writeUBytes((atUint8*)&vec, 16);
|
||||
}
|
||||
inline void writeVal(atVec4f val) {return writeVec4f(val);}
|
||||
inline void writeVal(atVec4f val) {writeVec4f(val);}
|
||||
|
||||
inline void writeVec4fLittle(atVec4f vec)
|
||||
{
|
||||
|
@ -416,7 +420,7 @@ public:
|
|||
utility::LittleFloat(vec.vec[3]);
|
||||
writeUBytes((atUint8*)&vec, 16);
|
||||
}
|
||||
inline void writeValLittle(atVec4f val) {return writeVec4fLittle(val);}
|
||||
inline void writeValLittle(atVec4f val) {writeVec4fLittle(val);}
|
||||
|
||||
inline void writeVec4fBig(atVec4f vec)
|
||||
{
|
||||
|
@ -426,7 +430,7 @@ public:
|
|||
utility::BigFloat(vec.vec[3]);
|
||||
writeUBytes((atUint8*)&vec, 16);
|
||||
}
|
||||
inline void writeValBig(atVec4f val) {return writeVec4fBig(val);}
|
||||
inline void writeValBig(atVec4f val) {writeVec4fBig(val);}
|
||||
|
||||
/*! \brief Converts a UTF8 string to a wide-char string in the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
|
@ -612,7 +616,7 @@ public:
|
|||
}
|
||||
}
|
||||
}
|
||||
inline void writeVal(const std::string& val) {return writeString(val);}
|
||||
inline void writeVal(const std::string& val) {writeString(val);}
|
||||
|
||||
/*! \brief Writes an wstring to the buffer and advances the buffer.
|
||||
*
|
||||
|
@ -647,7 +651,7 @@ public:
|
|||
}
|
||||
}
|
||||
}
|
||||
inline void writeVal(const std::wstring& val) {return writeWString(val);}
|
||||
inline void writeVal(const std::wstring& val) {writeWString(val);}
|
||||
|
||||
inline void writeWStringLittle(const std::wstring& str, atInt32 fixedLen = -1)
|
||||
{
|
||||
|
@ -676,7 +680,7 @@ public:
|
|||
}
|
||||
}
|
||||
}
|
||||
inline void writeValLittle(const std::wstring& val) {return writeWStringLittle(val);}
|
||||
inline void writeValLittle(const std::wstring& val) {writeWStringLittle(val);}
|
||||
|
||||
inline void writeWStringBig(const std::wstring& str, atInt32 fixedLen = -1)
|
||||
{
|
||||
|
@ -705,7 +709,7 @@ public:
|
|||
}
|
||||
}
|
||||
}
|
||||
inline void writeValBig(const std::wstring& val) {return writeWStringBig(val);}
|
||||
inline void writeValBig(const std::wstring& val) {writeWStringBig(val);}
|
||||
|
||||
inline void fill(atUint8 val, atUint64 length)
|
||||
{for (atUint64 l=0 ; l<length ; ++l) writeUBytes(&val, 1);}
|
||||
|
|
Loading…
Reference in New Issue