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
accountXML Namespace Reference

Enumerations

enum  Names {
  UNKNOWN, PLAYER, ADMIN, ACCOUNTS,
  NAME, PASSWORD, SERIAL, SERVERIP,
  SERVERPORT
}
 

Functions

void beginElement (void *userData, const XML_Char *name, const XML_Char **atts)
 
void endElement (void *userData, const XML_Char *name)
 

Variables

const EnumMap::Pair element_names []
 
const EnumMap::Pair attribute_names []
 
const EnumMap element_map (element_names, 4)
 
const EnumMap attribute_map (attribute_names, 5)
 
string curname
 
string file
 
Account tmpacct
 
int level = -1
 
vsUMap< string, Account * > accounttable
 
int nbaccounts = 0
 

Enumeration Type Documentation

Enumerator
UNKNOWN 
PLAYER 
ADMIN 
ACCOUNTS 
NAME 
PASSWORD 
SERIAL 
SERVERIP 
SERVERPORT 

Definition at line 73 of file accountsxml.cpp.

74 {
75  UNKNOWN,
76  PLAYER,
77  ADMIN,
78  ACCOUNTS,
79  //attributes
80  NAME,
81  PASSWORD,
82  SERIAL,
83  SERVERIP,
85 };

Function Documentation

void accountXML::beginElement ( void *  userData,
const XML_Char *  name,
const XML_Char **  atts 
)

Definition at line 113 of file accountsxml.cpp.

References ACCOUNTS, Account::ADMIN, ADMIN, CommXML::attribute_map, Account::callsign, CommXML::element_map, BeamXML::level, XMLSupport::EnumMap::lookup(), CommXML::NAME, Account::passwd, PASSWORD, Account::PLAYER, PLAYER, SERIAL, Account::serverip, SERVERIP, Account::serverport, SERVERPORT, tmpacct, Account::type, CommXML::UNKNOWN, Account::UNKNOWN, and VSFileSystem::vs_fprintf().

114 {
115  AttributeList attributes( atts );
116  tmpacct = Account();
117  Names elem = (Names) element_map.lookup( string( name ) );
118 
119  AttributeList::const_iterator iter;
120  switch (elem)
121  {
122  case UNKNOWN:
124  break;
125  case ACCOUNTS:
126  assert( level == -1 );
127  level++;
128  break;
129  case PLAYER:
130  case ADMIN:
131  assert( level == 0 );
132  level++;
133  switch (elem)
134  {
135  case PLAYER:
137  break;
138  case ADMIN:
140  break;
141  default:
143  break;
144  }
145  for (iter = attributes.begin(); iter != attributes.end(); iter++) {
146  switch ( attribute_map.lookup( (*iter).name ) )
147  {
148  case UNKNOWN:
149  VSFileSystem::vs_fprintf( stderr, "Unknown Account Element %s\n", (*iter).name.c_str() );
150  break;
151  case NAME:
152  tmpacct.callsign = (*iter).value;
153  break;
154  case PASSWORD:
155  tmpacct.passwd = (*iter).value;
156  break;
157  case SERVERIP:
158  tmpacct.serverip = (*iter).value;
159  break;
160  case SERVERPORT:
161  tmpacct.serverport = (*iter).value;
162  break;
163  default:
164  assert( 0 );
165  break;
166  }
167  }
168  break;
169  case NAME:
170  case PASSWORD:
171  case SERIAL:
172  case SERVERIP:
173  case SERVERPORT:
174  break;
175  }
176 }
void accountXML::endElement ( void *  userData,
const XML_Char *  name 
)

Definition at line 178 of file accountsxml.cpp.

References ACCOUNTS, accounttable, ADMIN, Account::callsign, CommXML::element_map, BeamXML::level, XMLSupport::EnumMap::lookup(), nbaccounts, PLAYER, strtoupper(), tmpacct, and CommXML::UNKNOWN.

179 {
180  Names elem = (Names) element_map.lookup( name );
181  switch (elem)
182  {
183  case UNKNOWN:
184  break;
185  case ACCOUNTS:
186  assert( level == 0 );
187  level--;
188  break;
189  case PLAYER:
190  case ADMIN:
191  assert( level == 1 );
192  level--;
195  nbaccounts++;
196  }
197  break;
198  default:
199  break;
200  }
201 }

Variable Documentation

vsUMap< string, Account* > accountXML::accounttable
const EnumMap accountXML::attribute_map(attribute_names, 5)
const EnumMap::Pair accountXML::attribute_names[]
Initial value:
= {
EnumMap::Pair( "UNKNOWN", UNKNOWN ),
EnumMap::Pair( "NAME", NAME ),
EnumMap::Pair( "PASSWORD", PASSWORD ),
EnumMap::Pair( "SERVERIP", SERVERIP ),
EnumMap::Pair( "SERVERPORT", SERVERPORT ),
}

Definition at line 94 of file accountsxml.cpp.

string accountXML::curname

Definition at line 104 of file accountsxml.cpp.

const EnumMap accountXML::element_map(element_names, 4)
const EnumMap::Pair accountXML::element_names[]
Initial value:
= {
EnumMap::Pair( "UNKNOWN", UNKNOWN ),
EnumMap::Pair( "PLAYER", PLAYER ),
EnumMap::Pair( "ADMIN", ADMIN ),
EnumMap::Pair( "ACCOUNTS", ACCOUNTS )
}

Definition at line 87 of file accountsxml.cpp.

int accountXML::level = -1

Definition at line 109 of file accountsxml.cpp.

int accountXML::nbaccounts = 0

Definition at line 111 of file accountsxml.cpp.

Referenced by endElement().

Account accountXML::tmpacct

Definition at line 107 of file accountsxml.cpp.

Referenced by beginElement(), and endElement().