Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
HtmlObject.cxx
1/*
2 * HalHTMLObject.cxx
3 *
4 * Created on: 8 paź 2020
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#include "HtmlObject.h"
10
11#include <TString.h>
12namespace Hal {
13 HtmlObject::HtmlObject() : TObject(), fClass(""), fID(""), fStyle(""), fContent(""), fOtherAttribs("") {}
14
15 HtmlObject::~HtmlObject() {}
16
17 HtmlObject::HtmlObject(const HtmlObject& other) :
18 TObject(other),
19 fClass(other.fClass),
20 fID(other.fID),
21 fStyle(other.fStyle),
22 fContent(other.fContent),
23 fOtherAttribs(other.fOtherAttribs) {}
24
25 void HtmlObject::AddContent(const HtmlObject& obj) { fContent = fContent + obj.ToString(); }
26
27 HtmlObject::HtmlObject(TString id, TString className, TString style) : fClass(className), fID(id), fStyle(style) {}
28
29 HtmlObject& HtmlObject::operator=(const HtmlObject& other) {
30 if (this == &other) return *this;
31 TObject::operator=(other);
32 fClass = other.fClass;
33 fID = other.fID;
34 fStyle = other.fStyle;
35 fContent = other.fContent;
36 fOtherAttribs = other.fOtherAttribs;
37 return *this;
38 }
39
40 TString HtmlObject::GetProperties() const {
41 TString properties;
42 if (GetStyle().Length() > 0) { properties = properties + " style=\"" + GetStyle() + "\" "; }
43 if (GetClass().Length() > 0) { properties = properties + " class=\"" + GetClass() + "\" "; }
44 if (fOtherAttribs.Length() > 0) properties = properties + fOtherAttribs;
45 if (GetId().Length() > 0) { properties = properties + " id=\"" + GetId() + "\" "; }
46 return properties;
47 }
48
49 TString HtmlObject::GetDefaultString(TString tag) const {
50 TString res = Form("<%s", tag.Data());
51 res = res + GetProperties();
52 res = res + ">\n" + GetContent() + "</" + tag + ">\n";
53 return res;
54 }
55
56 void HtmlObject::AddAtrib(TString name, TString value) {
57 fOtherAttribs = fOtherAttribs + Form(" %s=\"%s\"", name.Data(), value.Data());
58 }
59
60} // namespace Hal
TString GetDefaultString(TString tag) const
virtual TString ToString() const =0