Inheritance diagram for PreferenceSection:
Public Member Functions | |
PreferenceSection (LPTCHAR SectionName, UINT32 InitialSize) | |
Checks to see if the given preference exists in this chunk. Only exists in DEBUG builds. Creates a new section object. A chunk of memory is allocated to hold the preferences for this object. If the memory is not available for this, then the 'Valid' data member contains the value 'FALSE'. | |
~PreferenceSection () | |
Deletes all PreferenceChunk objects used by this section. | |
void | Write (OILPreferences *OILPrefs) |
Writes all the preferences in this section out to the preference file, using the OIL. | |
BOOL | AddPref (OILPreferences *OILPrefs, LPTCHAR Pref, PreferenceType Type, PrefData PrefVar) |
Adds a preference to this PreferenceSection object. If a new PreferenceChunk is needed to do this, it is allocated automatically, and added to this object's list of chunks. | |
BOOL | GetPrefValue (OILPreferences *OILPrefs, LPTCHAR Pref, PreferenceType Type, PrefData PrefVar) |
Reads a preference value from this PreferenceSection object by looking through all the chunks in this section for the named preference. | |
BOOL | SetPrefValue (OILPreferences *OILPrefs, LPTCHAR Pref, PreferenceType Type, PrefData PrefVar) |
Finds a preference value from this PreferenceSection object by looking through all the chunks in this section for the named preference and then sets the value to the specifed new value. | |
Public Attributes | |
LPTCHAR | Section |
BOOL | Valid |
List | ChunkList |
Definition at line 215 of file prefs.cpp.
|
Checks to see if the given preference exists in this chunk. Only exists in DEBUG builds. Creates a new section object. A chunk of memory is allocated to hold the preferences for this object. If the memory is not available for this, then the 'Valid' data member contains the value 'FALSE'.
Definition at line 596 of file prefs.cpp. 00597 { 00598 Valid = FALSE; 00599 00600 // Remember the name of this section (note that it uses the original - it does not 00601 // take a copy). 00602 Section = SectionName; 00603 00604 // Get a preference chunk for this section, using the size recommended 00605 // by the caller 00606 PreferenceChunk *pChunk = new PreferenceChunk(InitialSize); 00607 00608 if ((pChunk == NULL) || (!pChunk->Valid)) 00609 { 00610 delete pChunk; 00611 return; // Section is invalid 00612 } 00613 00614 // Got a chunk ok, so add it to the head of the (empty) list. 00615 ChunkList.AddHead(pChunk); 00616 00617 // Success 00618 Valid = TRUE; 00619 }
|
|
Deletes all PreferenceChunk objects used by this section.
Definition at line 636 of file prefs.cpp. 00637 { 00638 PreferenceChunk *pChunk; 00639 00640 // Delete all the chunks for this section 00641 do 00642 { 00643 // Unlink the first item from the list 00644 pChunk = (PreferenceChunk *) ChunkList.RemoveHead(); 00645 00646 // It doesn't matter if pChunk is NULL - delete handles it 00647 delete pChunk; 00648 00649 } while (pChunk != NULL); 00650 }
|
|
Adds a preference to this PreferenceSection object. If a new PreferenceChunk is needed to do this, it is allocated automatically, and added to this object's list of chunks.
Definition at line 674 of file prefs.cpp. 00676 { 00677 #ifdef _DEBUG 00678 if ((camStrnicmp(Pref, _T("blobby"), 7) == 0) || 00679 (camStrnicmp(Pref, _T("wobjob"), 7) == 0)) 00680 { 00681 // Silly names not allowed 00682 ENSURE(FALSE, "Preference section has suffered a cliche overload"); 00683 abort(); 00684 } 00685 #endif 00686 00687 // Used for scanning the chunk list 00688 PreferenceChunk *pChunk; 00689 00690 // In debug builds, check that this preference has not already been declared. 00691 // This check ensures that two preferences with the same name are not used. 00692 00693 #ifdef _DEBUG 00694 pChunk = (PreferenceChunk *) ChunkList.GetHead(); 00695 00696 while (pChunk != NULL) 00697 { 00698 ERROR3IF_PF((pChunk->PrefExists(Pref) != FALSE), ( "Preference '%s' in section '%s' declared more than once", Pref, Section ) ); 00699 00700 pChunk = (PreferenceChunk *) ChunkList.GetNext(pChunk); 00701 } 00702 00703 #endif 00704 00705 // New chunks are added to the head of the list, so the partially unused one 00706 // is always the first in the list. 00707 pChunk = (PreferenceChunk *) ChunkList.GetHead(); 00708 00709 // Try to add the preference to this chunk. 00710 if (!pChunk->AddPref(Pref, PrefVar, Type)) 00711 { 00712 // No room left in this chunk - try to get another one and put it in that. 00713 // The extension chunk is big enough to hold another 10 preferences (this is pretty 00714 // arbitrary). 00715 pChunk = new PreferenceChunk(10); 00716 00717 if ((pChunk == NULL) || (!pChunk->Valid)) 00718 { 00719 delete pChunk; 00720 return FALSE; // Failure - no memory left. 00721 } 00722 00723 // Got a chunk ok, so add it to the head of the list. 00724 ChunkList.AddHead(pChunk); 00725 00726 // Add the preference to it ('guaranteed' to work) 00727 pChunk->AddPref(Pref, PrefVar, Type); 00728 } 00729 00730 // Try to read the preference 00731 if (OILPrefs != NULL) 00732 OILPrefs->Read(Section, Pref, Type, PrefVar); 00733 00734 return TRUE; 00735 }
|
|
Reads a preference value from this PreferenceSection object by looking through all the chunks in this section for the named preference.
Definition at line 758 of file prefs.cpp. 00760 { 00761 #if !defined(EXCLUDE_FROM_RALPH) 00762 // Used for scanning the chunk list 00763 PreferenceChunk *pChunk; 00764 00765 // Check that this preference has not already been declared. 00766 // New chunks are added to the head of the list, so the partially unused one 00767 // is always the first in the list. 00768 pChunk = (PreferenceChunk *) ChunkList.GetHead(); 00769 00770 while (pChunk != NULL ) 00771 { 00772 // Try to read the preference value from this chunk. 00773 if (pChunk->GetPrefValue(Pref, PrefVar, Type)) 00774 return TRUE; // The read went ok so return that value to the caller 00775 00776 // Preference not in that chunk so move onto next chunk in list 00777 pChunk = (PreferenceChunk *) ChunkList.GetNext(pChunk); 00778 } 00779 #endif 00780 00781 return FALSE; // Value was not read ok, not the correct type or not present 00782 }
|
|
Finds a preference value from this PreferenceSection object by looking through all the chunks in this section for the named preference and then sets the value to the specifed new value.
Definition at line 806 of file prefs.cpp. 00808 { 00809 #if !defined(EXCLUDE_FROM_RALPH) 00810 // Used for scanning the chunk list 00811 PreferenceChunk *pChunk; 00812 00813 // Check that this preference has not already been declared. 00814 // New chunks are added to the head of the list, so the partially unused one 00815 // is always the first in the list. 00816 pChunk = (PreferenceChunk *) ChunkList.GetHead(); 00817 00818 while (pChunk != NULL ) 00819 { 00820 // Try to read the preference value from this chunk. 00821 if (pChunk->SetPrefValue(Pref, PrefVar, Type)) 00822 return TRUE; // The read went ok so return that value to the caller 00823 00824 // Preference not in that chunk so move onto next chunk in list 00825 pChunk = (PreferenceChunk *) ChunkList.GetNext(pChunk); 00826 } 00827 #endif 00828 00829 return FALSE; // Value was not set ok, not the correct type or not present 00830 }
|
|
Writes all the preferences in this section out to the preference file, using the OIL.
Definition at line 849 of file prefs.cpp. 00850 { 00851 // Write out each chunk in this section 00852 PreferenceChunk *pChunk = (PreferenceChunk *) ChunkList.GetHead(); 00853 00854 while (pChunk != NULL) 00855 { 00856 // Write out this chunk and move on to the next 00857 pChunk->Write(OILPrefs, Section); 00858 pChunk = (PreferenceChunk *) ChunkList.GetNext(pChunk); 00859 } 00860 }
|
|
|
|
|
|
|