Changeset 538


Ignore:
Timestamp:
04/14/14 17:42:25 (5 years ago)
Author:
jls17
Message:
  • optimization of page write performance
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/work_311/output/WebPage.cpp

    r532 r538  
    2727using namespace OUTPUT::WebPage; 
    2828 
     29// newline template to avoid lots of flush calls in file output stream 
     30// taken from http://kuhllib.com/2012/01/14/stop-excessive-use-of-stdendl/ 
     31template <typename cT, typename Traits> 
     32std::basic_ostream<cT, Traits>& newline(std::basic_ostream<cT, Traits>& out)  
     33{  
     34        return out << out.widen('\n');  
     35} 
     36 
    2937extern int nFilesCreated; 
    3038 
     
    6674void CWebPage::PageHeader(ostream &strm) 
    6775{ 
    68         strm << "<?xml version=\"1.0\" ?>" << endl; 
    69         strm << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" << endl; 
    70         strm << "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">" << endl; 
    71         strm << "<!-- saved from url=(0025)http://arinside.org/ -->" << endl; 
    72         strm << "<head>" << endl; 
    73         strm << "<title>" << title << "</title>" << endl; 
    74         strm << "<meta http-equiv=\"content-language\" content=\"EN\" />" << endl; 
    75         strm << "<meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\" />" << endl; 
    76         strm << "<meta http-equiv=\"expires\" content=\"-1\" />" << endl; 
    77         strm << "<meta name=\"author\" content=\"ARInside\" />" << endl; 
    78         strm << "<script type='text/javascript'>var rootLevel=" << rootLevel << ";</script>" << endl; 
    79         strm << GetReferenceManager() << endl; 
    80         strm << "</head>" << endl; 
     76        strm << "<?xml version=\"1.0\" ?>" << newline; 
     77        strm << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" << newline; 
     78        strm << "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">" << newline; 
     79        strm << "<!-- saved from url=(0025)http://arinside.org/ -->" << newline; 
     80        strm << "<head>" << newline; 
     81        strm << "<title>" << title << "</title>" << newline; 
     82        strm << "<meta http-equiv=\"content-language\" content=\"EN\" />" << newline; 
     83        strm << "<meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\" />" << newline; 
     84        strm << "<meta http-equiv=\"expires\" content=\"-1\" />" << newline; 
     85        strm << "<meta name=\"author\" content=\"ARInside\" />" << newline; 
     86        strm << "<script type='text/javascript'>var rootLevel=" << rootLevel << ";</script>" << newline; 
     87        strm << GetReferenceManager() << newline; 
     88        strm << "</head>" << newline; 
    8189} 
    8290 
    8391void CWebPage::DynamicHeaderText(ostream &strm) 
    8492{ 
    85         strm << "<table>" << endl; 
    86         strm << "<tr>" << endl; 
    87         strm << "<td>" << URLLink("Main", PAGE_MAINHOME, ImageTag::Server, rootLevel) << "</td>" << endl; 
    88         strm << "<td>" << " (Server: " << URLLink(appConfig.serverName, PAGE_SERVER_INFO, rootLevel) << "</td>" << endl; 
    89         strm << "<td>" << "@" << "</td>" << endl; 
    90         strm << "<td>" << "<a href=\"" << appConfig.companyUrl << "\" target=\"_blank\">" << appConfig.companyName << "</a>" << ")" << "</td>" << endl; 
    91         strm << "</tr>" << endl; 
    92         strm << "</table>" << endl;      
     93        strm << "<table>" << newline; 
     94        strm << "<tr>" << newline; 
     95        strm << "<td>" << URLLink("Main", PAGE_MAINHOME, ImageTag::Server, rootLevel) << "</td>" << newline; 
     96        strm << "<td>" << " (Server: " << URLLink(appConfig.serverName, PAGE_SERVER_INFO, rootLevel) << "</td>" << newline; 
     97        strm << "<td>" << "@" << "</td>" << newline; 
     98        strm << "<td>" << "<a href=\"" << appConfig.companyUrl << "\" target=\"_blank\">" << appConfig.companyName << "</a>" << ")" << "</td>" << newline; 
     99        strm << "</tr>" << newline; 
     100        strm << "</table>" << newline 
    93101} 
    94102 
     
    100108void CWebPage::DynamicFooterText(ostream &strm) 
    101109{ 
    102         strm << "<table><tr>" << endl; 
    103         strm << "<td>" << URLLink("Main", PAGE_MAINHOME, ImageTag::Next, rootLevel)<< "</td>" << endl; 
    104         strm << "<td>&nbsp;</td>" << endl; 
    105         strm << "<td>" << DirectURLLink(DirectURLLink::LinkToTop, rootLevel) << "</td>" << endl; 
    106         strm << "<td>&nbsp;</td>" << endl; 
     110        strm << "<table><tr>" << newline; 
     111        strm << "<td>" << URLLink("Main", PAGE_MAINHOME, ImageTag::Next, rootLevel)<< "</td>" << newline; 
     112        strm << "<td>&nbsp;</td>" << newline; 
     113        strm << "<td>" << DirectURLLink(DirectURLLink::LinkToTop, rootLevel) << "</td>" << newline; 
     114        strm << "<td>&nbsp;</td>" << newline; 
    107115#if ARINSIDE_TEST_SUPPORT 
    108116        if (appConfig.testMode) 
     
    111119#endif 
    112120                strm << "<td>(Page created " << CurrentDateTime() << " by <a href=\"http://arinside.org\" target=\"_blank\">ARInside v" << AppVersion <<"</a>)</td>"; 
    113         strm << "</tr></table>" << endl; 
     121        strm << "</tr></table>" << newline; 
    114122} 
    115123 
    116124void CWebPage::ContentOpen(ostream &strm) 
    117125{ 
    118         strm << "<body>" << endl; 
    119         strm << DirectURLLink::CreateTop << endl; 
    120         strm << "<table class=\"TblMain\">" << endl; 
    121         strm << "<tr><td class=\"TdMainHeader\" colspan=\"3\">" << endl; 
     126        strm << "<body>" << newline; 
     127        strm << DirectURLLink::CreateTop << newline; 
     128        strm << "<table class=\"TblMain\">" << newline; 
     129        strm << "<tr><td class=\"TdMainHeader\" colspan=\"3\">" << newline; 
    122130        DynamicHeaderText(strm); 
    123         strm << "</td></tr><tr><td class=\"TdMainMenu\">" << endl; 
     131        strm << "</td></tr><tr><td class=\"TdMainMenu\">" << newline; 
    124132        if (!navContent.empty()) 
    125133        { 
    126                 strm << "<div id=\"form_navigation\" class=\"form_navigation\">" << endl; 
    127                 strm << navContent << endl; 
    128                 strm << "</div>" << endl; 
    129         } 
    130         strm << "<iframe id=\"IFrameMenu\" src=\"" << RootPath(rootLevel) << "template/navigation." << CWebUtil::WebPageSuffix() << "\" name=\"Navigation\" frameborder=\"0\">" << endl; 
    131         strm << "<p>IFrame not supported by this browser.</p></iframe></td><td class=\"TdMainContent\">" << endl; 
     134                strm << "<div id=\"form_navigation\" class=\"form_navigation\">" << newline; 
     135                strm << navContent << newline; 
     136                strm << "</div>" << newline; 
     137        } 
     138        strm << "<iframe id=\"IFrameMenu\" src=\"" << RootPath(rootLevel) << "template/navigation." << CWebUtil::WebPageSuffix() << "\" name=\"Navigation\" frameborder=\"0\">" << newline; 
     139        strm << "<p>IFrame not supported by this browser.</p></iframe></td><td class=\"TdMainContent\">" << newline; 
    132140} 
    133141 
    134142void CWebPage::ContentClose(ostream &strm) 
    135143{ 
    136         strm << "</td>" << endl; 
    137         strm << "<td></td>" << endl;    // TODO: this column isn't used at all. Remove it completely from the table. 
    138  
    139         strm << "</tr><tr><td class=\"TdMainButtom\" colspan=\"3\">" << endl; 
     144        strm << "</td>" << newline; 
     145        strm << "<td></td>" << newline; // TODO: this column isn't used at all. Remove it completely from the table. 
     146 
     147        strm << "</tr><tr><td class=\"TdMainButtom\" colspan=\"3\">" << newline; 
    140148        DynamicFooterText(strm); 
    141         strm << endl << "</td></tr></table></body></html>" << endl; 
     149        strm << newline << "</td></tr></table></body></html>" << newline; 
    142150} 
    143151 
     
    204212void CWebPage::AddScriptReference(std::ostream &strm, const std::string &scriptPath) 
    205213{ 
    206         strm << "<script src=\"" << RootPath(rootLevel) << scriptPath << "\" type=\"text/javascript\"></script>" << endl; 
     214        strm << "<script src=\"" << RootPath(rootLevel) << scriptPath << "\" type=\"text/javascript\"></script>" << newline; 
    207215} 
    208216 
    209217void CWebPage::AddStyleSheetReference(std::ostream &strm, const std::string &cssPath) 
    210218{ 
    211         strm << "<link rel=\"stylesheet\" type=\"text/css\" href=\"" << RootPath(rootLevel) << cssPath << "\" />" << endl; 
     219        strm << "<link rel=\"stylesheet\" type=\"text/css\" href=\"" << RootPath(rootLevel) << cssPath << "\" />" << newline; 
    212220} 
    213221 
Note: See TracChangeset for help on using the changeset viewer.