VirtualBox

Changeset 16560 in vbox


Ignore:
Timestamp:
Feb 6, 2009 6:06:04 PM (16 years ago)
Author:
vboxsync
Message:

Main: do not include include/VBox/settings.h from other header files but only from implementations that need it (save compile time)

Location:
trunk
Files:
25 edited
1 copied

Legend:

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

    r16558 r16560  
    3939#include <limits>
    4040
     41#include <iprt/time.h>
     42
     43#include <VBox/com/Guid.h>
     44
     45#include <VBox/xml.h>
     46
     47// #include <stdarg.h>
     48
    4149/* these conflict with numeric_digits<>::min and max */
    4250#undef min
    4351#undef max
    44 
    45 #include <iprt/time.h>
    46 
    47 #include <VBox/xml.h>
    48 
    49 // #include <stdarg.h>
    5052
    5153
     
    439441 */
    440442DECLEXPORT (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. */
     452template<> com::Bstr FromString <com::Bstr> (const char *aValue);
     453
     454#endif
     455
     456/** Specialization of ToString for Bstr. */
     457template<> stdx::char_auto_ptr
     458ToString <com::Bstr> (const com::Bstr &aValue, unsigned int aExtra);
     459
     460/** Specialization of FromString for Guid. */
     461template<> com::Guid FromString <com::Guid> (const char *aValue);
     462
     463/** Specialization of ToString for Guid. */
     464template<> stdx::char_auto_ptr
     465ToString <com::Guid> (const com::Guid &aValue, unsigned int aExtra);
     466
     467#endif // VBOX_MAIN_SETTINGS_ADDONS
    441468
    442469// the rest
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r16518 r16560  
    15651565    /* For now we report 2 steps for every virtual system. Later we may add the
    15661566       progress of the image cloning. */
    1567     float opCountMax = 100.0/(app->m->llVirtualSystems.size() * 2);
     1567    float opCountMax = (float)100.0 / (app->m->llVirtualSystems.size() * 2);
    15681568    uint32_t opCount = 0;
    15691569
     
    16131613            Assert(vsdeRAM.size() == 1);
    16141614            const Utf8Str &memoryVBox = vsdeRAM.front()->strConfig;
    1615             uint64_t tt = RTStrToUInt64(memoryVBox.c_str()) / _1M;
     1615            ULONG tt = (ULONG)RTStrToUInt64(memoryVBox.c_str()) / _1M;
    16161616
    16171617            rc = pNewMachine->COMSETTER(MemorySize)(tt);
  • trunk/src/VBox/Main/AudioAdapterImpl.cpp

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

    r16558 r16560  
    2424#include "Logging.h"
    2525#include "GuestOSTypeImpl.h"
     26
    2627#include <iprt/cpputils.h>
     28#include <VBox/settings.h>
    2729
    2830// constructor / destructor
  • trunk/src/VBox/Main/DVDDriveImpl.cpp

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

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

    r16558 r16560  
    3333
    3434#include <VBox/err.h>
     35#include <VBox/settings.h>
    3536
    3637#include <iprt/param.h>
  • trunk/src/VBox/Main/HostImpl.cpp

    r16558 r16560  
    102102
    103103
    104 #include <VBox/usb.h>
    105 #include <VBox/x86.h>
    106 #include <VBox/err.h>
    107104#include <iprt/asm.h>
    108105#include <iprt/string.h>
     
    119116#include "netif.h"
    120117#endif
     118
     119#include <VBox/usb.h>
     120#include <VBox/x86.h>
     121#include <VBox/err.h>
     122#include <VBox/settings.h>
    121123
    122124#if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
  • trunk/src/VBox/Main/MachineImpl.cpp

    r16558 r16560  
    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)
    3329#endif
    3430
     
    7773#include <VBox/err.h>
    7874#include <VBox/param.h>
     75#include <VBox/settings.h>
     76
    7977#ifdef VBOX_WITH_GUEST_PROPS
    8078# include <VBox/HostServices/GuestPropertySvc.h>
  • trunk/src/VBox/Main/MediumImpl.cpp

    r16558 r16560  
    3030#include <VBox/com/array.h>
    3131
     32#include <VBox/err.h>
     33#include <VBox/settings.h>
     34
    3235#include <iprt/param.h>
    3336#include <iprt/path.h>
    3437#include <iprt/file.h>
    35 
    36 #include <VBox/err.h>
    3738
    3839////////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Main/NetworkAdapterImpl.cpp

    r16558 r16560  
    2929
    3030#include <VBox/err.h>
     31#include <VBox/settings.h>
    3132
    3233// constructor / destructor
  • trunk/src/VBox/Main/ParallelPortImpl.cpp

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

    r16558 r16560  
    2222 */
    2323
    24 #if defined(RT_OS_WINDOWS)
    25 #elif defined(RT_OS_LINUX)
    26 #endif
    27 
    2824#include "PerformanceImpl.h"
    2925
    3026#include "Logging.h"
    3127
     28#include <iprt/process.h>
     29
    3230#include <VBox/err.h>
    33 #include <iprt/process.h>
     31#include <VBox/settings.h>
    3432
    3533#include <vector>
  • trunk/src/VBox/Main/SATAControllerImpl.cpp

    r16558 r16560  
    2222 */
    2323
    24 
    25 
    2624#include "SATAControllerImpl.h"
    2725#include "MachineImpl.h"
     
    3129#include <iprt/string.h>
    3230#include <iprt/cpputils.h>
     31
    3332#include <VBox/err.h>
     33#include <VBox/settings.h>
    3434
    3535#include <algorithm>
  • trunk/src/VBox/Main/SerialPortImpl.cpp

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

    r16558 r16560  
    3232#include <iprt/path.h>
    3333#include <iprt/dir.h>
     34
     35#include <VBox/err.h>
    3436#include <VBox/param.h>
    35 #include <VBox/err.h>
     37#include <VBox/settings.h>
    3638
    3739// defines
  • trunk/src/VBox/Main/USBControllerImpl.cpp

    r16558 r16560  
    3333#include "Logging.h"
    3434
    35 
    3635#include <iprt/string.h>
    3736#include <iprt/cpputils.h>
     37
    3838#include <VBox/err.h>
     39#include <VBox/settings.h>
    3940
    4041#include <algorithm>
  • trunk/src/VBox/Main/VirtualBoxBase.cpp

    r16558 r16560  
    12141214}
    12151215
    1216 // Settings API additions
    1217 ////////////////////////////////////////////////////////////////////////////////
    1218 
    1219 #if defined VBOX_MAIN_SETTINGS_ADDONS
    1220 
    1221 namespace settings
    1222 {
    1223 
    1224 template<> stdx::char_auto_ptr
    1225 ToString <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 
    1262 template<> 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 
    1287 template<> stdx::char_auto_ptr
    1288 ToString <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: */
     1216
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r16558 r16560  
    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
    2350#include "VirtualBoxImpl.h"
     51#include "VirtualBoxImplExtra.h"
    2452
    2553#include "Global.h"
     
    4371#endif
    4472
    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>
     73// #include <stdio.h>
     74// #include <stdlib.h>
    7275
    7376// defines
  • trunk/src/VBox/Main/VirtualBoxImplExtra.cpp

    r16558 r16560  
    2424 */
    2525
     26#include <VBox/settings.h>
     27
    2628#include "VirtualBoxImpl.h"
     29#include "VirtualBoxImplExtra.h"
    2730
    2831#include "VirtualBoxXMLUtil.h"
     
    6972 */
    7073xml::Input *
    71 VirtualBox::SettingsTreeHelper::resolveEntity (const char *aURI, const char *aID)
     74SettingsTreeHelper::resolveEntity (const char *aURI, const char *aID)
    7275{
    7376    if (strcmp (aURI, VBOX_XML_SCHEMA_COMMON) == 0)
     
    138141 *                              freed by the caller using RTStrFree().
    139142 */
    140 bool VirtualBox::SettingsTreeHelper::
     143bool SettingsTreeHelper::
    141144needsConversion (const settings::Key &aRoot, char **aOldVersion) const
    142145{
     
    168171 * returns @c true for this tree.
    169172 */
    170 const char *VirtualBox::SettingsTreeHelper::templateUri() const
     173const char* SettingsTreeHelper::templateUri() const
    171174{
    172175    return VBOX_XML_SETTINGS_CONVERTER;
    173176}
    174 /* vi: set tabstop=4 shiftwidth=4 expandtab: */
     177
     178#if defined VBOX_MAIN_SETTINGS_ADDONS
     179
     180// Settings API additions
     181////////////////////////////////////////////////////////////////////////////////
     182
     183namespace settings
     184{
     185
     186template<> stdx::char_auto_ptr
     187ToString <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
     224template<> 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
     249template<> stdx::char_auto_ptr
     250ToString <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 */
  • trunk/src/VBox/Main/include/ApplianceImpl.h

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

    r15051 r16560  
    3838#include "Performance.h"
    3939
     40#undef min
     41#undef max
     42
    4043/* Each second we obtain new CPU load stats. */
    4144#define VBOX_USAGE_SAMPLER_MIN_INTERVAL 1000
     
    9396    {
    9497        /* Constructor. */
    95         Data() : period(0), count(0), min(0), max(0) { }
     98        Data()
     99            : period(0), count(0), min(0), max(0)
     100        {
     101        }
    96102
    97103        Bstr             name;
  • trunk/src/VBox/Main/include/VirtualBoxBase.h

    r16558 r16560  
    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 
    36 using namespace com;
    37 using namespace util;
    38 
    3925#include <iprt/cdefs.h>
    4026#include <iprt/critsect.h>
     
    4329#include <list>
    4430#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
     38namespace settings
     39{
     40class XmlTreeBackend;
     41class TreeBackend;
     42class Key;
     43}
     44
     45namespace xml
     46{
     47class File;
     48}
     49
     50#include "AutoLock.h"
     51
     52using namespace com;
     53using namespace util;
    4554
    4655#if !defined (VBOX_WITH_XPCOM)
     
    28252834};
    28262835
    2827 #if defined VBOX_MAIN_SETTINGS_ADDONS
    2828 
    2829 /**
    2830  * Settings API additions.
    2831  */
    2832 namespace 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. */
    2841 template<> com::Bstr FromString <com::Bstr> (const char *aValue);
    2842 
    2843 #endif
    2844 
    2845 /** Specialization of ToString for Bstr. */
    2846 template<> stdx::char_auto_ptr
    2847 ToString <com::Bstr> (const com::Bstr &aValue, unsigned int aExtra);
    2848 
    2849 /** Specialization of FromString for Guid. */
    2850 template<> com::Guid FromString <com::Guid> (const char *aValue);
    2851 
    2852 /** Specialization of ToString for Guid. */
    2853 template<> stdx::char_auto_ptr
    2854 ToString <com::Guid> (const com::Guid &aValue, unsigned int aExtra);
    2855 
    2856 } /* namespace settings */
    2857 
    2858 #endif /* VBOX_MAIN_SETTINGS_ADDONS */
    2859 
    28602836#endif // ____H_VIRTUALBOXBASEIMPL
    2861 /* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r16558 r16560  
    4040#include "PerformanceImpl.h"
    4141#endif /* VBOX_WITH_RESOURCE_USAGE_API */
    42 
    4342
    4443class Machine;
     
    275274    static HRESULT ensureFilePathExists (const char *aFileName);
    276275
    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 
    290276    static HRESULT loadSettingsTree (settings::XmlTreeBackend &aTree,
    291277                                     xml::File &aFile,
  • trunk/src/VBox/Main/xml/Settings.cpp

    r16558 r16560  
    11561156}
    11571157
     1158
    11581159} /* namespace settings */
    11591160
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