fixed incomplete-type warnings involving recursively-derived DNA types

This commit is contained in:
Jack Andersen 2015-07-14 12:57:42 -10:00
parent 24fedff58e
commit f3ba8819a4
2 changed files with 85 additions and 58 deletions

View File

@ -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')

View File

@ -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,12 +52,33 @@ 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; template <atInt32 sizeVar = -1>
using String = struct String<sizeVar, DNAE>;
template <atInt32 sizeVar = -1, Endian VE = DNAE>
using WString = struct WString<sizeVar, VE>;
template <atInt32 sizeVar = -1>
using UTF8 = struct UTF8<sizeVar, DNAE>;
template <off_t offset, SeekOrigin direction>
struct Seek {};
template <size_t 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) inline void read(IStreamReader& reader)
{ {
reset(new atUint8[sizeVar]); reset(new atUint8[sizeVar]);
@ -53,12 +88,12 @@ struct DNA
{ {
writer.writeUBytes(get(), sizeVar); writer.writeUBytes(get(), sizeVar);
} }
}; };
template <atInt32 sizeVar = -1> template <atInt32 sizeVar, Endian VE>
struct String : public DNA, public std::string struct String : public DNA<VE>, public std::string
{ {
Delete expl; typename DNA<VE>::Delete expl;
inline void read(IStreamReader& reader) inline void read(IStreamReader& reader)
{*this = reader.readString(sizeVar);} {*this = reader.readString(sizeVar);}
inline void write(IStreamWriter& writer) const inline void write(IStreamWriter& writer) const
@ -67,12 +102,12 @@ struct DNA
{return this->assign(__str);} {return this->assign(__str);}
inline std::string& operator=(std::string&& __str) inline std::string& operator=(std::string&& __str)
{this->swap(__str); return *this;} {this->swap(__str); return *this;}
}; };
template <atInt32 sizeVar = -1, Endian VE = DNAE> template <atInt32 sizeVar, Endian VE>
struct WString : public DNA, public std::wstring struct WString : public DNA<VE>, public std::wstring
{ {
Delete expl; typename DNA<VE>::Delete expl;
inline void read(IStreamReader& reader) inline void read(IStreamReader& reader)
{ {
reader.setEndian(VE); reader.setEndian(VE);
@ -87,12 +122,12 @@ struct DNA
{return this->assign(__str);} {return this->assign(__str);}
inline std::wstring& operator=(std::wstring&& __str) inline std::wstring& operator=(std::wstring&& __str)
{this->swap(__str); return *this;} {this->swap(__str); return *this;}
}; };
template <atInt32 sizeVar = -1> template <atInt32 sizeVar, Endian VE>
struct UTF8 : public DNA, public std::string struct UTF8 : public DNA<VE>, public std::string
{ {
Delete expl; typename DNA<VE>::Delete expl;
inline void read(IStreamReader& reader) inline void read(IStreamReader& reader)
{*this = reader.readUnicode(sizeVar);} {*this = reader.readUnicode(sizeVar);}
inline void write(IStreamWriter& writer) const inline void write(IStreamWriter& writer) const
@ -101,14 +136,6 @@ struct DNA
{return this->assign(__str);} {return this->assign(__str);}
inline std::string& operator=(std::string&& __str) inline std::string& operator=(std::string&& __str)
{this->swap(__str); return *this;} {this->swap(__str); return *this;}
};
template <off_t offset, SeekOrigin direction>
struct Seek {};
template <size_t align>
struct Align {};
}; };
/** Macro to automatically declare read/write methods in subclasses */ /** Macro to automatically declare read/write methods in subclasses */