summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-08-12 21:32:57 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-08-12 21:32:57 (GMT)
commit8ca27520a437bf33fb374d5a88731605cd3739e7 (patch)
treef081511e0f26946016529382c68000d3c6ea5a3a /src/client
parentca7c0e7370542a97dd03210e13ec2c56679d5ca4 (diff)
downloadpowder-8ca27520a437bf33fb374d5a88731605cd3739e7.zip
powder-8ca27520a437bf33fb374d5a88731605cd3739e7.tar.gz
Use forward declarations more to avoid excessive includes
Diffstat (limited to 'src/client')
-rw-r--r--src/client/Client.cpp179
-rw-r--r--src/client/Client.h61
-rw-r--r--src/client/GameSave.cpp24
-rw-r--r--src/client/GameSave.h9
-rw-r--r--src/client/SaveFile.cpp11
-rw-r--r--src/client/SaveFile.h18
-rw-r--r--src/client/SaveInfo.cpp29
-rw-r--r--src/client/SaveInfo.h32
-rw-r--r--src/client/ThumbnailBroker.cpp1
-rw-r--r--src/client/User.h8
10 files changed, 190 insertions, 182 deletions
diff --git a/src/client/Client.cpp b/src/client/Client.cpp
index 9908e69..192c87b 100644
--- a/src/client/Client.cpp
+++ b/src/client/Client.cpp
@@ -7,6 +7,7 @@
#include <time.h>
#include <stdio.h>
#include <deque>
+#include <fstream>
#ifdef MACOSX
#include <mach-o/dyld.h>
@@ -29,14 +30,22 @@
#include "MD5.h"
#include "graphics/Graphics.h"
#include "Misc.h"
+#include "Update.h"
+#include "HTTP.h"
#include "simulation/SaveRenderer.h"
#include "interface/Point.h"
#include "client/SaveInfo.h"
+#include "client/SaveFile.h"
+#include "client/GameSave.h"
+#include "search/Thumbnail.h"
+#include "preview/Comment.h"
#include "ClientListener.h"
-#include "Update.h"
#include "ThumbnailBroker.h"
+#include "cajun/reader.h"
+#include "cajun/writer.h"
+
extern "C"
{
#if defined(WIN) && !defined(__GNUC__)
@@ -65,13 +74,13 @@ Client::Client():
//Read config
std::ifstream configFile;
- configFile.open("powder.pref", ios::binary);
+ configFile.open("powder.pref", std::ios::binary);
if(configFile)
{
int fsize = configFile.tellg();
configFile.seekg(0, std::ios::end);
fsize = configFile.tellg() - (std::streampos)fsize;
- configFile.seekg(0, ios::beg);
+ configFile.seekg(0, std::ios::beg);
if(fsize)
{
json::Reader::Read(configDocument, configFile);
@@ -84,11 +93,11 @@ Client::Client():
std::string userElevation = ((json::String)(configDocument["User"]["Elevation"])).Value();
if(userElevation == "Admin")
- authUser.UserElevation = ElevationAdmin;
+ authUser.UserElevation = User::ElevationAdmin;
else if(userElevation == "Mod")
- authUser.UserElevation = ElevationModerator;
+ authUser.UserElevation = User::ElevationModerator;
else
- authUser.UserElevation= ElevationNone;
+ authUser.UserElevation = User::ElevationNone;
}
catch (json::Exception &e)
{
@@ -116,7 +125,7 @@ void Client::Initialise(std::string proxyString)
//Read stamps library
std::ifstream stampsLib;
- stampsLib.open(STAMPS_DIR PATH_SEP "stamps.def", ios::binary);
+ stampsLib.open(STAMPS_DIR PATH_SEP "stamps.def", std::ios::binary);
while(true)
{
char data[11];
@@ -404,7 +413,7 @@ void Client::WriteFile(std::vector<unsigned char> fileData, std::string filename
try
{
std::ofstream fileStream;
- fileStream.open(string(filename).c_str(), ios::binary);
+ fileStream.open(std::string(filename).c_str(), std::ios::binary);
if(fileStream.is_open())
{
fileStream.write((char*)&fileData[0], fileData.size());
@@ -424,7 +433,7 @@ bool Client::FileExists(std::string filename)
try
{
std::ifstream fileStream;
- fileStream.open(string(filename).c_str(), ios::binary);
+ fileStream.open(std::string(filename).c_str(), std::ios::binary);
if(fileStream.is_open())
{
exists = true;
@@ -443,7 +452,7 @@ void Client::WriteFile(std::vector<char> fileData, std::string filename)
try
{
std::ofstream fileStream;
- fileStream.open(string(filename).c_str(), ios::binary);
+ fileStream.open(std::string(filename).c_str(), std::ios::binary);
if(fileStream.is_open())
{
fileStream.write(&fileData[0], fileData.size());
@@ -462,10 +471,10 @@ std::vector<unsigned char> Client::ReadFile(std::string filename)
try
{
std::ifstream fileStream;
- fileStream.open(string(filename).c_str(), ios::binary);
+ fileStream.open(std::string(filename).c_str(), std::ios::binary);
if(fileStream.is_open())
{
- fileStream.seekg(0, ios::end);
+ fileStream.seekg(0, std::ios::end);
size_t fileSize = fileStream.tellg();
fileStream.seekg(0);
@@ -652,7 +661,7 @@ void Client::Shutdown()
//Save config
std::ofstream configFile;
- configFile.open("powder.pref", ios::trunc);
+ configFile.open("powder.pref", std::ios::trunc);
if(configFile)
{
if(authUser.ID)
@@ -661,9 +670,9 @@ void Client::Shutdown()
configDocument["User"]["SessionID"] = json::String(authUser.SessionID);
configDocument["User"]["SessionKey"] = json::String(authUser.SessionKey);
configDocument["User"]["Username"] = json::String(authUser.Username);
- if(authUser.UserElevation == ElevationAdmin)
+ if(authUser.UserElevation == User::ElevationAdmin)
configDocument["User"]["Elevation"] = json::String("Admin");
- else if(authUser.UserElevation == ElevationModerator)
+ else if(authUser.UserElevation == User::ElevationModerator)
configDocument["User"]["Elevation"] = json::String("Mod");
else
configDocument["User"]["Elevation"] = json::String("None");
@@ -767,13 +776,13 @@ RequestStatus Client::UploadSave(SaveInfo & save)
return RequestFailure;
}
-SaveFile * Client::GetStamp(string stampID)
+SaveFile * Client::GetStamp(std::string stampID)
{
std::ifstream stampFile;
- stampFile.open(string(STAMPS_DIR PATH_SEP + stampID + ".stm").c_str(), ios::binary);
+ stampFile.open(std::string(STAMPS_DIR PATH_SEP + stampID + ".stm").c_str(), std::ios::binary);
if(stampFile.is_open())
{
- stampFile.seekg(0, ios::end);
+ stampFile.seekg(0, std::ios::end);
size_t fileSize = stampFile.tellg();
stampFile.seekg(0);
@@ -781,7 +790,7 @@ SaveFile * Client::GetStamp(string stampID)
stampFile.read((char *)tempData, fileSize);
stampFile.close();
- SaveFile * file = new SaveFile(string(stampID).c_str());
+ SaveFile * file = new SaveFile(std::string(stampID).c_str());
GameSave * tempSave = new GameSave((char *)tempData, fileSize);
file->SetGameSave(tempSave);
return file;
@@ -792,13 +801,13 @@ SaveFile * Client::GetStamp(string stampID)
}
}
-void Client::DeleteStamp(string stampID)
+void Client::DeleteStamp(std::string stampID)
{
- for (std::list<string>::iterator iterator = stampIDs.begin(), end = stampIDs.end(); iterator != end; ++iterator)
+ for (std::list<std::string>::iterator iterator = stampIDs.begin(), end = stampIDs.end(); iterator != end; ++iterator)
{
if((*iterator) == stampID)
{
- stringstream stampFilename;
+ std::stringstream stampFilename;
stampFilename << STAMPS_DIR;
stampFilename << PATH_SEP;
stampFilename << stampID;
@@ -810,7 +819,7 @@ void Client::DeleteStamp(string stampID)
}
}
-string Client::AddStamp(GameSave * saveData)
+std::string Client::AddStamp(GameSave * saveData)
{
unsigned t=(unsigned)time(NULL);
if (lastStampTime!=t)
@@ -836,7 +845,7 @@ string Client::AddStamp(GameSave * saveData)
char * gameData = saveData->Serialise(gameDataLength);
std::ofstream stampStream;
- stampStream.open(string(STAMPS_DIR PATH_SEP + saveID.str()+".stm").c_str(), ios::binary);
+ stampStream.open(std::string(STAMPS_DIR PATH_SEP + saveID.str()+".stm").c_str(), std::ios::binary);
stampStream.write((const char *)gameData, gameDataLength);
stampStream.close();
@@ -857,8 +866,8 @@ void Client::updateStamps()
#endif
std::ofstream stampsStream;
- stampsStream.open(string(STAMPS_DIR PATH_SEP "stamps.def").c_str(), ios::binary);
- for (std::list<string>::const_iterator iterator = stampIDs.begin(), end = stampIDs.end(); iterator != end; ++iterator)
+ stampsStream.open(std::string(STAMPS_DIR PATH_SEP "stamps.def").c_str(), std::ios::binary);
+ for (std::list<std::string>::const_iterator iterator = stampIDs.begin(), end = stampIDs.end(); iterator != end; ++iterator)
{
stampsStream.write((*iterator).c_str(), 10);
}
@@ -872,17 +881,17 @@ int Client::GetStampsCount()
return stampIDs.size();
}
-vector<string> Client::GetStamps(int start, int count)
+std::vector<std::string> Client::GetStamps(int start, int count)
{
if(start+count > stampIDs.size()) {
if(start > stampIDs.size())
- return vector<string>();
+ return std::vector<std::string>();
count = stampIDs.size()-start;
}
- vector<string> stampRange;
+ std::vector<std::string> stampRange;
int index = 0;
- for (std::list<string>::const_iterator iterator = stampIDs.begin(), end = stampIDs.end(); iterator != end; ++iterator, ++index) {
+ for (std::list<std::string>::const_iterator iterator = stampIDs.begin(), end = stampIDs.end(); iterator != end; ++iterator, ++index) {
if(index>=start && index < start+count)
stampRange.push_back(*iterator);
}
@@ -979,7 +988,7 @@ std::vector<unsigned char> Client::GetSaveData(int saveID, int saveDate)
return saveData;
}
-LoginStatus Client::Login(string username, string password, User & user)
+LoginStatus Client::Login(std::string username, std::string password, User & user)
{
lastError = "";
std::stringstream urlStream;
@@ -1028,11 +1037,11 @@ LoginStatus Client::Login(string username, string password, User & user)
user.SessionKey = sessionKeyTemp.Value();
std::string userElevation = userElevationTemp.Value();
if(userElevation == "Admin")
- user.UserElevation = ElevationAdmin;
+ user.UserElevation = User::ElevationAdmin;
else if(userElevation == "Mod")
- user.UserElevation = ElevationModerator;
+ user.UserElevation = User::ElevationModerator;
else
- user.UserElevation= ElevationNone;
+ user.UserElevation= User::ElevationNone;
return LoginOkay;
}
else
@@ -1062,7 +1071,7 @@ LoginStatus Client::Login(string username, string password, User & user)
RequestStatus Client::DeleteSave(int saveID)
{
lastError = "";
- std::vector<string> * tags = NULL;
+ std::vector<std::string> * tags = NULL;
std::stringstream urlStream;
char * data = NULL;
int dataStatus, dataLength;
@@ -1114,7 +1123,7 @@ failure:
RequestStatus Client::AddComment(int saveID, std::string comment)
{
lastError = "";
- std::vector<string> * tags = NULL;
+ std::vector<std::string> * tags = NULL;
std::stringstream urlStream;
char * data = NULL;
int dataStatus, dataLength;
@@ -1175,7 +1184,7 @@ failure:
RequestStatus Client::FavouriteSave(int saveID, bool favourite)
{
lastError = "";
- std::vector<string> * tags = NULL;
+ std::vector<std::string> * tags = NULL;
std::stringstream urlStream;
char * data = NULL;
int dataStatus, dataLength;
@@ -1232,7 +1241,7 @@ failure:
RequestStatus Client::ReportSave(int saveID, std::string message)
{
lastError = "";
- std::vector<string> * tags = NULL;
+ std::vector<std::string> * tags = NULL;
std::stringstream urlStream;
char * data = NULL;
int dataStatus, dataLength;
@@ -1291,7 +1300,7 @@ failure:
RequestStatus Client::UnpublishSave(int saveID)
{
lastError = "";
- std::vector<string> * tags = NULL;
+ std::vector<std::string> * tags = NULL;
std::stringstream urlStream;
char * data = NULL;
int dataStatus, dataLength;
@@ -1383,7 +1392,7 @@ SaveInfo * Client::GetSave(int saveID, int saveDate)
json::Number tempComments = objDocument["Comments"];
json::Array tagsArray = objDocument["Tags"];
- vector<string> tempTags;
+ std::vector<std::string> tempTags;
for(int j = 0; j < tagsArray.Size(); j++)
{
@@ -1508,7 +1517,7 @@ std::vector<SaveComment*> * Client::GetComments(int saveID, int start, int count
return commentArray;
}
-std::vector<std::pair<std::string, int> > * Client::GetTags(int start, int count, string query, int & resultCount)
+std::vector<std::pair<std::string, int> > * Client::GetTags(int start, int count, std::string query, int & resultCount)
{
lastError = "";
resultCount = 0;
@@ -1557,7 +1566,7 @@ std::vector<std::pair<std::string, int> > * Client::GetTags(int start, int count
return tagArray;
}
-std::vector<SaveInfo*> * Client::SearchSaves(int start, int count, string query, string sort, std::string category, int & resultCount)
+std::vector<SaveInfo*> * Client::SearchSaves(int start, int count, std::string query, std::string sort, std::string category, int & resultCount)
{
lastError = "";
resultCount = 0;
@@ -1765,10 +1774,10 @@ Thumbnail * Client::GetThumbnail(int saveID, int saveDate)
return NULL;
}
-std::vector<string> * Client::RemoveTag(int saveID, string tag)
+std::vector<std::string> * Client::RemoveTag(int saveID, std::string tag)
{
lastError = "";
- std::vector<string> * tags = NULL;
+ std::vector<std::string> * tags = NULL;
std::stringstream urlStream;
char * data = NULL;
int dataStatus, dataLength;
@@ -1792,7 +1801,7 @@ std::vector<string> * Client::RemoveTag(int saveID, string tag)
json::Array tagsArray;
json::Reader::Read(tagsArray, dataStream);
- tags = new std::vector<string>();
+ tags = new std::vector<std::string>();
for(int j = 0; j < tagsArray.Size(); j++)
{
@@ -1814,10 +1823,10 @@ std::vector<string> * Client::RemoveTag(int saveID, string tag)
return tags;
}
-std::vector<string> * Client::AddTag(int saveID, string tag)
+std::vector<std::string> * Client::AddTag(int saveID, std::string tag)
{
lastError = "";
- std::vector<string> * tags = NULL;
+ std::vector<std::string> * tags = NULL;
std::stringstream urlStream;
char * data = NULL;
int dataStatus, dataLength;
@@ -1841,7 +1850,7 @@ std::vector<string> * Client::AddTag(int saveID, string tag)
json::Array tagsArray;
json::Reader::Read(tagsArray, dataStream);
- tags = new std::vector<string>();
+ tags = new std::vector<std::string>();
for(int j = 0; j < tagsArray.Size(); j++)
{
@@ -1863,11 +1872,11 @@ std::vector<string> * Client::AddTag(int saveID, string tag)
return tags;
}
-vector<std::string> Client::explodePropertyString(std::string property)
+std::vector<std::string> Client::explodePropertyString(std::string property)
{
- vector<string> stringArray;
- string current = "";
- for (string::iterator iter = property.begin(); iter != property.end(); ++iter) {
+ std::vector<std::string> stringArray;
+ std::string current = "";
+ for (std::string::iterator iter = property.begin(); iter != property.end(); ++iter) {
if (*iter == '.') {
if (current.length() > 0) {
stringArray.push_back(current);
@@ -1931,7 +1940,7 @@ int Client::GetPrefInteger(std::string property, int defaultValue)
{
}
- catch(exception & e)
+ catch(std::exception & e)
{
}
@@ -1959,19 +1968,19 @@ unsigned int Client::GetPrefUInteger(std::string property, unsigned int defaultV
{
}
- catch(exception & e)
+ catch(std::exception & e)
{
}
return defaultValue;
}
-vector<string> Client::GetPrefStringArray(std::string property)
+std::vector<std::string> Client::GetPrefStringArray(std::string property)
{
try
{
json::Array value = GetPref(property);
- vector<string> strArray;
+ std::vector<std::string> strArray;
for(json::Array::iterator iter = value.Begin(); iter != value.End(); ++iter)
{
try
@@ -1990,15 +1999,15 @@ vector<string> Client::GetPrefStringArray(std::string property)
{
}
- return vector<string>();
+ return std::vector<std::string>();
}
-vector<double> Client::GetPrefNumberArray(std::string property)
+std::vector<double> Client::GetPrefNumberArray(std::string property)
{
try
{
json::Array value = GetPref(property);
- vector<double> strArray;
+ std::vector<double> strArray;
for(json::Array::iterator iter = value.Begin(); iter != value.End(); ++iter)
{
try
@@ -2017,15 +2026,15 @@ vector<double> Client::GetPrefNumberArray(std::string property)
{
}
- return vector<double>();
+ return std::vector<double>();
}
-vector<int> Client::GetPrefIntegerArray(std::string property)
+std::vector<int> Client::GetPrefIntegerArray(std::string property)
{
try
{
json::Array value = GetPref(property);
- vector<int> intArray;
+ std::vector<int> intArray;
for(json::Array::iterator iter = value.Begin(); iter != value.End(); ++iter)
{
try
@@ -2051,15 +2060,15 @@ vector<int> Client::GetPrefIntegerArray(std::string property)
{
}
- return vector<int>();
+ return std::vector<int>();
}
-vector<unsigned int> Client::GetPrefUIntegerArray(std::string property)
+std::vector<unsigned int> Client::GetPrefUIntegerArray(std::string property)
{
try
{
json::Array value = GetPref(property);
- vector<unsigned int> intArray;
+ std::vector<unsigned int> intArray;
for(json::Array::iterator iter = value.Begin(); iter != value.End(); ++iter)
{
try
@@ -2085,15 +2094,15 @@ vector<unsigned int> Client::GetPrefUIntegerArray(std::string property)
{
}
- return vector<unsigned int>();
+ return std::vector<unsigned int>();
}
-vector<bool> Client::GetPrefBoolArray(std::string property)
+std::vector<bool> Client::GetPrefBoolArray(std::string property)
{
try
{
json::Array value = GetPref(property);
- vector<bool> strArray;
+ std::vector<bool> strArray;
for(json::Array::iterator iter = value.Begin(); iter != value.End(); ++iter)
{
try
@@ -2112,7 +2121,7 @@ vector<bool> Client::GetPrefBoolArray(std::string property)
{
}
- return vector<bool>();
+ return std::vector<bool>();
}
bool Client::GetPrefBool(std::string property, bool defaultValue)
@@ -2157,10 +2166,10 @@ void Client::SetPref(std::string property, unsigned int value)
SetPref(property, intValue);
}
-void Client::SetPref(std::string property, vector<string> value)
+void Client::SetPref(std::string property, std::vector<std::string> value)
{
json::Array newArray;
- for(vector<string>::iterator iter = value.begin(); iter != value.end(); ++iter)
+ for(std::vector<std::string>::iterator iter = value.begin(); iter != value.end(); ++iter)
{
newArray.Insert(json::String(*iter));
}
@@ -2168,10 +2177,10 @@ void Client::SetPref(std::string property, vector<string> value)
SetPref(property, newArrayValue);
}
-void Client::SetPref(std::string property, vector<double> value)
+void Client::SetPref(std::string property, std::vector<double> value)
{
json::Array newArray;
- for(vector<double>::iterator iter = value.begin(); iter != value.end(); ++iter)
+ for(std::vector<double>::iterator iter = value.begin(); iter != value.end(); ++iter)
{
newArray.Insert(json::Number(*iter));
}
@@ -2179,10 +2188,10 @@ void Client::SetPref(std::string property, vector<double> value)
SetPref(property, newArrayValue);
}
-void Client::SetPref(std::string property, vector<bool> value)
+void Client::SetPref(std::string property, std::vector<bool> value)
{
json::Array newArray;
- for(vector<bool>::iterator iter = value.begin(); iter != value.end(); ++iter)
+ for(std::vector<bool>::iterator iter = value.begin(); iter != value.end(); ++iter)
{
newArray.Insert(json::Boolean(*iter));
}
@@ -2190,10 +2199,10 @@ void Client::SetPref(std::string property, vector<bool> value)
SetPref(property, newArrayValue);
}
-void Client::SetPref(std::string property, vector<int> value)
+void Client::SetPref(std::string property, std::vector<int> value)
{
json::Array newArray;
- for(vector<int>::iterator iter = value.begin(); iter != value.end(); ++iter)
+ for(std::vector<int>::iterator iter = value.begin(); iter != value.end(); ++iter)
{
std::stringstream hexInt;
hexInt << std::hex << *iter;
@@ -2204,10 +2213,10 @@ void Client::SetPref(std::string property, vector<int> value)
SetPref(property, newArrayValue);
}
-void Client::SetPref(std::string property, vector<unsigned int> value)
+void Client::SetPref(std::string property, std::vector<unsigned int> value)
{
json::Array newArray;
- for(vector<unsigned int>::iterator iter = value.begin(); iter != value.end(); ++iter)
+ for(std::vector<unsigned int>::iterator iter = value.begin(); iter != value.end(); ++iter)
{
std::stringstream hexInt;
hexInt << std::hex << *iter;
@@ -2226,17 +2235,17 @@ void Client::SetPref(std::string property, bool value)
json::UnknownElement Client::GetPref(std::string property)
{
- vector<string> pTokens = Client::explodePropertyString(property);
+ std::vector<std::string> pTokens = Client::explodePropertyString(property);
const json::UnknownElement & configDocumentCopy = configDocument;
json::UnknownElement currentRef = configDocumentCopy;
- for(vector<string>::iterator iter = pTokens.begin(); iter != pTokens.end(); ++iter)
+ for(std::vector<std::string>::iterator iter = pTokens.begin(); iter != pTokens.end(); ++iter)
{
currentRef = ((const json::UnknownElement &)currentRef)[*iter];
}
return currentRef;
}
-void Client::setPrefR(std::deque<string> tokens, json::UnknownElement & element, json::UnknownElement & value)
+void Client::setPrefR(std::deque<std::string> tokens, json::UnknownElement & element, json::UnknownElement & value)
{
if(tokens.size())
{
@@ -2250,9 +2259,9 @@ void Client::setPrefR(std::deque<string> tokens, json::UnknownElement & element,
void Client::SetPref(std::string property, json::UnknownElement & value)
{
- vector<string> pTokens = Client::explodePropertyString(property);
- deque<string> dTokens(pTokens.begin(), pTokens.end());
- string token = dTokens.front();
+ std::vector<std::string> pTokens = Client::explodePropertyString(property);
+ std::deque<std::string> dTokens(pTokens.begin(), pTokens.end());
+ std::string token = dTokens.front();
dTokens.pop_front();
setPrefR(dTokens, configDocument[token], value);
}
diff --git a/src/client/Client.h b/src/client/Client.h
index 31f1fa1..d9fedd5 100644
--- a/src/client/Client.h
+++ b/src/client/Client.h
@@ -4,21 +4,20 @@
#include <queue>
#include <vector>
#include <list>
-#include <fstream>
#include "Config.h"
-#include "HTTP.h"
-#include "preview/Comment.h"
-#include "search/Thumbnail.h"
-#include "client/SaveInfo.h"
-#include "client/SaveFile.h"
#include "Singleton.h"
+
#include "User.h"
-#include "cajun/reader.h"
-#include "cajun/writer.h"
#include "cajun/elements.h"
+class Thumbnail;
+class SaveInfo;
+class SaveFile;
+class SaveComment;
+class GameSave;
+
enum LoginStatus {
LoginOkay, LoginError
};
@@ -55,7 +54,7 @@ private:
std::string lastError;
- list<string> stampIDs;
+ std::list<std::string> stampIDs;
int lastStampTime;
int lastStampName;
@@ -70,7 +69,7 @@ private:
int activeThumbRequestCompleteTimes[IMGCONNS];
std::string activeThumbRequestIDs[IMGCONNS];
void updateStamps();
- static vector<std::string> explodePropertyString(std::string property);
+ static std::vector<std::string> explodePropertyString(std::string property);
void notifyUpdateAvailable();
void notifyAuthUserChanged();
void notifyMessageOfTheDay();
@@ -79,7 +78,7 @@ private:
json::Object configDocument;
public:
- vector<ClientListener*> listeners;
+ std::vector<ClientListener*> listeners;
UpdateInfo GetUpdateInfo();
@@ -109,10 +108,10 @@ public:
RequestStatus ExecVote(int saveID, int direction);
RequestStatus UploadSave(SaveInfo & save);
- SaveFile * GetStamp(string stampID);
- void DeleteStamp(string stampID);
- string AddStamp(GameSave * saveData);
- vector<string> GetStamps(int start, int count);
+ SaveFile * GetStamp(std::string stampID);
+ void DeleteStamp(std::string stampID);
+ std::string AddStamp(GameSave * saveData);
+ std::vector<std::string> GetStamps(int start, int count);
int GetStampsCount();
SaveFile * GetFirstStamp();
@@ -120,10 +119,10 @@ public:
unsigned char * GetSaveData(int saveID, int saveDate, int & dataLength);
std::vector<unsigned char> GetSaveData(int saveID, int saveDate);
- LoginStatus Login(string username, string password, User & user);
+ LoginStatus Login(std::string username, std::string password, User & user);
void ClearThumbnailRequests();
- std::vector<SaveInfo*> * SearchSaves(int start, int count, string query, string sort, string category, int & resultCount);
- std::vector<std::pair<std::string, int> > * GetTags(int start, int count, string query, int & resultCount);
+ std::vector<SaveInfo*> * SearchSaves(int start, int count, std::string query, std::string sort, std::string category, int & resultCount);
+ std::vector<std::pair<std::string, int> > * GetTags(int start, int count, std::string query, int & resultCount);
std::vector<SaveComment*> * GetComments(int saveID, int start, int count);
Thumbnail * GetPreview(int saveID, int saveDate);
Thumbnail * GetThumbnail(int saveID, int saveDate);
@@ -134,8 +133,8 @@ public:
RequestStatus FavouriteSave(int saveID, bool favourite);
void SetAuthUser(User user);
User GetAuthUser();
- std::vector<string> * RemoveTag(int saveID, string tag); //TODO RequestStatus
- std::vector<string> * AddTag(int saveID, string tag);
+ std::vector<std::string> * RemoveTag(int saveID, std::string tag); //TODO RequestStatus
+ std::vector<std::string> * AddTag(int saveID, std::string tag);
std::string GetLastError() {
return lastError;
}
@@ -146,26 +145,26 @@ public:
double GetPrefNumber(std::string property, double defaultValue);
int GetPrefInteger(std::string property, int defaultValue);
unsigned int GetPrefUInteger(std::string property, unsigned int defaultValue);
- vector<string> GetPrefStringArray(std::string property);
- vector<double> GetPrefNumberArray(std::string property);
- vector<int> GetPrefIntegerArray(std::string property);
- vector<unsigned int> GetPrefUIntegerArray(std::string property);
- vector<bool> GetPrefBoolArray(std::string property);
+ std::vector<std::string> GetPrefStringArray(std::string property);
+ std::vector<double> GetPrefNumberArray(std::string property);
+ std::vector<int> GetPrefIntegerArray(std::string property);
+ std::vector<unsigned int> GetPrefUIntegerArray(std::string property);
+ std::vector<bool> GetPrefBoolArray(std::string property);
bool GetPrefBool(std::string property, bool defaultValue);
void SetPref(std::string property, std::string value);
void SetPref(std::string property, double value);
void SetPref(std::string property, int value);
void SetPref(std::string property, unsigned int value);
- void SetPref(std::string property, vector<string> value);
- void SetPref(std::string property, vector<double> value);
- void SetPref(std::string property, vector<int> value);
- void SetPref(std::string property, vector<unsigned int> value);
- void SetPref(std::string property, vector<bool> value);
+ void SetPref(std::string property, std::vector<std::string> value);
+ void SetPref(std::string property, std::vector<double> value);
+ void SetPref(std::string property, std::vector<int> value);
+ void SetPref(std::string property, std::vector<unsigned int> value);
+ void SetPref(std::string property, std::vector<bool> value);
void SetPref(std::string property, bool value);
json::UnknownElement GetPref(std::string property);
- void setPrefR(std::deque<string> tokens, json::UnknownElement & element, json::UnknownElement & value);
+ void setPrefR(std::deque<std::string> tokens, json::UnknownElement & element, json::UnknownElement & value);
void SetPref(std::string property, json::UnknownElement & value);
};
diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp
index f615c6f..3cb3c29 100644
--- a/src/client/GameSave.cpp
+++ b/src/client/GameSave.cpp
@@ -41,10 +41,10 @@ originalData(save.originalData)
{
setSize(save.blockWidth, save.blockHeight);
- copy(save.particles, save.particles+NPART, particles);
- copy(save.blockMapPtr, save.blockMapPtr+(blockHeight*blockWidth), blockMapPtr);
- copy(save.fanVelXPtr, save.fanVelXPtr+(blockHeight*blockWidth), fanVelXPtr);
- copy(save.fanVelYPtr, save.fanVelYPtr+(blockHeight*blockWidth), fanVelYPtr);
+ std::copy(save.particles, save.particles+NPART, particles);
+ std::copy(save.blockMapPtr, save.blockMapPtr+(blockHeight*blockWidth), blockMapPtr);
+ std::copy(save.fanVelXPtr, save.fanVelXPtr+(blockHeight*blockWidth), fanVelXPtr);
+ std::copy(save.fanVelYPtr, save.fanVelYPtr+(blockHeight*blockWidth), fanVelYPtr);
}
else
{
@@ -261,11 +261,11 @@ void GameSave::setSize(int newWidth, int newHeight)
particles = new Particle[NPART];
blockMapPtr = new unsigned char[blockHeight*blockWidth];
- fill(blockMapPtr, blockMapPtr+(blockHeight*blockWidth), 0);
+ std::fill(blockMapPtr, blockMapPtr+(blockHeight*blockWidth), 0);
fanVelXPtr = new float[(blockHeight)*(blockWidth)];
- fill(fanVelXPtr, fanVelXPtr+((blockHeight)*(blockWidth)), 0);
+ std::fill(fanVelXPtr, fanVelXPtr+((blockHeight)*(blockWidth)), 0);
fanVelYPtr = new float[(blockHeight)*(blockWidth)];
- fill(fanVelYPtr, fanVelYPtr+((blockHeight)*(blockWidth)), 0);
+ std::fill(fanVelYPtr, fanVelYPtr+((blockHeight)*(blockWidth)), 0);
blockMap = new unsigned char*[blockHeight];
for(int y = 0; y < blockHeight; y++)
@@ -330,11 +330,11 @@ void GameSave::Transform(matrix2d transform, vector2d translate)
unsigned char * blockMapPtrNew;
blockMapPtrNew = new unsigned char[newBlockHeight*newBlockWidth];
- fill(blockMapPtrNew, blockMapPtrNew+(newBlockHeight*newBlockWidth), 0);
+ std::fill(blockMapPtrNew, blockMapPtrNew+(newBlockHeight*newBlockWidth), 0);
fanVelXPtrNew = new float[newBlockHeight*newBlockWidth];
- fill(fanVelXPtrNew, fanVelXPtrNew+(newBlockHeight*newBlockWidth), 0);
+ std::fill(fanVelXPtrNew, fanVelXPtrNew+(newBlockHeight*newBlockWidth), 0);
fanVelYPtrNew = new float[(newBlockHeight)*(newBlockWidth)];
- fill(fanVelYPtrNew, fanVelYPtrNew+(newBlockHeight*newBlockWidth), 0);
+ std::fill(fanVelYPtrNew, fanVelYPtrNew+(newBlockHeight*newBlockWidth), 0);
blockMapNew = new unsigned char*[newBlockHeight];
for(int y = 0; y < newBlockHeight; y++)
@@ -992,7 +992,7 @@ void GameSave::readPSv(char * data, int dataLength)
memcpy(goltype, golTypesT, sizeof(int) * (golTypesCount));
free(golTypesT);
- vector<Element> elements = GetElements();
+ std::vector<Element> elements = GetElements();
try
{
@@ -1609,7 +1609,7 @@ char * GameSave::serialiseOPS(int & dataLength)
int posCount, signsCount;
bson b;
- fill(elementCount, elementCount+PT_NUM, 0);
+ std::fill(elementCount, elementCount+PT_NUM, 0);
//Get coords in blocks
blockX = 0;//orig_x0/CELL;
diff --git a/src/client/GameSave.h b/src/client/GameSave.h
index 2c86ea1..7f8e7fc 100644
--- a/src/client/GameSave.h
+++ b/src/client/GameSave.h
@@ -12,17 +12,18 @@
#include <string>
#include "Config.h"
#include "Misc.h"
+
#include "simulation/Sign.h"
#include "simulation/Particle.h"
-using namespace std;
+//using namespace std;
-struct ParseException: public exception {
+struct ParseException: public std::exception {
enum ParseResult { OK = 0, Corrupt, WrongVersion, InvalidDimensions, InternalError, MissingElement };
- string message;
+ std::string message;
ParseResult result;
public:
- ParseException(ParseResult result, string message_): message(message_), result(result) {}
+ ParseException(ParseResult result, std::string message_): message(message_), result(result) {}
const char * what() const throw()
{
return message.c_str();
diff --git a/src/client/SaveFile.cpp b/src/client/SaveFile.cpp
index 0694167..368d89d 100644
--- a/src/client/SaveFile.cpp
+++ b/src/client/SaveFile.cpp
@@ -6,8 +6,9 @@
*/
#include "SaveFile.h"
+#include "GameSave.h"
#include "Client.h"
- #include "search/Thumbnail.h"
+#include "search/Thumbnail.h"
SaveFile::SaveFile(SaveFile & save):
gameSave(NULL),
@@ -31,7 +32,7 @@ void SaveFile::SetThumbnail(Thumbnail * thumb)
thumbnail = thumb;
}
-SaveFile::SaveFile(string filename):
+SaveFile::SaveFile(std::string filename):
filename(filename),
displayName(filename),
gameSave(NULL),
@@ -50,17 +51,17 @@ void SaveFile::SetGameSave(GameSave * save)
gameSave = save;
}
-string SaveFile::GetName()
+std::string SaveFile::GetName()
{
return filename;
}
-string SaveFile::GetDisplayName()
+std::string SaveFile::GetDisplayName()
{
return displayName;
}
-void SaveFile::SetDisplayName(string displayName)
+void SaveFile::SetDisplayName(std::string displayName)
{
this->displayName = displayName;
}
diff --git a/src/client/SaveFile.h b/src/client/SaveFile.h
index d631bc1..9a9310f 100644
--- a/src/client/SaveFile.h
+++ b/src/client/SaveFile.h
@@ -9,31 +9,29 @@
#define SAVEFILE_H_
#include <string>
-#include "GameSave.h"
-
-
-using namespace std;
+class GameSave;
class Thumbnail;
+
class SaveFile {
public:
SaveFile(SaveFile & save);
- SaveFile(string filename);
+ SaveFile(std::string filename);
Thumbnail * GetThumbnail();
GameSave * GetGameSave();
void SetThumbnail(Thumbnail * thumb);
void SetGameSave(GameSave * save);
- string GetDisplayName();
- void SetDisplayName(string displayName);
- string GetName();
+ std::string GetDisplayName();
+ void SetDisplayName(std::string displayName);
+ std::string GetName();
virtual ~SaveFile();
private:
Thumbnail * thumbnail;
GameSave * gameSave;
- string filename;
- string displayName;
+ std::string filename;
+ std::string displayName;
};
#endif /* SAVEFILE_H_ */
diff --git a/src/client/SaveInfo.cpp b/src/client/SaveInfo.cpp
index 1df74c7..3b8b9a1 100644
--- a/src/client/SaveInfo.cpp
+++ b/src/client/SaveInfo.cpp
@@ -5,8 +5,9 @@
* Author: Simon
*/
-#include "client/SaveInfo.h"
-#include "client/Client.h"
+#include "SaveInfo.h"
+#include "GameSave.h"
+#include "Client.h"
SaveInfo::SaveInfo(SaveInfo & save) :
userName(save.userName), name(save.name), Description(save.Description), date(
@@ -16,15 +17,15 @@ SaveInfo::SaveInfo(SaveInfo & save) :
gameSave = new GameSave(*save.gameSave);
}
-SaveInfo::SaveInfo(int _id, int _date, int _votesUp, int _votesDown, string _userName,
- string _name) :
+SaveInfo::SaveInfo(int _id, int _date, int _votesUp, int _votesDown, std::string _userName,
+ std::string _name) :
id(_id), votesUp(_votesUp), votesDown(_votesDown), userName(_userName), name(
_name), Description("No description provided"), date(_date), Published(
true), gameSave(NULL), vote(0), tags(), Comments(0) {
}
-SaveInfo::SaveInfo(int _id, int date_, int _votesUp, int _votesDown, int _vote, string _userName,
- string _name, string description_, bool published_, vector<string> tags_) :
+SaveInfo::SaveInfo(int _id, int date_, int _votesUp, int _votesDown, int _vote, std::string _userName,
+ std::string _name, std::string description_, bool published_, std::vector<std::string> tags_) :
id(_id), votesUp(_votesUp), votesDown(_votesDown), userName(_userName), name(
_name), Description(description_), date(date_), Published(
published_), gameSave(NULL), vote(_vote), tags(tags_), Comments(0) {
@@ -38,17 +39,17 @@ SaveInfo::~SaveInfo()
}
}
-void SaveInfo::SetName(string name) {
+void SaveInfo::SetName(std::string name) {
this->name = name;
}
-string SaveInfo::GetName() {
+std::string SaveInfo::GetName() {
return name;
}
-void SaveInfo::SetDescription(string description) {
+void SaveInfo::SetDescription(std::string description) {
Description = description;
}
-string SaveInfo::GetDescription() {
+std::string SaveInfo::GetDescription() {
return Description;
}
@@ -69,11 +70,11 @@ int SaveInfo::GetVote()
return vote;
}
-void SaveInfo::SetUserName(string userName) {
+void SaveInfo::SetUserName(std::string userName) {
this->userName = userName;
}
-string SaveInfo::GetUserName() {
+std::string SaveInfo::GetUserName() {
return userName;
}
@@ -98,11 +99,11 @@ int SaveInfo::GetVotesDown() {
return votesDown;
}
-void SaveInfo::SetTags(vector<string> tags)
+void SaveInfo::SetTags(std::vector<std::string> tags)
{
this->tags = tags;
}
-vector<string> SaveInfo::GetTags()
+std::vector<std::string> SaveInfo::GetTags()
{
return tags;
}
diff --git a/src/client/SaveInfo.h b/src/client/SaveInfo.h
index a54741a..6c3a2a3 100644
--- a/src/client/SaveInfo.h
+++ b/src/client/SaveInfo.h
@@ -5,10 +5,8 @@
#include <string>
#include <stdlib.h>
#include <iostream>
-#include <string.h>
-#include "GameSave.h"
-using namespace std;
+class GameSave;
class SaveInfo
{
@@ -24,34 +22,34 @@ public:
SaveInfo(SaveInfo & save);
- SaveInfo(int _id, int _date, int _votesUp, int _votesDown, string _userName, string _name);
+ SaveInfo(int _id, int _date, int _votesUp, int _votesDown, std::string _userName, std::string _name);
- SaveInfo(int _id, int date_, int _votesUp, int _votesDown, int _vote, string _userName, string _name, string description_, bool published_, vector<string> tags);
+ SaveInfo(int _id, int date_, int _votesUp, int _votesDown, int _vote, std::string _userName, std::string _name, std::string description_, bool published_, std::vector<std::string> tags);
~SaveInfo();
- string userName;
- string name;
+ std::string userName;
+ std::string name;
- string Description;
+ std::string Description;
- vector<string> tags;
+ std::vector<std::string> tags;
int vote;
bool Published;
- void SetName(string name);
- string GetName();
+ void SetName(std::string name);
+ std::string GetName();
- void SetDescription(string description);
- string GetDescription();
+ void SetDescription(std::string description);
+ std::string GetDescription();
void SetPublished(bool published);
bool GetPublished();
- void SetUserName(string userName);
- string GetUserName();
+ void SetUserName(std::string userName);
+ std::string GetUserName();
void SetID(int id);
int GetID();
@@ -65,8 +63,8 @@ public:
void SetVotesDown(int votesDown);
int GetVotesDown();
- void SetTags(vector<string> tags);
- vector<string> GetTags();
+ void SetTags(std::vector<std::string> tags);
+ std::vector<std::string> GetTags();
GameSave * GetGameSave();
void SetGameSave(GameSave * gameSave);
diff --git a/src/client/ThumbnailBroker.cpp b/src/client/ThumbnailBroker.cpp
index 86a38d8..0a36fc0 100644
--- a/src/client/ThumbnailBroker.cpp
+++ b/src/client/ThumbnailBroker.cpp
@@ -4,6 +4,7 @@
#include "ThumbnailBroker.h"
#include "ThumbnailListener.h"
#include "Client.h"
+#include "HTTP.h"
#include "GameSave.h"
#include "search/Thumbnail.h"
#include "simulation/SaveRenderer.h"
diff --git a/src/client/User.h b/src/client/User.h
index 163f463..5a47a3e 100644
--- a/src/client/User.h
+++ b/src/client/User.h
@@ -10,14 +10,14 @@
#include <string>
-enum Elevation
-{
- ElevationAdmin, ElevationModerator, ElevationNone
-};
class User
{
public:
+ enum Elevation
+ {
+ ElevationAdmin, ElevationModerator, ElevationNone
+ };
int ID;
std::string Username;
std::string SessionID;