Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
accountsxml.h File Reference
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include "const.h"
#include <assert.h>
#include "networking/lowlevel/netui.h"

Go to the source code of this file.

Classes

class  Account
 

Functions

AccountgetAcctNoReload (const string &key)
 
AccountgetAcctTemplate (const string &key)
 
vector< Account * > getAllAccounts ()
 
void LoadAccounts (const char *filename)
 
AccountgetAcctSerial (ObjSerial ser)
 
AccountgetAcctAddress (SOCKETALT ser)
 
void addAcct (std::string key, Account *)
 

Function Documentation

void addAcct ( std::string  key,
Account  
)
Account* getAcctAddress ( SOCKETALT  ser)

Definition at line 230 of file accountsxml.cpp.

References accountXML::accounttable.

Referenced by AccountServer::removeDeadSockets().

231 {
232  for (vsUMap< string, Account* >::iterator iter = accounttable.begin();
233  iter != accounttable.end();
234  ++iter)
235  if (iter->second)
236  if ( iter->second->getSocket().sameAddress( ser ) )
237  return iter->second;
238  return NULL;
239 }
Account* getAcctNoReload ( const string &  key)

Definition at line 261 of file accountsxml.cpp.

References accountXML::accounttable, and strtoupper().

Referenced by AccountServer::recvMsg().

262 {
263  return accounttable[strtoupper( key )];
264 }
Account* getAcctSerial ( ObjSerial  ser)

Definition at line 219 of file accountsxml.cpp.

References accountXML::accounttable.

Referenced by AccountServer::writeSave().

220 {
221  for (vsUMap< string, Account* >::iterator iter = accounttable.begin();
222  iter != accounttable.end();
223  ++iter)
224  if (iter->second)
225  if (iter->second->getSerial() == ser)
226  return iter->second;
227  return NULL;
228 }
Account* getAcctTemplate ( const string &  key)

Definition at line 266 of file accountsxml.cpp.

References accountXML::accounttable, accountXML::file, LoadAccounts(), and strtoupper().

Referenced by AccountServer::recvMsg().

267 {
268  Account *acct = accounttable[strtoupper( key )];
269  if (acct == NULL) {
270  LoadAccounts( file.c_str() );
271  acct = accounttable[strtoupper( key )];
272  }
273  return acct;
274 }
vector< Account* > getAllAccounts ( )

Definition at line 208 of file accountsxml.cpp.

References accountXML::accounttable.

209 {
210  vector< Account* >retval;
211  for (vsUMap< string, Account* >::iterator iter = accounttable.begin();
212  iter != accounttable.end();
213  ++iter)
214  if (iter->second)
215  retval.push_back( iter->second );
216  return retval;
217 }
void LoadAccounts ( const char *  filename)

Definition at line 241 of file accountsxml.cpp.

References VSFileSystem::AccountFile, BeamXML::beginElement(), VSFileSystem::VSFile::Close(), BeamXML::endElement(), f, accountXML::file, VSFileSystem::Ok, VSFileSystem::VSFile::OpenReadOnly(), VSFileSystem::VSFile::ReadFull(), and VSFileSystem::VSFile::Size().

Referenced by getAcctTemplate(), and AccountServer::start().

242 {
243  file = filename;
244  VSFile f;
245  VSError err = f.OpenReadOnly( filename, AccountFile );
246  if (err > Ok)
247  return;
248  XML_Parser parser = XML_ParserCreate( NULL );
249  XML_SetElementHandler( parser, &beginElement, &endElement );
250  std::string data( f.ReadFull() );
251  XML_Parse( parser, data.c_str(), f.Size(), 1 );
252  f.Close();
253  XML_ParserFree( parser );
254 }