mirror of https://github.com/libAthena/athena.git
fixed incomplete-type warnings involving recursively-derived DNA types
This commit is contained in:
parent
24fedff58e
commit
f3ba8819a4
2
PKGBUILD
2
PKGBUILD
|
@ -1,7 +1,7 @@
|
||||||
# PKGBUILD for libAthena
|
# PKGBUILD for libAthena
|
||||||
_pkgname=libathena
|
_pkgname=libathena
|
||||||
pkgname=$_pkgname-git
|
pkgname=$_pkgname-git
|
||||||
pkgver=2.0.0.7.g87306a1
|
pkgver=2.0.0.8.g24fedff
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Basic cross platform IO library"
|
pkgdesc="Basic cross platform IO library"
|
||||||
arch=('i686' 'x86_64')
|
arch=('i686' 'x86_64')
|
||||||
|
|
|
@ -18,6 +18,20 @@ namespace Athena
|
||||||
namespace io
|
namespace io
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/* forward-declaration dance for recursively-derived types */
|
||||||
|
|
||||||
|
template <size_t sizeVar, Endian VE>
|
||||||
|
struct Buffer;
|
||||||
|
|
||||||
|
template <atInt32 sizeVar, Endian VE>
|
||||||
|
struct String;
|
||||||
|
|
||||||
|
template <atInt32 sizeVar, Endian VE>
|
||||||
|
struct WString;
|
||||||
|
|
||||||
|
template <atInt32 sizeVar, Endian VE>
|
||||||
|
struct UTF8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Base DNA class used against 'atdna'
|
* @brief Base DNA class used against 'atdna'
|
||||||
*
|
*
|
||||||
|
@ -38,70 +52,17 @@ struct DNA
|
||||||
template <typename T, size_t cntVar, Endian VE = DNAE>
|
template <typename T, size_t cntVar, Endian VE = DNAE>
|
||||||
using Vector = std::vector<T>;
|
using Vector = std::vector<T>;
|
||||||
|
|
||||||
struct Delete {};
|
|
||||||
|
|
||||||
template <size_t sizeVar>
|
template <size_t sizeVar>
|
||||||
struct Buffer : public DNA, public std::unique_ptr<atUint8[]>
|
using Buffer = struct Buffer<sizeVar, DNAE>;
|
||||||
{
|
|
||||||
Delete expl;
|
|
||||||
inline void read(IStreamReader& reader)
|
|
||||||
{
|
|
||||||
reset(new atUint8[sizeVar]);
|
|
||||||
reader.readUBytesToBuf(get(), sizeVar);
|
|
||||||
}
|
|
||||||
inline void write(IStreamWriter& writer) const
|
|
||||||
{
|
|
||||||
writer.writeUBytes(get(), sizeVar);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <atInt32 sizeVar = -1>
|
template <atInt32 sizeVar = -1>
|
||||||
struct String : public DNA, public std::string
|
using String = struct String<sizeVar, DNAE>;
|
||||||
{
|
|
||||||
Delete expl;
|
|
||||||
inline void read(IStreamReader& reader)
|
|
||||||
{*this = reader.readString(sizeVar);}
|
|
||||||
inline void write(IStreamWriter& writer) const
|
|
||||||
{writer.writeString(*this, sizeVar);}
|
|
||||||
inline std::string& operator=(const std::string& __str)
|
|
||||||
{return this->assign(__str);}
|
|
||||||
inline std::string& operator=(std::string&& __str)
|
|
||||||
{this->swap(__str); return *this;}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <atInt32 sizeVar = -1, Endian VE = DNAE>
|
template <atInt32 sizeVar = -1, Endian VE = DNAE>
|
||||||
struct WString : public DNA, public std::wstring
|
using WString = struct WString<sizeVar, VE>;
|
||||||
{
|
|
||||||
Delete expl;
|
|
||||||
inline void read(IStreamReader& reader)
|
|
||||||
{
|
|
||||||
reader.setEndian(VE);
|
|
||||||
*this = reader.readWString(sizeVar);
|
|
||||||
}
|
|
||||||
inline void write(IStreamWriter& writer) const
|
|
||||||
{
|
|
||||||
writer.setEndian(VE);
|
|
||||||
writer.writeWString(*this, sizeVar);
|
|
||||||
}
|
|
||||||
inline std::wstring& operator=(const std::wstring& __str)
|
|
||||||
{return this->assign(__str);}
|
|
||||||
inline std::wstring& operator=(std::wstring&& __str)
|
|
||||||
{this->swap(__str); return *this;}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <atInt32 sizeVar = -1>
|
template <atInt32 sizeVar = -1>
|
||||||
struct UTF8 : public DNA, public std::string
|
using UTF8 = struct UTF8<sizeVar, DNAE>;
|
||||||
{
|
|
||||||
Delete expl;
|
|
||||||
inline void read(IStreamReader& reader)
|
|
||||||
{*this = reader.readUnicode(sizeVar);}
|
|
||||||
inline void write(IStreamWriter& writer) const
|
|
||||||
{writer.writeUnicode(*this, sizeVar);}
|
|
||||||
inline std::string& operator=(const std::string& __str)
|
|
||||||
{return this->assign(__str);}
|
|
||||||
inline std::string& operator=(std::string&& __str)
|
|
||||||
{this->swap(__str); return *this;}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <off_t offset, SeekOrigin direction>
|
template <off_t offset, SeekOrigin direction>
|
||||||
struct Seek {};
|
struct Seek {};
|
||||||
|
@ -109,6 +70,72 @@ struct DNA
|
||||||
template <size_t align>
|
template <size_t align>
|
||||||
struct Align {};
|
struct Align {};
|
||||||
|
|
||||||
|
struct Delete {};
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Concrete DNA types */
|
||||||
|
|
||||||
|
template <size_t sizeVar, Endian VE>
|
||||||
|
struct Buffer : public DNA<VE>, public std::unique_ptr<atUint8[]>
|
||||||
|
{
|
||||||
|
typename DNA<VE>::Delete expl;
|
||||||
|
inline void read(IStreamReader& reader)
|
||||||
|
{
|
||||||
|
reset(new atUint8[sizeVar]);
|
||||||
|
reader.readUBytesToBuf(get(), sizeVar);
|
||||||
|
}
|
||||||
|
inline void write(IStreamWriter& writer) const
|
||||||
|
{
|
||||||
|
writer.writeUBytes(get(), sizeVar);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <atInt32 sizeVar, Endian VE>
|
||||||
|
struct String : public DNA<VE>, public std::string
|
||||||
|
{
|
||||||
|
typename DNA<VE>::Delete expl;
|
||||||
|
inline void read(IStreamReader& reader)
|
||||||
|
{*this = reader.readString(sizeVar);}
|
||||||
|
inline void write(IStreamWriter& writer) const
|
||||||
|
{writer.writeString(*this, sizeVar);}
|
||||||
|
inline std::string& operator=(const std::string& __str)
|
||||||
|
{return this->assign(__str);}
|
||||||
|
inline std::string& operator=(std::string&& __str)
|
||||||
|
{this->swap(__str); return *this;}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <atInt32 sizeVar, Endian VE>
|
||||||
|
struct WString : public DNA<VE>, public std::wstring
|
||||||
|
{
|
||||||
|
typename DNA<VE>::Delete expl;
|
||||||
|
inline void read(IStreamReader& reader)
|
||||||
|
{
|
||||||
|
reader.setEndian(VE);
|
||||||
|
*this = reader.readWString(sizeVar);
|
||||||
|
}
|
||||||
|
inline void write(IStreamWriter& writer) const
|
||||||
|
{
|
||||||
|
writer.setEndian(VE);
|
||||||
|
writer.writeWString(*this, sizeVar);
|
||||||
|
}
|
||||||
|
inline std::wstring& operator=(const std::wstring& __str)
|
||||||
|
{return this->assign(__str);}
|
||||||
|
inline std::wstring& operator=(std::wstring&& __str)
|
||||||
|
{this->swap(__str); return *this;}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <atInt32 sizeVar, Endian VE>
|
||||||
|
struct UTF8 : public DNA<VE>, public std::string
|
||||||
|
{
|
||||||
|
typename DNA<VE>::Delete expl;
|
||||||
|
inline void read(IStreamReader& reader)
|
||||||
|
{*this = reader.readUnicode(sizeVar);}
|
||||||
|
inline void write(IStreamWriter& writer) const
|
||||||
|
{writer.writeUnicode(*this, sizeVar);}
|
||||||
|
inline std::string& operator=(const std::string& __str)
|
||||||
|
{return this->assign(__str);}
|
||||||
|
inline std::string& operator=(std::string&& __str)
|
||||||
|
{this->swap(__str); return *this;}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Macro to automatically declare read/write methods in subclasses */
|
/** Macro to automatically declare read/write methods in subclasses */
|
||||||
|
|
Loading…
Reference in New Issue