// Get ( [resource requesting the query], [setting name], [return buffer], [return buffer length], [delete node] ) // // bDeleteNode contains a boolean to indicate whether the table contains one entry or multiple entries. If multiple // entries are used, the resource's storage node (which only gets deleted on resource stop) is used to store any // matching nodes that you have access to. The boolean is meant to let the caller know that the XML node that is // returned should be deleted after usage, for the sake of memory usage. // // Returns the XML node. // // If ( bDeleteNode == TRUE ), always remove the XML node after you're done with it! CXMLNode *CSettings::Get(const char *szLocalResource, const char *szSetting, bool &bDeleteNode) { CResource * pResource; CXMLNode * pNode = NULL; char szQueryResource[MAX_RESOURCE_LENGTH] = {0}; SettingStatus eStatus = NotFound; bDeleteNode = false; // Get the temporary storage node associated with this resource CResource *pLocalResource = m_pResourceManager->GetResource(szLocalResource); CXMLNode * pStorage = pLocalResource ? pLocalResource->GetStorageNode() : nullptr; // Get the actual resource name from the specified setting, and get the resource class if (!GetResourceName(szSetting, szQueryResource, MAX_RESOURCE_LENGTH - 1)) { // No name was specified, so use the local resource pResource = m_pResourceManager->GetResource(szLocalResource); } else pResource = m_pResourceManager->GetResource(szQueryResource); // If we have a valid resource if (pResource) { CXMLNode *pSource = pResource->GetSettingsNode(); // Try to get the value for the appropriate setting from the settings registry if (pStorage) { pNode = Get(m_pNodeGlobalSettings, pStorage, "", szLocalResource, szSetting, bDeleteNode, eStatus); // If we're getting all of the resource's settings, throw in those from the meta as well if (bDeleteNode) { SettingStatus eMetaStatus = NotFound; CXMLNode * pMetaNode = Get(pSource, pStorage, pResource->GetName().c_str(), szLocalResource, szSetting, bDeleteNode, eMetaStatus, pNode); if (eMetaStatus == Found) { eStatus = eMetaStatus; pNode = pMetaNode; } } } // See if we found a matching setting if (eStatus == Found) return pNode; // Found else if (eStatus == NotFound) { // Not found, continue searching // Try to get the value for the appropriate setting from the resource's meta XML file if (pSource) pNode = Get(pSource, pStorage, pResource->GetName().c_str(), szLocalResource, szSetting, bDeleteNode, eStatus); if (eStatus == Found) return pNode; } } else { // Try to get the value for the appropriate setting from the settings registry pNode = Get(m_pNodeGlobalSettings, pStorage, "", szLocalResource, szSetting, bDeleteNode, eStatus); if (eStatus == Found) return pNode; } return NULL; // No access or no settings found }