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
GalaxyXML::Galaxy Class Reference

#include <galaxy_xml.h>

Inheritance diagram for GalaxyXML::Galaxy:
GalaxyXML::SGalaxy

Public Member Functions

const string & getPlanetNameFromInitial (const string &abbrev) const
 
const string & getPlanetNameFromTexture (const string &tex) const
 
const string & getPlanetVariable (const string &name, const string &defaultvalue) const
 
const string & getPlanetVariable (const string &planet, const string &name, const string &defaultvalue) const
 
void writeGalaxy (VSFileSystem::VSFile &f) const
 
SGalaxygetPlanetTypes ()
 
bool setPlanetVariable (const string &name, const string &value)
 
void addPlanetSection (const std::vector< string > &section)
 
bool setPlanetVariable (const string &planet, const string &name, const string &value)
 
 Galaxy ()
 
 Galaxy (const char *configfile)
 
 Galaxy (const SGalaxy &g)
 
- Public Member Functions inherited from GalaxyXML::SGalaxy
 SGalaxy ()
 
 SGalaxy (const char *configfile)
 
 SGalaxy (const SGalaxy &g)
 
void writeGalaxy (VSFileSystem::VSFile &f) const
 
void writeSector (VSFileSystem::VSFile &f, int tabs, const string &sectorType, SGalaxy *planet_types) const
 
void processGalaxy (const string &sys)
 
void processSystem (const string &sys, const QVector &suggested_coordinates)
 
 ~SGalaxy ()
 
const string & getVariable (const std::vector< string > &section, const string &name, const string &default_value) const
 
const string & getRandSystem (const string &section, const string &default_value) const
 
const string & getVariable (const string &section, const string &name, const string &defaultvalue) const
 
const string & getVariable (const string &section, const string &subsection, const string &name, const string &defaultvalue) const
 
bool setVariable (const string &section, const string &name, const string &value)
 
bool setVariable (const string &section, const string &subsection, const string &name, const string &value)
 
void addSection (const std::vector< string > &section)
 
void setVariable (const std::vector< string > &section, const string &name, const string &value)
 
SubHeirarchygetHeirarchy ()
 
const std::string & operator[] (const std::string &s) const
 

Additional Inherited Members

- Protected Member Functions inherited from GalaxyXML::SGalaxy
SGalaxyoperator= (const SGalaxy &a)
 
- Protected Attributes inherited from GalaxyXML::SGalaxy
class SubHeirarchysubheirarchy
 
StringMap data
 

Detailed Description

Definition at line 59 of file galaxy_xml.h.

Constructor & Destructor Documentation

GalaxyXML::Galaxy::Galaxy ( )
inline

Definition at line 96 of file galaxy_xml.h.

References GalaxyXML::SGalaxy::subheirarchy.

97  {
98  subheirarchy = NULL;
99  planet_types = NULL;
100  }
Galaxy::Galaxy ( const char *  configfile)

Definition at line 538 of file galaxy_xml.cpp.

538  : SGalaxy( configfile )
539 {
540  planet_types = getInitialPlanetTypes();
541  setupPlanetTypeMaps();
542 }
Galaxy::Galaxy ( const SGalaxy g)

Definition at line 533 of file galaxy_xml.cpp.

533  : SGalaxy( g )
534 {
535  planet_types = getInitialPlanetTypes();
536  setupPlanetTypeMaps();
537 }

Member Function Documentation

void GalaxyXML::Galaxy::addPlanetSection ( const std::vector< string > &  section)
const string& GalaxyXML::Galaxy::getPlanetNameFromInitial ( const string &  abbrev) const
inline

Definition at line 69 of file galaxy_xml.h.

Referenced by readplanetentity().

70  {
71  static std::string empty_string;
72  StringMap::const_iterator it = initial2name.find( abbrev );
73  if ( it != initial2name.end() )
74  return it->second;
75 
76  else
77  return empty_string;
78  }
const string& GalaxyXML::Galaxy::getPlanetNameFromTexture ( const string &  tex) const
inline

Definition at line 79 of file galaxy_xml.h.

Referenced by Planet::getHumanReadablePlanetType().

80  {
81  static std::string empty_string;
82  StringMap::const_iterator it = texture2name.find( tex );
83  if ( it != texture2name.end() )
84  return it->second;
85 
86  else
87  return empty_string;
88  }
SGalaxy * Galaxy::getPlanetTypes ( )

Definition at line 310 of file galaxy_xml.cpp.

311 {
312  return planet_types;
313 }
const string & Galaxy::getPlanetVariable ( const string &  name,
const string &  defaultvalue 
) const

Definition at line 446 of file galaxy_xml.cpp.

References j.

Referenced by CriteriaContains::isDestination(), StarSystemGent::MakePlanet(), and readplanetentity().

447 {
448  if (planet_types) {
449  StringMap::const_iterator j = planet_types->data.find( name );
450  if ( j != planet_types->data.end() )
451  return (*j).second;
452  }
453  return defaultvalue;
454 }
const string & Galaxy::getPlanetVariable ( const string &  planet,
const string &  name,
const string &  defaultvalue 
) const

Definition at line 426 of file galaxy_xml.cpp.

References GalaxyXML::SGalaxy::data, g, i, j, second(), and GalaxyXML::SGalaxy::subheirarchy.

427 {
428  SGalaxy *planet_types = &( ( *subheirarchy->find( "<planets>" ) ).second );
429  if (planet_types) {
430  SubHeirarchy::const_iterator i;
431  i = planet_types->subheirarchy->find( section );
432  if ( i == planet_types->subheirarchy->end() ) {
433  return getPlanetVariable( name, defaultvalue );
434  } else {
435  const SGalaxy *g = &(*i).second;
436  StringMap::const_iterator j = g->data.find( name );
437  if ( j == g->data.end() )
438  return getPlanetVariable( name, defaultvalue );
439  else
440  return (*j).second;
441  }
442  }
443  return defaultvalue;
444 }
bool Galaxy::setPlanetVariable ( const string &  name,
const string &  value 
)

Definition at line 410 of file galaxy_xml.cpp.

411 {
412  if (!planet_types)
413  return false;
414  planet_types->data[name] = value;
415  return true;
416 }
bool Galaxy::setPlanetVariable ( const string &  planet,
const string &  name,
const string &  value 
)

Definition at line 418 of file galaxy_xml.cpp.

419 {
420  if (!planet_types)
421  return false;
422  planet_types->getHeirarchy()[section].data[name] = value;
423  return true;
424 }
void Galaxy::writeGalaxy ( VSFileSystem::VSFile f) const

Definition at line 249 of file galaxy_xml.cpp.

References VSFileSystem::VSFile::Fprintf(), and GalaxyXML::SGalaxy::writeSector().

250 {
251  f.Fprintf( "<galaxy>\n<systems>\n" );
252  writeSector( f, 1, "sector", planet_types );
253  f.Fprintf( "</systems>\n" );
254  if (planet_types) {
255  f.Fprintf( "<planets>\n" );
256  planet_types->writeSector( f, 1, "planet", NULL );
257  f.Fprintf( "</planets>\n" );
258  }
259  f.Fprintf( "</galaxy>\n" );
260 }

The documentation for this class was generated from the following files: