mirror of https://github.com/libAthena/athena.git
renamed read/writeUnicode methods to be more reflective of functionality
This commit is contained in:
parent
6405bffdd2
commit
c6a6d3b9c4
|
@ -30,7 +30,7 @@ template <atInt32 sizeVar, Endian VE>
|
||||||
struct WString;
|
struct WString;
|
||||||
|
|
||||||
template <atInt32 sizeVar, Endian VE>
|
template <atInt32 sizeVar, Endian VE>
|
||||||
struct UTF8;
|
struct WStringAsString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Base DNA class used against 'atdna'
|
* @brief Base DNA class used against 'atdna'
|
||||||
|
@ -62,7 +62,7 @@ struct DNA
|
||||||
using WString = struct WString<sizeVar, VE>;
|
using WString = struct WString<sizeVar, VE>;
|
||||||
|
|
||||||
template <atInt32 sizeVar = -1>
|
template <atInt32 sizeVar = -1>
|
||||||
using UTF8 = struct UTF8<sizeVar, DNAE>;
|
using WStringAsString = struct WStringAsString<sizeVar, DNAE>;
|
||||||
|
|
||||||
template <off_t offset, SeekOrigin direction>
|
template <off_t offset, SeekOrigin direction>
|
||||||
struct Seek {};
|
struct Seek {};
|
||||||
|
@ -125,13 +125,13 @@ struct WString : public DNA<VE>, public std::wstring
|
||||||
};
|
};
|
||||||
|
|
||||||
template <atInt32 sizeVar, Endian VE>
|
template <atInt32 sizeVar, Endian VE>
|
||||||
struct UTF8 : public DNA<VE>, public std::string
|
struct WStringAsString : public DNA<VE>, public std::string
|
||||||
{
|
{
|
||||||
typename DNA<VE>::Delete expl;
|
typename DNA<VE>::Delete expl;
|
||||||
inline void read(IStreamReader& reader)
|
inline void read(IStreamReader& reader)
|
||||||
{*this = reader.readUnicode(sizeVar);}
|
{*this = reader.readWStringAsString(sizeVar);}
|
||||||
inline void write(IStreamWriter& writer) const
|
inline void write(IStreamWriter& writer) const
|
||||||
{writer.writeUnicode(*this, sizeVar);}
|
{writer.writeStringAsWString(*this, sizeVar);}
|
||||||
inline std::string& operator=(const std::string& __str)
|
inline std::string& operator=(const std::string& __str)
|
||||||
{return this->assign(__str);}
|
{return this->assign(__str);}
|
||||||
inline std::string& operator=(std::string&& __str)
|
inline std::string& operator=(std::string&& __str)
|
||||||
|
|
|
@ -293,13 +293,13 @@ public:
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Reads a Unicode string and advances the position in the file
|
/*! \brief Reads a wide-char string, converts to UTF8 and advances the position in the file
|
||||||
*
|
*
|
||||||
* \param fixedLen If non-negative, this is a fixed-length string read
|
* \param fixedLen If non-negative, this is a fixed-length string read
|
||||||
* \return std::string The value at the current address
|
* \return std::string The value at the current address
|
||||||
* \throw IOException when address is out of range
|
* \throw IOException when address is out of range
|
||||||
*/
|
*/
|
||||||
inline std::string readUnicode(atInt32 fixedLen = -1)
|
inline std::string readWStringAsString(atInt32 fixedLen = -1)
|
||||||
{
|
{
|
||||||
std::wstring tmp;
|
std::wstring tmp;
|
||||||
atUint16 chr = readUint16();
|
atUint16 chr = readUint16();
|
||||||
|
|
|
@ -273,14 +273,14 @@ public:
|
||||||
writeUBytes((atUint8*)&vec, 16);
|
writeUBytes((atUint8*)&vec, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Writes an unicode string to the buffer and advances the buffer.
|
/*! \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.
|
* It also swaps the bytes depending on the platform and Stream settings.
|
||||||
*
|
*
|
||||||
* \sa Endian
|
* \sa Endian
|
||||||
* \param str The string to write to the buffer
|
* \param str The string to write to the buffer
|
||||||
* \param fixedLen If not -1, the number of characters to zero-fill string to
|
* \param fixedLen If not -1, the number of characters to zero-fill string to
|
||||||
*/
|
*/
|
||||||
inline void writeUnicode(const std::string& str, atInt32 fixedLen = -1)
|
inline void writeStringAsWString(const std::string& str, atInt32 fixedLen = -1)
|
||||||
{
|
{
|
||||||
std::string tmpStr = "\xEF\xBB\xBF" + str;
|
std::string tmpStr = "\xEF\xBB\xBF" + str;
|
||||||
|
|
||||||
|
|
|
@ -198,12 +198,12 @@ WiiBanner* WiiSaveReader::readBanner()
|
||||||
animSpeed = base::readUint16();
|
animSpeed = base::readUint16();
|
||||||
base::seek(22);
|
base::seek(22);
|
||||||
|
|
||||||
gameTitle = base::readUnicode();
|
gameTitle = base::readWStringAsString();
|
||||||
|
|
||||||
if (base::position() != 0x0080)
|
if (base::position() != 0x0080)
|
||||||
base::seek(0x0080, SeekOrigin::Begin);
|
base::seek(0x0080, SeekOrigin::Begin);
|
||||||
|
|
||||||
subTitle = base::readUnicode();
|
subTitle = base::readWStringAsString();
|
||||||
|
|
||||||
if (base::position() != 0x00C0)
|
if (base::position() != 0x00C0)
|
||||||
base::seek(0x00C0, SeekOrigin::Begin);
|
base::seek(0x00C0, SeekOrigin::Begin);
|
||||||
|
|
|
@ -110,12 +110,12 @@ void WiiSaveWriter::writeBanner(WiiBanner* banner)
|
||||||
base::writeInt16(banner->animationSpeed());
|
base::writeInt16(banner->animationSpeed());
|
||||||
base::seek(22);
|
base::seek(22);
|
||||||
|
|
||||||
base::writeUnicode(banner->title());
|
base::writeStringAsWString(banner->title());
|
||||||
|
|
||||||
if (base::position() != 0x0080)
|
if (base::position() != 0x0080)
|
||||||
base::seek(0x0080, SeekOrigin::Begin);
|
base::seek(0x0080, SeekOrigin::Begin);
|
||||||
|
|
||||||
base::writeUnicode(banner->subtitle());
|
base::writeStringAsWString(banner->subtitle());
|
||||||
|
|
||||||
if (base::position() != 0x00C0)
|
if (base::position() != 0x00C0)
|
||||||
base::seek(0x00C0, SeekOrigin::Begin);
|
base::seek(0x00C0, SeekOrigin::Begin);
|
||||||
|
|
Loading…
Reference in New Issue