Index: trunk/src/VBox/Main/MachineImpl.cpp
===================================================================
--- trunk/src/VBox/Main/MachineImpl.cpp	(revision 14853)
+++ trunk/src/VBox/Main/MachineImpl.cpp	(revision 14854)
@@ -2390,4 +2390,5 @@
     {
         using namespace settings;
+        using namespace vboxxml;
 
         /* load the settings file (we don't reuse the existing handle but
@@ -2493,4 +2494,5 @@
     {
         using namespace settings;
+        using namespace vboxxml;
 
         /* load the settings file (we don't reuse the existing handle but
@@ -2568,4 +2570,5 @@
     {
         using namespace settings;
+        using namespace vboxxml;
 
         /* load the settings file */
@@ -4709,4 +4712,5 @@
     {
         using namespace settings;
+        using namespace vboxxml;
 
         /* no concurrent file access is possible in init() so open by handle */
@@ -5866,4 +5870,5 @@
     {
         using namespace settings;
+        using namespace vboxxml;
 
         /* this object is locked for writing to prevent concurrent reads and writes */
@@ -6061,4 +6066,5 @@
     {
         using namespace settings;
+        using namespace vboxxml;
 
         /* load the settings file */
@@ -6623,5 +6629,5 @@
                                                emptyStr);
     }
-    catch (ENoMemory e)
+    catch (vboxxml::ENoMemory e)
     {
         return E_OUTOFMEMORY;
@@ -6705,4 +6711,5 @@
     {
         using namespace settings;
+        using namespace vboxxml;
 
         /* load the settings file */
Index: trunk/src/VBox/Main/Makefile.kmk
===================================================================
--- trunk/src/VBox/Main/Makefile.kmk	(revision 14853)
+++ trunk/src/VBox/Main/Makefile.kmk	(revision 14854)
@@ -555,4 +555,5 @@
 	include
 VBoxSettings_SOURCES    = \
+	xml/vboxxml.cpp \
 	xml/Settings.cpp
 VBoxSettings_LDFLAGS.darwin = -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/$(notdir $(LIB_SETTINGS)) -Wl,-x # no debug info please.
Index: trunk/src/VBox/Main/VirtualBoxBase.cpp
===================================================================
--- trunk/src/VBox/Main/VirtualBoxBase.cpp	(revision 14853)
+++ trunk/src/VBox/Main/VirtualBoxBase.cpp	(revision 14854)
@@ -1255,5 +1255,5 @@
 
     if (RT_FAILURE (vrc))
-        throw LogicError (RT_SRC_POS);
+        throw vboxxml::LogicError (RT_SRC_POS);
 
     return result;
@@ -1293,5 +1293,5 @@
     int vrc = RTUuidToStr (aValue.raw(), result.get() + 1, RTUUID_STR_LENGTH);
     if (RT_FAILURE (vrc))
-        throw LogicError (RT_SRC_POS);
+        throw vboxxml::LogicError (RT_SRC_POS);
 
     result.get() [0] = '{';
Index: trunk/src/VBox/Main/VirtualBoxImpl.cpp
===================================================================
--- trunk/src/VBox/Main/VirtualBoxImpl.cpp	(revision 14853)
+++ trunk/src/VBox/Main/VirtualBoxImpl.cpp	(revision 14854)
@@ -221,4 +221,5 @@
         {
             using namespace settings;
+            using namespace vboxxml;
 
             /* no concurrent file access is possible in init() so open by handle */
@@ -1421,4 +1422,5 @@
     {
         using namespace settings;
+        using namespace vboxxml;
 
         /* load the settings file (we don't reuse the existing handle but
@@ -1519,4 +1521,5 @@
     {
         using namespace settings;
+        using namespace vboxxml;
 
         /* load the settings file (we don't reuse the existing handle but
@@ -1579,4 +1582,5 @@
     {
         using namespace settings;
+        using namespace vboxxml;
 
         /* load the settings file */
@@ -3144,4 +3148,5 @@
     {
         using namespace settings;
+        using namespace vboxxml;
 
         /* load the settings file */
@@ -3763,5 +3768,5 @@
 /* static */
 HRESULT VirtualBox::loadSettingsTree (settings::XmlTreeBackend &aTree,
-                                      settings::File &aFile,
+                                      vboxxml::File &aFile,
                                       bool aValidate,
                                       bool aCatchLoadErrors,
@@ -3798,5 +3803,5 @@
         }
     }
-    catch (const EIPRTFailure &err)
+    catch (const vboxxml::EIPRTFailure &err)
     {
         if (!aCatchLoadErrors)
@@ -3837,5 +3842,5 @@
 /* static */
 HRESULT VirtualBox::saveSettingsTree (settings::TreeBackend &aTree,
-                                      settings::File &aFile,
+                                      vboxxml::File &aFile,
                                       Utf8Str &aFormatVersion)
 {
@@ -3851,5 +3856,5 @@
             aFormatVersion = VBOX_XML_VERSION_FULL;
     }
-    catch (const EIPRTFailure &err)
+    catch (const vboxxml::EIPRTFailure &err)
     {
         /* this is the only expected exception for now */
Index: trunk/src/VBox/Main/VirtualBoxImplExtra.cpp
===================================================================
--- trunk/src/VBox/Main/VirtualBoxImplExtra.cpp	(revision 14853)
+++ trunk/src/VBox/Main/VirtualBoxImplExtra.cpp	(revision 14854)
@@ -68,10 +68,10 @@
  *              a wrong URI/ID pair.
  */
-settings::Input *
+vboxxml::Input *
 VirtualBox::SettingsTreeHelper::resolveEntity (const char *aURI, const char *aID)
 {
     if (strcmp (aURI, VBOX_XML_SCHEMA_COMMON) == 0)
     {
-        return new settings::
+        return new vboxxml::
             MemoryBuf ((const char *) g_ab_xml_VirtualBox_settings_common_xsd,
                        g_cb_xml_VirtualBox_settings_common_xsd, aURI);
@@ -80,5 +80,5 @@
     if (strcmp (aURI, VBOX_XML_SCHEMA_ROOT) == 0)
     {
-        return new settings::
+        return new vboxxml::
             MemoryBuf ((const char *) g_ab_xml_VirtualBox_settings_root_xsd,
                        g_cb_xml_VirtualBox_settings_root_xsd, aURI);
@@ -87,5 +87,5 @@
     if (strcmp (aURI, VBOX_XML_SCHEMA) == 0)
     {
-        return new settings::
+        return new vboxxml::
             MemoryBuf ((const char *) g_ab_xml_VirtualBox_settings_xsd,
                        g_cb_xml_VirtualBox_settings_xsd, aURI);
@@ -94,5 +94,5 @@
     if (strcmp (aURI, VBOX_XML_SETTINGS_CONVERTER) == 0)
     {
-        return new settings::
+        return new vboxxml::
             MemoryBuf ((const char *) g_ab_xml_SettingsConverter_xsl,
                        g_cb_xml_SettingsConverter_xsl, aURI);
Index: trunk/src/VBox/Main/include/VirtualBoxImpl.h
===================================================================
--- trunk/src/VBox/Main/include/VirtualBoxImpl.h	(revision 14853)
+++ trunk/src/VBox/Main/include/VirtualBoxImpl.h	(revision 14854)
@@ -280,5 +280,5 @@
 
         // InputResolver interface
-        settings::Input *resolveEntity (const char *aURI, const char *aID);
+        vboxxml::Input *resolveEntity (const char *aURI, const char *aID);
 
         // AutoConverter interface
@@ -288,5 +288,5 @@
 
     static HRESULT loadSettingsTree (settings::XmlTreeBackend &aTree,
-                                     settings::File &aFile,
+                                     vboxxml::File &aFile,
                                      bool aValidate,
                                      bool aCatchLoadErrors,
@@ -304,5 +304,5 @@
      */
     static HRESULT loadSettingsTree_FirstTime (settings::XmlTreeBackend &aTree,
-                                               settings::File &aFile,
+                                               vboxxml::File &aFile,
                                                Utf8Str &aFormatVersion)
     {
@@ -320,5 +320,5 @@
      */
     static HRESULT loadSettingsTree_Again (settings::XmlTreeBackend &aTree,
-                                           settings::File &aFile)
+                                           vboxxml::File &aFile)
     {
         return loadSettingsTree (aTree, aFile, true, false, true);
@@ -333,5 +333,5 @@
      */
     static HRESULT loadSettingsTree_ForUpdate (settings::XmlTreeBackend &aTree,
-                                               settings::File &aFile)
+                                               vboxxml::File &aFile)
     {
         return loadSettingsTree (aTree, aFile, true, false, false);
@@ -339,5 +339,5 @@
 
     static HRESULT saveSettingsTree (settings::TreeBackend &aTree,
-                                     settings::File &aFile,
+                                     vboxxml::File &aFile,
                                      Utf8Str &aFormatVersion);
 
Index: trunk/src/VBox/Main/xml/Settings.cpp
===================================================================
--- trunk/src/VBox/Main/xml/Settings.cpp	(revision 14853)
+++ trunk/src/VBox/Main/xml/Settings.cpp	(revision 14854)
@@ -143,5 +143,5 @@
             break;
         default:
-            throw ENotImplemented (RT_SRC_POS);
+            throw vboxxml::ENotImplemented (RT_SRC_POS);
     }
 
@@ -287,5 +287,5 @@
             break;
         default:
-            throw ENotImplemented (RT_SRC_POS);
+            throw vboxxml::ENotImplemented (RT_SRC_POS);
     }
 
@@ -295,5 +295,5 @@
         return result;
 
-    throw EIPRTFailure (vrc);
+    throw vboxxml::EIPRTFailure (vrc);
 }
 
@@ -348,205 +348,4 @@
 
 //////////////////////////////////////////////////////////////////////////////
-// File Class
-//////////////////////////////////////////////////////////////////////////////
-
-struct File::Data
-{
-    Data()
-        : fileName (NULL), handle (NIL_RTFILE), opened (false) {}
-
-    char *fileName;
-    RTFILE handle;
-    bool opened : 1;
-};
-
-File::File (Mode aMode, const char *aFileName)
-    : m (new Data())
-{
-    m->fileName = RTStrDup (aFileName);
-    if (m->fileName == NULL)
-        throw ENoMemory();
-
-    unsigned flags = 0;
-    switch (aMode)
-    {
-        case Mode_Read:
-            flags = RTFILE_O_READ;
-            break;
-        case Mode_Write:
-            flags = RTFILE_O_WRITE | RTFILE_O_CREATE;
-            break;
-        case Mode_ReadWrite:
-            flags = RTFILE_O_READ | RTFILE_O_WRITE;
-    }
-
-    int vrc = RTFileOpen (&m->handle, aFileName, flags);
-    if (RT_FAILURE (vrc))
-        throw EIPRTFailure (vrc);
-
-    m->opened = true;
-}
-
-File::File (RTFILE aHandle, const char *aFileName /* = NULL */)
-    : m (new Data())
-{
-    if (aHandle == NIL_RTFILE)
-        throw EInvalidArg (RT_SRC_POS);
-
-    m->handle = aHandle;
-
-    if (aFileName)
-    {
-        m->fileName = RTStrDup (aFileName);
-        if (m->fileName == NULL)
-            throw ENoMemory();
-    }
-
-    setPos (0);
-}
-
-File::~File()
-{
-    if (m->opened)
-        RTFileClose (m->handle);
-
-    RTStrFree (m->fileName);
-}
-
-const char *File::uri() const
-{
-    return m->fileName;
-}
-
-uint64_t File::pos() const
-{
-    uint64_t p = 0;
-    int vrc = RTFileSeek (m->handle, 0, RTFILE_SEEK_CURRENT, &p);
-    if (RT_SUCCESS (vrc))
-        return p;
-
-    throw EIPRTFailure (vrc);
-}
-
-void File::setPos (uint64_t aPos)
-{
-    uint64_t p = 0;
-    unsigned method = RTFILE_SEEK_BEGIN;
-    int vrc = VINF_SUCCESS;
-
-    /* check if we overflow int64_t and move to INT64_MAX first */
-    if (((int64_t) aPos) < 0)
-    {
-        vrc = RTFileSeek (m->handle, INT64_MAX, method, &p);
-        aPos -= (uint64_t) INT64_MAX;
-        method = RTFILE_SEEK_CURRENT;
-    }
-    /* seek the rest */
-    if (RT_SUCCESS (vrc))
-        vrc = RTFileSeek (m->handle, (int64_t) aPos, method, &p);
-    if (RT_SUCCESS (vrc))
-        return;
-
-    throw EIPRTFailure (vrc);
-}
-
-int File::read (char *aBuf, int aLen)
-{
-    size_t len = aLen;
-    int vrc = RTFileRead (m->handle, aBuf, len, &len);
-    if (RT_SUCCESS (vrc))
-        return len;
-
-    throw EIPRTFailure (vrc);
-}
-
-int File::write (const char *aBuf, int aLen)
-{
-    size_t len = aLen;
-    int vrc = RTFileWrite (m->handle, aBuf, len, &len);
-    if (RT_SUCCESS (vrc))
-        return len;
-
-    throw EIPRTFailure (vrc);
-
-    return -1 /* failure */;
-}
-
-void File::truncate()
-{
-    int vrc = RTFileSetSize (m->handle, pos());
-    if (RT_SUCCESS (vrc))
-        return;
-
-    throw EIPRTFailure (vrc);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// MemoryBuf Class
-//////////////////////////////////////////////////////////////////////////////
-
-struct MemoryBuf::Data
-{
-    Data()
-        : buf (NULL), len (0), uri (NULL), pos (0) {}
-
-    const char *buf;
-    size_t len;
-    char *uri;
-
-    size_t pos;
-};
-
-MemoryBuf::MemoryBuf (const char *aBuf, size_t aLen, const char *aURI /* = NULL */)
-    : m (new Data())
-{
-    if (aBuf == NULL)
-        throw EInvalidArg (RT_SRC_POS);
-
-    m->buf = aBuf;
-    m->len = aLen;
-    m->uri = RTStrDup (aURI);
-}
-
-MemoryBuf::~MemoryBuf()
-{
-    RTStrFree (m->uri);
-}
-
-const char *MemoryBuf::uri() const
-{
-    return m->uri;
-}
-
-uint64_t MemoryBuf::pos() const
-{
-    return m->pos;
-}
-
-void MemoryBuf::setPos (uint64_t aPos)
-{
-    size_t pos = (size_t) aPos;
-    if ((uint64_t) pos != aPos)
-        throw EInvalidArg();
-
-    if (pos > m->len)
-        throw EInvalidArg();
-
-    m->pos = pos;
-}
-
-int MemoryBuf::read (char *aBuf, int aLen)
-{
-    if (m->pos >= m->len)
-        return 0 /* nothing to read */;
-
-    size_t len = m->pos + aLen < m->len ? aLen : m->len - m->pos;
-    memcpy (aBuf, m->buf + m->pos, len);
-    m->pos += len;
-
-    return len;
-}
-
-//////////////////////////////////////////////////////////////////////////////
 // XmlKeyBackend Class
 //////////////////////////////////////////////////////////////////////////////
@@ -602,5 +401,5 @@
 void XmlKeyBackend::setName (const char *aName)
 {
-    throw ENotImplemented (RT_SRC_POS);
+    throw vboxxml::ENotImplemented (RT_SRC_POS);
 }
 
@@ -659,5 +458,5 @@
             value = xmlEncodeSpecialChars (mNode->doc, value);
             if (value == NULL)
-                throw ENoMemory();
+                throw vboxxml::ENoMemory();
         }
 
@@ -685,5 +484,5 @@
             int rc = xmlRemoveProp (attr);
             if (rc != 0)
-                throw EInvalidArg (RT_SRC_POS);
+                throw vboxxml::EInvalidArg (RT_SRC_POS);
         }
         return;
@@ -693,5 +492,5 @@
                                   (const xmlChar *) aValue);
     if (attr == NULL)
-        throw ENoMemory();
+        throw vboxxml::ENoMemory();
 }
 
@@ -746,5 +545,5 @@
     xmlNodePtr node = xmlNewChild (mNode, NULL, (const xmlChar *) aName, NULL);
     if (node == NULL)
-        throw ENoMemory();
+        throw vboxxml::ENoMemory();
 
     return Key (new XmlKeyBackend (node));
@@ -772,5 +571,5 @@
     {
         if (!aErr)
-            throw EInvalidArg (RT_SRC_POS);
+            throw vboxxml::EInvalidArg (RT_SRC_POS);
 
         char *msg = Format (aErr);
@@ -824,5 +623,5 @@
     struct IOCtxt
     {
-        IOCtxt (Stream *aStream, std::auto_ptr <stdx::exception_trap_base> &aErr)
+        IOCtxt (vboxxml::Stream *aStream, std::auto_ptr <stdx::exception_trap_base> &aErr)
             : stream (aStream), deleteStreamOnClose (false)
             , err (aErr) {}
@@ -833,5 +632,5 @@
         void resetErr() { err.reset(); }
 
-        Stream *stream;
+        vboxxml::Stream *stream;
         bool deleteStreamOnClose;
 
@@ -841,16 +640,16 @@
     struct InputCtxt : public IOCtxt
     {
-        InputCtxt (Input *aInput, std::auto_ptr <stdx::exception_trap_base> &aErr)
+        InputCtxt (vboxxml::Input *aInput, std::auto_ptr <stdx::exception_trap_base> &aErr)
             : IOCtxt (aInput, aErr), input (aInput) {}
 
-        Input *input;
+        vboxxml::Input *input;
     };
 
     struct OutputCtxt : public IOCtxt
     {
-        OutputCtxt (Output *aOutput, std::auto_ptr <stdx::exception_trap_base> &aErr)
+        OutputCtxt (vboxxml::Output *aOutput, std::auto_ptr <stdx::exception_trap_base> &aErr)
             : IOCtxt (aOutput, aErr), output (aOutput) {}
 
-        Output *output;
+        vboxxml::Output *output;
     };
 };
@@ -862,5 +661,5 @@
     m->ctxt = xmlNewParserCtxt();
     if (m->ctxt == NULL)
-        throw ENoMemory();
+        throw vboxxml::ENoMemory();
 }
 
@@ -901,5 +700,5 @@
 extern "C" void *xsltGenericErrorContext;
 
-void XmlTreeBackend::rawRead (Input &aInput, const char *aSchema /* = NULL */,
+void XmlTreeBackend::rawRead (vboxxml::Input &aInput, const char *aSchema /* = NULL */,
                               int aFlags /* = 0 */)
 {
@@ -965,5 +764,5 @@
                 /* parse the XSLT template */
                 {
-                    Input *xsltInput =
+                    vboxxml::Input *xsltInput =
                         m->inputResolver->resolveEntity
                             (m->autoConverter->templateUri(), NULL);
@@ -1001,8 +800,8 @@
                 {
                     if (errorStr != NULL)
-                        throw LogicError (errorStr);
+                        throw vboxxml::LogicError (errorStr);
                     /* errorStr is freed in catch(...) below */
 
-                    throw LogicError (RT_SRC_POS);
+                    throw vboxxml::LogicError (RT_SRC_POS);
                 }
 
@@ -1012,5 +811,5 @@
                     xmlDocPtr newDoc = xsltApplyStylesheet (xslt, doc, NULL);
                     if (newDoc == NULL && errorStr == NULL)
-                        throw LogicError (RT_SRC_POS);
+                        throw vboxxml::LogicError (RT_SRC_POS);
 
                     if (errorStr != NULL)
@@ -1074,5 +873,5 @@
                 schemaCtxt = xmlSchemaNewParserCtxt (aSchema);
                 if (schemaCtxt == NULL)
-                    throw LogicError (RT_SRC_POS);
+                    throw vboxxml::LogicError (RT_SRC_POS);
 
                 /* set our error handlers */
@@ -1088,5 +887,5 @@
                     validCtxt = xmlSchemaNewValidCtxt (schema);
                     if (validCtxt == NULL)
-                        throw LogicError (RT_SRC_POS);
+                        throw vboxxml::LogicError (RT_SRC_POS);
 
                     /* instruct to create default attribute's values in the document */
@@ -1109,5 +908,5 @@
 
                     if (errorStr == NULL)
-                        throw LogicError (RT_SRC_POS);
+                        throw vboxxml::LogicError (RT_SRC_POS);
 
                     throw Error (errorStr);
@@ -1166,5 +965,5 @@
 }
 
-void XmlTreeBackend::rawWrite (Output &aOutput)
+void XmlTreeBackend::rawWrite (vboxxml::Output &aOutput)
 {
     /* reset error variables used to memorize exceptions while inside the
@@ -1188,5 +987,5 @@
                                            XML_SAVE_FORMAT);
     if (saveCtxt == NULL)
-        throw LogicError (RT_SRC_POS);
+        throw vboxxml::LogicError (RT_SRC_POS);
 
     long rc = xmlSaveDoc (saveCtxt, m->doc);
@@ -1199,5 +998,5 @@
         /* there must be an exception from the Output implementation,
          * otherwise the save operation must always succeed. */
-        throw LogicError (RT_SRC_POS);
+        throw vboxxml::LogicError (RT_SRC_POS);
     }
 
@@ -1238,8 +1037,8 @@
         return ctxt->input->read (aBuf, aLen);
     }
-    catch (const EIPRTFailure &err) { ctxt->setErr (err); }
-    catch (const settings::Error &err) { ctxt->setErr (err); }
+    catch (const vboxxml::EIPRTFailure &err) { ctxt->setErr (err); }
+    catch (const vboxxml::Error &err) { ctxt->setErr (err); }
     catch (const std::exception &err) { ctxt->setErr (err); }
-    catch (...) { ctxt->setErr (LogicError (RT_SRC_POS)); }
+    catch (...) { ctxt->setErr (vboxxml::LogicError (RT_SRC_POS)); }
 
     return -1 /* failure */;
@@ -1259,8 +1058,8 @@
         return ctxt->output->write (aBuf, aLen);
     }
-    catch (const EIPRTFailure &err) { ctxt->setErr (err); }
-    catch (const settings::Error &err) { ctxt->setErr (err); }
+    catch (const vboxxml::EIPRTFailure &err) { ctxt->setErr (err); }
+    catch (const vboxxml::Error &err) { ctxt->setErr (err); }
     catch (const std::exception &err) { ctxt->setErr (err); }
-    catch (...) { ctxt->setErr (LogicError (RT_SRC_POS)); }
+    catch (...) { ctxt->setErr (vboxxml::LogicError (RT_SRC_POS)); }
 
     return -1 /* failure */;
@@ -1291,8 +1090,8 @@
         return 0 /* success */;
     }
-    catch (const EIPRTFailure &err) { ctxt->setErr (err); }
-    catch (const settings::Error &err) { ctxt->setErr (err); }
+    catch (const vboxxml::EIPRTFailure &err) { ctxt->setErr (err); }
+    catch (const vboxxml::Error &err) { ctxt->setErr (err); }
     catch (const std::exception &err) { ctxt->setErr (err); }
-    catch (...) { ctxt->setErr (LogicError (RT_SRC_POS)); }
+    catch (...) { ctxt->setErr (vboxxml::LogicError (RT_SRC_POS)); }
 
     return -1 /* failure */;
@@ -1398,5 +1197,5 @@
     try
     {
-        Input *input = sThat->m->inputResolver->resolveEntity (aURI, aID);
+        vboxxml::Input *input = sThat->m->inputResolver->resolveEntity (aURI, aID);
         if (input == NULL)
             return NULL;
@@ -1433,10 +1232,10 @@
         delete ctxt;
 
-        throw ENoMemory();
-    }
-    catch (const EIPRTFailure &err) { sThat->m->trappedErr.reset (stdx::new_exception_trap (err)); }
-    catch (const settings::Error &err) { sThat->m->trappedErr.reset (stdx::new_exception_trap (err)); }
+        throw vboxxml::ENoMemory();
+    }
+    catch (const vboxxml::EIPRTFailure &err) { sThat->m->trappedErr.reset (stdx::new_exception_trap (err)); }
+    catch (const vboxxml::Error &err) { sThat->m->trappedErr.reset (stdx::new_exception_trap (err)); }
     catch (const std::exception &err) { sThat->m->trappedErr.reset (stdx::new_exception_trap (err)); }
-    catch (...) { sThat->m->trappedErr.reset (stdx::new_exception_trap (LogicError (RT_SRC_POS))); }
+    catch (...) { sThat->m->trappedErr.reset (stdx::new_exception_trap (vboxxml::LogicError (RT_SRC_POS))); }
 
     return NULL;
@@ -1444,2 +1243,3 @@
 
 } /* namespace settings */
+
