VirtualBox

Changeset 16558 in vbox


Ignore:
Timestamp:
Feb 6, 2009 4:41:43 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
42504
Message:

Main: back out r42503

Location:
trunk
Files:
1 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/settings.h

    r16557 r16558  
    4444
    4545#include <iprt/time.h>
    46 
    47 #include <VBox/com/Guid.h>
    4846
    4947#include <VBox/xml.h>
     
    441439 */
    442440DECLEXPORT (stdx::char_auto_ptr) ToString (const void *aData, size_t aLen);
    443 
    444 #if defined VBOX_MAIN_SETTINGS_ADDONS
    445 
    446 /// @todo once string data in Bstr and Utf8Str is auto_ref_ptr, enable the
    447 /// code below
    448 
    449 #if 0
    450 
    451 /** Specialization of FromString for Bstr. */
    452 template<> com::Bstr FromString <com::Bstr> (const char *aValue);
    453 
    454 #endif
    455 
    456 /** Specialization of ToString for Bstr. */
    457 template<> stdx::char_auto_ptr
    458 ToString <com::Bstr> (const com::Bstr &aValue, unsigned int aExtra);
    459 
    460 /** Specialization of FromString for Guid. */
    461 template<> com::Guid FromString <com::Guid> (const char *aValue);
    462 
    463 /** Specialization of ToString for Guid. */
    464 template<> stdx::char_auto_ptr
    465 ToString <com::Guid> (const com::Guid &aValue, unsigned int aExtra);
    466 
    467 #endif // VBOX_MAIN_SETTINGS_ADDONS
    468441
    469442// the rest
  • trunk/src/VBox/Main/AudioAdapterImpl.cpp

    r16557 r16558  
    2525
    2626#include <iprt/cpputils.h>
    27 
    28 #include <VBox/settings.h>
    2927
    3028// constructor / destructor
  • trunk/src/VBox/Main/BIOSSettingsImpl.cpp

    r16557 r16558  
    2424#include "Logging.h"
    2525#include "GuestOSTypeImpl.h"
    26 
    2726#include <iprt/cpputils.h>
    28 #include <VBox/settings.h>
    2927
    3028// constructor / destructor
  • trunk/src/VBox/Main/DVDDriveImpl.cpp

    r16557 r16558  
    3535#include <iprt/string.h>
    3636#include <iprt/cpputils.h>
    37 
    38 #include <VBox/settings.h>
    3937
    4038// constructor / destructor
  • trunk/src/VBox/Main/FloppyDriveImpl.cpp

    r16557 r16558  
    3535#include <iprt/string.h>
    3636#include <iprt/cpputils.h>
    37 
    38 #include <VBox/settings.h>
    3937
    4038// constructor / destructor
  • trunk/src/VBox/Main/HardDisk2Impl.cpp

    r16557 r16558  
    3333
    3434#include <VBox/err.h>
    35 #include <VBox/settings.h>
    3635
    3736#include <iprt/param.h>
  • trunk/src/VBox/Main/HostImpl.cpp

    r16557 r16558  
    102102
    103103
     104#include <VBox/usb.h>
     105#include <VBox/x86.h>
     106#include <VBox/err.h>
    104107#include <iprt/asm.h>
    105108#include <iprt/string.h>
     
    116119#include "netif.h"
    117120#endif
    118 
    119 #include <VBox/usb.h>
    120 #include <VBox/x86.h>
    121 #include <VBox/err.h>
    122 #include <VBox/settings.h>
    123121
    124122#if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
  • trunk/src/VBox/Main/MachineImpl.cpp

    r16557 r16558  
    2727#ifndef __STDC_CONSTANT_MACROS
    2828# define __STDC_CONSTANT_MACROS
     29#endif
     30
     31#if defined(RT_OS_WINDOWS)
     32#elif defined(RT_OS_LINUX)
    2933#endif
    3034
     
    7377#include <VBox/err.h>
    7478#include <VBox/param.h>
    75 #include <VBox/settings.h>
    76 
    7779#ifdef VBOX_WITH_GUEST_PROPS
    7880# include <VBox/HostServices/GuestPropertySvc.h>
  • trunk/src/VBox/Main/MediumImpl.cpp

    r16557 r16558  
    3030#include <VBox/com/array.h>
    3131
    32 #include <VBox/err.h>
    33 #include <VBox/settings.h>
    34 
    3532#include <iprt/param.h>
    3633#include <iprt/path.h>
    3734#include <iprt/file.h>
     35
     36#include <VBox/err.h>
    3837
    3938////////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Main/NetworkAdapterImpl.cpp

    r16557 r16558  
    2929
    3030#include <VBox/err.h>
    31 #include <VBox/settings.h>
    3231
    3332// constructor / destructor
  • trunk/src/VBox/Main/ParallelPortImpl.cpp

    r16557 r16558  
    2727#include <iprt/string.h>
    2828#include <iprt/cpputils.h>
    29 
    30 #include <VBox/settings.h>
    3129
    3230// constructor / destructor
  • trunk/src/VBox/Main/PerformanceImpl.cpp

    r16557 r16558  
    2222 */
    2323
     24#if defined(RT_OS_WINDOWS)
     25#elif defined(RT_OS_LINUX)
     26#endif
     27
    2428#include "PerformanceImpl.h"
    2529
    2630#include "Logging.h"
    2731
     32#include <VBox/err.h>
    2833#include <iprt/process.h>
    29 
    30 #include <VBox/err.h>
    31 #include <VBox/settings.h>
    3234
    3335#include <vector>
  • trunk/src/VBox/Main/SATAControllerImpl.cpp

    r16557 r16558  
    2222 */
    2323
     24
     25
    2426#include "SATAControllerImpl.h"
    2527#include "MachineImpl.h"
     
    2931#include <iprt/string.h>
    3032#include <iprt/cpputils.h>
    31 
    3233#include <VBox/err.h>
    33 #include <VBox/settings.h>
    3434
    3535#include <algorithm>
  • trunk/src/VBox/Main/SerialPortImpl.cpp

    r16557 r16558  
    2727#include <iprt/string.h>
    2828#include <iprt/cpputils.h>
    29 
    30 #include <VBox/settings.h>
    3129
    3230// constructor / destructor
  • trunk/src/VBox/Main/SystemPropertiesImpl.cpp

    r16557 r16558  
    3232#include <iprt/path.h>
    3333#include <iprt/dir.h>
    34 
     34#include <VBox/param.h>
    3535#include <VBox/err.h>
    36 #include <VBox/param.h>
    37 #include <VBox/settings.h>
    3836
    3937// defines
  • trunk/src/VBox/Main/USBControllerImpl.cpp

    r16557 r16558  
    3333#include "Logging.h"
    3434
     35
    3536#include <iprt/string.h>
    3637#include <iprt/cpputils.h>
    37 
    3838#include <VBox/err.h>
    39 #include <VBox/settings.h>
    4039
    4140#include <algorithm>
  • trunk/src/VBox/Main/VirtualBoxBase.cpp

    r16557 r16558  
    12141214}
    12151215
    1216 
     1216// Settings API additions
     1217////////////////////////////////////////////////////////////////////////////////
     1218
     1219#if defined VBOX_MAIN_SETTINGS_ADDONS
     1220
     1221namespace settings
     1222{
     1223
     1224template<> stdx::char_auto_ptr
     1225ToString <com::Bstr> (const com::Bstr &aValue, unsigned int aExtra)
     1226{
     1227    stdx::char_auto_ptr result;
     1228
     1229    if (aValue.raw() == NULL)
     1230        throw ENoValue();
     1231
     1232    /* The only way to cause RTUtf16ToUtf8Ex return a number of bytes needed
     1233     * w/o allocating the result buffer itself is to provide that both cch
     1234     * and *ppsz are not NULL. */
     1235    char dummy [1];
     1236    char *dummy2 = dummy;
     1237    size_t strLen = 1;
     1238
     1239    int vrc = RTUtf16ToUtf8Ex (aValue.raw(), RTSTR_MAX,
     1240                               &dummy2, strLen, &strLen);
     1241    if (RT_SUCCESS (vrc))
     1242    {
     1243        /* the string only contains '\0' :) */
     1244        result.reset (new char [1]);
     1245        result.get() [0] = '\0';
     1246        return result;
     1247    }
     1248
     1249    if (vrc == VERR_BUFFER_OVERFLOW)
     1250    {
     1251        result.reset (new char [strLen + 1]);
     1252        char *buf = result.get();
     1253        vrc = RTUtf16ToUtf8Ex (aValue.raw(), RTSTR_MAX, &buf, strLen + 1, NULL);
     1254    }
     1255
     1256    if (RT_FAILURE (vrc))
     1257        throw xml::LogicError (RT_SRC_POS);
     1258
     1259    return result;
     1260}
     1261
     1262template<> com::Guid FromString <com::Guid> (const char *aValue)
     1263{
     1264    if (aValue == NULL)
     1265        throw ENoValue();
     1266
     1267    /* For settings, the format is always {XXX...XXX} */
     1268    char buf [RTUUID_STR_LENGTH];
     1269    if (aValue == NULL || *aValue != '{' ||
     1270        strlen (aValue) != RTUUID_STR_LENGTH + 1 ||
     1271        aValue [RTUUID_STR_LENGTH] != '}')
     1272        throw ENoConversion(com::Utf8StrFmt("'%s' is not Guid", aValue));
     1273
     1274    /* strip { and } */
     1275    memcpy (buf, aValue + 1, RTUUID_STR_LENGTH - 1);
     1276    buf [RTUUID_STR_LENGTH - 1] = '\0';
     1277    /* we don't use Guid (const char *) because we want to throw
     1278     * ENoConversion on format error */
     1279    RTUUID uuid;
     1280    int vrc = RTUuidFromStr (&uuid, buf);
     1281    if (RT_FAILURE (vrc))
     1282        throw ENoConversion(com::Utf8StrFmt("'%s' is not Guid (%Rrc)", aValue, vrc));
     1283
     1284    return com::Guid (uuid);
     1285}
     1286
     1287template<> stdx::char_auto_ptr
     1288ToString <com::Guid> (const com::Guid &aValue, unsigned int aExtra)
     1289{
     1290    /* For settings, the format is always {XXX...XXX} */
     1291    stdx::char_auto_ptr result (new char [RTUUID_STR_LENGTH + 2]);
     1292
     1293    int vrc = RTUuidToStr (aValue.raw(), result.get() + 1, RTUUID_STR_LENGTH);
     1294    if (RT_FAILURE (vrc))
     1295        throw xml::LogicError (RT_SRC_POS);
     1296
     1297    result.get() [0] = '{';
     1298    result.get() [RTUUID_STR_LENGTH] = '}';
     1299    result.get() [RTUUID_STR_LENGTH + 1] = '\0';
     1300
     1301    return result;
     1302}
     1303
     1304} /* namespace settings */
     1305
     1306#endif /* VBOX_MAIN_SETTINGS_ADDONS */
     1307/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r16557 r16558  
    2121 */
    2222
    23 #include <iprt/path.h>
    24 #include <iprt/dir.h>
    25 #include <iprt/file.h>
    26 #include <iprt/string.h>
    27 #include <iprt/uuid.h>
    28 #include <iprt/thread.h>
    29 #include <iprt/process.h>
    30 #include <iprt/env.h>
    31 #include <iprt/cpputils.h>
    32 
    33 #include <VBox/com/com.h>
    34 #include <VBox/com/array.h>
    35 
    36 #include <VBox/err.h>
    37 #include <VBox/param.h>
    38 #include <VBox/VBoxHDD-new.h>
    39 #include <VBox/settings.h>
    40 #include <VBox/version.h>
    41 
    42 #include <package-generated.h>
    43 
    44 #include <algorithm>
    45 #include <set>
    46 #include <memory> // for auto_ptr
    47 
    48 #include <typeinfo>
    49 
    5023#include "VirtualBoxImpl.h"
    51 #include "VirtualBoxImplExtra.h"
    5224
    5325#include "Global.h"
     
    7143#endif
    7244
    73 // #include <stdio.h>
    74 // #include <stdlib.h>
     45#include <stdio.h>
     46#include <stdlib.h>
     47
     48#include <iprt/path.h>
     49#include <iprt/dir.h>
     50#include <iprt/file.h>
     51#include <iprt/string.h>
     52#include <iprt/uuid.h>
     53#include <iprt/thread.h>
     54#include <iprt/process.h>
     55#include <iprt/env.h>
     56#include <iprt/cpputils.h>
     57
     58#include <VBox/err.h>
     59#include <VBox/param.h>
     60#include <VBox/VBoxHDD-new.h>
     61#include <VBox/version.h>
     62#include <package-generated.h>
     63
     64#include <VBox/com/com.h>
     65#include <VBox/com/array.h>
     66
     67#include <algorithm>
     68#include <set>
     69#include <memory> // for auto_ptr
     70
     71#include <typeinfo>
    7572
    7673// defines
  • trunk/src/VBox/Main/VirtualBoxImplExtra.cpp

    r16557 r16558  
    2424 */
    2525
    26 #include <VBox/settings.h>
    27 
    2826#include "VirtualBoxImpl.h"
    29 #include "VirtualBoxImplExtra.h"
    3027
    3128#include "VirtualBoxXMLUtil.h"
     
    7269 */
    7370xml::Input *
    74 SettingsTreeHelper::resolveEntity (const char *aURI, const char *aID)
     71VirtualBox::SettingsTreeHelper::resolveEntity (const char *aURI, const char *aID)
    7572{
    7673    if (strcmp (aURI, VBOX_XML_SCHEMA_COMMON) == 0)
     
    141138 *                              freed by the caller using RTStrFree().
    142139 */
    143 bool SettingsTreeHelper::
     140bool VirtualBox::SettingsTreeHelper::
    144141needsConversion (const settings::Key &aRoot, char **aOldVersion) const
    145142{
     
    171168 * returns @c true for this tree.
    172169 */
    173 const char* SettingsTreeHelper::templateUri() const
     170const char *VirtualBox::SettingsTreeHelper::templateUri() const
    174171{
    175172    return VBOX_XML_SETTINGS_CONVERTER;
    176173}
    177 
    178 #if defined VBOX_MAIN_SETTINGS_ADDONS
    179 
    180 // Settings API additions
    181 ////////////////////////////////////////////////////////////////////////////////
    182 
    183 namespace settings
    184 {
    185 
    186 template<> stdx::char_auto_ptr
    187 ToString <com::Bstr> (const com::Bstr &aValue, unsigned int aExtra)
    188 {
    189     stdx::char_auto_ptr result;
    190 
    191     if (aValue.raw() == NULL)
    192         throw ENoValue();
    193 
    194     /* The only way to cause RTUtf16ToUtf8Ex return a number of bytes needed
    195      * w/o allocating the result buffer itself is to provide that both cch
    196      * and *ppsz are not NULL. */
    197     char dummy [1];
    198     char *dummy2 = dummy;
    199     size_t strLen = 1;
    200 
    201     int vrc = RTUtf16ToUtf8Ex (aValue.raw(), RTSTR_MAX,
    202                                &dummy2, strLen, &strLen);
    203     if (RT_SUCCESS (vrc))
    204     {
    205         /* the string only contains '\0' :) */
    206         result.reset (new char [1]);
    207         result.get() [0] = '\0';
    208         return result;
    209     }
    210 
    211     if (vrc == VERR_BUFFER_OVERFLOW)
    212     {
    213         result.reset (new char [strLen + 1]);
    214         char *buf = result.get();
    215         vrc = RTUtf16ToUtf8Ex (aValue.raw(), RTSTR_MAX, &buf, strLen + 1, NULL);
    216     }
    217 
    218     if (RT_FAILURE (vrc))
    219         throw xml::LogicError (RT_SRC_POS);
    220 
    221     return result;
    222 }
    223 
    224 template<> com::Guid FromString <com::Guid> (const char *aValue)
    225 {
    226     if (aValue == NULL)
    227         throw ENoValue();
    228 
    229     /* For settings, the format is always {XXX...XXX} */
    230     char buf [RTUUID_STR_LENGTH];
    231     if (aValue == NULL || *aValue != '{' ||
    232         strlen (aValue) != RTUUID_STR_LENGTH + 1 ||
    233         aValue [RTUUID_STR_LENGTH] != '}')
    234         throw ENoConversion(com::Utf8StrFmt("'%s' is not Guid", aValue));
    235 
    236     /* strip { and } */
    237     memcpy (buf, aValue + 1, RTUUID_STR_LENGTH - 1);
    238     buf [RTUUID_STR_LENGTH - 1] = '\0';
    239     /* we don't use Guid (const char *) because we want to throw
    240      * ENoConversion on format error */
    241     RTUUID uuid;
    242     int vrc = RTUuidFromStr (&uuid, buf);
    243     if (RT_FAILURE (vrc))
    244         throw ENoConversion(com::Utf8StrFmt("'%s' is not Guid (%Rrc)", aValue, vrc));
    245 
    246     return com::Guid (uuid);
    247 }
    248 
    249 template<> stdx::char_auto_ptr
    250 ToString <com::Guid> (const com::Guid &aValue, unsigned int aExtra)
    251 {
    252     /* For settings, the format is always {XXX...XXX} */
    253     stdx::char_auto_ptr result (new char [RTUUID_STR_LENGTH + 2]);
    254 
    255     int vrc = RTUuidToStr (aValue.raw(), result.get() + 1, RTUUID_STR_LENGTH);
    256     if (RT_FAILURE (vrc))
    257         throw xml::LogicError (RT_SRC_POS);
    258 
    259     result.get() [0] = '{';
    260     result.get() [RTUUID_STR_LENGTH] = '}';
    261     result.get() [RTUUID_STR_LENGTH + 1] = '\0';
    262 
    263     return result;
    264 }
    265 
    266 #endif // VBOX_MAIN_SETTINGS_ADDONS
    267 
    268 } /* namespace settings */
     174/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r16557 r16558  
    2727#include "VirtualBoxBase.h"
    2828
    29 namespace xml
    30 {
    31     class Node;
    32 }
     29// #include <string>
    3330
    3431class VirtualBox;
  • trunk/src/VBox/Main/include/VirtualBoxBase.h

    r16557 r16558  
    2323#define ____H_VIRTUALBOXBASEIMPL
    2424
     25#include "VBox/com/string.h"
     26#include "VBox/com/Guid.h"
     27#include "VBox/com/ptr.h"
     28#include "VBox/com/ErrorInfo.h"
     29
     30#include "VBox/com/VirtualBox.h"
     31
     32#include <VBox/settings.h>
     33
     34#include "AutoLock.h"
     35
     36using namespace com;
     37using namespace util;
     38
    2539#include <iprt/cdefs.h>
    2640#include <iprt/critsect.h>
     
    2943#include <list>
    3044#include <map>
    31 
    32 #include "VBox/com/ErrorInfo.h"
    33 
    34 #include "VBox/com/VirtualBox.h"
    35 
    36 // avoid including VBox/settings.h and VBox/xml.h;
    37 // only declare the classes
    38 namespace settings
    39 {
    40 class XmlTreeBackend;
    41 class TreeBackend;
    42 class Key;
    43 }
    44 
    45 namespace xml
    46 {
    47 class File;
    48 }
    49 
    50 #include "AutoLock.h"
    51 
    52 using namespace com;
    53 using namespace util;
    5445
    5546#if !defined (VBOX_WITH_XPCOM)
     
    28342825};
    28352826
     2827#if defined VBOX_MAIN_SETTINGS_ADDONS
     2828
     2829/**
     2830 * Settings API additions.
     2831 */
     2832namespace settings
     2833{
     2834
     2835/// @todo once string data in Bstr and Utf8Str is auto_ref_ptr, enable the
     2836/// code below
     2837
     2838#if 0
     2839
     2840/** Specialization of FromString for Bstr. */
     2841template<> com::Bstr FromString <com::Bstr> (const char *aValue);
     2842
     2843#endif
     2844
     2845/** Specialization of ToString for Bstr. */
     2846template<> stdx::char_auto_ptr
     2847ToString <com::Bstr> (const com::Bstr &aValue, unsigned int aExtra);
     2848
     2849/** Specialization of FromString for Guid. */
     2850template<> com::Guid FromString <com::Guid> (const char *aValue);
     2851
     2852/** Specialization of ToString for Guid. */
     2853template<> stdx::char_auto_ptr
     2854ToString <com::Guid> (const com::Guid &aValue, unsigned int aExtra);
     2855
     2856} /* namespace settings */
     2857
     2858#endif /* VBOX_MAIN_SETTINGS_ADDONS */
     2859
    28362860#endif // ____H_VIRTUALBOXBASEIMPL
     2861/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r16557 r16558  
    4040#include "PerformanceImpl.h"
    4141#endif /* VBOX_WITH_RESOURCE_USAGE_API */
     42
    4243
    4344class Machine;
     
    274275    static HRESULT ensureFilePathExists (const char *aFileName);
    275276
     277    class SettingsTreeHelper : public settings::XmlTreeBackend::InputResolver
     278                             , public settings::XmlTreeBackend::AutoConverter
     279    {
     280    public:
     281
     282        // InputResolver interface
     283        xml::Input *resolveEntity (const char *aURI, const char *aID);
     284
     285        // AutoConverter interface
     286        bool needsConversion (const settings::Key &aRoot, char **aOldVersion) const;
     287        const char *templateUri() const;
     288    };
     289
    276290    static HRESULT loadSettingsTree (settings::XmlTreeBackend &aTree,
    277291                                     xml::File &aFile,
  • trunk/src/VBox/Main/xml/Settings.cpp

    r16557 r16558  
    11561156}
    11571157
    1158 
    11591158} /* namespace settings */
    11601159
Note: See TracChangeset for help on using the changeset viewer.

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