VirtualBox

Changeset 16188 in vbox


Ignore:
Timestamp:
Jan 22, 2009 7:58:31 PM (16 years ago)
Author:
vboxsync
Message:

Merge OVF branch.

Location:
trunk
Files:
10 edited

Legend:

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

    r14922 r16188  
    292292//////////////////////////////////////////////////////////////////////////////
    293293
    294 /**
    295  * Temporary holder for the formatted string.
    296  *
    297  * Instances of this class are used for passing the formatted string as an
    298  * argument to an Error constructor or to another function that takes
    299  * <tr>const char *</tr> and makes a copy of the string it points to.
    300  */
    301 class VBOXXML_CLASS FmtStr
    302 {
    303 public:
    304 
    305     /**
    306      * Creates a formatted string using the format string and a set of
    307      * printf-like arguments.
    308      */
    309     FmtStr (const char *aFmt, ...)
    310     {
    311         va_list args;
    312         va_start (args, aFmt);
    313         RTStrAPrintfV (&mStr, aFmt, args);
    314         va_end (args);
    315     }
    316 
    317     ~FmtStr() { RTStrFree (mStr); }
    318 
    319     operator const char *() { return mStr; }
    320 
    321 private:
    322 
    323     DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP (FmtStr)
    324 
    325     char *mStr;
    326 };
    327 
    328294// string -> type conversions
    329295//////////////////////////////////////////////////////////////////////////////
     
    626592        catch (const ENoValue &)
    627593        {
    628             throw ENoValue (FmtStr ("No such attribute '%s'", aName));
     594            throw ENoValue(xml::FmtStr("No such attribute '%s'", aName));
    629595        }
    630596    }
     
    681647        catch (const ENoValue &)
    682648        {
    683             throw ENoValue (FmtStr ("No value for attribute '%s'", aName));
     649            throw ENoValue(xml::FmtStr("No value for attribute '%s'", aName));
    684650        }
    685651    }
     
    795761        if (key.isNull())
    796762        {
    797             throw ENoKey(FmtStr("No such key '%s'", aName));
     763            throw ENoKey(xml::FmtStr("No such key '%s'", aName));
    798764        }
    799765        return key;
  • trunk/include/VBox/xml.h

    r14923 r16188  
    100100{
    101101
     102// Helpers
     103//////////////////////////////////////////////////////////////////////////////
     104
     105/**
     106 * Temporary holder for the formatted string.
     107 *
     108 * Instances of this class are used for passing the formatted string as an
     109 * argument to an Error constructor or to another function that takes
     110 * <tr>const char *</tr> and makes a copy of the string it points to.
     111 */
     112class VBOXXML_CLASS FmtStr
     113{
     114public:
     115
     116    /**
     117     * Creates a formatted string using the format string and a set of
     118     * printf-like arguments.
     119     */
     120    FmtStr(const char *aFmt, ...)
     121    {
     122        va_list args;
     123        va_start(args, aFmt);
     124        RTStrAPrintfV(&mStr, aFmt, args);
     125        va_end(args);
     126    }
     127
     128    ~FmtStr() { RTStrFree (mStr); }
     129
     130    operator const char *() { return mStr; }
     131
     132private:
     133
     134    DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP (FmtStr)
     135
     136    char *mStr;
     137};
     138
     139
    102140// Exceptions
    103141//////////////////////////////////////////////////////////////////////////////
     
    446484
    447485/*
     486 * Node
     487 *
     488 */
     489
     490class Node;
     491typedef std::list<const Node*> NodesList;
     492
     493class VBOXXML_CLASS Node
     494{
     495public:
     496    Node();
     497    ~Node();
     498
     499    const char* getName() const;
     500    const char* getValue() const;
     501    bool copyValue(int32_t &i) const;
     502    bool copyValue(uint32_t &i) const;
     503    bool copyValue(int64_t &i) const;
     504    bool copyValue(uint64_t &i) const;
     505
     506    int getLineNumber() const;
     507
     508    int getChildElements(NodesList &children,
     509                         const char *pcszMatch = NULL) const;
     510
     511    const Node* findChildElement(const char *pcszMatch) const;
     512    const Node* findChildElementFromId(const char *pcszId) const;
     513
     514    const Node* findAttribute(const char *pcszMatch) const;
     515    bool getAttributeValue(const char *pcszMatch, std::string &str) const;
     516    bool getAttributeValue(const char *pcszMatch, int64_t &i) const;
     517    bool getAttributeValue(const char *pcszMatch, uint64_t &i) const;
     518
     519private:
     520    friend class Document;
     521    friend class XmlFileParser;
     522
     523    Node(const Node &x);      // no copying
     524
     525    void buildChildren();
     526
     527    /* Obscure class data */
     528    struct Data;
     529    Data *m;
     530};
     531
     532/*
     533 * NodesLoop
     534 *
     535 */
     536
     537class VBOXXML_CLASS NodesLoop
     538{
     539public:
     540    NodesLoop(const Node &node, const char *pcszMatch = NULL);
     541    ~NodesLoop();
     542    const Node* forAllNodes() const;
     543
     544private:
     545    struct Data;
     546    Data *m;
     547};
     548
     549/*
     550 * Document
     551 *
     552 */
     553
     554class VBOXXML_CLASS Document
     555{
     556public:
     557    Document();
     558    ~Document();
     559    Document(const Document &x);
     560    Document& operator=(const Document &x);
     561
     562    const Node* getRootElement() const;
     563
     564private:
     565    friend class XmlFileParser;
     566
     567    void refreshInternals();
     568
     569    /* Obscure class data */
     570    struct Data;
     571    Data *m;
     572};
     573
     574/*
    448575 * XmlParserBase
    449576 *
     
    470597    ~XmlFileParser();
    471598
    472     void read(const char *pcszFilename);
     599    void read(const char *pcszFilename, Document &doc);
    473600
    474601private:
  • trunk/src/VBox/Main/Makefile.kmk

    r16174 r16188  
    251251        VirtualBoxImpl.cpp \
    252252        VirtualBoxImplExtra.cpp \
     253        ApplianceImpl.cpp \
    253254        MachineImpl.cpp \
    254255        SnapshotImpl.cpp \
     
    426427
    427428endif # VBOX_WITH_XPCOM
     429
     430
     431#
     432# VBoxSettings
     433#
     434DLLS += VBoxSettings
     435VBoxSettings_TEMPLATE   = VBOXMAINDLL
     436VBoxSettings_NAME       = $(basename $(notdir $(LIB_SETTINGS)))
     437VBoxSettings_SDKS       = VBOX_LIBXSLT VBOX_LIBXML2 VBOX_ZLIB VBOX_BOOST
     438VBoxSettings_DEFS       = IN_VBOXXML_R3
     439VBoxSettings_INCS       = \
     440        include
     441VBoxSettings_SOURCES    = \
     442        xml/xml.cpp \
     443        xml/Settings.cpp
     444VBoxSettings_LDFLAGS.darwin = -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/$(notdir $(LIB_SETTINGS)) -Wl,-x # no debug info please.
    428445
    429446
     
    556573
    557574#
    558 # VBoxSettings
    559 #
    560 DLLS += VBoxSettings
    561 VBoxSettings_TEMPLATE   = VBOXMAINDLL
    562 VBoxSettings_NAME       = $(basename $(notdir $(LIB_SETTINGS)))
    563 VBoxSettings_SDKS       = VBOX_LIBXSLT VBOX_LIBXML2 VBOX_ZLIB
    564 VBoxSettings_DEFS       = IN_VBOXXML_R3
    565 VBoxSettings_INCS       = \
    566         include
    567 VBoxSettings_SOURCES    = \
    568         xml/xml.cpp \
    569         xml/Settings.cpp
    570 VBoxSettings_LDFLAGS.darwin = -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/$(notdir $(LIB_SETTINGS)) -Wl,-x # no debug info please.
    571 
    572 
    573 #
    574575# VBoxCOM - COM Abstraction Layer library
    575576#
  • trunk/src/VBox/Main/VirtualBoxBase.cpp

    r14904 r16188  
    12701270        strlen (aValue) != RTUUID_STR_LENGTH + 1 ||
    12711271        aValue [RTUUID_STR_LENGTH] != '}')
    1272         throw ENoConversion (FmtStr ("'%s' is not Guid", aValue));
     1272        throw ENoConversion(xml::FmtStr("'%s' is not Guid", aValue));
    12731273
    12741274    /* strip { and } */
     
    12801280    int vrc = RTUuidFromStr (&uuid, buf);
    12811281    if (RT_FAILURE (vrc))
    1282         throw ENoConversion (FmtStr ("'%s' is not Guid (%Rrc)", aValue, vrc));
     1282        throw ENoConversion(xml::FmtStr("'%s' is not Guid (%Rrc)", aValue, vrc));
    12831283
    12841284    return com::Guid (uuid);
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r16174 r16188  
    17291729    </method>
    17301730
     1731    <method name="openAppliance">
     1732      <desc>
     1733        Attempts to open the given appliance, which must be in Open Virtual Machine Format (OVF).
     1734
     1735        As prescribed by the OVF standard, VirtualBox supports OVF in two formats:
     1736
     1737        <ol>
     1738          <li>If the OVF is distributed as a set of files, then @a file must be a fully qualified
     1739          path name to an existing OVF descriptor file with an <tt>.ovf</tt> file extension. If
     1740          this descriptor file references other files, as OVF appliances distributed as a set of
     1741          files most likely do, those files must be in the same directory as the descriptor file.</li>
     1742
     1743          <li>If the OVF is distributed as a single file, it must be in TAR format and have the
     1744          <tt>.ova</tt> file extension. This TAR file must then contain at least the OVF descriptor
     1745          files and optionally other files.</li>
     1746        </ol>
     1747
     1748        In both cases, VirtualBox will open the OVF descriptor file, parse its contents and create a
     1749        new instance of IAppliance representing the OVF file.
     1750
     1751        This method succeeds if the OVF is syntactically valid and, by itself, without errors. The
     1752        returned IAppliance object can then be used to retrieve information about the appliance and
     1753        import it into VirtualBox. The mere fact that this method returns successfully does not mean
     1754        that VirtualBox supports all features requested by the appliance; see the documentation for
     1755        <link to="IAppliance" /> for details.
     1756
     1757      </desc>
     1758      <param name="file" type="wstring" dir="in">
     1759        <desc>
     1760          Name of appliance file to open (either with an <tt>.ovf</tt> or <tt>.ova</tt> extension, depending
     1761          on whether the appliance is distributed as a set of files or as a single file, respectively).
     1762        </desc>
     1763      </param>
     1764      <param name="machine" type="IAppliance" dir="return">
     1765        <desc>New appliance.</desc>
     1766      </param>
     1767    </method>
     1768
    17311769    <method name="createHardDisk2">
    17321770      <desc>
     
    26912729
    26922730  </interface>
     2731
     2732  <!--
     2733  // IAppliance
     2734  /////////////////////////////////////////////////////////////////////////
     2735  -->
     2736
     2737  <enum
     2738    name="CIMOSType"
     2739    uuid="86ef5f8c-18b2-4db8-a314-33721b59f89b"
     2740  >
     2741    <desc>
     2742      OVF operating system values according to CIM V2.20 (as of Nov 2008); http://www.dmtf.org/standards/cim/cim_schema_v220
     2743    </desc>
     2744
     2745    <const name="CIMOS_Unknown" value="0" />      <!-- "Unknown" -->
     2746    <const name="CIMOS_Other" value="1" />      <!-- "Other" -->
     2747    <const name="CIMOS_MACOS" value="2" />      <!-- "MACOS" -->
     2748    <const name="CIMOS_ATTUNIX" value="3" />      <!-- "ATTUNIX" -->
     2749    <const name="CIMOS_DGUX" value="4" />      <!-- "DGUX" -->
     2750    <const name="CIMOS_DECNT" value="5" />      <!-- "DECNT" -->
     2751    <const name="CIMOS_Tru64UNIX" value="6" />      <!-- "Tru64 UNIX" -->
     2752    <const name="CIMOS_OpenVMS" value="7" />      <!-- "OpenVMS" -->
     2753    <const name="CIMOS_HPUX" value="8" />      <!-- "HPUX" -->
     2754    <const name="CIMOS_AIX" value="9" />      <!-- "AIX" -->
     2755    <const name="CIMOS_MVS" value="10" />      <!-- "MVS" -->
     2756    <const name="CIMOS_OS400" value="11" />      <!-- "OS400" -->
     2757    <const name="CIMOS_OS2" value="12" />      <!-- "OS/2" -->
     2758    <const name="CIMOS_JavaVM" value="13" />      <!-- "JavaVM" -->
     2759    <const name="CIMOS_MSDOS" value="14" />      <!-- "MSDOS" -->
     2760    <const name="CIMOS_WIN3x" value="15" />      <!-- "WIN3x" -->
     2761    <const name="CIMOS_WIN95" value="16" />      <!-- "WIN95" -->
     2762    <const name="CIMOS_WIN98" value="17" />      <!-- "WIN98" -->
     2763    <const name="CIMOS_WINNT" value="18" />      <!-- "WINNT" -->
     2764    <const name="CIMOS_WINCE" value="19" />      <!-- "WINCE" -->
     2765    <const name="CIMOS_NCR3000" value="20" />      <!-- "NCR3000" -->
     2766    <const name="CIMOS_NetWare" value="21" />      <!-- "NetWare" -->
     2767    <const name="CIMOS_OSF" value="22" />      <!-- "OSF" -->
     2768    <const name="CIMOS_DCOS" value="23" />      <!-- "DC/OS" -->
     2769    <const name="CIMOS_ReliantUNIX" value="24" />      <!-- "Reliant UNIX" -->
     2770    <const name="CIMOS_SCOUnixWare" value="25" />      <!-- "SCO UnixWare" -->
     2771    <const name="CIMOS_SCOOpenServer" value="26" />      <!-- "SCO OpenServer" -->
     2772    <const name="CIMOS_Sequent" value="27" />      <!-- "Sequent" -->
     2773    <const name="CIMOS_IRIX" value="28" />      <!-- "IRIX" -->
     2774    <const name="CIMOS_Solaris" value="29" />      <!-- "Solaris" -->
     2775    <const name="CIMOS_SunOS" value="30" />      <!-- "SunOS" -->
     2776    <const name="CIMOS_U6000" value="31" />      <!-- "U6000" -->
     2777    <const name="CIMOS_ASERIES" value="32" />      <!-- "ASERIES" -->
     2778    <const name="CIMOS_HPNonStopOS" value="33" />      <!-- "HP NonStop OS" -->
     2779    <const name="CIMOS_HPNonStopOSS" value="34" />      <!-- "HP NonStop OSS" -->
     2780    <const name="CIMOS_BS2000" value="35" />      <!-- "BS2000" -->
     2781    <const name="CIMOS_LINUX" value="36" />      <!-- "LINUX" -->
     2782    <const name="CIMOS_Lynx" value="37" />      <!-- "Lynx" -->
     2783    <const name="CIMOS_XENIX" value="38" />      <!-- "XENIX" -->
     2784    <const name="CIMOS_VM" value="39" />      <!-- "VM" -->
     2785    <const name="CIMOS_InteractiveUNIX" value="40" />      <!-- "Interactive UNIX" -->
     2786    <const name="CIMOS_BSDUNIX" value="41" />      <!-- "BSDUNIX" -->
     2787    <const name="CIMOS_FreeBSD" value="42" />      <!-- "FreeBSD" -->
     2788    <const name="CIMOS_NetBSD" value="43" />      <!-- "NetBSD" -->
     2789    <const name="CIMOS_GNUHurd" value="44" />      <!-- "GNU Hurd" -->
     2790    <const name="CIMOS_OS9" value="45" />      <!-- "OS9" -->
     2791    <const name="CIMOS_MACHKernel" value="46" />      <!-- "MACH Kernel" -->
     2792    <const name="CIMOS_Inferno" value="47" />      <!-- "Inferno" -->
     2793    <const name="CIMOS_QNX" value="48" />      <!-- "QNX" -->
     2794    <const name="CIMOS_EPOC" value="49" />      <!-- "EPOC" -->
     2795    <const name="CIMOS_IxWorks" value="50" />      <!-- "IxWorks" -->
     2796    <const name="CIMOS_VxWorks" value="51" />      <!-- "VxWorks" -->
     2797    <const name="CIMOS_MiNT" value="52" />      <!-- "MiNT" -->
     2798    <const name="CIMOS_BeOS" value="53" />      <!-- "BeOS" -->
     2799    <const name="CIMOS_HPMPE" value="54" />      <!-- "HP MPE" -->
     2800    <const name="CIMOS_NextStep" value="55" />      <!-- "NextStep" -->
     2801    <const name="CIMOS_PalmPilot" value="56" />      <!-- "PalmPilot" -->
     2802    <const name="CIMOS_Rhapsody" value="57" />      <!-- "Rhapsody" -->
     2803    <const name="CIMOS_Windows2000" value="58" />      <!-- "Windows 2000" -->
     2804    <const name="CIMOS_Dedicated" value="59" />      <!-- "Dedicated" -->
     2805    <const name="CIMOS_OS390" value="60" />      <!-- "OS/390" -->
     2806    <const name="CIMOS_VSE" value="61" />      <!-- "VSE" -->
     2807    <const name="CIMOS_TPF" value="62" />      <!-- "TPF" -->
     2808    <const name="CIMOS_WindowsMe" value="63" />      <!-- "Windows (R) Me" -->
     2809    <const name="CIMOS_CalderaOpenUNIX" value="64" />      <!-- "Caldera Open UNIX" -->
     2810    <const name="CIMOS_OpenBSD" value="65" />      <!-- "OpenBSD" -->
     2811    <const name="CIMOS_NotApplicable" value="66" />      <!-- "Not Applicable" -->
     2812    <const name="CIMOS_WindowsXP" value="67" />      <!-- "Windows XP" -->
     2813    <const name="CIMOS_zOS" value="68" />      <!-- "z/OS" -->
     2814    <const name="CIMOS_MicrosoftWindowsServer2003" value="69" />      <!-- "Microsoft Windows Server 2003" -->
     2815    <const name="CIMOS_MicrosoftWindowsServer2003_64" value="70" />      <!-- "Microsoft Windows Server 2003 64-Bit" -->
     2816    <const name="CIMOS_WindowsXP_64" value="71" />      <!-- "Windows XP 64-Bit" -->
     2817    <const name="CIMOS_WindowsXPEmbedded" value="72" />      <!-- "Windows XP Embedded" -->
     2818    <const name="CIMOS_WindowsVista" value="73" />      <!-- "Windows Vista" -->
     2819    <const name="CIMOS_WindowsVista_64" value="74" />      <!-- "Windows Vista 64-Bit" -->
     2820    <const name="CIMOS_WindowsEmbeddedforPointofService" value="75" />      <!-- "Windows Embedded for Point of Service" -->
     2821    <const name="CIMOS_MicrosoftWindowsServer2008" value="76" />      <!-- "Microsoft Windows Server 2008" -->
     2822    <const name="CIMOS_MicrosoftWindowsServer2008_64" value="77" />      <!-- "Microsoft Windows Server 2008 64-Bit" -->
     2823    <const name="CIMOS_FreeBSD_64" value="78" />      <!-- "FreeBSD 64-Bit" -->
     2824    <const name="CIMOS_RedHatEnterpriseLinux" value="79" />      <!-- "RedHat Enterprise Linux" -->
     2825    <const name="CIMOS_RedHatEnterpriseLinux_64" value="80" />      <!-- "RedHat Enterprise Linux 64-Bit" -->
     2826    <const name="CIMOS_Solaris_64" value="81" />      <!-- "Solaris 64-Bit" -->
     2827    <const name="CIMOS_SUSE" value="82" />      <!-- "SUSE" -->
     2828    <const name="CIMOS_SUSE_64" value="83" />      <!-- "SUSE 64-Bit" -->
     2829    <const name="CIMOS_SLES" value="84" />      <!-- "SLES" -->
     2830    <const name="CIMOS_SLES_64" value="85" />      <!-- "SLES 64-Bit" -->
     2831    <const name="CIMOS_NovellOES" value="86" />      <!-- "Novell OES" -->
     2832    <const name="CIMOS_NovellLinuxDesktop" value="87" />      <!-- "Novell Linux Desktop" -->
     2833    <const name="CIMOS_SunJavaDesktopSystem" value="88" />      <!-- "Sun Java Desktop System" -->
     2834    <const name="CIMOS_Mandriva" value="89" />      <!-- "Mandriva" -->
     2835    <const name="CIMOS_Mandriva_64" value="90" />      <!-- "Mandriva 64-Bit" -->
     2836    <const name="CIMOS_TurboLinux" value="91" />      <!-- "TurboLinux" -->
     2837    <const name="CIMOS_TurboLinux_64" value="92" />      <!-- "TurboLinux 64-Bit" -->
     2838    <const name="CIMOS_Ubuntu" value="93" />      <!-- "Ubuntu" -->
     2839    <const name="CIMOS_Ubuntu_64" value="94" />      <!-- "Ubuntu 64-Bit" -->
     2840    <const name="CIMOS_Debian" value="95" />      <!-- "Debian" -->
     2841    <const name="CIMOS_Debian_64" value="96" />      <!-- "Debian 64-Bit" -->
     2842    <const name="CIMOS_Linux_2_4_x" value="97" />      <!-- "Linux 2.4.x" -->
     2843    <const name="CIMOS_Linux_2_4_x_64" value="98" />      <!-- "Linux 2.4.x 64-Bit" -->
     2844    <const name="CIMOS_Linux_2_6_x" value="99" />      <!-- "Linux 2.6.x" -->
     2845    <const name="CIMOS_Linux_2_6_x_64" value="100" />      <!-- "Linux 2.6.x 64-Bit" -->
     2846    <const name="CIMOS_Linux_64" value="101" />      <!-- "Linux 64-Bit" -->
     2847    <const name="CIMOS_Other_64" value="102" />      <!-- "Other 64-Bit" -->
     2848  </enum>
     2849
     2850  <enum
     2851    name="OVFResourceType"
     2852    uuid="646a78d7-6f04-49f4-82c4-75c28a75a4cd"
     2853  >
     2854    <desc>
     2855      OVF resource type.
     2856    </desc>
     2857
     2858    <const name="Other" value="1" />
     2859    <const name="ComputerSystem" value="2" />
     2860    <const name="Processor" value="3" />
     2861    <const name="Memory" value="4" />
     2862    <const name="IdeCController" value="5" />
     2863    <const name="ParallelScsiHba" value="6" />
     2864    <const name="FcHba" value="7" />
     2865    <const name="iScsiHba" value="8" />
     2866    <const name="IbHca" value="9" />
     2867    <const name="EthernetAdapter" value="10" />
     2868    <const name="OtherNetworkAdapter" value="11" />
     2869    <const name="IoSlot" value="12" />
     2870    <const name="IoDevice" value="13" />
     2871    <const name="FloppyDrive" value="14" />
     2872    <const name="CdDrive" value="15" />
     2873    <const name="DvdDrive" value="16" />
     2874    <const name="HardDisk" value="17" />
     2875  </enum>
     2876
     2877  <interface
     2878     name="IAppliance" extends="$unknown"
     2879     uuid="f3aa3a74-7b66-425b-9d3d-973924ddf163"
     2880     wsmap="managed"
     2881     >
     2882    <desc>
     2883        Represents an appliance in OVF format. An instance of this is returned by
     2884        <link to="IVirtualBox::openAppliance" />.
     2885
     2886        Opening an appliance is a two-step process with VirtualBox: first
     2887        <link to="IVirtualBox::openAppliance" /> is called, which succeeds if the
     2888        appliance file is syntactically valid, irrespective of whether VirtualBox
     2889        can handle the appliance.
     2890
     2891        Once that method has returned an IAppliance instance, one can inspect the
     2892        member data of that instance to determine whether VirtualBox can handle
     2893        the requirements of that appliance and create local virtual machines
     2894        accordingly.
     2895    </desc>
     2896
     2897    <attribute name="path" type="wstring" readonly="yes">
     2898      <desc>Path to the main file of the OVF appliance, which is either the <tt>.ovf</tt> or
     2899      the <tt>.ova</tt> file passed to <link to="IVirtualBox::openAppliance" />.</desc>
     2900    </attribute>
     2901
     2902    <attribute name="virtualSystemDescriptions" type="IVirtualSystemDescription" readonly="yes" safearray="yes">
     2903      <desc></desc>
     2904    </attribute>
     2905
     2906    <method name="getDisks">
     2907      <desc>
     2908        Returns disk information from the appliance specification in a string
     2909        array. Each array item represents one piece of disk information, with the
     2910        information fields separated by tab (\t) characters.
     2911
     2912        The caller should be prepared for additional fields being appended to
     2913        this string in future versions of VirtualBox and therefore check for
     2914        the number of tabs in the strings returned.
     2915
     2916        In the current version, the following eight fields are returned per string
     2917        in the array:
     2918
     2919        <ol>
     2920            <li>Disk ID (unique string identifier given to disk)</li>
     2921            <li>Capacity (unsigned integer indicating the maximum capacity of the disk)</li>
     2922            <li>Populated size (optional unsigned integer indicating the current size of the
     2923            disk; can be approximate; -1 if unspecified)</li>
     2924            <li>Format (string identifying the disk format, typically
     2925            "http://www.vmware.com/specifications/vmdk.html#sparse")</li>
     2926            <li>Reference (where to find the disk image, typically a file name; if empty,
     2927            then the disk should be created on import)</li>
     2928            <li>Image size (optional unsigned integer indicating the size of the image,
     2929            which need not necessarily be the same as the values specified above, since
     2930            the image may be compressed or sparse; -1 if not specified)</li>
     2931            <li>Chunk size (optional unsigned integer if the image is split into chunks;
     2932            presently unsupported and always -1)</li>
     2933            <li>Compression (optional string equalling "gzip" if the image is gzip-compressed)</li>
     2934        </ol>
     2935
     2936      </desc>
     2937
     2938      <param name="aDisks" type="wstring" dir="out" safearray="yes">
     2939        <desc>Array of strings to receive disk information.</desc>
     2940      </param>
     2941
     2942      <param name="cDisks" type="unsigned long" dir="return">
     2943        <desc>Count of array items returned in aDisks.</desc>
     2944      </param>
     2945    </method>
     2946
     2947    <method name="importAppliance">
     2948    </method>
     2949
     2950  </interface>
     2951
     2952  <enum
     2953    name="VirtualSystemDescriptionType"
     2954    uuid="36209b5a-8f96-44de-a0af-1bb037cef324"
     2955  >
     2956    <desc>
     2957    </desc>
     2958
     2959    <const name="OS" value="0" />
     2960    <const name="CPU" value="1" />
     2961    <const name="Memory" value="2" />
     2962    <const name="HarddiskControllerIDE" value="3" />
     2963    <const name="HarddiskControllerSATA" value="4" />
     2964    <const name="HarddiskControllerSCSI" value="5" />
     2965    <const name="Harddisk" value="6" />
     2966    <const name="NetworkAdapter" value="7" />
     2967
     2968  </enum>
     2969
     2970  <interface
     2971     name="IVirtualSystemDescription" extends="$unknown"
     2972     uuid="c76de96b-b316-4a42-9afb-18ce08cce0c9"
     2973     wsmap="managed"
     2974     >
     2975
     2976    <method name="getDescription">
     2977      <desc></desc>
     2978
     2979      <param name="aTypes" type="VirtualSystemDescriptionType" dir="out" safearray="yes">
     2980        <desc></desc>
     2981      </param>
     2982
     2983      <param name="aRefs" type="unsigned long" dir="out" safearray="yes">
     2984        <desc></desc>
     2985      </param>
     2986
     2987      <param name="aOrigValues" type="wstring" dir="out" safearray="yes">
     2988        <desc></desc>
     2989      </param>
     2990
     2991      <param name="aAutoValues" type="wstring" dir="out" safearray="yes">
     2992        <desc></desc>
     2993      </param>
     2994
     2995      <param name="aConfiguration" type="wstring" dir="out" safearray="yes">
     2996        <desc></desc>
     2997      </param>
     2998
     2999    </method>
     3000
     3001    <method name="SetFinalValues">
     3002      <desc></desc>
     3003
     3004      <param name="aFinaleValues" type="wstring" dir="in" safearray="yes">
     3005        <desc></desc>
     3006      </param>
     3007
     3008    </method>
     3009
     3010  </interface>
     3011
    26933012
    26943013  <!--
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r15318 r16188  
    5555class Host;
    5656class SystemProperties;
     57class IAppliance;
    5758
    5859#ifdef RT_OS_WINDOWS
     
    146147    STDMETHOD(FindMachine) (IN_BSTR aName, IMachine **aMachine);
    147148    STDMETHOD(UnregisterMachine) (IN_GUID aId, IMachine **aMachine);
     149    STDMETHOD(OpenAppliance) (IN_BSTR aName, IAppliance **anAppliance);
    148150
    149151    STDMETHOD(CreateHardDisk2) (IN_BSTR aFormat, IN_BSTR aLocation,
  • trunk/src/VBox/Main/testcase/tstAPI.cpp

    r15581 r16188  
    12551255    } while (false);
    12561256#endif /* VBOX_WITH_RESOURCE_USAGE_API */
     1257#if 1
     1258    // check of OVF appliance handling
     1259    ///////////////////////////////////////////////////////////////////////////
     1260    do
     1261    {
     1262        Bstr ovf = L"/home/poetzsch/projects/out.ovf";
     1263        //Bstr ovf = L"/home/poetzsch/projects/someOVF.ovf";
     1264//        Bstr ovf = L"/Users/poetzsch/projects/someOVF.ovf";
     1265//        Bstr ovf = L"/Users/poetzsch/projects/out.ovf";
     1266//        Bstr name = argc > 1 ? argv [1] : "dsl";
     1267        printf ("Try to open %ls ...\n", ovf.raw());
     1268
     1269        ComPtr <IAppliance> appliance;
     1270        CHECK_ERROR_BREAK (virtualBox,
     1271                           OpenAppliance (ovf, appliance.asOutParam()));
     1272        Bstr path;
     1273        CHECK_ERROR_BREAK (appliance, COMGETTER (Path)(path.asOutParam()));
     1274        printf ("Successfully opened %ls.\n", path.raw());
     1275        printf ("Appliance:\n");
     1276        // Fetch all disks
     1277        com::SafeArray<BSTR> retDisks;
     1278        ULONG diskCount = 0;
     1279        CHECK_ERROR_BREAK (appliance,
     1280                           GetDisks (ComSafeArrayAsOutParam  (retDisks), (&diskCount)));
     1281        if (retDisks.size() > 0)
     1282        {
     1283            printf ("Disks:");
     1284            for (unsigned i = 0; i < retDisks.size(); i++)
     1285                printf (" %ls", Bstr (retDisks [i]).raw());
     1286            printf ("\n");
     1287        }
     1288        /* Fetch all virtual system descriptions */
     1289        com::SafeIfaceArray<IVirtualSystemDescription> retVSD;
     1290        CHECK_ERROR_BREAK (appliance,
     1291                           COMGETTER (VirtualSystemDescriptions) (ComSafeArrayAsOutParam (retVSD)));
     1292        if (retVSD.size() > 0)
     1293        {
     1294            for (unsigned i = 0; i < retVSD.size(); ++i)
     1295            {
     1296                com::SafeArray<VirtualSystemDescriptionType_T> retTypes;
     1297                com::SafeArray<ULONG> retRefs;
     1298                com::SafeArray<BSTR> retOrigValues;
     1299                com::SafeArray<BSTR> retAutoValues;
     1300                com::SafeArray<BSTR> retConfiguration;
     1301                CHECK_ERROR_BREAK (retVSD [i],
     1302                                   GetDescription (ComSafeArrayAsOutParam (retTypes),
     1303                                                   ComSafeArrayAsOutParam (retRefs),
     1304                                                   ComSafeArrayAsOutParam (retOrigValues),
     1305                                                   ComSafeArrayAsOutParam (retAutoValues),
     1306                                                   ComSafeArrayAsOutParam (retConfiguration)));
     1307
     1308                printf ("VirtualSystemDescription:\n");
     1309                for (unsigned a = 0; a < retTypes.size(); ++a)
     1310                {
     1311                    printf (" %d %u %ls %ls %ls\n",
     1312                            retTypes [a],
     1313                            retRefs [a],
     1314                            Bstr (retOrigValues [a]).raw(),
     1315                            Bstr (retAutoValues [a]).raw(),
     1316                            Bstr (retConfiguration [a]).raw());
     1317                }
     1318            }
     1319            printf ("\n");
     1320        }
     1321    }
     1322    while (FALSE);
     1323    printf ("\n");
     1324#endif
    12571325
    12581326    printf ("Press enter to release Session and VirtualBox instances...");
  • trunk/src/VBox/Main/xml/Settings.cpp

    r14922 r16188  
    5858        return aChar - 'a' + 0xA;
    5959
    60     throw ENoConversion (FmtStr ("'%c' (0x%02X) is not hex", aChar, aChar));
     60    throw ENoConversion(xml::FmtStr ("'%c' (0x%02X) is not hex", aChar, aChar));
    6161}
    6262
     
    121121    }
    122122
    123     throw ENoConversion (FmtStr ("'%s' is not integer", aValue));
     123    throw ENoConversion(xml::FmtStr("'%s' is not integer", aValue));
    124124}
    125125
     
    142142        return false;
    143143
    144     throw ENoConversion (FmtStr ("'%s' is not bool", aValue));
     144    throw ENoConversion(xml::FmtStr("'%s' is not bool", aValue));
    145145}
    146146
     
    176176        }
    177177        else
    178             throw ENoConversion (FmtStr ("'%s' is not UTC date", aValue));
    179     }
    180 
    181     throw ENoConversion (FmtStr ("'%s' is not ISO date", aValue));
     178            throw ENoConversion(xml::FmtStr("'%s' is not UTC date", aValue));
     179    }
     180
     181    throw ENoConversion(xml::FmtStr("'%s' is not ISO date", aValue));
    182182}
    183183
     
    192192    /* therefore, the original length must be even */
    193193    if (len % 2 != 0)
    194         throw ENoConversion (FmtStr ("'%.*s' is not binary data",
    195                                      aLen, aValue));
     194        throw ENoConversion(xml::FmtStr("'%.*s' is not binary data",
     195                                        aLen, aValue));
    196196
    197197    stdx::char_auto_ptr result (new char [len]);
     
    265265    RTTIME time;
    266266    if (!RTTimeExplode (&time, &aValue))
    267         throw ENoConversion (FmtStr ("timespec %lld ms is invalid",
    268                                      RTTimeSpecGetMilli (&aValue)));
     267        throw ENoConversion(xml::FmtStr("timespec %lld ms is invalid",
     268                                        RTTimeSpecGetMilli (&aValue)));
    269269
    270270    /* Store ISO date (xsd:dateTime). The format is:
  • trunk/src/VBox/Main/xml/xml.cpp

    r14963 r16188  
    3636
    3737#include <string>
     38#include <list>
     39#include <map>
     40
     41#include "boost/shared_ptr.hpp"
    3842
    3943#include "VBox/xml.h"
     
    4145
    4246/**
    43  * Global module initialization structure.
     47 * Global module initialization structure. This is to wrap non-reentrant bits
     48 * of libxml, among other things.
    4449 *
    4550 * The constructor and destructor of this structure are used to perform global
     
    109114        throw EInvalidArg (RT_SRC_POS);
    110115
    111     char *msg = Format (aErr);
    112     setWhat (msg);
    113     RTStrFree (msg);
     116    char *msg = Format(aErr);
     117    setWhat(msg);
     118    RTStrFree(msg);
    114119}
    115120
     
    122127{
    123128    const char *msg = aErr->message ? aErr->message : "<none>";
    124     size_t msgLen = strlen (msg);
     129    size_t msgLen = strlen(msg);
    125130    /* strip spaces, trailing EOLs and dot-like char */
    126     while (msgLen && strchr (" \n.?!", msg [msgLen - 1]))
    127         -- msgLen;
     131    while (msgLen && strchr(" \n.?!", msg [msgLen - 1]))
     132        --msgLen;
    128133
    129134    char *finalMsg = NULL;
    130     RTStrAPrintf (&finalMsg, "%.*s.\nLocation: '%s', line %d (%d), column %d",
    131                     msgLen, msg, aErr->file, aErr->line, aErr->int1, aErr->int2);
     135    RTStrAPrintf(&finalMsg, "%.*s.\nLocation: '%s', line %d (%d), column %d",
     136                 msgLen, msg, aErr->file, aErr->line, aErr->int1, aErr->int2);
    132137
    133138    return finalMsg;
     
    389394
    390395/*
     396 * Node
     397 *
     398 *
     399 */
     400
     401struct Node::Data
     402{
     403    xmlNode     *plibNode;          // != NULL if this is an element
     404    xmlAttr     *plibAttr;          // != NULL if this is an element
     405
     406    Node     *pParent;       // NULL only for the root element
     407    const char  *pcszName;          // points either into plibNode or plibAttr
     408
     409    struct compare_const_char
     410    {
     411        bool operator()(const char* s1, const char* s2) const
     412        {
     413            return strcmp(s1, s2) < 0;
     414        }
     415    };
     416
     417    // attributes, if this is an element; can be empty
     418    typedef std::map<const char*, boost::shared_ptr<Node>, compare_const_char > AttributesMap;
     419    AttributesMap attribs;
     420
     421    // child elements, if this is an element; can be empty
     422    typedef std::list< boost::shared_ptr<Node> > InternalNodesList;
     423    InternalNodesList children;
     424};
     425
     426Node::Node()
     427    : m(new Data)
     428{
     429    m->plibNode = NULL;
     430    m->plibAttr = NULL;
     431    m->pParent = NULL;
     432}
     433
     434Node::~Node()
     435{
     436    delete m;
     437}
     438
     439void Node::buildChildren()       // private
     440{
     441    // go thru this element's attributes
     442    xmlAttr *plibAttr = m->plibNode->properties;
     443    while (plibAttr)
     444    {
     445        const char *pcszAttribName = (const char*)plibAttr->name;
     446        boost::shared_ptr<Node> pNew(new Node);
     447        pNew->m->plibAttr = plibAttr;
     448        pNew->m->pcszName = (const char*)plibAttr->name;
     449        pNew->m->pParent = this;
     450        // store
     451        m->attribs[pcszAttribName] = pNew;
     452
     453        plibAttr = plibAttr->next;
     454    }
     455
     456    // go thru this element's child elements
     457    xmlNodePtr plibNode = m->plibNode->children;
     458    while (plibNode)
     459    {
     460        // create a new Node for this child element
     461        boost::shared_ptr<Node> pNew(new Node);
     462        pNew->m->plibNode = plibNode;
     463        pNew->m->pcszName = (const char*)plibNode->name;
     464        pNew->m->pParent = this;
     465        // store
     466        m->children.push_back(pNew);
     467
     468        // recurse for this child element to get its own children
     469        pNew->buildChildren();
     470
     471        plibNode = plibNode->next;
     472    }
     473}
     474
     475const char* Node::getName() const
     476{
     477    return m->pcszName;
     478}
     479
     480/**
     481 * Returns the value of a node. If this node is an attribute, returns
     482 * the attribute value; if this node is an element, then this returns
     483 * the element text content.
     484 * @return
     485 */
     486const char* Node::getValue() const
     487{
     488    if (    (m->plibAttr)
     489         && (m->plibAttr->children)
     490       )
     491        // libxml hides attribute values in another node created as a
     492        // single child of the attribute node, and it's in the content field
     493        return (const char*)m->plibAttr->children->content;
     494
     495    if (    (m->plibNode)
     496         && (m->plibNode->children)
     497       )
     498        return (const char*)m->plibNode->children->content;
     499
     500    return NULL;
     501}
     502
     503/**
     504 * Copies the value of a node into the given integer variable.
     505 * Returns TRUE only if a value was found and was actually an
     506 * integer of the given type.
     507 * @return
     508 */
     509bool Node::copyValue(int32_t &i) const
     510{
     511    const char *pcsz;
     512    if (    ((pcsz = getValue()))
     513         && (VINF_SUCCESS == RTStrToInt32Ex(pcsz, NULL, 10, &i))
     514       )
     515        return true;
     516
     517    return false;
     518}
     519
     520/**
     521 * Copies the value of a node into the given integer variable.
     522 * Returns TRUE only if a value was found and was actually an
     523 * integer of the given type.
     524 * @return
     525 */
     526bool Node::copyValue(uint32_t &i) const
     527{
     528    const char *pcsz;
     529    if (    ((pcsz = getValue()))
     530         && (VINF_SUCCESS == RTStrToUInt32Ex(pcsz, NULL, 10, &i))
     531       )
     532        return true;
     533
     534    return false;
     535}
     536
     537/**
     538 * Copies the value of a node into the given integer variable.
     539 * Returns TRUE only if a value was found and was actually an
     540 * integer of the given type.
     541 * @return
     542 */
     543bool Node::copyValue(int64_t &i) const
     544{
     545    const char *pcsz;
     546    if (    ((pcsz = getValue()))
     547         && (VINF_SUCCESS == RTStrToInt64Ex(pcsz, NULL, 10, &i))
     548       )
     549        return true;
     550
     551    return false;
     552}
     553
     554/**
     555 * Copies the value of a node into the given integer variable.
     556 * Returns TRUE only if a value was found and was actually an
     557 * integer of the given type.
     558 * @return
     559 */
     560bool Node::copyValue(uint64_t &i) const
     561{
     562    const char *pcsz;
     563    if (    ((pcsz = getValue()))
     564         && (VINF_SUCCESS == RTStrToUInt64Ex(pcsz, NULL, 10, &i))
     565       )
     566        return true;
     567
     568    return false;
     569}
     570
     571/**
     572 * Returns the line number of the current node in the source XML file.
     573 * Useful for error messages.
     574 * @return
     575 */
     576int Node::getLineNumber() const
     577{
     578    if (m->plibAttr)
     579        return m->pParent->m->plibNode->line;
     580
     581    return m->plibNode->line;
     582}
     583
     584/**
     585 * Builds a list of direct child elements of the current element that
     586 * match the given string; if pcszMatch is NULL, all direct child
     587 * elements are returned.
     588 * @param children out: list of nodes to which children will be appended.
     589 * @param pcszMatch in: match string, or NULL to return all children.
     590 * @return Number of items appended to the list (0 if none).
     591 */
     592int Node::getChildElements(NodesList &children,
     593                              const char *pcszMatch /*= NULL*/)
     594    const
     595{
     596    int i = 0;
     597    Data::InternalNodesList::const_iterator
     598        it,
     599        last = m->children.end();
     600    for (it = m->children.begin();
     601         it != last;
     602         ++it)
     603    {
     604        // export this child node if ...
     605        if (    (!pcszMatch)    // the caller wants all nodes or
     606             || (!strcmp(pcszMatch, (**it).getName())) // the element name matches
     607           )
     608        {
     609            children.push_back((*it).get());
     610            ++i;
     611        }
     612    }
     613    return i;
     614}
     615
     616/**
     617 * Returns the first child element whose name matches pcszMatch.
     618 * @param pcszMatch
     619 * @return
     620 */
     621const Node* Node::findChildElement(const char *pcszMatch)
     622    const
     623{
     624    Data::InternalNodesList::const_iterator
     625        it,
     626        last = m->children.end();
     627    for (it = m->children.begin();
     628         it != last;
     629         ++it)
     630    {
     631        if (!strcmp(pcszMatch, (**it).getName())) // the element name matches
     632            return (*it).get();
     633    }
     634
     635    return NULL;
     636}
     637
     638/**
     639 * Returns the first child element whose "id" attribute matches pcszId.
     640 * @param pcszId identifier to look for.
     641 * @return child element or NULL if not found.
     642 */
     643const Node* Node::findChildElementFromId(const char *pcszId) const
     644{
     645    Data::InternalNodesList::const_iterator
     646        it,
     647        last = m->children.end();
     648    for (it = m->children.begin();
     649         it != last;
     650         ++it)
     651    {
     652        const Node *pElem = (*it).get();
     653        const Node *pAttr;
     654        if (    ((pAttr = pElem->findAttribute("id")))
     655             && (!strcmp(pAttr->getValue(), pcszId))
     656           )
     657            return pElem;
     658    }
     659
     660    return NULL;
     661}
     662
     663/**
     664 *
     665 * @param pcszMatch
     666 * @return
     667 */
     668const Node* Node::findAttribute(const char *pcszMatch) const
     669{
     670    Data::AttributesMap::const_iterator it;
     671
     672    it = m->attribs.find(pcszMatch);
     673    if (it != m->attribs.end())
     674        return it->second.get();
     675
     676    return NULL;
     677}
     678
     679/**
     680 * Convenience method which attempts to find the attribute with the given
     681 * name and returns its value as a string.
     682 *
     683 * @param pcszMatch name of attribute to find.
     684 * @param str out: attribute value
     685 * @return TRUE if attribute was found and str was thus updated.
     686 */
     687bool Node::getAttributeValue(const char *pcszMatch, std::string &str) const
     688{
     689    const Node* pAttr;
     690    if ((pAttr = findAttribute(pcszMatch)))
     691    {
     692        str = pAttr->getValue();
     693        return true;
     694    }
     695
     696    return false;
     697}
     698
     699/**
     700 * Convenience method which attempts to find the attribute with the given
     701 * name and returns its value as a signed long integer. This calls
     702 * RTStrToInt64Ex internally and will only output the integer if that
     703 * function returns no error.
     704 *
     705 * @param pcszMatch name of attribute to find.
     706 * @param i out: attribute value
     707 * @return TRUE if attribute was found and str was thus updated.
     708 */
     709bool Node::getAttributeValue(const char *pcszMatch, int64_t &i) const
     710{
     711    std::string str;
     712    if (    (getAttributeValue(pcszMatch, str))
     713         && (VINF_SUCCESS == RTStrToInt64Ex(str.c_str(), NULL, 10, &i))
     714       )
     715        return true;
     716
     717    return false;
     718}
     719
     720/**
     721 * Convenience method which attempts to find the attribute with the given
     722 * name and returns its value as an unsigned long integer.This calls
     723 * RTStrToUInt64Ex internally and will only output the integer if that
     724 * function returns no error.
     725 *
     726 * @param pcszMatch name of attribute to find.
     727 * @param i out: attribute value
     728 * @return TRUE if attribute was found and str was thus updated.
     729 */
     730bool Node::getAttributeValue(const char *pcszMatch, uint64_t &i) const
     731{
     732    std::string str;
     733    if (    (getAttributeValue(pcszMatch, str))
     734         && (VINF_SUCCESS == RTStrToUInt64Ex(str.c_str(), NULL, 10, &i))
     735       )
     736        return true;
     737
     738    return false;
     739}
     740
     741/*
     742 * NodesLoop
     743 *
     744 */
     745
     746struct NodesLoop::Data
     747{
     748    NodesList listElements;
     749    NodesList::const_iterator it;
     750};
     751
     752NodesLoop::NodesLoop(const Node &node, const char *pcszMatch /* = NULL */)
     753{
     754    m = new Data;
     755    node.getChildElements(m->listElements, pcszMatch);
     756    m->it = m->listElements.begin();
     757}
     758
     759NodesLoop::~NodesLoop()
     760{
     761    delete m;
     762}
     763
     764
     765/**
     766 * Handy convenience helper for looping over all child elements. Create an
     767 * instance of NodesLoop on the stack and call this method until it returns
     768 * NULL, like this:
     769 * <code>
     770 *      xml::Node node;         // should point to an element
     771 *      xml::NodesLoop loop(node, "child");  // find all "child" elements under node
     772 *      const xml::Node *pChild = NULL;
     773 *      while (pChild = loop.forAllNodes())
     774 *          ...;
     775 * </code>
     776 * @param node
     777 * @param pcszMatch
     778 * @return
     779 */
     780const Node* NodesLoop::forAllNodes() const
     781{
     782    const Node *pNode = NULL;
     783
     784    if (m->it != m->listElements.end())
     785    {
     786        pNode = *(m->it);
     787        ++(m->it);
     788    }
     789
     790    return pNode;
     791}
     792
     793/*
     794 * Document
     795 *
     796 *
     797 */
     798
     799struct Document::Data
     800{
     801    xmlDocPtr   pDocument;
     802    Node     *pRootElement;
     803
     804    Data()
     805    {
     806        pDocument = NULL;
     807        pRootElement = NULL;
     808    }
     809
     810    ~Data()
     811    {
     812        reset();
     813    }
     814
     815    void reset()
     816    {
     817        if (pDocument)
     818        {
     819            xmlFreeDoc(pDocument);
     820            pDocument = NULL;
     821        }
     822        if (pRootElement)
     823        {
     824            delete pRootElement;
     825            pRootElement = NULL;
     826        }
     827    }
     828
     829    void copyFrom(const Document::Data *p)
     830    {
     831        if (p->pDocument)
     832        {
     833            pDocument = xmlCopyDoc(p->pDocument,
     834                                   1);      // recursive == copy all
     835        }
     836    }
     837};
     838
     839Document::Document()
     840    : m(new Data)
     841{
     842}
     843
     844Document::Document(const Document &x)
     845    : m(new Data)
     846{
     847    m->copyFrom(x.m);
     848};
     849
     850Document& Document::operator=(const Document &x)
     851{
     852    m->reset();
     853    m->copyFrom(x.m);
     854    return *this;
     855};
     856
     857Document::~Document()
     858{
     859    delete m;
     860}
     861
     862/**
     863 * private method to refresh all internal structures after the internal pDocument
     864 * has changed. Called from XmlFileParser::read(). m->reset() must have been
     865 * called before to make sure all members except the internal pDocument are clean.
     866 */
     867void Document::refreshInternals() // private
     868{
     869    m->pRootElement = new Node();
     870    m->pRootElement->m->plibNode = xmlDocGetRootElement(m->pDocument);
     871    m->pRootElement->m->pcszName = (const char*)m->pRootElement->m->plibNode->name;
     872
     873    m->pRootElement->buildChildren();
     874}
     875
     876const Node* Document::getRootElement() const
     877{
     878    return m->pRootElement;
     879}
     880
     881/*
    391882 * XmlParserBase
    392883 *
     
    462953};
    463954
    464 void XmlFileParser::read(const char *pcszFilename)
     955/**
     956 * Reads the given file and fills the given Document object with its contents.
     957 * Throws XmlError on parsing errors.
     958 *
     959 * The document that is passed in will be reset before being filled if not empty.
     960 *
     961 * @param pcszFilename in: name fo file to parse.
     962 * @param doc out: document to be reset and filled with data according to file contents.
     963 */
     964void XmlFileParser::read(const char *pcszFilename,
     965                         Document &doc)
    465966{
    466967    GlobalLock lock();
    467968//     global.setExternalEntityLoader(ExternalEntityLoader);
    468969
    469     xmlDocPtr doc = NULL;
    470     ReadContext *pContext = NULL;
    471 
    472970    m->strXmlFilename = pcszFilename;
    473971
    474     try
    475     {
    476         pContext = new ReadContext(pcszFilename);
    477         doc = xmlCtxtReadIO(m->ctxt,
    478                             ReadCallback,
    479                             CloseCallback,
    480                             pContext,
    481                             pcszFilename,
    482                             NULL,       // encoding
    483                             XML_PARSE_NOBLANKS);
    484         if (doc == NULL)
    485         {
    486             throw XmlError(xmlCtxtGetLastError(m->ctxt));
    487         }
    488 
    489         xmlFreeDoc(doc);
    490         doc = NULL;
    491 
    492         delete pContext;
    493         pContext = NULL;
    494     }
    495     catch (...)
    496     {
    497         if (doc != NULL)
    498             xmlFreeDoc(doc);
    499 
    500         if (pContext)
    501             delete pContext;
    502 
    503         throw;
    504     }
     972    ReadContext context(pcszFilename);
     973    doc.m->reset();
     974    if (!(doc.m->pDocument = xmlCtxtReadIO(m->ctxt,
     975                                           ReadCallback,
     976                                           CloseCallback,
     977                                           &context,
     978                                           pcszFilename,
     979                                           NULL,       // encoding = auto
     980                                           XML_PARSE_NOBLANKS)))
     981        throw XmlError(xmlCtxtGetLastError(m->ctxt));
     982
     983    doc.refreshInternals();
    505984}
    506985
  • trunk/src/VBox/Main/xpcom/server.cpp

    r15904 r16188  
    8888#include <VirtualBoxImpl.h>
    8989#include <MachineImpl.h>
     90#include <ApplianceImpl.h>
    9091#include <SnapshotImpl.h>
    9192#include <MediumImpl.h>
     
    122123NS_DECL_CLASSINFO(Machine)
    123124NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Machine, IMachine)
     125
     126NS_DECL_CLASSINFO(Appliance)
     127NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Appliance, IAppliance)
     128
     129NS_DECL_CLASSINFO(VirtualSystemDescription)
     130NS_IMPL_THREADSAFE_ISUPPORTS1_CI(VirtualSystemDescription, IVirtualSystemDescription)
    124131
    125132NS_DECL_CLASSINFO(SessionMachine)
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