VirtualBox

Ignore:
Timestamp:
Mar 9, 2008 11:54:02 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
28816
Message:

Main/Settings: Perform conversion in a loop to allow for multi-step version to version updates (e.g. v1.0->v1.1->v1.2) which saves from patching all previous transformation rules when on every version change but still makes it possible to update from too old versions to the most recent one.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/VirtualBoxImplExtra.cpp

    r7341 r7387  
    7575 *
    7676 * The implementation normally checks for the "version" value of the
    77  * root key to determine if the conversion is necessary. The
    78  * implementation must return a string representing the old version
    79  * (before conversion) in the @c aOldVersion argument -- this string is
    80  * used by XmlTreeBackend::oldVersion() and must be non-NULL to indicate
    81  * that the conversion has been performed on the tree. The returned
    82  * string must be allocated using RTStrDup or such.
     77 * root key to determine if the conversion is necessary. When the
     78 * @a aOldVersion argument is not NULL, the implementation must return a
     79 * non-NULL non-empty string representing the old version (before
     80 * conversion) in it this string is used by XmlTreeBackend::oldVersion()
     81 * and must be non-NULL to indicate that the conversion has been
     82 * performed on the tree. The returned string must be allocated using
     83 * RTStrDup() or such.
     84 *
     85 * This method is called again after the successful transformation to
     86 * let the implementation retry the version check and request another
     87 * transformation if necessary. This may be used to perform multi-step
     88 * conversion like this: 1.1 => 1.2, 1.2 => 1.3 (instead of 1.1 => 1.3)
     89 * which saves from the need to update all previous conversion
     90 * templates to make each of them convert directly to the recent
     91 * version.
     92 *
     93 * @note Multi-step transformations are performed in a loop that exits
     94 *       only when this method returns @false. It's up to the
     95 *       implementation to detect cycling (repeated requests to convert
     96 *       from the same version) wrong version order, etc. and throw an
     97 *       EConversionCycle exception to break the loop without returning
     98 *       @false (which means the transformation succeeded).
    8399 *
    84100 * @param aRoot                 Root settings key.
    85  * @param aOldVersionString     Old version string (allocated by
    86  *                              RTStrDup or such).
     101 * @param aOldVersionString     Where to store old version string
     102 *                              pointer. May be NULL.
    87103 */
    88104bool VirtualBox::SettingsTreeHelper::
    89 needsConversion (const settings::Key &aRoot, char *&aOldVersion) const
     105needsConversion (const settings::Key &aRoot, char **aOldVersion) const
    90106{
    91107    if (strcmp (aRoot.name(), "VirtualBox") == 0)
     
    98114            {
    99115                /* version mismatch */
    100                 aOldVersion = RTStrDup (version);
     116                if (aOldVersion != NULL)
     117                    *aOldVersion = RTStrDup (version);
     118
    101119                return true;
    102120            }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette