Cleande up the deserialization code
This commit is contained in:
@@ -41,6 +41,8 @@ public:
|
||||
virtual JQuadPtr getIcon(){return JQuadPtr();}
|
||||
|
||||
bool parseLine(const string& s);
|
||||
|
||||
friend ostream& operator<<(ostream& out, const Damageable& p);
|
||||
};
|
||||
|
||||
class Damage: public Interruptible
|
||||
@@ -71,8 +73,4 @@ class DamageStack : public GuiLayer, public Interruptible
|
||||
DamageStack(GameObserver *observer);
|
||||
};
|
||||
|
||||
ostream& operator<<(ostream& out, const Damageable& p);
|
||||
|
||||
istream& operator>>(istream& in, Damageable& p);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -202,8 +202,7 @@ public:
|
||||
};
|
||||
|
||||
ostream& operator<<(ostream&, const MTGGameZone&);
|
||||
istream& operator>>(istream&, MTGGameZone&);
|
||||
ostream& operator<<(ostream&, const MTGPlayerCards&);
|
||||
istream& operator>>(istream&, MTGPlayerCards&);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -95,8 +95,6 @@ public:
|
||||
** Returns the path to the stats file of currently selected deck.
|
||||
*/
|
||||
std::string GetCurrentDeckStatsFile();
|
||||
|
||||
friend istream& operator>>(istream& in, Player& p);
|
||||
bool parseLine(const string& s);
|
||||
};
|
||||
|
||||
|
||||
@@ -100,4 +100,19 @@ bool FileExists(const string & filename);
|
||||
std::string buildFilePath(const vector<string> & folders, const string & filename);
|
||||
std::string ensureFolder(const string & folderName);
|
||||
|
||||
template <class T> istream& operator>>(istream& in, T& p)
|
||||
{
|
||||
string s;
|
||||
|
||||
while(std::getline(in, s))
|
||||
{
|
||||
if(!p.parseLine(s))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user