From db60ee66d8e6b54ea840f19add9982d3e5746b86 Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 3 May 2016 21:58:16 +0000 Subject: [PATCH] Functions4U HTML fix git-svn-id: svn://ultimatepp.org/upp/trunk@9790 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- bazaar/Functions4U/GatherTpp.cpp | 2 +- bazaar/Functions4U/Html/htmld.cpp | 63 ++++++++++++++++++++++++------- bazaar/Functions4U/Html/htmld.h | 40 +++++++++++++------- bazaar/SysInfo/SysInfo.cpp | 48 +++++++++++------------ 4 files changed, 102 insertions(+), 51 deletions(-) diff --git a/bazaar/Functions4U/GatherTpp.cpp b/bazaar/Functions4U/GatherTpp.cpp index bf0c28e7f..e2c1211eb 100644 --- a/bazaar/Functions4U/GatherTpp.cpp +++ b/bazaar/Functions4U/GatherTpp.cpp @@ -253,7 +253,7 @@ void GatherTpp::ExportPage(int i, String htmlFolder, String keywords) .BgColor(bg) .Alink(Red).Link(Black).Vlink(Blue) / html; - SaveFile(AppendFileName(htmlFolder, links[i]), content); + SaveFile(AppendFileName(htmlFolder, links[i]), ~content); } String GatherTpp::TopicFileName(const char *topic) diff --git a/bazaar/Functions4U/Html/htmld.cpp b/bazaar/Functions4U/Html/htmld.cpp index e34cb4922..17651b492 100644 --- a/bazaar/Functions4U/Html/htmld.cpp +++ b/bazaar/Functions4U/Html/htmld.cpp @@ -188,7 +188,7 @@ HtmlTagD& HtmlTagD::Background(const char *s) { return Attr("BACKGROUND", s); } HtmlTagD& HtmlTagD::OnClick(const char *s) { return Atth("onClick", s); } HtmlsD HtmlTagD::GetTag() const { - return tag.IsEmpty() ? (String&)tag : tag + '>'; + return IsNull(tag) ? ~tag : ~tag + ">"; } HtmlsD HtmlTagD::GetEndTag() const { @@ -198,8 +198,8 @@ HtmlsD HtmlTagD::GetEndTag() const { void HtmlTagD::Combine(const HtmlTagD& tag2) { if(tag2.IsEmpty()) return; - if(tag.GetLength()) { - tag = tag + '>' + tag2.tag; + if(!IsNull(tag)) { + tag = tag + ">" + tag2.tag; end = tag2.end + end; } else { @@ -344,15 +344,15 @@ HtmlsD HtmlBlockD(HtmlsD html, double width, double left, double top, double rig if(top) h = HtmlRowD() / HtmlCellD().Height(top) / ""; if(left || right || align != ALIGN_LEFT) - h += HtmlRowD() / ( + h << HtmlRowD() / ( HtmlCellD().Width(left) + HtmlCellD().Align(align).Width(width) / html + HtmlCellD().Width(right) ); if(bottom) - h += HtmlRowD() / HtmlCellD().Height(bottom) / ""; - return h.GetLength() ? HtmlTableD().Border(0).Width(-100).CellSpacing(0).CellPadding(0) / h - : html; + h << HtmlRowD() / HtmlCellD().Height(bottom) / ""; + return !IsNull(h) ? HtmlTableD().Border(0).Width(-100).CellSpacing(0).CellPadding(0) / h + : html; } HtmlTagD HtmlHeaderD(const char *title, String css, const char *other) @@ -373,6 +373,43 @@ HtmlTagD HtmlHeaderD(const char *title, String css, const char *other) return HtmlSingleTagD(h) / HtmlTagD("BODY"); } +HtmlsD operator+(const HtmlsD& a, const HtmlsD& b) +{ + return ~a + ~b; +} + +HtmlsD operator+(const HtmlsD& s, const HtmlTagD& tag) +{ + HtmlsD h; + h.Cat(s); + h.Cat(tag); + return h; +} + +HtmlsD operator+(const HtmlTagD& tag, const HtmlsD& s) +{ + HtmlsD h; + h.Cat(tag); + h.Cat(s); + return h; +} + +HtmlsD operator+(const HtmlsD& a, const char *b) +{ + HtmlsD h; + h.Cat(a); + h.Cat(b); + return h; +} + +HtmlsD operator+(const char *a, const HtmlsD& b) +{ + HtmlsD h; + h.Cat(a); + h.Cat(b); + return h; +} + HtmlsD operator+(const HtmlTagD& tag1, const HtmlTagD& tag2) { HtmlsD h; @@ -434,9 +471,9 @@ HtmlTagD& operator/=(HtmlTagD& tag, const HtmlTagD& s) HtmlTagD operator % (const HtmlTagD& t1, const HtmlTagD& t2) { - if(t1.Tag().IsEmpty()) + if(IsNull(t1.Tag())) return t2; - else if(t2.Tag().IsEmpty()) + else if(IsNull(t2.Tag())) return t1; else { @@ -554,16 +591,16 @@ HtmlTagD HtmlDialogD(int width) HtmlsD HtmlHeadD(String title, const char *charset) { HtmlsD head; - head << HtmlTagD("TITLE") / title << '\n' - << HtmlSingleTagD("META") + head << HtmlTagD("TITLE") / title << "\n" + << HtmlSingleTagD("META") .Attr("HTTP-EQUIV", "Content-Type") .Attr("CONTENT", String("text/html; charset=") + charset); - return HtmlTagD("HEAD") % head + "\n\n"; + return HtmlTagD("HEAD") % ~head + "\n\n"; } HtmlsD HtmlPageD(String title, const HtmlsD& body, Color bgcolor, const char *charset) { - return HtmlTagD("HTML") % (HtmlHeadD(title, charset) + HtmlTagD("BODY").BgColor(bgcolor) % body); + return HtmlTagD("HTML") % ~(HtmlHeadD(title, charset) + HtmlTagD("BODY").BgColor(bgcolor) % ~body); } HtmlsD HtmlTitlePageD(String title, const HtmlsD& body, Color bgcolor, const char *charset) diff --git a/bazaar/Functions4U/Html/htmld.h b/bazaar/Functions4U/Html/htmld.h index b72f92673..ff4d90d74 100644 --- a/bazaar/Functions4U/Html/htmld.h +++ b/bazaar/Functions4U/Html/htmld.h @@ -7,9 +7,11 @@ String ToHtmlD(const char *s); class HtmlTagD; -class HtmlsD : public String, Moveable { +class HtmlsD : Moveable { + String text; + public: - bool IsNullInstance() const { return IsEmpty(); } + bool IsNullInstance() const { return text.IsEmpty(); } HtmlsD& Text(const char *s); HtmlsD& Quote(const char *text); @@ -34,19 +36,22 @@ public: HtmlsD& Tag(const char *tag); HtmlsD& Gat(); + HtmlsD& Cat(String s) { text.Cat(s); return *this; } + HtmlsD& Cat(const char *s) { text.Cat(s); return *this; } + HtmlsD& Cat(char c) { text.Cat(c); return *this; } + HtmlsD& Cat(const char *s, int n) { text.Cat(s, n); return *this; } + HtmlsD& Cat(const HtmlsD& s) { return Cat(~s); } HtmlsD& Cat(const HtmlTagD& tag); - HtmlsD& Cat(String s) { String::Cat(s); return *this; } - HtmlsD& Cat(const char *s) { String::Cat(s); return *this; } - HtmlsD& Cat(char c) { String::Cat(c); return *this; } - HtmlsD& Cat(const char *s, int n) { String::Cat(s, n); return *this; } HtmlsD& Nbsp(); HtmlsD& Br(); HtmlsD& Hr(); HtmlsD& Lf(); + + String operator~() const { return text; } - HtmlsD(const char *s) : String(s) {} - HtmlsD(const String& s) : String(s) {} + HtmlsD(const char *s) : text(s) {} + HtmlsD(const String& s) : text(s) {} HtmlsD() {} HtmlsD(const Nuller&) {} }; @@ -172,8 +177,8 @@ public: HtmlTagD operator()() const { return *this; } HtmlsD operator~() const { return ApplyTo(Null); } - operator HtmlsD() const { return ApplyTo(Null); } - String ToString() const { return ApplyTo(Null); } + operator HtmlsD() const { return ApplyTo(Null); } + String ToString() const { return ~ApplyTo(Null); } const HtmlsD& Tag() const { return tag; } HtmlsD& Tag() { return tag; } @@ -181,7 +186,7 @@ public: const String& End() const { return end; } String& End() { return end; } - bool IsEmpty() const { return tag.IsEmpty(); } + bool IsEmpty() const { return IsNull(tag); } HtmlTagD(const char *s); HtmlTagD() {} @@ -229,11 +234,20 @@ HtmlsD operator+(const HtmlTagD& tag, const String& s); HtmlsD operator+(const char *s, const HtmlTagD& tag); HtmlsD operator+(const HtmlTagD& tag, const char *s); +HtmlsD operator+(const HtmlsD& s, const HtmlTagD& tag); +HtmlsD operator+(const HtmlTagD& tag, const HtmlsD& s); +HtmlsD operator+(const HtmlsD& a, const char *b); +HtmlsD operator+(const char *a, const HtmlsD& b); +HtmlsD operator+(const HtmlsD& a, const String& b); +HtmlsD operator+(const String& a, const HtmlsD& b); +HtmlsD operator+(const HtmlsD& a, const HtmlsD& b); + HtmlTagD operator/(const HtmlTagD& t1, const HtmlTagD& t2); HtmlTagD& operator/=(HtmlTagD& tag, const HtmlTagD& s); -inline HtmlsD operator/(const HtmlTagD& tag, String s) { return tag.ApplyTo(s); } -inline HtmlsD operator/(const HtmlTagD& tag, const char *s) { return tag.ApplyTo(s); } +inline HtmlsD operator/(const HtmlTagD& tag, const HtmlsD& s) { return tag.ApplyTo(~s); } +inline HtmlsD operator/(const HtmlTagD& tag, String s) { return tag.ApplyTo(s); } +inline HtmlsD operator/(const HtmlTagD& tag, const char *s) { return tag.ApplyTo(s); } ////////////////////////////////////////////////////////////////////// // from htmlutil diff --git a/bazaar/SysInfo/SysInfo.cpp b/bazaar/SysInfo/SysInfo.cpp index f2e9cf922..4f3467add 100644 --- a/bazaar/SysInfo/SysInfo.cpp +++ b/bazaar/SysInfo/SysInfo.cpp @@ -459,10 +459,10 @@ double GetCpuTemperature() { void NetAdapter::Copy(const NetAdapter& src) { - description <<= src.description; - fullname <<= src.fullname; - mac <<= src.mac; - type <<= src.type; + description = src.description; + fullname = src.fullname; + mac = src.mac; + type = src.type; } void NetAdapter::Xmlize(XmlIO &xml) { @@ -2052,16 +2052,16 @@ Vector SystemSignature::GetDiff(const SystemSignature &other) const { } void SystemSignature::Copy(const SystemSignature& src) { - manufacturer <<= src.manufacturer; - productName <<= src.productName; - version <<= src.version; - mbSerial <<= src.mbSerial; + manufacturer = src.manufacturer; + productName = src.productName; + version = src.version; + mbSerial = src.mbSerial; numberOfProcessors = src.numberOfProcessors; - hdSerial <<= src.hdSerial; - userName <<= src.userName; + hdSerial = src.hdSerial; + userName = src.userName; netAdapters.SetCount(src.netAdapters.GetCount()); for (int i = 0; i < src.netAdapters.GetCount(); ++i) - netAdapters[i] <<= src.netAdapters[i]; + netAdapters[i] = src.netAdapters[i]; } void SystemSignature::Xmlize(XmlIO &xml) { @@ -2095,22 +2095,22 @@ void SystemOverview::Load() { } void SystemOverview::Copy(const SystemOverview& src) { - signature <<= src.signature; - biosVersion <<= src.biosVersion; - biosSerial <<= src.biosSerial; + signature.Copy(src.signature); + biosVersion = src.biosVersion; + biosSerial = src.biosSerial; biosReleaseDate = src.biosReleaseDate; - computerName <<= src.computerName; - kernel <<= src.kernel; - kerVersion <<= src.kerVersion; - kerArchitecture <<= src.kerArchitecture; - distro <<= src.distro; - distVersion <<= src.distVersion; - desktop <<= src.desktop; - deskVersion <<= src.deskVersion; - compilerName <<= src.compilerName; + computerName = src.computerName; + kernel = src.kernel; + kerVersion = src.kerVersion; + kerArchitecture = src.kerArchitecture; + distro = src.distro; + distVersion = src.distVersion; + desktop = src.desktop; + deskVersion = src.deskVersion; + compilerName = src.compilerName; compilerVersion = src.compilerVersion; compilerTime = src.compilerTime; - compilerMode <<= src.compilerMode; + compilerMode = src.compilerMode; } void SystemOverview::Xmlize(XmlIO &xml) {