* Working on Wii Port

This commit is contained in:
Antidote
2013-09-08 20:36:54 -07:00
parent baf16a6fbd
commit 740fbd4273
12 changed files with 415 additions and 48 deletions

View File

@@ -52,6 +52,17 @@ public:
*/
BinaryReader(const std::string& filename);
/*! \brief Sets the target file
*
* \sa Endian
* \param filepath The path to write to.
*/
void setFilepath(const std::string& filepath);
/*! \brief Returns the target file
*
*/
std::string filepath() const;
/*! \brief Reads a Int16 and swaps to proper endianness depending on platform
* and Stream settings, and advances the current position

View File

@@ -47,12 +47,25 @@ public:
* \param stream The stream to write data to
*/
BinaryWriter(const Stream& stream);
/*! \brief This constructor creates an instance from a file on disk.
*
* \param filename The file to create the stream from
*/
BinaryWriter(const std::string& filename);
/*! \brief Sets the target file
*
* \sa Endian
* \param filepath The path to write to.
*/
void setFilepath(const std::string& filepath);
/*! \brief Returns the target file
*
*/
std::string filepath() const;
/*! \brief Saves the file to the specified file.
*
* \param filename If not empty, the filename to save to
@@ -145,6 +158,7 @@ public:
* \param str The string to write to the buffer
*/
void writeString(const std::string& str);
protected:
Int8 readByte();
Int8* readBytes(Int64);

View File

@@ -176,19 +176,19 @@ public:
*
* \return Int64 The length of the stream.
*/
Int64 length();
Int64 length() const;
/*! \brief Returns the current position in the stream.
*
* \return Int64 The current position in the stream.
*/
Int64 position();
Int64 position() const;
/*! \brief Returns whether or not the stream is at the end.
*
* \return bool True if at end; False otherwise.
*/
bool atEnd();
bool atEnd() const;
/*! \brief Sets whether the Stream resizes when the at the end of the buffer.
*

View File

@@ -40,11 +40,11 @@ public:
*/
enum TextMode
{
Open, //!< The file is opened if it exists.
Create, //!< Create the file if it does not exist.
Open = 0x01, //!< The file is opened if it exists.
Create = 0x02, //!< Create the file if it does not exist.
OpenOrCreate = Open|Create, //!< If the file does not exist when opening the file it is created
Truncate, //!< All the data currently that is in the file is erased.
Append //!< After opening the file the current line is set to the end of the buffer
Truncate = 0x04, //!< All the data currently that is in the file is erased.
Append = 0x08 //!< After opening the file the current line is set to the end of the buffer
};
/*! \enum AccessMode
@@ -57,8 +57,9 @@ public:
ReadWrite //!< The Stream can be read from or written to.
};
TextStream();
/*! \brief This constructor opens the file and loads all the lines. */
TextStream(const std::string& filename, TextMode fileMode = Open, AccessMode accessMode = ReadWrite);
TextStream(const std::string& filename, Uint32 fileMode = Open, AccessMode accessMode = ReadWrite);
/*! \brief Creates a new buffer and saves all lines to the specified file.
* \param filename The file, including path to save to.
@@ -144,14 +145,20 @@ public:
*
* \return TextMode The mode to set.
*/
TextMode textMode() const;
Uint32 textMode() const;
/*! \brief Empties the stream.
*
*/
void truncate();
bool isOpenForReading() const;
bool isOpenForWriting() const;
private:
void loadLines();
std::string m_filename;
TextMode m_textmode;
Uint32 m_textmode;
AccessMode m_accessmode;
std::vector<std::string> m_lines;

View File

@@ -17,6 +17,7 @@
#define __UTILITY_H__
#include <string>
#include <vector>
#include "Types.hpp"
namespace zelda
@@ -27,9 +28,9 @@ namespace utility
bool isEmpty(Int8*, Uint32);
Uint16 swapU16(Uint16 val );
Int16 swap16 (Int16 val );
Uint32 swapU32(Uint32 val);
Int32 swap32 (Int32 val );
Int16 swap16 (Int16 val );
Uint32 swapU32(Uint32 val);
Int32 swap32 (Int32 val );
Uint64 swapU64(Uint64 val);
Int64 swap64 (Int64 val);
@@ -40,6 +41,14 @@ bool isSystemBigEndian();
void fillRandom(Uint8 * rndArea, Uint8 count);
std::vector<std::string> split(const std::string &s, char delim);
void tolower(std::string& str);
void toupper(std::string& str);
std::string sprintf(const char* fmt, ...);
bool parseBool(const std::string& boolean, bool &valid);
int countChar(const std::string& str, const char chr, int& lastOccur);
} // utility
} // zelda