/* $Id: objectpaths.cpp,v 1.3 2005/06/28 13:55:21 chfreund Exp $ */ #include "object.hpp" #include "string.hpp" #include "objectpaths.hpp" /**********************************************************/ SettingDef ObjectPaths::m_SettingDef[NUMBER_OF_OBJECT_IDs+1]; /**********************************************************/ ObjectPaths::ObjectPaths() { // A NULL string as ID string of the definition at the first // position signalizes, that ObjectPaths::ObjectPaths // is called for the first time. Initialize the setting // definitions in this case. if( ! m_SettingDef[0].m_IDString ) initSettingDefs(); } /**********************************************************/ ObjectPaths::~ObjectPaths() {} /**********************************************************/ bool ObjectPaths::load( const char* const basePath, const char* const file, const char* const section ) { const char fn[] = "ObjectPaths::load:"; String fullPath( basePath ); fullPath += '/'; fullPath += file; reset(); if( section ) restrictToSection( section ); // read paths from file if( ! CHECK(readSettings(m_SettingDef, fullPath.getString()), "%s could not load paths from \"%s\"\n", fn, fullPath.getString()) || // check read settings agains definitions ! CHECK(finalCheck(m_SettingDef), "%s failed final check\n") ) { return false; } removeSection(); return true; } /**********************************************************/ void ObjectPaths::initSettingDefs() { for( int i = 0; i < NUMBER_OF_OBJECT_IDs; i++ ) { m_SettingDef[i].m_IDString = Object::getIDString( i ); m_SettingDef[i].m_Type = Setting::STRING; m_SettingDef[i].m_Attributes = Setting::COMMA_SEPARATED | Setting::EXPLICIT_ASSIGNMENT; m_SettingDef[i].m_minNumParams = 2; m_SettingDef[i].m_maxNumParams = 2; } } /**********************************************************/