From f3ba8819a495fa2fdc4cf87087928723d75fca22 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 14 Jul 2015 12:57:42 -1000 Subject: [PATCH] fixed incomplete-type warnings involving recursively-derived DNA types --- PKGBUILD | 2 +- include/Athena/DNA.hpp | 141 ++++++++++++++++++++++++----------------- 2 files changed, 85 insertions(+), 58 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index af1f657..e82fc07 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,7 +1,7 @@ # PKGBUILD for libAthena _pkgname=libathena pkgname=$_pkgname-git -pkgver=2.0.0.7.g87306a1 +pkgver=2.0.0.8.g24fedff pkgrel=1 pkgdesc="Basic cross platform IO library" arch=('i686' 'x86_64') diff --git a/include/Athena/DNA.hpp b/include/Athena/DNA.hpp index 21ca776..7910c78 100644 --- a/include/Athena/DNA.hpp +++ b/include/Athena/DNA.hpp @@ -18,6 +18,20 @@ namespace Athena namespace io { +/* forward-declaration dance for recursively-derived types */ + +template +struct Buffer; + +template +struct String; + +template +struct WString; + +template +struct UTF8; + /** * @brief Base DNA class used against 'atdna' * @@ -38,70 +52,17 @@ struct DNA template using Vector = std::vector; - struct Delete {}; - template - struct Buffer : public DNA, public std::unique_ptr - { - 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); - } - }; + using Buffer = struct Buffer; template - struct String : public DNA, public std::string - { - 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;} - }; + using String = struct String; template - struct WString : public DNA, public std::wstring - { - 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;} - }; + using WString = struct WString; template - struct UTF8 : public DNA, public std::string - { - 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;} - }; + using UTF8 = struct UTF8; template struct Seek {}; @@ -109,6 +70,72 @@ struct DNA template struct Align {}; + struct Delete {}; +}; + +/* Concrete DNA types */ + +template +struct Buffer : public DNA, public std::unique_ptr +{ + typename DNA::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 +struct String : public DNA, public std::string +{ + typename DNA::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 +struct WString : public DNA, public std::wstring +{ + typename DNA::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 +struct UTF8 : public DNA, public std::string +{ + typename DNA::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 */