* Standardized Exception messages

* Added zelda::error namespace
* Moved all Exceptions to zelda::error
* Moved all Read/Write classes to zelda::io
* Added "base" to all classes that inherit from BinaryReader/Writers
* Changed all references to BinaryReader/Writer functions to base for
readability.
This commit is contained in:
Antidote
2013-07-21 00:49:07 -07:00
parent 0fc335ef14
commit d06c96d3aa
36 changed files with 732 additions and 500 deletions

View File

@@ -23,6 +23,9 @@
namespace zelda
{
class ALTTPFile;
namespace io
{
/*! \class ALTTPFileReader
* \brief A Link to the Past save data reader class
@@ -31,10 +34,10 @@ namespace zelda
* all work is done using a memory buffer, and not read directly from the disk.
* \sa BinaryReader
*/
class ALTTPFile;
class ALTTPFileReader : public io::BinaryReader
{
BINARYREADER_BASE
public:
/*! \brief This constructor takes an existing buffer to read from.
*
@@ -60,5 +63,6 @@ private:
ALTTPDungeonItemFlags readDungeonFlags();
};
} // io
} // zelda
#endif // __ALTTP_FILE_READER_HPP__

View File

@@ -23,9 +23,10 @@
namespace zelda
{
class ALTTPFile;
namespace io
{
/*! \class ALTTPFileWriter
* \brief A Link to the Past save data writer class
*
@@ -35,6 +36,8 @@ class ALTTPFile;
*/
class ALTTPFileWriter : public io::BinaryWriter
{
BINARYWRITER_BASE
public:
/*! \brief This constructor takes an existing buffer to write to.
*
@@ -62,6 +65,7 @@ private:
Uint16 calculateChecksum(Uint32 game);
};
} // io
} // zelda
#endif // __ALTTP_FILE_WRITER_HPP__

View File

@@ -174,7 +174,7 @@ protected:
#ifndef BINARYREADER_BASE
#define BINARYREADER_BASE \
private: \
private: \
typedef zelda::io::BinaryReader base;
#endif // BINARYREADER_BASE
#endif // __BINARYREADER_HPP__

View File

@@ -1,3 +1,18 @@
// This file is part of libZelda.
//
// libZelda is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libZelda is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libZelda. If not, see <http://www.gnu.org/licenses/>
#ifndef COMPRESSION_HPP
#define COMPRESSION_HPP

View File

@@ -20,6 +20,8 @@
namespace zelda
{
namespace error
{
/*! \class Exception
* \brief The baseclass for all Exceptions.
@@ -49,5 +51,6 @@ protected:
std::string m_message; //!< The error message string
};
} // error
} // zelda
#endif

View File

@@ -20,6 +20,8 @@
namespace zelda
{
namespace error
{
/*! \class FileNotFoundException
* \brief An excpeption thrown when a file could not be found at the given path.
@@ -48,6 +50,7 @@ private:
std::string m_filename;
};
} // error
} // zelda
#endif

View File

@@ -21,6 +21,8 @@
namespace zelda
{
namespace error
{
/*! \class IOException
* \brief An excpeption thrown on inappropriate IO calls.
@@ -40,8 +42,9 @@ public:
*/
IOException(const std::string& message) :
Exception("IOException: " + message)
{};
{}
};
} // error
} // zelda
#endif

View File

@@ -21,6 +21,8 @@
namespace zelda
{
namespace error
{
/*! \class InvalidOperationException
* \brief An excpeption thrown on Invalid Operations calls.
@@ -43,6 +45,7 @@ public:
}
};
} // error
} // zelda
#endif // __INVALID_OPERATION_EXCEPTION_HPP__

View File

@@ -24,6 +24,9 @@ namespace zelda
class MCFile;
namespace io
{
/*! \class MCFileReader
* \brief The Minish Cap Save save data reader class
*
@@ -33,6 +36,7 @@ class MCFile;
*/
class MCFileReader : public io::BinaryReader
{
BINARYREADER_BASE
public:
/*!
* \brief This constructor takes an existing buffer to read from.
@@ -57,6 +61,7 @@ public:
MCFile* readFile();
};
} // io
} // zelda
#endif // __MCFILEREADER_HPP__

View File

@@ -33,6 +33,7 @@ class MCFile;
*/
class MCFileWriter : public io::BinaryWriter
{
BINARYWRITER_BASE
public:
/*!
* \brief This constructor takes an existing buffer to write to.

View File

@@ -22,73 +22,7 @@
namespace zelda
{
/*!
* \brief The WiiImage class
*/
class WiiImage
{
public:
/*!
* \brief WiiImage
*/
WiiImage();
/*!
* \brief WiiImage
* \param width
* \param height
* \param data
*/
WiiImage(Uint32 width, Uint32 height, Uint8* data);
~WiiImage();
/*!
* \brief setWidth
* \param width
*/
void setWidth(const Uint32 width);
/*!
* \brief width
* \return
*/
Uint32 width() const;
/*!
* \brief setHeight
* \param height
*/
void setHeight(const Uint32 height);
/*!
* \brief height
* \return
*/
Uint32 height() const;
/*!
* \brief setData
* \param data
*/
void setData(const Uint8* data);
/*!
* \brief data
* \return
*/
Uint8* data();
/*!
* \brief toRGBA32 DOES NOT WORK!!! DO NOT USE!!!
* \return
*/
Uint8* toRGBA32();
private:
Uint32 m_width;
Uint32 m_height;
Uint8* m_data;
};
class WiiImage;
/*! \class WiiBanner
* \brief Wii banner container class
*

View File

@@ -17,6 +17,9 @@
#include "Types.hpp"
namespace zelda
{
/*!
* \brief The WiiImage class
*/
@@ -88,4 +91,6 @@ private:
Uint8* m_data;
};
} // zelda
#endif // WIIIMAGE_HPP

View File

@@ -21,12 +21,14 @@
namespace zelda
{
class WiiSave;
class WiiBanner;
class WiiFile;
class WiiImage;
namespace io
{
/*! \class WiiSaveReader
* \brief Wii data.bin reader class
*
@@ -36,6 +38,7 @@ class WiiImage;
*/
class WiiSaveReader : public io::BinaryReader
{
BINARYREADER_BASE
public:
/*! \brief This constructor takes an existing buffer to read from.
*
@@ -62,5 +65,6 @@ private:
void readCerts(Uint32 totalSize);
};
} // io
} // zelda
#endif // __WII_SAVE_READER_HPP__

View File

@@ -28,6 +28,9 @@ class WiiBanner;
class WiiFile;
class WiiImage;
namespace io
{
/*! \class WiiSaveWriter
* \brief Wii data.bin writer class
*
@@ -37,6 +40,7 @@ class WiiImage;
*/
class WiiSaveWriter : public io::BinaryWriter
{
BINARYWRITER_BASE
public:
/*! \brief This constructor creates an instance from a file on disk.
*
@@ -64,5 +68,6 @@ private:
void writeCerts(Uint32 filesSize, Uint32 ngId, Uint8* ngPriv, Uint8* ngSig, Uint32 ngKeyId);
};
} // io
} // zelda
#endif // __WII_SAVE_WRITER_HPP__

View File

@@ -1,3 +1,18 @@
// This file is part of libZelda.
//
// libZelda is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libZelda is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libZelda. If not, see <http://www.gnu.org/licenses/>
#ifndef ZQUEST_HPP
#define ZQUEST_HPP
@@ -7,17 +22,41 @@
namespace zelda
{
/*!
* \brief The ZQuest class
*/
class ZQuest
{
public:
/*!
* \brief Major
*/
static const Uint32 Major;
/*!
* \brief Minor
*/
static const Uint32 Minor;
/*!
* \brief Revision
*/
static const Uint32 Revision;
/*!
* \brief Build
*/
static const Uint32 Build;
/*!
* \brief Version
*/
static const Uint32 Version;
/*!
* \brief Magic
*/
static const Uint32 Magic;
/*!
* \brief The Game enum
*/
enum Game
{
NoGame,
@@ -41,22 +80,73 @@ public:
ALinkBetweenWorlds // Not released
};
/*!
* \brief ZQuest
*/
ZQuest();
/*!
* \brief ZQuest
* \param game
* \param endian
* \param data
* \param length
*/
ZQuest(Game game, Endian endian, Uint8* data, Uint32 length);
~ZQuest();
/*!
* \brief setGame
* \param game
*/
void setGame(Game game);
/*!
* \brief game
* \return
*/
Game game() const;
/*!
* \brief setEndian
* \param endian
*/
void setEndian(Endian endian);
/*!
* \brief endian
* \return
*/
Endian endian() const;
/*!
* \brief setData
* \param data
*/
void setData(Uint8* data);
/*!
* \brief data
* \return
*/
Uint8* data() const;
/*!
* \brief setLength
* \param length
*/
void setLength(Uint32 length);
/*!
* \brief length
* \return
*/
Uint32 length() const;
/*!
* \brief gameString
* \return
*/
std::string gameString() const;
private:
Game m_game;

View File

@@ -1,22 +1,57 @@
#ifndef ZQUESTFILEREADER_HPP
#define ZQUESTFILEREADER_HPP
// This file is part of libZelda.
//
// libZelda is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libZelda is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libZelda. If not, see <http://www.gnu.org/licenses/>
#ifndef __ZQUESTFILEREADER_HPP__
#define __ZQUESTFILEREADER_HPP__
#include "BinaryReader.hpp"
namespace zelda
{
class ZQuest;
namespace io
{
/*!
* \brief The ZQuestFileReader class
*/
class ZQuestFileReader : public io::BinaryReader
{
BINARYREADER_BASE
public:
public:
/*!
* \brief ZQuestFileReader
* \param data
* \param length
*/
ZQuestFileReader(Uint8* data, Uint64 length);
/*!
* \brief ZQuestFileReader
* \param filename
*/
ZQuestFileReader(const std::string& filename);
/*!
* \brief read
* \return
*/
ZQuest* read();
};
} // io
} // zelda
#endif // ZQUESTFILEREADER_HPP
#endif // __ZQUESTFILEREADER_HPP__

View File

@@ -1,5 +1,20 @@
#ifndef ZQUESTFILEWRITER_HPP
#define ZQUESTFILEWRITER_HPP
// This file is part of libZelda.
//
// libZelda is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libZelda is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libZelda. If not, see <http://www.gnu.org/licenses/>
#ifndef __ZQUESTFILEWRITER_HPP__
#define __ZQUESTFILEWRITER_HPP__
#include <BinaryWriter.hpp>
@@ -7,15 +22,38 @@ namespace zelda
{
class ZQuest;
namespace io
{
/*!
* \brief The ZQuestFileWriter class
*/
class ZQuestFileWriter : public io::BinaryWriter
{
BINARYWRITER_BASE
public:
/*!
* \brief ZQuestFileWriter
* \param data
* \param length
*/
ZQuestFileWriter(Uint8* data, Uint64 length);
/*!
* \brief ZQuestFileWriter
* \param filename
*/
ZQuestFileWriter(const std::string& filename);
/*!
* \brief write
* \param quest
* \param compress
*/
void write(ZQuest* quest, bool compress = true);
};
}
#endif // ZQUESTFILEWRITER_HPP
} // io
} // zelda
#endif // __ZQUESTFILEWRITER_HPP__