VirtualBox

Changeset 17400 in vbox


Ignore:
Timestamp:
Mar 5, 2009 1:55:30 PM (16 years ago)
Author:
vboxsync
Message:

OVF: more XML write and export.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

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

    r17362 r17400  
    24602460        writer.write(pAppliance->m->strPath.c_str());
    24612461    }
     2462    catch(xml::Error &x)
     2463    {
     2464        rc = setError(VBOX_E_FILE_ERROR,
     2465                      x.what());
     2466    }
    24622467    catch(HRESULT aRC)
    24632468    {
  • trunk/src/VBox/Main/xml/xml.cpp

    r17362 r17400  
    967967}
    968968
    969 struct ReadWriteContext
     969struct IOContext
    970970{
    971971    File file;
    972972    com::Utf8Str error;
    973973
    974     ReadWriteContext(const char *pcszFilename)
    975         : file(File::Mode_Read, pcszFilename)     // @todo must be write for writer
     974    IOContext(const char *pcszFilename, File::Mode mode)
     975        : file(mode, pcszFilename)
    976976    {
    977977    }
     
    985985    {
    986986        error = x.what();
     987    }
     988};
     989
     990struct ReadContext : IOContext
     991{
     992    ReadContext(const char *pcszFilename)
     993        : IOContext(pcszFilename, File::Mode_Read)
     994    {
     995    }
     996};
     997
     998struct WriteContext : IOContext
     999{
     1000    WriteContext(const char *pcszFilename)
     1001        : IOContext(pcszFilename, File::Mode_Write)
     1002    {
    9871003    }
    9881004};
     
    10051021    m->strXmlFilename = pcszFilename;
    10061022
    1007     ReadWriteContext context(pcszFilename);
     1023    ReadContext context(pcszFilename);
    10081024    doc.m->reset();
    10091025    if (!(doc.m->plibDocument = xmlCtxtReadIO(m->ctxt,
     
    10221038int XmlFileParser::ReadCallback(void *aCtxt, char *aBuf, int aLen)
    10231039{
    1024     ReadWriteContext *pContext = static_cast<ReadWriteContext*>(aCtxt);
     1040    ReadContext *pContext = static_cast<ReadContext*>(aCtxt);
    10251041
    10261042    /* To prevent throwing exceptions while inside libxml2 code, we catch
     
    10681084}
    10691085
    1070 int XmlFileWriter::WriteCallback(void *aCtxt, const char *aBuf, int aLen)
    1071 {
    1072     ReadWriteContext *pContext = static_cast<ReadWriteContext*>(aCtxt);
    1073 
    1074     /* To prevent throwing exceptions while inside libxml2 code, we catch
    1075      * them and forward to our level using a couple of variables. */
    1076     try
    1077     {
    1078         return pContext->file.write(aBuf, aLen);
    1079     }
    1080     catch (const xml::EIPRTFailure &err) { pContext->setError(err); }
    1081     catch (const xml::Error &err) { pContext->setError(err); }
    1082     catch (const std::exception &err) { pContext->setError(err); }
    1083     catch (...) { pContext->setError(xml::LogicError(RT_SRC_POS)); }
    1084 
    1085     return -1 /* failure */;
    1086 }
    1087 
    1088 int XmlFileWriter::CloseCallback(void *aCtxt)
    1089 {
    1090     /// @todo to be written
    1091 
    1092     return -1;
    1093 }
    1094 
    10951086void XmlFileWriter::write(const char *pcszFilename)
    10961087{
    1097     ReadWriteContext context(pcszFilename);
     1088    WriteContext context(pcszFilename);
    10981089
    10991090    GlobalLock lock();
     
    11271118}
    11281119
     1120int XmlFileWriter::WriteCallback(void *aCtxt, const char *aBuf, int aLen)
     1121{
     1122    WriteContext *pContext = static_cast<WriteContext*>(aCtxt);
     1123
     1124    /* To prevent throwing exceptions while inside libxml2 code, we catch
     1125     * them and forward to our level using a couple of variables. */
     1126    try
     1127    {
     1128        return pContext->file.write(aBuf, aLen);
     1129    }
     1130    catch (const xml::EIPRTFailure &err) { pContext->setError(err); }
     1131    catch (const xml::Error &err) { pContext->setError(err); }
     1132    catch (const std::exception &err) { pContext->setError(err); }
     1133    catch (...) { pContext->setError(xml::LogicError(RT_SRC_POS)); }
     1134
     1135    return -1 /* failure */;
     1136}
     1137
     1138int XmlFileWriter::CloseCallback(void *aCtxt)
     1139{
     1140    /// @todo to be written
     1141
     1142    return -1;
     1143}
     1144
    11291145
    11301146} // end namespace xml
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