#include "TRootSnifferStore.h"
ClassImp(TRootSnifferStore)
TRootSnifferStore::TRootSnifferStore() :
TObject(),
fResPtr(0),
fResClass(0),
fResMember(0),
fResNumChilds(-1),
fResRestrict(0)
{
}
TRootSnifferStore::~TRootSnifferStore()
{
}
void TRootSnifferStore::SetResult(void *_res, TClass *_rescl,
TDataMember *_resmemb, Int_t _res_chld, Int_t _restr)
{
fResPtr = _res;
fResClass = _rescl;
fResMember = _resmemb;
fResNumChilds = _res_chld;
fResRestrict = _restr;
}
ClassImp(TRootSnifferStoreXml)
void TRootSnifferStoreXml::CreateNode(Int_t lvl, const char *nodename)
{
fBuf->Append(TString::Format("%*s<item _name=\"%s\"", fCompact ? 0 : (lvl + 1) * 2, "", nodename));
}
void TRootSnifferStoreXml::SetField(Int_t, const char *field, const char *value,
Bool_t)
{
if (strpbrk(value, "<>&\'\"") == 0) {
fBuf->Append(TString::Format(" %s=\"%s\"", field, value));
} else {
fBuf->Append(TString::Format(" %s=\"", field));
const char *v = value;
while (*v != 0) {
switch (*v) {
case '<' :
fBuf->Append("<");
break;
case '>' :
fBuf->Append(">");
break;
case '&' :
fBuf->Append("&");
break;
case '\'' :
fBuf->Append("'");
break;
case '\"' :
fBuf->Append(""");
break;
default:
fBuf->Append(*v);
break;
}
v++;
}
fBuf->Append("\"");
}
}
void TRootSnifferStoreXml::BeforeNextChild(Int_t, Int_t nchld, Int_t)
{
if (nchld == 0) fBuf->Append(TString::Format(">%s", (fCompact ? "" : "\n")));
}
void TRootSnifferStoreXml::CloseNode(Int_t lvl, Int_t numchilds)
{
if (numchilds > 0)
fBuf->Append(TString::Format("%*s</item>%s", fCompact ? 0 : (lvl + 1) * 2, "", (fCompact ? "" : "\n")));
else
fBuf->Append(TString::Format("/>%s", (fCompact ? "" : "\n")));
}
ClassImp(TRootSnifferStoreJson)
void TRootSnifferStoreJson::CreateNode(Int_t lvl, const char *nodename)
{
fBuf->Append(TString::Format("%*s{", fCompact ? 0 : lvl * 4, ""));
if (!fCompact) fBuf->Append("\n");
fBuf->Append(TString::Format("%*s\"_name\"%s\"%s\"", fCompact ? 0 : lvl * 4 + 2, "", (fCompact ? ":" : " : "), nodename));
}
void TRootSnifferStoreJson::SetField(Int_t lvl, const char *field,
const char *value, Bool_t with_quotes)
{
fBuf->Append(",");
if (!fCompact) fBuf->Append("\n");
fBuf->Append(TString::Format("%*s\"%s\"%s", fCompact ? 0 : lvl * 4 + 2, "", field, (fCompact ? ":" : " : ")));
if (!with_quotes) {
fBuf->Append(value);
} else {
fBuf->Append("\"");
for (const char *v = value; *v != 0; v++)
switch (*v) {
case '\n':
fBuf->Append("\\n");
break;
case '\t':
fBuf->Append("\\t");
break;
case '\"':
fBuf->Append("\\\"");
break;
case '\\':
fBuf->Append("\\\\");
break;
case '\b':
fBuf->Append("\\b");
break;
case '\f':
fBuf->Append("\\f");
break;
case '\r':
fBuf->Append("\\r");
break;
case '/':
fBuf->Append("\\/");
break;
default:
if ((*v > 31) && (*v < 127))
fBuf->Append(*v);
else
fBuf->Append(TString::Format("\\u%04x", (unsigned) *v));
}
fBuf->Append("\"");
}
}
void TRootSnifferStoreJson::BeforeNextChild(Int_t lvl, Int_t nchld, Int_t)
{
fBuf->Append(",");
if (!fCompact) fBuf->Append("\n");
if (nchld == 0)
fBuf->Append(TString::Format("%*s\"_childs\"%s", (fCompact ? 0 : lvl * 4 + 2), "", (fCompact ? ":[" : " : [\n")));
}
void TRootSnifferStoreJson::CloseNode(Int_t lvl, Int_t numchilds)
{
if (numchilds > 0)
fBuf->Append(TString::Format("%s%*s]", (fCompact ? "" : "\n"), fCompact ? 0 : lvl * 4 + 2, ""));
fBuf->Append(TString::Format("%s%*s}", (fCompact ? "" : "\n"), fCompact ? 0 : lvl * 4, ""));
}
TRootSnifferStore.cxx:100 TRootSnifferStore.cxx:101 TRootSnifferStore.cxx:102 TRootSnifferStore.cxx:103 TRootSnifferStore.cxx:104 TRootSnifferStore.cxx:105 TRootSnifferStore.cxx:106 TRootSnifferStore.cxx:107 TRootSnifferStore.cxx:108 TRootSnifferStore.cxx:109 TRootSnifferStore.cxx:110 TRootSnifferStore.cxx:111 TRootSnifferStore.cxx:112 TRootSnifferStore.cxx:113 TRootSnifferStore.cxx:114 TRootSnifferStore.cxx:115 TRootSnifferStore.cxx:116 TRootSnifferStore.cxx:117 TRootSnifferStore.cxx:118 TRootSnifferStore.cxx:119 TRootSnifferStore.cxx:120 TRootSnifferStore.cxx:121 TRootSnifferStore.cxx:122 TRootSnifferStore.cxx:123 TRootSnifferStore.cxx:124 TRootSnifferStore.cxx:125 TRootSnifferStore.cxx:126 TRootSnifferStore.cxx:127 TRootSnifferStore.cxx:128 TRootSnifferStore.cxx:129 TRootSnifferStore.cxx:130 TRootSnifferStore.cxx:131 TRootSnifferStore.cxx:132 TRootSnifferStore.cxx:133 TRootSnifferStore.cxx:134 TRootSnifferStore.cxx:135 TRootSnifferStore.cxx:136 TRootSnifferStore.cxx:137 TRootSnifferStore.cxx:138 TRootSnifferStore.cxx:139 TRootSnifferStore.cxx:140 TRootSnifferStore.cxx:141 TRootSnifferStore.cxx:142 TRootSnifferStore.cxx:143 TRootSnifferStore.cxx:144 TRootSnifferStore.cxx:145 TRootSnifferStore.cxx:146 TRootSnifferStore.cxx:147 TRootSnifferStore.cxx:148 TRootSnifferStore.cxx:149 TRootSnifferStore.cxx:150 TRootSnifferStore.cxx:151 TRootSnifferStore.cxx:152 TRootSnifferStore.cxx:153 TRootSnifferStore.cxx:154 TRootSnifferStore.cxx:155 TRootSnifferStore.cxx:156 TRootSnifferStore.cxx:157 TRootSnifferStore.cxx:158 TRootSnifferStore.cxx:159 TRootSnifferStore.cxx:160 TRootSnifferStore.cxx:161 TRootSnifferStore.cxx:162 TRootSnifferStore.cxx:163 TRootSnifferStore.cxx:164 TRootSnifferStore.cxx:165 TRootSnifferStore.cxx:166 TRootSnifferStore.cxx:167 TRootSnifferStore.cxx:168 TRootSnifferStore.cxx:169 TRootSnifferStore.cxx:170 TRootSnifferStore.cxx:171 TRootSnifferStore.cxx:172 TRootSnifferStore.cxx:173 TRootSnifferStore.cxx:174 TRootSnifferStore.cxx:175 TRootSnifferStore.cxx:176 TRootSnifferStore.cxx:177 TRootSnifferStore.cxx:178 TRootSnifferStore.cxx:179 TRootSnifferStore.cxx:180 TRootSnifferStore.cxx:181 TRootSnifferStore.cxx:182 TRootSnifferStore.cxx:183 TRootSnifferStore.cxx:184 TRootSnifferStore.cxx:185 TRootSnifferStore.cxx:186 TRootSnifferStore.cxx:187 TRootSnifferStore.cxx:188 TRootSnifferStore.cxx:189 TRootSnifferStore.cxx:190 TRootSnifferStore.cxx:191 TRootSnifferStore.cxx:192 TRootSnifferStore.cxx:193 TRootSnifferStore.cxx:194 TRootSnifferStore.cxx:195 TRootSnifferStore.cxx:196 TRootSnifferStore.cxx:197 TRootSnifferStore.cxx:198 TRootSnifferStore.cxx:199 TRootSnifferStore.cxx:200 TRootSnifferStore.cxx:201 TRootSnifferStore.cxx:202 TRootSnifferStore.cxx:203 TRootSnifferStore.cxx:204 TRootSnifferStore.cxx:205 TRootSnifferStore.cxx:206 TRootSnifferStore.cxx:207 TRootSnifferStore.cxx:208 TRootSnifferStore.cxx:209 TRootSnifferStore.cxx:210 TRootSnifferStore.cxx:211 TRootSnifferStore.cxx:212 TRootSnifferStore.cxx:213 TRootSnifferStore.cxx:214 TRootSnifferStore.cxx:215