- Timestamp:
- Dec 5, 2012 12:08:52 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 82492
- Location:
- trunk
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/Guid.h
r34071 r44039 48 48 { 49 49 50 typedef enum 51 { 52 ZERO_GUID, 53 NORMAL_GUID, 54 INVALID_GUID 55 }GuidState_t; 56 50 57 /** 51 58 * Helper class that represents the UUID type and hides platform-specific … … 60 67 ::RTUuidClear(&mUuid); 61 68 refresh(); 69 mGuidState = ZERO_GUID; 62 70 } 63 71 … … 66 74 mUuid = that.mUuid; 67 75 refresh(); 76 if (isEmpty()) 77 mGuidState = ZERO_GUID; 78 else 79 mGuidState = NORMAL_GUID; 68 80 } 69 81 … … 72 84 mUuid = that; 73 85 refresh(); 86 if (isEmpty()) 87 mGuidState = ZERO_GUID; 88 else 89 mGuidState = NORMAL_GUID; 74 90 } 75 91 … … 79 95 ::memcpy(&mUuid, &that, sizeof(GUID)); 80 96 refresh(); 97 if (isEmpty()) 98 mGuidState = ZERO_GUID; 99 else 100 mGuidState = NORMAL_GUID; 81 101 } 82 102 … … 92 112 Guid(const char *that) 93 113 { 114 mGuidState = NORMAL_GUID; 115 94 116 int rc = ::RTUuidFromStr(&mUuid, that); 117 95 118 if (RT_FAILURE(rc)) 119 { 96 120 ::RTUuidClear(&mUuid); 121 mGuidState = INVALID_GUID; 122 } 123 else if(isEmpty()) 124 mGuidState = ZERO_GUID; 97 125 refresh(); 98 126 } … … 109 137 Guid(const Bstr &that) 110 138 { 111 int rc = !that.isEmpty() 112 ? ::RTUuidFromUtf16(&mUuid, that.raw()) 113 : VERR_INVALID_UUID_FORMAT; 139 mGuidState = NORMAL_GUID; 140 141 if (that.isEmpty()) 142 { 143 ::RTUuidClear(&mUuid); 144 mGuidState = ZERO_GUID; 145 } 146 else 147 { 148 int rc = ::RTUuidFromUtf16(&mUuid, that.raw()); 149 if (RT_FAILURE(rc)) 150 { 151 ::RTUuidClear(&mUuid); 152 mGuidState = INVALID_GUID; 153 } 154 } 155 156 refresh(); 157 } 158 159 Guid& operator=(const Guid &that) 160 { 161 mGuidState = NORMAL_GUID; 162 ::memcpy(&mUuid, &that.mUuid, sizeof (RTUUID)); 163 if (isEmpty()) 164 mGuidState = ZERO_GUID; 165 refresh(); 166 return *this; 167 } 168 Guid& operator=(const GUID &guid) 169 { 170 mGuidState = NORMAL_GUID; 171 ::memcpy(&mUuid, &guid, sizeof (GUID)); 172 if (isEmpty()) 173 mGuidState = ZERO_GUID; 174 refresh(); 175 return *this; 176 } 177 Guid& operator=(const RTUUID &guid) 178 { 179 mGuidState = NORMAL_GUID; 180 ::memcpy(&mUuid, &guid, sizeof (RTUUID)); 181 if (isEmpty()) 182 mGuidState = ZERO_GUID; 183 refresh(); 184 return *this; 185 } 186 Guid& operator=(const char *str) 187 { 188 mGuidState = NORMAL_GUID; 189 int rc = ::RTUuidFromStr(&mUuid, str); 190 114 191 if (RT_FAILURE(rc)) 192 { 115 193 ::RTUuidClear(&mUuid); 116 refresh(); 117 } 118 119 Guid& operator=(const Guid &that) 120 { 121 ::memcpy(&mUuid, &that.mUuid, sizeof (RTUUID)); 122 refresh(); 123 return *this; 124 } 125 Guid& operator=(const GUID &guid) 126 { 127 ::memcpy(&mUuid, &guid, sizeof (GUID)); 128 refresh(); 129 return *this; 130 } 131 Guid& operator=(const RTUUID &guid) 132 { 133 ::memcpy(&mUuid, &guid, sizeof (RTUUID)); 134 refresh(); 135 return *this; 136 } 137 Guid& operator=(const char *str) 138 { 139 int rc = ::RTUuidFromStr(&mUuid, str); 140 if (RT_FAILURE(rc)) 141 ::RTUuidClear(&mUuid); 142 refresh(); 194 mGuidState = INVALID_GUID; 195 } 196 else 197 { 198 if (isEmpty()) 199 mGuidState = ZERO_GUID; 200 } 201 202 refresh(); 203 143 204 return *this; 144 205 } … … 147 208 { 148 209 ::RTUuidCreate(&mUuid); 210 mGuidState = NORMAL_GUID; 149 211 refresh(); 150 212 } … … 152 214 { 153 215 ::RTUuidClear(&mUuid); 216 mGuidState = ZERO_GUID; 154 217 refresh(); 155 218 } … … 164 227 { 165 228 char buf[RTUUID_STR_LENGTH]; 229 230 ::memset(buf,0,RTUUID_STR_LENGTH); 231 232 if (mGuidState == INVALID_GUID) 233 { 234 /* What to return in case of wrong Guid */ 235 return Utf8Str("00000000-0000-0000-0000-00000000000"); 236 } 237 166 238 ::RTUuidToStr(&mUuid, buf, RTUUID_STR_LENGTH); 239 240 167 241 return Utf8Str(buf); 168 242 } … … 176 250 Utf8Str toStringCurly() const 177 251 { 252 253 if (mGuidState == INVALID_GUID) 254 { 255 /* What to return in case of wrong Guid */ 256 return Utf8Str("{00000000-0000-0000-0000-00000000000}"); 257 } 258 178 259 char buf[RTUUID_STR_LENGTH + 2] = "{"; 260 179 261 ::RTUuidToStr(&mUuid, buf + 1, RTUUID_STR_LENGTH); 180 262 buf[sizeof(buf) - 2] = '}'; 181 263 buf[sizeof(buf) - 1] = '\0'; 264 182 265 return Utf8Str(buf); 183 266 } … … 191 274 Bstr toUtf16() const 192 275 { 193 if ( isEmpty())194 return Bstr( );276 if (mGuidState == INVALID_GUID) 277 return Bstr("00000000-0000-0000-0000-00000000000"); 195 278 196 279 RTUTF16 buf[RTUUID_STR_LENGTH]; … … 199 282 } 200 283 201 bool isEmpty() const 202 { 203 return ::RTUuidIsNull(&mUuid); 204 } 205 206 bool isNotEmpty() const 207 { 208 return !::RTUuidIsNull(&mUuid); 284 bool isValid() const 285 { 286 bool res = true; 287 if (mGuidState == INVALID_GUID) 288 res = false; 289 290 return res; 291 } 292 293 bool isZero() const 294 { 295 return (::RTUuidIsNull(&mUuid) && mGuidState == ZERO_GUID); 209 296 } 210 297 … … 257 344 if (ppGuid) 258 345 *ppGuid = (nsID *)nsMemory::Clone(&mUuid, sizeof(nsID)); 346 259 347 return *this; 260 348 } … … 309 397 static const Guid Empty; 310 398 399 protected: 400 401 bool isEmpty() const 402 { 403 return ::RTUuidIsNull(&mUuid); 404 } 405 406 bool isNotEmpty() const 407 { 408 return !::RTUuidIsNull(&mUuid); 409 } 410 311 411 private: 312 412 /** … … 327 427 /** The UUID. */ 328 428 RTUUID mUuid; 429 430 GuidState_t mGuidState; 329 431 330 432 #ifdef DEBUG … … 335 437 #endif 336 438 }; 337 439 /* 338 440 inline Bstr asGuidStr(const Bstr& str) 339 441 { … … 341 443 return guid.isEmpty() ? Bstr() : guid.toUtf16(); 342 444 } 343 445 */ 344 446 inline bool isValidGuid(const Bstr& str) 345 447 { 346 448 Guid guid(str); 347 return !guid.isEmpty(); 449 return guid.isValid(); 450 // return !guid.isEmpty(); 348 451 } 349 452 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp
r42551 r44039 874 874 875 875 Bstr usbId = a->argv[2]; 876 if (Guid(usbId).isEmpty()) 876 877 Guid guid(usbId); 878 if (!guid.isValid()) 877 879 { 878 880 // assume address … … 897 899 CHECK_ERROR_BREAK(dev, COMGETTER(Id)(usbId.asOutParam())); 898 900 } 901 } 902 else if (guid.isZero()) 903 { 904 errorArgument("Zero UUID argument '%s'", a->argv[2]); 905 rc = E_FAIL; 906 break; 899 907 } 900 908 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r44028 r44039 159 159 160 160 /* If it is no UUID, convert the filename to an absolute one. */ 161 if ( id.isEmpty())161 if (!id.isValid()) 162 162 { 163 163 int irc = RTPathAbs(pszFilenameOrUuid, szFilenameAbs, sizeof(szFilenameAbs)); -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r42472 r44039 950 950 // first check if a UUID was supplied 951 951 uuidVM = argv[curArg]; 952 if (uuidVM.isEmpty()) 952 953 if (!uuidVM.isValid()) 953 954 { 954 955 LogFlow(("invalid UUID format, assuming it's a VM name\n")); 955 956 vmName = argv[curArg]; 957 } 958 else if (uuidVM.isZero()) 959 { 960 RTPrintf("Error: UUID argument is zero!\n"); 961 return 1; 956 962 } 957 963 } … … 1417 1423 * Do we have a UUID? 1418 1424 */ 1419 if ( !uuidVM.isEmpty())1425 if (uuidVM.isValid()) 1420 1426 { 1421 1427 rc = pVirtualBox->FindMachine(uuidVM.toUtf16().raw(), pMachine.asOutParam()); … … 1443 1449 goto leave; 1444 1450 } 1445 }1446 else if (uuidVM.isEmpty())1447 {1448 RTPrintf("Error: no machine specified!\n");1449 goto leave;1450 1451 } 1451 1452 -
trunk/src/VBox/Main/include/VirtualBoxBase.h
r42129 r44039 384 384 Guid tmpGuid(a_Arg); \ 385 385 (a_GuidVar) = tmpGuid; \ 386 if (RT_UNLIKELY((a_GuidVar).is Empty())) \386 if (RT_UNLIKELY((a_GuidVar).isValid() == false)) \ 387 387 return setError(E_INVALIDARG, \ 388 388 tr("GUID argument %s is not valid (\"%ls\")"), #a_Arg, Bstr(a_Arg).raw()); \ -
trunk/src/VBox/Main/src-all/ProgressImpl.cpp
r41184 r44039 200 200 { 201 201 /* remove the added progress on failure to complete the initialization */ 202 if (aAutoUninitSpan.initFailed() && !mId.isEmpty())202 if (aAutoUninitSpan.initFailed() && mId.isValid() && !mId.isZero()) 203 203 mParent->removeProgress(mId.ref()); 204 204 -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r43952 r44039 3177 3177 { 3178 3178 #ifdef VBOX_WITH_USB 3179 CheckComArgExpr(aId, Guid(aId).is Empty() == false);3179 CheckComArgExpr(aId, Guid(aId).isValid() == true); 3180 3180 CheckComArgOutPointerValid(aDevice); 3181 3181 … … 3489 3489 STDMETHODIMP Console::DeleteSnapshot(IN_BSTR aId, IProgress **aProgress) 3490 3490 { 3491 CheckComArgExpr(aId, Guid(aId).is Empty() == false);3491 CheckComArgExpr(aId, Guid(aId).isValid() == true); 3492 3492 CheckComArgOutPointerValid(aProgress); 3493 3493 … … 3512 3512 STDMETHODIMP Console::DeleteSnapshotAndAllChildren(IN_BSTR aId, IProgress **aProgress) 3513 3513 { 3514 CheckComArgExpr(aId, Guid(aId).is Empty() == false);3514 CheckComArgExpr(aId, Guid(aId).isValid() == true); 3515 3515 CheckComArgOutPointerValid(aProgress); 3516 3516 … … 3535 3535 STDMETHODIMP Console::DeleteSnapshotRange(IN_BSTR aStartId, IN_BSTR aEndId, IProgress **aProgress) 3536 3536 { 3537 CheckComArgExpr(aStartId, Guid(aStartId).is Empty() == false);3538 CheckComArgExpr(aEndId, Guid(aEndId).is Empty() == false);3537 CheckComArgExpr(aStartId, Guid(aStartId).isValid() == true); 3538 CheckComArgExpr(aEndId, Guid(aEndId).isValid() == true); 3539 3539 CheckComArgOutPointerValid(aProgress); 3540 3540 -
trunk/src/VBox/Main/src-client/RemoteUSBBackend.cpp
r38986 r44039 901 901 for (i = 0; i < RT_ELEMENTS(aGuids); i++) 902 902 { 903 if (aGuids[i].is Empty())903 if (aGuids[i].isZero()) 904 904 { 905 905 aGuids[i] = *pUuid; -
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r43041 r44039 2640 2640 if (cHardDisks == 1) 2641 2641 { 2642 if (hdUuid.is Empty())2642 if (hdUuid.isZero()) 2643 2643 hdUuid = thisUuid; 2644 2644 else … … 2647 2647 else 2648 2648 { 2649 if (thisUuid.isEmpty())2649 if (thisUuid.isZero()) 2650 2650 fInconsistent = true; 2651 2651 else if (thisUuid == hdUuid) … … 2700 2700 settings::AttachedDevice &d = *dit; 2701 2701 2702 if (d.uuid.is Empty())2702 if (d.uuid.isZero()) 2703 2703 // empty DVD and floppy media 2704 2704 continue; -
trunk/src/VBox/Main/src-server/HostImpl.cpp
r43958 r44039 1434 1434 return E_NOTIMPL; 1435 1435 #else 1436 if ( Guid(id).isEmpty())1436 if (!Guid(id).isValid()) 1437 1437 return E_INVALIDARG; 1438 1438 if (!networkInterface) … … 1538 1538 { 1539 1539 #ifdef VBOX_WITH_USB 1540 CheckComArgExpr(aId, Guid (aId).is Empty() == false);1540 CheckComArgExpr(aId, Guid (aId).isValid() == true); 1541 1541 CheckComArgOutPointerValid(aDevice); 1542 1542 … … 1869 1869 1870 1870 Guid uuid(strNameOrId); 1871 if ( !uuid.isEmpty())1871 if (uuid.isValid() && !uuid.isZero()) 1872 1872 return findHostDriveById(mediumType, uuid, true /* fRefresh */, pMedium); 1873 1873 -
trunk/src/VBox/Main/src-server/HostNetworkInterfaceImpl.cpp
r43933 r44039 70 70 71 71 ComAssertRet(!aInterfaceName.isEmpty(), E_INVALIDARG); 72 ComAssertRet(!aGuid.is Empty(), E_INVALIDARG);72 ComAssertRet(!aGuid.isValid(), E_INVALIDARG); 73 73 74 74 /* Enclose the state transition NotReady->InInit->Ready */ … … 185 185 186 186 // ComAssertRet(aInterfaceName, E_INVALIDARG); 187 // ComAssertRet( !aGuid.isEmpty(), E_INVALIDARG);187 // ComAssertRet(aGuid.isValid(), E_INVALIDARG); 188 188 ComAssertRet(pIf, E_INVALIDARG); 189 189 -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r43949 r44039 685 685 AssertReturn(!isSessionMachine(), E_FAIL); 686 686 AssertReturn(!isSnapshotMachine(), E_FAIL); 687 AssertReturn( !mData->mUuid.isEmpty(), E_FAIL);687 AssertReturn(mData->mUuid.isValid(), E_FAIL); 688 688 AssertReturn(!mData->mAccessible, E_FAIL); 689 689 … … 854 854 * because at this point we did not call uninitDataAndChildObjects() yet 855 855 * and therefore also removeBackReference() for all these mediums was not called! */ 856 if (!uuidMachine.isEmpty()) // can be empty if we're called from a failure of Machine::init 856 857 if (uuidMachine.isValid() && !uuidMachine.isZero()) // can be empty if we're called from a failure of Machine::init 857 858 mParent->unregisterMachineMedia(uuidMachine); 858 859 … … 1000 1001 // never be found by findMachine() 1001 1002 Guid test(aName); 1002 if (test.isNotEmpty()) 1003 //if (test.isNotEmpty()) 1004 if (test.isValid()) 1003 1005 return setError(E_INVALIDARG, tr("A machine cannot have a UUID as its name")); 1004 1006 … … 1338 1340 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1339 1341 1340 if ( !mHWData->mHardwareUUID.isEmpty())1342 if (mHWData->mHardwareUUID.isValid()) 1341 1343 mHWData->mHardwareUUID.toUtf16().cloneTo(aUUID); 1342 1344 else … … 1349 1351 { 1350 1352 Guid hardwareUUID(aUUID); 1351 if ( hardwareUUID.isEmpty())1353 if (!hardwareUUID.isValid()) 1352 1354 return E_INVALIDARG; 1353 1355 … … 5293 5295 { 5294 5296 Guid uuid(aNameOrId); 5295 if ( !uuid.isEmpty())5297 if (uuid.isValid()) 5296 5298 rc = findSnapshotById(uuid, pSnapshot, true /* aSetError */); 5297 5299 else … … 9029 9031 } 9030 9032 9031 if (aId.is Empty())9033 if (aId.isZero()) 9032 9034 aSnapshot = mData->mFirstSnapshot; 9033 9035 else -
trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp
r42109 r44039 951 951 * with the stuff from the snapshot. */ 952 952 settings::Snapshot sn; 953 if (!d->snapshotId.isEmpty()) 953 954 if (d->snapshotId.isValid() && !d->snapshotId.isZero()) 954 955 if (!d->findSnapshot(trgMCF.llFirstSnapshot, d->snapshotId, sn)) 955 956 throw p->setError(E_FAIL, … … 960 961 if (d->mode == CloneMode_MachineState) 961 962 { 962 if ( !sn.uuid.isEmpty())963 if (sn.uuid.isValid() && !sn.uuid.isZero()) 963 964 { 964 965 trgMCF.hardwareMachine = sn.hardware; … … 971 972 } 972 973 else if ( d->mode == CloneMode_MachineAndChildStates 973 && !sn.uuid.isEmpty()) 974 && sn.uuid.isValid() 975 && !sn.uuid.isZero()) 974 976 { 975 977 if (!d->pOldMachineState.isNull()) … … 1323 1325 /* Update the path in the configuration either for the current 1324 1326 * machine state or the snapshots. */ 1325 if ( sst.snapshotUuid.isEmpty())1327 if (!sst.snapshotUuid.isValid() || sst.snapshotUuid.isZero()) 1326 1328 trgMCF.strStateFile = strTrgSaveState; 1327 1329 else -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r44029 r44039 69 69 const Guid &aSnapshotId = Guid::Empty) 70 70 : machineId(aMachineId), 71 fInCurState(aSnapshotId.is Empty())72 { 73 if ( !aSnapshotId.isEmpty())71 fInCurState(aSnapshotId.isZero()) 72 { 73 if (aSnapshotId.isValid() && !aSnapshotId.isZero()) 74 74 llSnapshotIds.push_back(aSnapshotId); 75 75 } … … 942 942 unconst(m->pVirtualBox) = aVirtualBox; 943 943 944 if ( !uuidMachineRegistry.isEmpty())944 if (uuidMachineRegistry.isValid() && !uuidMachineRegistry.isZero()) 945 945 m->llRegistryIDs.push_back(uuidMachineRegistry); 946 946 … … 1087 1087 else 1088 1088 { 1089 AssertStmt(!m->id.is Empty(),1089 AssertStmt(!m->id.isZero(), 1090 1090 alock.release(); autoCaller.release(); uninit(); return E_FAIL); 1091 1091 … … 1142 1142 unconst(m->pVirtualBox) = aVirtualBox; 1143 1143 1144 if ( !uuidMachineRegistry.isEmpty())1144 if (uuidMachineRegistry.isValid() && !uuidMachineRegistry.isZero()) 1145 1145 m->llRegistryIDs.push_back(uuidMachineRegistry); 1146 1146 … … 2000 2000 { 2001 2001 imageId = Guid(aImageId); 2002 if ( imageId.isEmpty())2003 return setError(E_INVALIDARG, tr("Argument %s is empty"), "aImageId");2002 if (!imageId.isValid()) 2003 return setError(E_INVALIDARG, tr("Argument %s is invalid"), "aImageId"); 2004 2004 } 2005 2005 } … … 2061 2061 ComSafeArrayOut(BSTR, aSnapshotIds)) 2062 2062 { 2063 CheckComArgExpr(aMachineId, Guid(aMachineId).is Empty() == false);2063 CheckComArgExpr(aMachineId, Guid(aMachineId).isValid() == true); 2064 2064 CheckComArgOutSafeArrayPointerValid(aSnapshotIds); 2065 2065 … … 3401 3401 const Guid &aSnapshotId /*= Guid::Empty*/) 3402 3402 { 3403 AssertReturn( !aMachineId.isEmpty(), E_FAIL);3403 AssertReturn(aMachineId.isValid(), E_FAIL); 3404 3404 3405 3405 LogFlowThisFunc(("ENTER, aMachineId: {%RTuuid}, aSnapshotId: {%RTuuid}\n", aMachineId.raw(), aSnapshotId.raw())); … … 3443 3443 // to a machine a medium which represents the machine's current state, 3444 3444 // so set the flag 3445 if (aSnapshotId.isEmpty()) 3445 3446 if (aSnapshotId.isZero()) 3446 3447 { 3447 3448 /* sanity: no duplicate attachments */ … … 3499 3500 const Guid &aSnapshotId /*= Guid::Empty*/) 3500 3501 { 3501 AssertReturn( !aMachineId.isEmpty(), E_FAIL);3502 AssertReturn(aMachineId.isValid(), E_FAIL); 3502 3503 3503 3504 AutoCaller autoCaller(this); … … 3511 3512 AssertReturn(it != m->backRefs.end(), E_FAIL); 3512 3513 3513 if (aSnapshotId.is Empty())3514 if (aSnapshotId.isZero()) 3514 3515 { 3515 3516 /* remove the current state attachment */ … … 4589 4590 && ( !aMachineId 4590 4591 || m->backRefs.size() != 1 4591 || aMachineId->is Empty()4592 || aMachineId->isZero() 4592 4593 || *getFirstMachineBackrefId() != *aMachineId 4593 || ( (!aSnapshotId || !aSnapshotId->is Empty())4594 || ( (!aSnapshotId || !aSnapshotId->isZero()) 4594 4595 && *getFirstMachineBackrefSnapshotId() != *aSnapshotId))) 4595 4596 throw setError(VBOX_E_OBJECT_IN_USE, … … 5435 5436 /* are we dealing with a new medium constructed using the existing 5436 5437 * location? */ 5437 bool isImport = m->id.is Empty();5438 bool isImport = m->id.isZero(); 5438 5439 unsigned uOpenFlags = VD_OPEN_FLAGS_INFO; 5439 5440 … … 5560 5561 mediumId = uuid; 5561 5562 5562 if (mediumId.is Empty() && (m->hddOpenMode == OpenReadOnly))5563 if (mediumId.isZero() && (m->hddOpenMode == OpenReadOnly)) 5563 5564 // only when importing a VDMK that has no UUID, create one in memory 5564 5565 mediumId.create(); … … 5566 5567 else 5567 5568 { 5568 Assert(!mediumId.isEmpty());5569 Assert(!mediumId.isZero()); 5569 5570 5570 5571 if (mediumId != uuid) … … 6034 6035 || ( autoCaller.state() == InInit 6035 6036 && m->state != MediumState_NotCreated 6036 && m->id.is Empty()6037 && m->id.isZero() 6037 6038 && m->strFormat.isEmpty() 6038 6039 && m->formatObj.isNull()), … … 6593 6594 * the setLocation() argument). Otherwise we have to generate it */ 6594 6595 Guid id = m->id; 6595 fGenerateUuid = id.isEmpty(); 6596 6597 fGenerateUuid = id.isZero(); 6596 6598 if (fGenerateUuid) 6597 6599 { … … 6730 6732 * the setLocation() argument). Otherwise we have to generate it */ 6731 6733 Guid targetId = pTarget->m->id; 6732 fGenerateUuid = targetId.isEmpty(); 6734 6735 fGenerateUuid = targetId.isZero(); 6733 6736 if (fGenerateUuid) 6734 6737 { … … 7234 7237 * the setLocation() argument). Otherwise we have to generate it */ 7235 7238 Guid targetId = pTarget->m->id; 7236 fGenerateUuid = targetId.isEmpty(); 7239 7240 fGenerateUuid = targetId.isZero(); 7237 7241 if (fGenerateUuid) 7238 7242 { … … 8052 8056 * the setLocation() argument). Otherwise we have to generate it */ 8053 8057 Guid targetId = m->id; 8054 fGenerateUuid = targetId.isEmpty(); 8058 8059 fGenerateUuid = targetId.isZero(); 8055 8060 if (fGenerateUuid) 8056 8061 { -
trunk/src/VBox/Main/src-server/SnapshotImpl.cpp
r43915 r44039 115 115 LogFlowThisFunc(("uuid=%s aParent->uuid=%s\n", aId.toString().c_str(), (aParent) ? aParent->m->uuid.toString().c_str() : "")); 116 116 117 ComAssertRet(!aId.is Empty() && !aName.isEmpty() && aMachine, E_INVALIDARG);117 ComAssertRet(!aId.isZero() && aId.isValid() && !aName.isEmpty() && aMachine, E_INVALIDARG); 118 118 119 119 /* Enclose the state transition NotReady->InInit->Ready */ … … 329 329 // never be found by findMachine() 330 330 Guid test(aName); 331 if (test.isNotEmpty()) 331 332 if (!test.isZero() && test.isValid()) 332 333 return setError(E_INVALIDARG, tr("A machine cannot have a UUID as its name")); 333 334 … … 956 957 LogFlowThisFunc(("mName={%s}\n", aSessionMachine->mUserData->s.strName.c_str())); 957 958 958 AssertReturn(aSessionMachine && !Guid(aSnapshotId).isEmpty(), E_INVALIDARG); 959 Guid l_guid(aSnapshotId); 960 AssertReturn(aSessionMachine && (!l_guid.isZero() && l_guid.isValid()), E_INVALIDARG); 959 961 960 962 /* Enclose the state transition NotReady->InInit->Ready */ … … 1097 1099 LogFlowThisFunc(("mName={%s}\n", aMachine->mUserData->s.strName.c_str())); 1098 1100 1099 AssertReturn(aMachine && !Guid(aSnapshotId).isEmpty(), E_INVALIDARG); 1101 Guid l_guid(aSnapshotId); 1102 AssertReturn(aMachine && (!l_guid.isZero() && l_guid.isValid()), E_INVALIDARG); 1100 1103 1101 1104 /* Enclose the state transition NotReady->InInit->Ready */ … … 2062 2065 Guid startId(aStartId); 2063 2066 Guid endId(aEndId); 2064 AssertReturn(aInitiator && !startId.isEmpty() && !endId.isEmpty(), E_INVALIDARG); 2067 2068 AssertReturn(aInitiator && !startId.isZero() && !endId.isZero() && startId.isValid() && endId.isValid(), E_INVALIDARG); 2069 2065 2070 AssertReturn(aMachineState && aProgress, E_POINTER); 2066 2071 … … 2463 2468 replaceSnapshotId = *pSnapshotId; 2464 2469 2465 if ( !replaceMachineId.isEmpty())2470 if (replaceMachineId.isValid() && !replaceMachineId.isZero()) 2466 2471 { 2467 2472 // Adjust the backreferences, otherwise merging will assert. … … 3240 3245 } 3241 3246 3242 if ( !aMachineId.isEmpty())3247 if (aMachineId.isValid() && !aMachineId.isZero()) 3243 3248 { 3244 3249 // reattach the source media to the snapshot -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r44029 r44039 1453 1453 } 1454 1454 } 1455 if (id.isEmpty()) 1455 1456 if (id.isZero()) 1456 1457 fDirectoryIncludesUUID = false; 1458 else if (!id.isValid()) 1459 { 1460 /* do something else */ 1461 return setError(E_INVALIDARG, 1462 tr("'%ls' is not a valid Guid"), 1463 id.toStringCurly().c_str()); 1464 } 1457 1465 1458 1466 Utf8Str strGroup(aGroup); … … 1649 1657 } 1650 1658 /* Create UUID if none was specified. */ 1651 if (id.is Empty())1659 if (id.isZero()) 1652 1660 id.create(); 1661 else if (!id.isValid()) 1662 { 1663 /* do something else */ 1664 return setError(E_INVALIDARG, 1665 tr("'%ls' is not a valid Guid"), 1666 id.toStringCurly().c_str()); 1667 } 1653 1668 1654 1669 /* NULL settings file means compose automatically */ … … 1780 1795 1781 1796 Guid id(aNameOrId); 1782 if (!id.isEmpty()) 1797 if (id.isValid() && !id.isZero()) 1798 1783 1799 rc = findMachine(id, 1784 1800 true /* fPermitInaccessible */, … … 1953 1969 { 1954 1970 case DeviceType_HardDisk: 1955 if ( !id.isEmpty())1971 if (id.isValid() && !id.isZero()) 1956 1972 rc = findHardDiskById(id, false /* setError */, &pMedium); 1957 1973 else … … 1963 1979 case DeviceType_Floppy: 1964 1980 case DeviceType_DVD: 1965 if ( !id.isEmpty())1981 if (id.isValid() && !id.isZero()) 1966 1982 rc = findDVDOrFloppyImage(deviceType, &id, Utf8Str::Empty, 1967 1983 false /* setError */, &pMedium); … … 3407 3423 ComObjPtr<Medium> *aHardDisk /*= NULL*/) 3408 3424 { 3409 AssertReturn(!id.is Empty(), E_INVALIDARG);3425 AssertReturn(!id.isZero(), E_INVALIDARG); 3410 3426 3411 3427 // we use the hard disks map, but it is protected by the … … 3614 3630 ComObjPtr<Medium> &pMedium) 3615 3631 { 3616 if (uuid.is Empty())3632 if (uuid.isZero()) 3617 3633 { 3618 3634 // that's easy 3619 3635 pMedium.setNull(); 3620 3636 return S_OK; 3637 } 3638 else if (!uuid.isValid()) 3639 { 3640 /* handling of case invalid GUID */ 3641 return setError(VBOX_E_OBJECT_NOT_FOUND, 3642 tr("Guid '%ls' is invalid"), 3643 uuid.toString().c_str()); 3621 3644 } 3622 3645 … … 3821 3844 ComObjPtr<Medium> *ppMedium) 3822 3845 { 3823 AssertReturn(!aId.is Empty() && !aLocation.isEmpty(), E_FAIL);3846 AssertReturn(!aId.isZero() && !aLocation.isEmpty(), E_FAIL); 3824 3847 AssertReturn(ppMedium, E_INVALIDARG); 3825 3848 … … 3834 3857 const char *pcszType = NULL; 3835 3858 3836 if ( !aId.isEmpty())3859 if (aId.isValid() && !aId.isZero()) 3837 3860 rc = findHardDiskById(aId, false /* aSetError */, &pMediumFound); 3838 3861 if (FAILED(rc) && !aLocation.isEmpty()) … … 4423 4446 HRESULT VirtualBox::unregisterMachineMedia(const Guid &uuidMachine) 4424 4447 { 4425 Assert(!uuidMachine.is Empty());4448 Assert(!uuidMachine.isZero() && uuidMachine.isValid()); 4426 4449 4427 4450 LogFlowFuncEnter(); -
trunk/src/VBox/Main/xml/Settings.cpp
r43041 r44039 383 383 { 384 384 guid = strUUID.c_str(); 385 if (guid.isEmpty()) 385 if (guid.isZero()) 386 throw ConfigFileError(this, NULL, N_("UUID \"%s\" has zero format"), strUUID.c_str()); 387 else if (!guid.isValid()) 386 388 throw ConfigFileError(this, NULL, N_("UUID \"%s\" has invalid format"), strUUID.c_str()); 387 389 } … … 3545 3547 if (m->sv >= SettingsVersion_v1_4) 3546 3548 pelmHardware->setAttribute("version", hw.strVersion); 3547 if ( (m->sv >= SettingsVersion_v1_9) 3548 && (!hw.uuid.isEmpty()) 3549 3550 if ((m->sv >= SettingsVersion_v1_9) 3551 && !hw.uuid.isZero() 3552 && hw.uuid.isValid() 3549 3553 ) 3550 3554 pelmHardware->setAttribute("uuid", hw.uuid.toStringCurly()); … … 3862 3866 if (att.fTempEject) 3863 3867 pelmDVD->setAttribute("tempeject", att.fTempEject); 3864 if (!att.uuid.isEmpty()) 3868 3869 if (!att.uuid.isZero() && att.uuid.isValid()) 3865 3870 pelmDVD->createChild("Image")->setAttribute("uuid", att.uuid.toStringCurly()); 3866 3871 else if (att.strHostDriveSrc.length()) … … 3878 3883 const AttachedDevice &att = sctl.llAttachedDevices.front(); 3879 3884 pelmFloppy->setAttribute("enabled", true); 3880 if (!att.uuid.isEmpty()) 3885 3886 if (!att.uuid.isZero() && att.uuid.isValid()) 3881 3887 pelmFloppy->createChild("Image")->setAttribute("uuid", att.uuid.toStringCurly()); 3882 3888 else if (att.strHostDriveSrc.length()) … … 4451 4457 4452 4458 // attached image, if any 4453 if ( !att.uuid.isEmpty() 4454 && ( att.deviceType == DeviceType_HardDisk 4459 if (!att.uuid.isZero() 4460 && att.uuid.isValid() 4461 && (att.deviceType == DeviceType_HardDisk 4455 4462 || !fSkipRemovableMedia 4456 4463 ) … … 4655 4662 ) 4656 4663 elmMachine.setAttributePath("stateFile", strStateFile); 4657 if ( (fl & BuildMachineXML_IncludeSnapshots) 4658 && !uuidCurrentSnapshot.isEmpty()) 4664 4665 if ((fl & BuildMachineXML_IncludeSnapshots) 4666 && !uuidCurrentSnapshot.isZero() 4667 && uuidCurrentSnapshot.isValid()) 4659 4668 elmMachine.setAttribute("currentSnapshot", uuidCurrentSnapshot.toStringCurly()); 4660 4669 … … 5174 5183 || !machineUserData.strTeleporterAddress.isEmpty() 5175 5184 || !machineUserData.strTeleporterPassword.isEmpty() 5176 || !hardwareMachine.uuid.isEmpty()5185 || (!hardwareMachine.uuid.isZero() && hardwareMachine.uuid.isValid()) 5177 5186 ) 5178 5187 )
Note:
See TracChangeset
for help on using the changeset viewer.