explicitly use std in STL

This commit is contained in:
James Turk 2003-06-11 00:15:07 +00:00
parent fc991bbcc8
commit 7c63dd9981
20 changed files with 172 additions and 175 deletions

View File

@ -14,7 +14,7 @@
Definition file for VersinInfo class, simple class for containing and comparing
version numbers.
<br>$Id: VersionInfo.h,v 1.2 2003/06/10 23:24:47 cozman Exp $<br>
<br>$Id: VersionInfo.h,v 1.3 2003/06/11 00:15:24 cozman Exp $<br>
\author James Turk
**/
@ -38,7 +38,7 @@ class VersionInfo
//! Version release number, changes on every release.
unsigned int release;
//! String Description of release. (Often blank.)
string extra;
std::string extra;
/*!
\brief Constructor for VersionInfo.
@ -47,17 +47,17 @@ class VersionInfo
\param maj Major version number.
\param min Minor version number.
\param rel Version release number.
\param ext Extra info string, optional (defaults to empty string).
\param ext Extra info std::string, optional (defaults to empty std::string).
**/
VersionInfo(unsigned int maj, unsigned int min, unsigned int rel, string ext="");
VersionInfo(unsigned int maj, unsigned int min, unsigned int rel, std::string ext="");
/*!
\brief Get string representing version number.
\brief Get std::string representing version number.
Get dotted version number major.minor.release [extra].
\return Formatted version string.
\return Formatted version std::string.
**/
string GetString() const;
std::string GetString() const;
/*!
\brief Less than operator overload for comparing VersionInfo.

View File

@ -54,6 +54,5 @@
#include <cstdarg>
#include <cctype>
#include <ctime>
using namespace std;
#endif //__ze_includes_h__

View File

@ -14,7 +14,7 @@
Definition file for ZEngine Utilities which are used throughout the engine and can be used in
conjunction with ZEngine.
<br>$Id: ZE_Utility.h,v 1.4 2003/05/13 01:30:50 cozman Exp $<br>
<br>$Id: ZE_Utility.h,v 1.5 2003/06/11 00:15:25 cozman Exp $<br>
\author James Turk
**/
@ -28,15 +28,15 @@ namespace ZE
{
/*!
\brief Parses a string and interprets variable arguments, similar to sprintf.
\brief Parses a std::string and interprets variable arguments, similar to sprintf.
Takes % identifiers out of fmtstr and parses them, replacing them with cooresponding values
in the variable arguments list. For more detail view stdarg documentation.
\param fmtstr defines format of resulting string
\param fmtstr defines format of resulting std::string
\param ... variable number of arguments after fmtstr
\return string of parsed and combined string
\return std::string of parsed and combined std::string
**/
string FormatStr(const char *fmtstr, ...);
std::string FormatStr(const char *fmtstr, ...);
//////////
//Memory//
@ -80,7 +80,6 @@ void FreeMusic(Mix_Music *&music);
void FreeFont(TTF_Font *&font);
#endif
}
#endif //__ze_utility_h__

View File

@ -40,16 +40,16 @@ class ZConfigFile
/*!
\brief ZConfigFile Variable class.
ZConfigFile class for mapping a variable name to it's value, stored in string form (later converted to
ZConfigFile class for mapping a variable name to it's value, stored in std::string form (later converted to
bool or int if needed).
**/
class ZCF_Variable
{
public:
//! Variable name.
string var;
std::string var;
//! Value associated with variable.
string val;
std::string val;
};
/*!
@ -61,25 +61,25 @@ class ZConfigFile
{
public:
//! Section name.
string section;
std::string section;
//! STL list of variables.
list<ZCF_Variable> varList;
std::list<ZCF_Variable> varList;
};
protected:
//! List of sections of internal type.
list<ZCF_Section> rFileLayout;
std::list<ZCF_Section> rFileLayout;
//! Filename of file currently open.
string rFilename;
std::string rFilename;
/*!
\brief Reformat a string in a form more suitable to parsing.
\brief Reformat a std::string in a form more suitable to parsing.
Removes whitespace from a string and makes all characters lowercase.
\param str The string to get a clean version of.
\return Cleaned string.
Removes whitespace from a std::string and makes all characters lowercase.
\param str The std::string to get a clean version of.
\return Cleaned std::string.
**/
string CleanString(string str) const;
std::string CleanString(std::string str) const;
/*!
\brief Check if a section exists.
@ -88,7 +88,7 @@ class ZConfigFile
\param sec Section to check for.
\return bool, true if section exists in file.
**/
bool Exists(string sec) const;
bool Exists(std::string sec) const;
/*!
\brief Check if a variable exists.
@ -98,7 +98,7 @@ class ZConfigFile
\param var Variable to check for.
\return bool, true if section exists in file.
**/
bool Exists(string sec, string var) const;
bool Exists(std::string sec, std::string var) const;
/*!
\brief Internal function to set variables.
@ -108,7 +108,7 @@ class ZConfigFile
\param var Variable to set.
\param val Value to set variable to.
**/
void SetVariable(string sec, string var, string val);
void SetVariable(std::string sec, std::string var, std::string val);
/*!
\brief Internal function to get value of a variable.
@ -119,7 +119,7 @@ class ZConfigFile
\param defVal Value to return if variable doesnt exist.
\return Value of variable.
**/
string GetVariable(string sec, string var, string defVal) const;
std::string GetVariable(std::string sec, std::string var, std::string defVal) const;
public:
@ -136,7 +136,7 @@ class ZConfigFile
Constructor takes filename, and calls process on it.
\param filename File to load as ZConfigFile.
**/
ZConfigFile(string filename);
ZConfigFile(std::string filename);
/*!
\brief Destructor, flushes file.
@ -151,7 +151,7 @@ class ZConfigFile
Parses the file, reading the contents into the fileLayout map.
\param filename File to parse and attach this ZDataFile to.
**/
void Process(string filename);
void Process(std::string filename);
/*!
\brief Get value in floating point format from file.
@ -163,7 +163,7 @@ class ZConfigFile
\param defVal Value to return if var does not exist within section.
\return Contents of the variable in floating point format.
**/
float GetFloat(string section, string var, float defVal) const;
float GetFloat(std::string section, std::string var, float defVal) const;
/*!
\brief Get value in integer format from file.
@ -174,7 +174,7 @@ class ZConfigFile
\param defVal Value to return if var does not exist within section.
\return Contents of the variable in integer format.
**/
int GetInt(string section, string var, int defVal) const;
int GetInt(std::string section, std::string var, int defVal) const;
/*!
\brief Get value in boolean format from file.
@ -186,18 +186,18 @@ class ZConfigFile
\param defVal Value to return if var does not exist within section.
\return Contents of the variable in boolean format.
**/
bool GetBool(string section, string var, bool defVal) const;
bool GetBool(std::string section, std::string var, bool defVal) const;
/*!
\brief Get value in string format from file.
\brief Get value in std::string format from file.
Get the current value of a variable in the file, or defVal if not found in file.
\param section Name of section to seek variable under.
\param var Name of variable to seek value for.
\param defVal Value to return if var does not exist within section.
\return Contents of the variable in string format.
\return Contents of the variable in std::string format.
**/
string GetString(string section, string var, string defVal) const;
std::string GetString(std::string section, std::string var, std::string defVal) const;
/*!
\brief Set value in floating point format in file.
@ -209,7 +209,7 @@ class ZConfigFile
\param var Name of variable to set value for.
\param val Floating point value to set variable to in file.
**/
void SetFloat(string section, string var, float val);
void SetFloat(std::string section, std::string var, float val);
/*!
\brief Set value in integer format in file.
@ -220,7 +220,7 @@ class ZConfigFile
\param var Name of variable to set value for.
\param val Integer value to set variable to in file.
**/
void SetInt(string section, string var, int val);
void SetInt(std::string section, std::string var, int val);
/*!
\brief Set value in boolean format in file.
@ -231,10 +231,10 @@ class ZConfigFile
\param var Name of variable to set value for.
\param val Boolean value to set variable to in file.
**/
void SetBool(string section, string var, bool val);
void SetBool(std::string section, std::string var, bool val);
/*!
\brief Set value in string format in file.
\brief Set value in std::string format in file.
Set the new value of a variable in the file to val, creating the section and variable
if not already found in file.
@ -242,7 +242,7 @@ class ZConfigFile
\param var Name of variable to set value for.
\param val String value to set variable to in file.
**/
void SetString(string section, string var, string val);
void SetString(std::string section, std::string var, std::string val);
/*!
\brief Write all values to file

View File

@ -13,7 +13,7 @@
\brief Definition file for core ZEngine class.
ZEngine Game Engine core Engine definition.
<br>$Id: ZE_ZEngine.h,v 1.39 2003/06/10 23:24:47 cozman Exp $<br>
<br>$Id: ZE_ZEngine.h,v 1.40 2003/06/11 00:15:25 cozman Exp $<br>
\author James Turk
**/
@ -96,7 +96,7 @@ class ZEngine
//! Mouse Button Information
Uint8 mMouseB;
//! Stack of Errors which have occured.
queue<ZError> mErrorQueue;
std::queue<ZError> mErrorQueue;
//! Current error.
ZError mCurError;
//! Option controlling how logfile is used.
@ -181,7 +181,7 @@ class ZEngine
\param icon Path to Icon File.
\return result of setting up the display, true if everything went ok, false if any setup failed (check GetLastError).
**/
bool CreateDisplay(string title, string icon="");
bool CreateDisplay(std::string title, std::string icon="");
/*!
\brief Quit SDL and any Subsystems.
@ -488,7 +488,7 @@ class ZEngine
Sets up PhysicsFS, must be called when application is started.
\param argv argv[0] from application's main.
**/
void InitPhysFS(string argv);
void InitPhysFS(std::string argv);
/*!
\brief Add Directory to PhysFS Search Path.
@ -496,7 +496,7 @@ class ZEngine
Add Directory to PhysicsFS search path, the path it looks in for files when attempting to load.
\param dir Directory to add to search path.
**/
void AddPhysFSDir(string dir);
void AddPhysFSDir(std::string dir);
#endif //USE_PHYSFS
@ -524,7 +524,7 @@ class ZEngine
\param logFile Name of file to use as log, passing in stderr or stdio will set the log to the C streams.
Passing in nothing will not change the current error log file, which defaults to stderr.
**/
void SetErrorLog(bool logAll, string logFile="");
void SetErrorLog(bool logAll, std::string logFile="");
/*!
\brief Report an error.
@ -532,11 +532,11 @@ class ZEngine
Adds the error to the the error queue, and sets the current error to this error.
\since 0.8.2
\param code ZErrorCode of error.
\param desc Optional string describing error.
\param desc Optional std::string describing error.
\param file Optional argument specifying the file the error occured in.
\param line Optional argument specifying the line the error occured on.
**/
void ReportError(ZErrorCode code, string desc="", string file="", unsigned int line=0);
void ReportError(ZErrorCode code, std::string desc="", std::string file="", unsigned int line=0);
/*!
\brief Get the last error.
@ -550,11 +550,11 @@ class ZEngine
/*!
\brief Write to the log.
Write a string to the log, allowing special usage of the error log.
Write a std::string to the log, allowing special usage of the error log.
\since 0.8.2
\param str String to write to log file.
**/
void WriteLog(string str);
void WriteLog(std::string str);
/*!
\brief Flush Stack of Errors to file.
@ -628,7 +628,7 @@ class ZEngine
\param filename path to file to load.
\return A SDL_Surface pointer to data.
**/
SDL_Surface* LoadImage(string filename);
SDL_Surface* LoadImage(std::string filename);
#ifdef USE_SDL_MIXER
/*!
@ -638,7 +638,7 @@ class ZEngine
\param filename path to file to load.
\return A Mix_Chunk pointer to data.
**/
Mix_Chunk* LoadSound(string filename);
Mix_Chunk* LoadSound(std::string filename);
/*!
\brief Load a Music File
@ -647,7 +647,7 @@ class ZEngine
\param filename path to file to load.
\return A Mix_Music pointer to data.
**/
Mix_Music* LoadMusic(string filename);
Mix_Music* LoadMusic(std::string filename);
#endif
#ifdef USE_SDL_TTF
@ -659,7 +659,7 @@ class ZEngine
\param size point size of font
\return A TTF_Font pointer to data.
**/
TTF_Font* LoadFont(string filename, int size);
TTF_Font* LoadFont(std::string filename, int size);
#endif
/////////////

View File

@ -14,7 +14,7 @@
Definition file for ZError, the Error logging class for ZEngine.
This class should never be used by the average user, it is used by ZEngine to store information on an error.
<br>$Id: ZE_ZError.h,v 1.10 2003/06/06 03:02:55 cozman Exp $<br>
<br>$Id: ZE_ZError.h,v 1.11 2003/06/11 00:15:25 cozman Exp $<br>
\author James Turk
**/
@ -23,7 +23,6 @@
#include "ZE_Utility.h"
#include <string>
using namespace std;
namespace ZE
{
@ -67,28 +66,28 @@ class ZError
{
protected:
//! Static Array of Error Identifiers
static string *sErrorDesc;
static std::string *sErrorDesc;
//! Error ID.
ZErrorCode rCode;
//! Error Description.
string rDescription;
std::string rDescription;
//! File which error occured in.
string rFilename;
std::string rFilename;
//! Line which error occured on.
unsigned int rLine;
public:
/*!
\brief Construct string table for error strings.
\brief Construct std::string table for error strings.
Constructs a string table for errors, enabling ZEngine to properly delete the table on exit.
Constructs a std::string table for errors, enabling ZEngine to properly delete the table on exit.
**/
static void CreateStringTable();
/*!
\brief Destroy string table of error strings.
\brief Destroy std::string table of error strings.
Properly delete the string table, freeing all memory used by the strings.
Properly delete the std::string table, freeing all memory used by the strings.
**/
static void DestroyStringTable();
@ -101,7 +100,7 @@ class ZError
\param file Optional argument specifying the file the error occured in.
\param line Optional argument specifying the line the error occured on.
**/
ZError(ZErrorCode code=ZERR_NONE, string desc="", string file="", int line=0);
ZError(ZErrorCode code=ZERR_NONE, std::string desc="", std::string file="", int line=0);
/*!
\brief Virtual Destructor.
@ -119,7 +118,7 @@ class ZError
\param file Optional argument specifying the file the error occured in.
\param line Optional argument specifying the line the error occured on.
**/
void Create(ZErrorCode code, string desc="", string file="", int line=0);
void Create(ZErrorCode code, std::string desc="", std::string file="", int line=0);
/////////////
//Accessors//
@ -134,11 +133,11 @@ class ZError
ZErrorCode Code() const;
/*!
\brief Get formatted string for log file.
\brief Get formatted std::string for log file.
Return the string to be written to the logfile. Called by ZEngine in LogError.
Return the std::string to be written to the logfile. Called by ZEngine in LogError.
**/
string LogString() const;
std::string LogString() const;
};
}

View File

@ -41,7 +41,7 @@ class ZFont
//! Pointer to font data.
TTF_Font *rFont;
//! Filename, for resizing.
string rFilename;
std::string rFilename;
//! SDL_Color for current text color.
SDL_Color rColor;
//! SDL_Color for background color to be used in shaded draws.
@ -67,7 +67,7 @@ class ZFont
\param filename Font to open.
\param size Size to use for font.
**/
ZFont(string filename, int size);
ZFont(std::string filename, int size);
/*!
\brief Destructor, frees memory.
@ -83,7 +83,7 @@ class ZFont
\param filename Font to open.
\param size Size to use for font.
**/
void Open(string filename, int size);
void Open(std::string filename, int size);
/*!
\brief Release font.
@ -97,22 +97,22 @@ class ZFont
////////////////////////
/*!
\brief Draws a string in a color to a ZImage.
\brief Draws a std::string in a color to a ZImage.
Draw to a surface in specified color and associate that surface with a ZImage.
\param text String to write.
\param image ZImage to draw to.
**/
void DrawText(string text, ZImage &image) const;
void DrawText(std::string text, ZImage &image) const;
/*!
\brief Draws a string with a colored background to a ZImage.
\brief Draws a std::string with a colored background to a ZImage.
Draw to a surface a string with a background of rBGColor and lettering in the normal color and associate that surface with a ZImage.
Draw to a surface a std::string with a background of rBGColor and lettering in the normal color and associate that surface with a ZImage.
\param text String to write.
\param image ZImage to draw to.
**/
void DrawShadedText(string text, ZImage &image) const;
void DrawShadedText(std::string text, ZImage &image) const;
/*!
\brief Set Text rColor.
@ -211,7 +211,7 @@ class ZFont
\param text String to get width of.
\return Width of String in Current font.
**/
int StringWidth(string text) const;
int StringWidth(std::string text) const;
/*!
\brief Get String Height.
@ -220,7 +220,7 @@ class ZFont
\param text String to get height of.
\return Height of String in Current font.
**/
int StringHeight(string text) const;
int StringHeight(std::string text) const;
};
}

View File

@ -13,7 +13,7 @@
\brief Definition file for ZImage.
Definition file for ZImage, the OpenGL version of the ZImage class for ZEngine.
<br>$Id: ZE_ZImage.h,v 1.18 2003/05/13 01:30:51 cozman Exp $<br>
<br>$Id: ZE_ZImage.h,v 1.19 2003/06/11 00:15:26 cozman Exp $<br>
\author James Turk
**/
@ -77,7 +77,7 @@ class ZImage
Constructor is same as calling ZImage::Open() on passed filename.
\param filename File to open as rImage.
**/
ZImage(string filename);
ZImage(std::string filename);
/*!
\brief Constructor to Construct from SDL_Surface*.
@ -130,7 +130,7 @@ class ZImage
Open a file using ZEngine. Loads into rImage member of class.
\param filename File to open as rImage.
**/
void Open(string filename);
void Open(std::string filename);
/*!
\brief Cuts part of an existing image to create a new image.

View File

@ -13,7 +13,7 @@
\brief Definition file for ZMusic.
Definition file for ZMusic, the Music file wrapper for ZEngine.
<br>$Id: ZE_ZMusic.h,v 1.8 2003/05/13 01:30:51 cozman Exp $<br>
<br>$Id: ZE_ZMusic.h,v 1.9 2003/06/11 00:15:26 cozman Exp $<br>
\author James Turk
**/
@ -61,7 +61,7 @@ class ZMusic
Constructor simply calls ZMusic::Open() with same filename. (WAV,MOD,MID,OGG)
\param filename Music to open.
**/
ZMusic(string filename);
ZMusic(std::string filename);
/*!
\brief Destructor, frees memory.
@ -76,7 +76,7 @@ class ZMusic
Open a music file to be used.
\param filename Music to open.
**/
void Open(string filename);
void Open(std::string filename);
/*!
\brief Release music.

View File

@ -13,7 +13,7 @@
\brief Definition file for ZSound.
Definition file for ZSound, the Sound Effect wrapper for ZEngine.
<br>$Id: ZE_ZSound.h,v 1.8 2003/05/13 01:30:51 cozman Exp $<br>
<br>$Id: ZE_ZSound.h,v 1.9 2003/06/11 00:15:26 cozman Exp $<br>
\author James Turk
**/
@ -63,7 +63,7 @@ class ZSound
Constructor simply calls ZSound::Open() with same filename. (WAV,MOD,MID,OGG)
\param filename Sound effect to open.
**/
ZSound(string filename);
ZSound(std::string filename);
/*!
\brief Destructor, frees memory.
@ -78,7 +78,7 @@ class ZSound
Open a music file to be used.
\param filename Music to open.
**/
void Open(string filename);
void Open(std::string filename);
/*!
\brief Release sound effect.

View File

@ -6,17 +6,17 @@
Implementation file for VersinInfo class, simple class for containing and comparing
version numbers.
<br>$Id: VersionInfo.cpp,v 1.2 2003/06/10 23:24:47 cozman Exp $<br>
<br>$Id: VersionInfo.cpp,v 1.3 2003/06/11 00:15:07 cozman Exp $<br>
\author James Turk
**/
VersionInfo::VersionInfo(unsigned int maj, unsigned int min, unsigned int rel, string ext) :
VersionInfo::VersionInfo(unsigned int maj, unsigned int min, unsigned int rel, std::string ext) :
major(maj), minor(min), release(rel), extra(ext)
{
}
string VersionInfo::GetString() const
std::string VersionInfo::GetString() const
{
if(extra.length())
return ZE::FormatStr("%d.%d.%d [%s]",major,minor,release,extra.c_str());

View File

@ -13,7 +13,7 @@
\brief Source file for ZEngine utility functions.
Source file containing open utilities for use inside and alongside ZEngine.
<br>$Id: ZE_Utility.cpp,v 1.7 2003/05/13 01:31:30 cozman Exp $<br>
<br>$Id: ZE_Utility.cpp,v 1.8 2003/06/11 00:15:08 cozman Exp $<br>
\author James Turk
**/
@ -22,7 +22,7 @@
namespace ZE
{
string FormatStr(const char *fmtstr, ...)
std::string FormatStr(const char *fmtstr, ...)
{
char buf[512];
va_list args;

View File

@ -13,7 +13,7 @@
\brief Source file for ZClient.
Implementation file for ZClient, the TCP Client class for ZEngine.
<br>$Id: ZE_ZClient.cpp,v 1.7 2003/05/13 01:31:30 cozman Exp $<br>
<br>$Id: ZE_ZClient.cpp,v 1.8 2003/06/11 00:15:08 cozman Exp $<br>
\author James Turk
**/
@ -24,7 +24,7 @@
namespace ZE
{
string num2dotted4(unsigned int num)
std::string num2dotted4(unsigned int num)
{
vector<int> ip;
int d=16777216; //2^24

View File

@ -13,7 +13,7 @@
\brief Source file for ZConfigFile.
Implementation of ZConfigFile, the ZEngine INI-Style Config File.
<br>$Id: ZE_ZConfigFile.cpp,v 1.10 2003/05/13 01:31:30 cozman Exp $<br>
<br>$Id: ZE_ZConfigFile.cpp,v 1.11 2003/06/11 00:15:08 cozman Exp $<br>
\author James Turk
**/
@ -22,13 +22,13 @@
namespace ZE
{
string ZConfigFile::CleanString(string str) const
std::string ZConfigFile::CleanString(std::string str) const
{
string tmpStr;
std::string tmpStr;
bool inQuotes = false;
//cycle through, only copy spaces and if a character is uppercase, convert it to lowercase
for(string::size_type i = 0; i < str.length(); ++i)
for(std::string::size_type i = 0; i < str.length(); ++i)
{
if(!isspace(str[i]) || inQuotes)
{
@ -42,9 +42,9 @@ string ZConfigFile::CleanString(string str) const
return tmpStr;
}
bool ZConfigFile::Exists(string sec) const
bool ZConfigFile::Exists(std::string sec) const
{
list<ZCF_Section>::const_iterator secIter;
std::list<ZCF_Section>::const_iterator secIter;
sec = CleanString(sec);
@ -56,10 +56,10 @@ bool ZConfigFile::Exists(string sec) const
return false;
}
bool ZConfigFile::Exists(string sec, string var) const
bool ZConfigFile::Exists(std::string sec, std::string var) const
{
list<ZCF_Section>::const_iterator secIter;
list<ZCF_Variable>::const_iterator varIter;
std::list<ZCF_Section>::const_iterator secIter;
std::list<ZCF_Variable>::const_iterator varIter;
sec = CleanString(sec);
var = CleanString(var);
@ -78,10 +78,10 @@ bool ZConfigFile::Exists(string sec, string var) const
return false;
}
void ZConfigFile::SetVariable(string sec, string var, string val)
void ZConfigFile::SetVariable(std::string sec, std::string var, std::string val)
{
list<ZCF_Section>::iterator secIter;
list<ZCF_Variable>::iterator varIter;
std::list<ZCF_Section>::iterator secIter;
std::list<ZCF_Variable>::iterator varIter;
if(Exists(CleanString(sec)))
{
@ -122,10 +122,10 @@ void ZConfigFile::SetVariable(string sec, string var, string val)
}
}
string ZConfigFile::GetVariable(string sec, string var, string defVal) const
std::string ZConfigFile::GetVariable(std::string sec, std::string var, std::string defVal) const
{
list<ZCF_Section>::const_iterator secIter;
list<ZCF_Variable>::const_iterator varIter;
std::list<ZCF_Section>::const_iterator secIter;
std::list<ZCF_Variable>::const_iterator varIter;
sec = CleanString(sec);
var = CleanString(var);
@ -159,7 +159,7 @@ string ZConfigFile::GetVariable(string sec, string var, string defVal) const
ZConfigFile::ZConfigFile() {}
ZConfigFile::ZConfigFile(string rFilename)
ZConfigFile::ZConfigFile(std::string rFilename)
{
Process(rFilename);
}
@ -169,35 +169,35 @@ ZConfigFile::~ZConfigFile()
Close();
}
void ZConfigFile::Process(string filename)
void ZConfigFile::Process(std::string filename)
{
rFilename = filename;
ifstream cfile(rFilename.c_str());
string section, str, var, tmp;
std::ifstream cfile(rFilename.c_str());
std::string section, str, var, tmp;
rFileLayout.clear();
while(!cfile.eof() && cfile.is_open())
{
getline(cfile,str); //read in a line
std::getline(cfile,str); //read in a line
tmp = CleanString(str); //get a clean version
//if string is bracketed it is a section, if it begins in a letter it is a variable
//if std::string is bracketed it is a section, if it begins in a letter it is a variable
if(tmp[0] == '[' && tmp[tmp.length()-1] == ']')
section = str;
else if(isalpha(tmp[0]))
{
var = str.substr(0,str.find('=')); //split the string at the equals sign
var = str.substr(0,str.find('=')); //split the std::string at the equals sign
SetVariable(section,var,str.substr(str.find('=')+1,str.length()-var.length()-1));
}
}
cfile.close();
}
float ZConfigFile::GetFloat(string section, string var, float defVal) const
float ZConfigFile::GetFloat(std::string section, std::string var, float defVal) const
{
string val;
std::string val;
char tmp[20];
section = CleanString(section);
@ -214,9 +214,9 @@ float ZConfigFile::GetFloat(string section, string var, float defVal) const
return static_cast<float>(atof(val.c_str())); //atof returns a double(?!)
}
int ZConfigFile::GetInt(string section, string var, int defVal) const
int ZConfigFile::GetInt(std::string section, std::string var, int defVal) const
{
string val;
std::string val;
char tmp[20];
section = CleanString(section);
@ -233,9 +233,9 @@ int ZConfigFile::GetInt(string section, string var, int defVal) const
return atoi(val.c_str());
}
bool ZConfigFile::GetBool(string section, string var, bool defVal) const
bool ZConfigFile::GetBool(std::string section, std::string var, bool defVal) const
{
string val,tmp;
std::string val,tmp;
section = CleanString(section);
var = CleanString(var);
@ -253,9 +253,9 @@ bool ZConfigFile::GetBool(string section, string var, bool defVal) const
return defVal;
}
string ZConfigFile::GetString(string section, string var, string defVal) const
std::string ZConfigFile::GetString(std::string section, std::string var, std::string defVal) const
{
string val;
std::string val;
section = CleanString(section);
var = CleanString(var);
@ -273,7 +273,7 @@ string ZConfigFile::GetString(string section, string var, string defVal) const
return val;
}
void ZConfigFile::SetFloat(string section, string var, float val)
void ZConfigFile::SetFloat(std::string section, std::string var, float val)
{
char buf[20];
sprintf(buf,"%f",val);
@ -282,7 +282,7 @@ void ZConfigFile::SetFloat(string section, string var, float val)
SetVariable(section,var,buf);
}
void ZConfigFile::SetInt(string section, string var, int val)
void ZConfigFile::SetInt(std::string section, std::string var, int val)
{
char buf[20];
sprintf(buf,"%d",val);
@ -291,15 +291,15 @@ void ZConfigFile::SetInt(string section, string var, int val)
SetVariable(section,var,buf);
}
void ZConfigFile::SetBool(string section, string var, bool val)
void ZConfigFile::SetBool(std::string section, std::string var, bool val)
{
string tmp = val ? "true" : "false";
std::string tmp = val ? "true" : "false";
section = '[' + section + ']';
SetVariable(section,var,tmp);
}
void ZConfigFile::SetString(string section, string var, string val)
void ZConfigFile::SetString(std::string section, std::string var, std::string val)
{
section = '[' + section + ']';
val = "\"" + val + "\"";
@ -308,14 +308,14 @@ void ZConfigFile::SetString(string section, string var, string val)
void ZConfigFile::Flush()
{
list<ZCF_Section>::iterator secIter;
list<ZCF_Variable>::iterator varIter;
string secName;
std::list<ZCF_Section>::iterator secIter;
std::list<ZCF_Variable>::iterator varIter;
std::string secName;
//in case the filename is already cleared somehow
if(rFilename.length())
{
ofstream cfile(rFilename.c_str(), ios::out|ios::trunc);
std::ofstream cfile(rFilename.c_str(), std::ios::out|std::ios::trunc);
if(cfile)
{
@ -326,13 +326,13 @@ void ZConfigFile::Flush()
secName = CleanString((*secIter).section);
if(secName.length() && secName[0] == '[' && secName[secName.length()-1] == ']')
{
cfile << (*secIter).section << endl; //write out raw section title
cfile << (*secIter).section << std::endl; //write out raw section title
//for each variable in section, write out variable=value
for(varIter = (*secIter).varList.begin(); varIter != (*secIter).varList.end(); ++varIter)
{
if(CleanString((*varIter).var).length()) //ensures that variable is valid
cfile << (*varIter).var << '=' << (*varIter).val << endl;
cfile << (*varIter).var << '=' << (*varIter).val << std::endl;
}
}
}

View File

@ -13,7 +13,7 @@
\brief Central source file for ZEngine.
Actual implementation of ZEngine singleton class, the core of ZEngine.
<br>$Id: ZE_ZEngine.cpp,v 1.44 2003/06/10 23:24:47 cozman Exp $<br>
<br>$Id: ZE_ZEngine.cpp,v 1.45 2003/06/11 00:15:08 cozman Exp $<br>
\author James Turk
**/
@ -22,7 +22,7 @@
namespace ZE
{
VersionInfo ZEngine::Version(0,8,3);
VersionInfo ZEngine::Version(0,8,4,"dev");
ZEngine *ZEngine::sInstance=NULL;
ZEngine::ZEngine()
@ -97,7 +97,7 @@ void ZEngine::SetupSound(int rate, bool stereo)
}
#endif
bool ZEngine::CreateDisplay(string title, string icon)
bool ZEngine::CreateDisplay(std::string title, std::string icon)
{
Uint32 flags=0;
SDL_Surface *iconImg;
@ -557,24 +557,24 @@ void ZEngine::SetEventFilter(SDL_EventFilter filter)
#ifdef USE_PHYSFS
void ZEngine::InitPhysFS(string argv)
void ZEngine::InitPhysFS(std::string argv)
{
string::size_type pos;
std::string::size_type pos;
PHYSFS_init(argv.c_str());
pos = argv.rfind(PHYSFS_getDirSeparator());
if(pos != string::npos)
if(pos != std::string::npos)
AddPhysFSDir(argv.substr(0,pos));
}
void ZEngine::AddPhysFSDir(string dir)
void ZEngine::AddPhysFSDir(std::string dir)
{
PHYSFS_addToSearchPath(dir.c_str(),0);
}
#endif //USE_PHYSFS
void ZEngine::SetErrorLog(bool logAll, string logFile)
void ZEngine::SetErrorLog(bool logAll, std::string logFile)
{
mLogAllErrors = logAll;
if(logFile.length())
@ -588,7 +588,7 @@ void ZEngine::SetErrorLog(bool logAll, string logFile)
}
}
void ZEngine::ReportError(ZErrorCode code, string desc, string file, unsigned int line)
void ZEngine::ReportError(ZErrorCode code, std::string desc, std::string file, unsigned int line)
{
mCurError.Create(code,desc,file,line);
@ -608,7 +608,7 @@ ZErrorCode ZEngine::GetLastError()
return code;
}
void ZEngine::WriteLog(string str)
void ZEngine::WriteLog(std::string str)
{
fprintf(mErrlog,str.c_str());
fprintf(mErrlog,"\n");
@ -654,7 +654,7 @@ double ZEngine::RandDouble(double min, double max)
return min + (genrand_real1()*(max-min));
}
SDL_Surface* ZEngine::LoadImage(string filename)
SDL_Surface* ZEngine::LoadImage(std::string filename)
{
SDL_Surface *image;
//using physfs//
@ -694,7 +694,7 @@ SDL_Surface* ZEngine::LoadImage(string filename)
#ifdef USE_SDL_MIXER
Mix_Chunk* ZEngine::LoadSound(string filename)
Mix_Chunk* ZEngine::LoadSound(std::string filename)
{
Mix_Chunk *sound;
@ -716,7 +716,7 @@ Mix_Chunk* ZEngine::LoadSound(string filename)
return sound;
}
Mix_Music* ZEngine::LoadMusic(string filename)
Mix_Music* ZEngine::LoadMusic(std::string filename)
{
Mix_Music *music;
@ -743,7 +743,7 @@ Mix_Music* ZEngine::LoadMusic(string filename)
#ifdef USE_SDL_TTF
TTF_Font* ZEngine::LoadFont(string filename, int size)
TTF_Font* ZEngine::LoadFont(std::string filename, int size)
{
TTF_Font *font;

View File

@ -13,7 +13,7 @@
\brief Source file for ZError.
Implementation of ZError, the ZEngine internal error information storage class.
<br>$Id: ZE_ZError.cpp,v 1.8 2003/05/13 01:31:30 cozman Exp $<br>
<br>$Id: ZE_ZError.cpp,v 1.9 2003/06/11 00:15:09 cozman Exp $<br>
\author James Turk
**/
@ -22,13 +22,13 @@
namespace ZE
{
string *ZError::sErrorDesc = NULL;
std::string *ZError::sErrorDesc = NULL;
void ZError::CreateStringTable()
{
if(!sErrorDesc)
{
sErrorDesc = new string[ZERR_LAST];
sErrorDesc = new std::string[ZERR_LAST];
sErrorDesc[ZERR_NONE] = "No Error. [%s]";
sErrorDesc[ZERR_SDL_INTERNAL] = "SDL Error. [%s]";
sErrorDesc[ZERR_SDL_INIT] = "Error Initializing SDL: %s";
@ -59,7 +59,7 @@ void ZError::DestroyStringTable()
}
}
ZError::ZError(ZErrorCode code, string desc, string file, int line)
ZError::ZError(ZErrorCode code, std::string desc, std::string file, int line)
{
rCode = code;
rDescription = desc;
@ -71,7 +71,7 @@ ZError::~ZError()
{
}
void ZError::Create(ZErrorCode code, string desc, string file, int line)
void ZError::Create(ZErrorCode code, std::string desc, std::string file, int line)
{
rCode = code;
rDescription = desc;
@ -84,9 +84,9 @@ ZErrorCode ZError::Code() const
return rCode;
}
string ZError::LogString() const
std::string ZError::LogString() const
{
string msg;
std::string msg;
msg = rDescription.length() ? FormatStr(sErrorDesc[rCode].c_str(),rDescription.c_str()) : sErrorDesc[rCode];

View File

@ -13,7 +13,7 @@
\brief Source file for ZFont.
Implementation of ZFont, the basic Font class for ZEngine.
<br>$Id: ZE_ZFont.cpp,v 1.10 2003/05/13 01:31:30 cozman Exp $<br>
<br>$Id: ZE_ZFont.cpp,v 1.11 2003/06/11 00:15:09 cozman Exp $<br>
\author James Turk
**/
@ -32,7 +32,7 @@ ZFont::ZFont()
rBGColor.r = rBGColor.g = rBGColor.b = rBGColor.unused = 0;
}
ZFont::ZFont(string filename, int size)
ZFont::ZFont(std::string filename, int size)
{
rEngine = ZEngine::GetInstance();
rFont = NULL;
@ -46,7 +46,7 @@ ZFont::~ZFont()
Release();
}
void ZFont::Open(string filename, int size)
void ZFont::Open(std::string filename, int size)
{
Release();
rFont = rEngine->LoadFont(filename,size);
@ -57,12 +57,12 @@ void ZFont::Release()
FreeFont(rFont);
}
void ZFont::DrawText(string text, ZImage &image) const
void ZFont::DrawText(std::string text, ZImage &image) const
{
image.Attach(TTF_RenderText_Solid(rFont, text.c_str(), rColor));
}
void ZFont::DrawShadedText(string text, ZImage &image) const
void ZFont::DrawShadedText(std::string text, ZImage &image) const
{
image.Attach(TTF_RenderText_Shaded(rFont, text.c_str(), rColor, rBGColor));
}
@ -165,7 +165,7 @@ int ZFont::LineSkip() const
}
}
int ZFont::StringWidth(string text) const
int ZFont::StringWidth(std::string text) const
{
int w,h;
@ -181,7 +181,7 @@ int ZFont::StringWidth(string text) const
}
}
int ZFont::StringHeight(string text) const
int ZFont::StringHeight(std::string text) const
{
int w,h;

View File

@ -13,7 +13,7 @@
\brief Source file for ZImage.
Implementation of ZImage, the Image class for ZEngine.
<br>$Id: ZE_ZImage.cpp,v 1.33 2003/06/02 02:16:57 cozman Exp $<br>
<br>$Id: ZE_ZImage.cpp,v 1.34 2003/06/11 00:15:09 cozman Exp $<br>
\author James Turk
**/
@ -38,7 +38,7 @@ ZImage::ZImage(const ZImage &rhs)
OpenFromImage(rhs.Surface(),0,0,(Sint16)rhs.Width(),(Sint16)rhs.Height());
}
ZImage::ZImage(string filename)
ZImage::ZImage(std::string filename)
{
rEngine = ZEngine::GetInstance();
rImage = NULL;
@ -75,7 +75,7 @@ ZImage::~ZImage()
Release();
}
void ZImage::Open(string filename)
void ZImage::Open(std::string filename)
{
SDL_Surface *image;

View File

@ -13,7 +13,7 @@
\brief Source file for ZMusic.
Implementation of ZMusic, the basic Music class for ZEngine.
<br>$Id: ZE_ZMusic.cpp,v 1.8 2003/05/13 01:31:30 cozman Exp $<br>
<br>$Id: ZE_ZMusic.cpp,v 1.9 2003/06/11 00:15:10 cozman Exp $<br>
\author James Turk
**/
@ -32,7 +32,7 @@ ZMusic::ZMusic()
rMusic = NULL;
}
ZMusic::ZMusic(string filename)
ZMusic::ZMusic(std::string filename)
{
rEngine = ZEngine::GetInstance();
rMusic = NULL;
@ -44,7 +44,7 @@ ZMusic::~ZMusic()
Release();
}
void ZMusic::Open(string filename)
void ZMusic::Open(std::string filename)
{
Release();
rMusic = rEngine->LoadMusic(filename);

View File

@ -13,7 +13,7 @@
\brief Source file for ZSound.
Implementation of ZSound, the basic Sound class for ZEngine.
<br>$Id: ZE_ZSound.cpp,v 1.8 2003/05/13 01:31:30 cozman Exp $<br>
<br>$Id: ZE_ZSound.cpp,v 1.9 2003/06/11 00:15:10 cozman Exp $<br>
\author James Turk
**/
@ -33,7 +33,7 @@ ZSound::ZSound()
rChannelID = -1; //request channel ID
}
ZSound::ZSound(string filename)
ZSound::ZSound(std::string filename)
{
rEngine = ZEngine::GetInstance();
rSound = NULL;
@ -46,7 +46,7 @@ ZSound::~ZSound()
Release();
}
void ZSound::Open(string filename)
void ZSound::Open(std::string filename)
{
Release();
rSound = rEngine->LoadSound(filename);