Changeset 31480 in vbox
- Timestamp:
- Aug 9, 2010 12:28:25 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MediumImpl.cpp
r31479 r31480 150 150 bool hostDrive : 1; 151 151 152 typedef std::map<Bstr, Bstr> PropertyMap; 153 PropertyMap properties; 152 settings::PropertiesMap mapProperties; 154 153 155 154 bool implicit : 1; … … 993 992 const Utf8Str &name = it->first; 994 993 const Utf8Str &value = it->second; 995 m-> properties[Bstr(name)] = Bstr(value);994 m->mapProperties[name] = value; 996 995 } 997 996 … … 1963 1962 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1964 1963 1965 Data::PropertyMap::const_iterator it = m->properties.find(Bstr(aName));1966 if (it == m-> properties.end())1964 settings::PropertiesMap::const_iterator it = m->mapProperties.find(Utf8Str(aName)); 1965 if (it == m->mapProperties.end()) 1967 1966 return setError(VBOX_E_OBJECT_NOT_FOUND, 1968 1967 tr("Property '%ls' does not exist"), aName); … … 1991 1990 } 1992 1991 1993 Data::PropertyMap::iterator it = m->properties.find(Bstr(aName));1994 if (it == m-> properties.end())1992 settings::PropertiesMap::iterator it = m->mapProperties.find(Utf8Str(aName)); 1993 if (it == m->mapProperties.end()) 1995 1994 return setError(VBOX_E_OBJECT_NOT_FOUND, 1996 1995 tr("Property '%ls' does not exist"), 1997 1996 aName); 1998 1997 1999 if (aValue && !*aValue) 2000 it->second = (const char *)NULL; 2001 else 2002 it->second = aValue; 1998 it->second = aValue; 2003 1999 2004 2000 // save the global settings; for that we should hold only the VirtualBox lock … … 2025 2021 NOREF(aNames); 2026 2022 2027 com::SafeArray<BSTR> names(m-> properties.size());2028 com::SafeArray<BSTR> values(m-> properties.size());2023 com::SafeArray<BSTR> names(m->mapProperties.size()); 2024 com::SafeArray<BSTR> values(m->mapProperties.size()); 2029 2025 size_t i = 0; 2030 2026 2031 for ( Data::PropertyMap::const_iterator it = m->properties.begin();2032 it != m-> properties.end();2027 for (settings::PropertiesMap::const_iterator it = m->mapProperties.begin(); 2028 it != m->mapProperties.end(); 2033 2029 ++it) 2034 2030 { … … 2063 2059 ++i) 2064 2060 { 2065 if (m-> properties.find(Bstr(names[i])) == m->properties.end())2061 if (m->mapProperties.find(Utf8Str(names[i])) == m->mapProperties.end()) 2066 2062 return setError(VBOX_E_OBJECT_NOT_FOUND, 2067 2063 tr("Property '%ls' does not exist"), names[i]); … … 2073 2069 ++i) 2074 2070 { 2075 Data::PropertyMap::iterator it = m->properties.find(Bstr(names[i])); 2076 AssertReturn(it != m->properties.end(), E_FAIL); 2077 2078 if (values[i] && !*values[i]) 2079 it->second = (const char *)NULL; 2080 else 2081 it->second = values[i]; 2071 settings::PropertiesMap::iterator it = m->mapProperties.find(Utf8Str(names[i])); 2072 AssertReturn(it != m->mapProperties.end(), E_FAIL); 2073 2074 it->second = Utf8Str(values[i]); 2082 2075 } 2083 2076 … … 3027 3020 /* optional properties */ 3028 3021 data.properties.clear(); 3029 for ( Data::PropertyMap::const_iterator it = m->properties.begin();3030 it != m-> properties.end();3022 for (settings::PropertiesMap::const_iterator it = m->mapProperties.begin(); 3023 it != m->mapProperties.end(); 3031 3024 ++it) 3032 3025 { … … 3034 3027 if (!it->second.isEmpty()) 3035 3028 { 3036 Utf8Strname = it->first;3037 Utf8Strvalue = it->second;3029 const Utf8Str &name = it->first; 3030 const Utf8Str &value = it->second; 3038 3031 data.properties[name] = value; 3039 3032 } … … 4919 4912 * properties is meant to be constant. */ 4920 4913 4921 Assert(m-> properties.empty());4914 Assert(m->mapProperties.empty()); 4922 4915 4923 4916 for (MediumFormat::PropertyList::const_iterator it = m->formatObj->getProperties().begin(); … … 4925 4918 ++it) 4926 4919 { 4927 m-> properties.insert(std::make_pair(it->strName, Utf8Str::Empty));4920 m->mapProperties.insert(std::make_pair(it->strName, Utf8Str::Empty)); 4928 4921 } 4929 4922 } … … 5015 5008 5016 5009 /* static */ 5017 DECLCALLBACK(int) Medium::vdConfigQuerySize(void *pvUser, const char *pszName, 5010 DECLCALLBACK(int) Medium::vdConfigQuerySize(void *pvUser, 5011 const char *pszName, 5018 5012 size_t *pcbValue) 5019 5013 { … … 5023 5017 AssertReturn(that != NULL, VERR_GENERAL_FAILURE); 5024 5018 5025 Data::PropertyMap::const_iterator it = 5026 that->m->properties.find(Bstr(pszName)); 5027 if (it == that->m->properties.end()) 5019 settings::PropertiesMap::const_iterator it = that->m->mapProperties.find(Utf8Str(pszName)); 5020 if (it == that->m->mapProperties.end()) 5028 5021 return VERR_CFGM_VALUE_NOT_FOUND; 5029 5022 … … 5038 5031 5039 5032 /* static */ 5040 DECLCALLBACK(int) Medium::vdConfigQuery(void *pvUser, const char *pszName, 5041 char *pszValue, size_t cchValue) 5033 DECLCALLBACK(int) Medium::vdConfigQuery(void *pvUser, 5034 const char *pszName, 5035 char *pszValue, 5036 size_t cchValue) 5042 5037 { 5043 5038 AssertReturn(VALID_PTR(pszValue), VERR_INVALID_POINTER); … … 5046 5041 AssertReturn(that != NULL, VERR_GENERAL_FAILURE); 5047 5042 5048 Data::PropertyMap::const_iterator it = 5049 that->m->properties.find(Bstr(pszName)); 5050 if (it == that->m->properties.end()) 5043 settings::PropertiesMap::const_iterator it = that->m->mapProperties.find(Utf8Str(pszName)); 5044 if (it == that->m->mapProperties.end()) 5051 5045 return VERR_CFGM_VALUE_NOT_FOUND; 5052 5053 Utf8Str value = it->second;5054 if (value.length() >= cchValue)5055 return VERR_CFGM_NOT_ENOUGH_SPACE;5056 5046 5057 5047 /* we interpret null values as "no value" in Medium */ 5058 5048 if (it->second.isEmpty()) 5059 5049 return VERR_CFGM_VALUE_NOT_FOUND; 5050 5051 const Utf8Str &value = it->second; 5052 if (value.length() >= cchValue) 5053 return VERR_CFGM_NOT_ENOUGH_SPACE; 5060 5054 5061 5055 memcpy(pszValue, value.c_str(), value.length() + 1);
Note:
See TracChangeset
for help on using the changeset viewer.