renamed read/writeUnicode methods to be more reflective of functionality

This commit is contained in:
Jack Andersen 2015-07-21 09:04:25 -10:00
parent 6405bffdd2
commit c6a6d3b9c4
5 changed files with 13 additions and 13 deletions

View File

@ -30,7 +30,7 @@ template <atInt32 sizeVar, Endian VE>
struct WString;
template <atInt32 sizeVar, Endian VE>
struct UTF8;
struct WStringAsString;
/**
* @brief Base DNA class used against 'atdna'
@ -62,7 +62,7 @@ struct DNA
using WString = struct WString<sizeVar, VE>;
template <atInt32 sizeVar = -1>
using UTF8 = struct UTF8<sizeVar, DNAE>;
using WStringAsString = struct WStringAsString<sizeVar, DNAE>;
template <off_t offset, SeekOrigin direction>
struct Seek {};
@ -125,13 +125,13 @@ struct WString : public DNA<VE>, public std::wstring
};
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;
inline void read(IStreamReader& reader)
{*this = reader.readUnicode(sizeVar);}
{*this = reader.readWStringAsString(sizeVar);}
inline void write(IStreamWriter& writer) const
{writer.writeUnicode(*this, sizeVar);}
{writer.writeStringAsWString(*this, sizeVar);}
inline std::string& operator=(const std::string& __str)
{return this->assign(__str);}
inline std::string& operator=(std::string&& __str)

View File

@ -293,13 +293,13 @@ public:
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
* \return std::string The value at the current address
* \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;
atUint16 chr = readUint16();

View File

@ -273,14 +273,14 @@ public:
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.
*
* \sa Endian
* \param str The string to write to the buffer
* \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;

View File

@ -198,12 +198,12 @@ WiiBanner* WiiSaveReader::readBanner()
animSpeed = base::readUint16();
base::seek(22);
gameTitle = base::readUnicode();
gameTitle = base::readWStringAsString();
if (base::position() != 0x0080)
base::seek(0x0080, SeekOrigin::Begin);
subTitle = base::readUnicode();
subTitle = base::readWStringAsString();
if (base::position() != 0x00C0)
base::seek(0x00C0, SeekOrigin::Begin);

View File

@ -110,12 +110,12 @@ void WiiSaveWriter::writeBanner(WiiBanner* banner)
base::writeInt16(banner->animationSpeed());
base::seek(22);
base::writeUnicode(banner->title());
base::writeStringAsWString(banner->title());
if (base::position() != 0x0080)
base::seek(0x0080, SeekOrigin::Begin);
base::writeUnicode(banner->subtitle());
base::writeStringAsWString(banner->subtitle());
if (base::position() != 0x00C0)
base::seek(0x00C0, SeekOrigin::Begin);