long slConfig::Read(const wxString& key, long defaultVal) const { long ret; if ( slConfigBaseType::Read( key, &ret ) ) return ret; else if ( m_global_config && m_global_config->Read( key, &ret ) ) { if ( IsRecordingDefaults() ) ((slConfig*)this)->Write( key, ret ); return ret; } if ( IsRecordingDefaults() ) ((slConfig*)this)->Write( key, defaultVal ); return defaultVal; }
wxString slConfig::Read(const wxString& key, const wxString& defaultVal ) const { //1. value from self, 2. value from global, 3. default value wxString ret; if ( slConfigBaseType::Read( key, &ret ) ) return ret; else if ( m_global_config && m_global_config->Read( key, &ret ) ) { //basically this means we're treating the global value as a default to our self //and write it according to policy if ( IsRecordingDefaults() ) ((slConfig*)this)->Write( key, ret ); return ret; } if ( IsRecordingDefaults() ) ((slConfig*)this)->Write( key, defaultVal ); return defaultVal; }
bool slConfig::Read(const wxString& key, bool* b, bool defaultVal) const { if ( slConfigBaseType::Read( key, b, defaultVal ) ) return true; else if ( m_global_config && m_global_config->Read( key, b, defaultVal ) ) return true; if ( IsRecordingDefaults() ) ((slConfig*)this)->Write( key, defaultVal ); return false; }
bool slConfig::Read(const wxString& key, long* l) const { if ( slConfigBaseType::Read( key, l ) ) return true; else if ( m_global_config && m_global_config->Read( key, l ) ) { if ( l && IsRecordingDefaults() ) ((slConfig*)this)->Write( key, *l ); return true; } return false; }
bool slConfig::Read(const wxString& key, wxString* str, const wxString& defaultVal) const { // do not pass the default to this first call since it might write it back immeadiately if ( slConfigBaseType::Read( key, str ) ) return true; else if ( m_global_config && m_global_config->Read( key, str, defaultVal ) ) return true;//means the default was not used //at this point the last call will have modified *str with defaultVal if ( IsRecordingDefaults() ) ((slConfig*)this)->Write( key, defaultVal ); return false; }
bool slConfig::Read(const wxString& key, wxString* str) const { //value was found in self -> return true if ( slConfigBaseType::Read( key, str ) ) return true; //value was found in global. while technically this constitutes using a default value //we still return true since no default value was passed as argument to the original call else if ( m_global_config && m_global_config->Read( key, str ) ) { if ( str && IsRecordingDefaults() ) ((slConfig*)this)->Write( key, *str ); return true; } return false; }
bool wxFileConfig::Read(const wxString& key, wxString* pStr, const wxString& defVal) const { wxConfigPathChanger path(this, key); ConfigEntry *pEntry = m_pCurrentGroup->FindEntry(path.Name()); bool ok; if (pEntry == NULL) { if( IsRecordingDefaults() ) ((wxFileConfig *)this)->Write(key,defVal); *pStr = ExpandEnvVars(defVal); ok = FALSE; } else { *pStr = ExpandEnvVars(pEntry->Value()); ok = TRUE; } return ok; }