Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
PreprocessFunction.cxx
Go to the documentation of this file.
1// @(#)root/roostats:$Id$
2// Author: Kyle Cranmer, George Lewis
3/*************************************************************************
4 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11////////////////////////////////////////////////////////////////////////////////
12/**
13 * \ingroup HistFactory
14 */
15
17
18#include <sstream>
19
20namespace {
21
22/// Replaces the XML special characters with their escape codes.
23std::string escapeXML(const std::string &src)
24{
25 std::stringstream dst;
26 for (char ch : src) {
27 switch (ch) {
28 case '&': dst << "&amp;"; break;
29 case '\'': dst << "&apos;"; break;
30 case '"': dst << "&quot;"; break;
31 case '<': dst << "&lt;"; break;
32 case '>': dst << "&gt;"; break;
33 default: dst << ch; break;
34 }
35 }
36 return dst.str();
37}
38
39} // namespace
40
41RooStats::HistFactory::PreprocessFunction::PreprocessFunction(std::string const &name, std::string const &expression,
42 std::string const &dependents)
43 : fName(name), fExpression(expression), fDependents(dependents)
44{
45}
46
48{
49 return "expr::" + fName + "('" + fExpression + "',{" + fDependents + "})";
50}
51
53{
54 stream << "\t \t Name: " << fName << "\t \t Expression: " << fExpression << "\t \t Dependents: " << fDependents
55 << std::endl;
56}
57
59{
60 xml << "<Function Name=\"" << fName << "\" "
61 << "Expression=\"" << escapeXML(fExpression) << "\" "
62 << "Dependents=\"" << fDependents << "\" "
63 << "/>\n";
64}
char name[80]
Definition TGX11.cxx:110
void Print(std::ostream &=std::cout) const