Exports a HTML page to a file named as per the supplied file path.
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hzDocHtml::Export | (hzString&,) |
Declared in file: hzDocument.h
Defined in file : hzDocHtml.cpp
Function Logic:
Function body:
hzEcode hzDocHtml::Export (hzString& filepath)
{
// Exports a HTML page to a file named as per the supplied file path.
//
// Arguments: 1) filepath The file to export the HTML document to
//
// Returns: E_ARGUMENT If no export file path is supplied
// E_NODATA If there is no HTML elements in the document
// E_OPENFAIL If the supplied
// E_WRITEFAIL If a write file occurs during export
// E_OK If the export ran to completion
_hzfunc("hzDocHtml::Export") ;
ofstream os ; // Output stream
hzChain Z ; // Working chain for output construction
hzEcode rc = E_OK ; // Return code
if (!filepath)
return hzerr(E_ARGUMENT, "No pathname supplied") ;
if (!m_pRoot)
{
if (!m_Content.Size())
return hzerr(E_NODATA, "Empty page (no root node). Nothing written to file %s\n", *filepath) ;
}
// Dump out to file
os.clear() ;
os.open(*filepath) ;
if (os.fail())
return hzerr(E_OPENFAIL, "Could not open file %s\n", *filepath) ;
if (m_Info.m_urlReq)
Z.Printf("URL (req): %s\n", *m_Info.m_urlReq) ;
if (*m_Info.m_urlAct)
Z.Printf("URL (act): %s\n", *m_Info.m_urlAct) ;
os << Z ;
if (os.fail())
rc = E_WRITEFAIL ;
Z.Clear() ;
if (rc == E_OK)
{
if (m_pRoot)
rc = _xport(Z, m_pRoot) ;
else
Z = m_Content ;
os << Z ;
if (os.fail())
rc = E_WRITEFAIL ;
}
os.close() ;
return rc ;
}