CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes

ConfigurationDBHandler Class Reference

List of all members.

Public Member Functions

virtual void characters (const XMLCh *const chars, const unsigned int length)
virtual void characters (const XMLCh *const chars, const unsigned int length)
 ConfigurationDBHandler (std::list< ConfigurationDatabaseStandardXMLParser::Item > &items)
 ConfigurationDBHandler (std::map< std::string, std::string > &parameters, std::vector< std::string > &items, std::string &encoding)
virtual void endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
virtual void endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
virtual void ignorableWhitespace (const XMLCh *chars, const unsigned int length)
virtual void ignorableWhitespace (const XMLCh *chars, const unsigned int length)
virtual void startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs)
virtual void startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs)
virtual ~ConfigurationDBHandler ()
virtual ~ConfigurationDBHandler ()

Private Types

enum  { md_Idle, md_Parameter, md_Data }
enum  { md_Idle, md_Parameter, md_Data }

Private Member Functions

bool cvt2String (const XMLCh *val, std::string &ou)
bool cvt2String (const XMLCh *val, std::string &ou)
bool isItemElement (const XMLCh *const localname)

Private Attributes

std::string & m_dataEncoding
std::list
< ConfigurationDatabaseStandardXMLParser::Item > & 
m_items
std::vector< std::string > & m_items
enum ConfigurationDBHandler:: { ... }  m_mode
enum ConfigurationDBHandler:: { ... }  m_mode
std::map< std::string,
std::string > & 
m_parameters
std::string m_pname
std::string m_ptype
std::string m_text
char m_workc [512]
ConfigurationDatabaseStandardXMLParser::Item m_workitem
XMLCh m_workx [256]
int n_elements
XMLCh * xc_Data
XMLCh * xc_elements
XMLCh * xc_encoding
XMLCh * xc_header [ITEMELEMENTNAMES]
XMLCh * xc_name
XMLCh * xc_Parameter
XMLCh * xc_type

Static Private Attributes

static const int ITEMELEMENTNAMES = 3

Detailed Description

Definition at line 38 of file ConfigurationDatabaseStandardXMLParser.cc.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
md_Idle 
md_Parameter 
md_Data 

Definition at line 46 of file HcalPatternXMLParser.cc.

anonymous enum [private]
Enumerator:
md_Idle 
md_Parameter 
md_Data 

Definition at line 39 of file ConfigurationDatabaseStandardXMLParser.cc.


Constructor & Destructor Documentation

ConfigurationDBHandler::ConfigurationDBHandler ( std::list< ConfigurationDatabaseStandardXMLParser::Item > &  items) [inline]

Definition at line 41 of file ConfigurationDatabaseStandardXMLParser.cc.

References m_items, m_mode, md_Idle, xc_Data, xc_elements, xc_encoding, xc_header, xc_name, xc_Parameter, and xc_type.

                                                                                       : m_items(items) {
      m_mode=md_Idle;
      xc_Parameter=XMLString::transcode("Parameter");
      xc_Data=XMLString::transcode("Data");
      xc_name=XMLString::transcode("name");
      xc_type=XMLString::transcode("type");
      xc_elements=XMLString::transcode("elements");      
      xc_encoding=XMLString::transcode("encoding");
      xc_header[0]=XMLString::transcode("CFGBrick");
      xc_header[1]=XMLString::transcode("LUT");
      xc_header[2]=XMLString::transcode("Pattern");
      m_items.clear();
    }
virtual ConfigurationDBHandler::~ConfigurationDBHandler ( ) [inline, virtual]
ConfigurationDBHandler::ConfigurationDBHandler ( std::map< std::string, std::string > &  parameters,
std::vector< std::string > &  items,
std::string &  encoding 
) [inline]

Definition at line 48 of file HcalPatternXMLParser.cc.

References m_items, m_mode, m_parameters, md_Idle, xc_Data, xc_elements, xc_encoding, xc_name, xc_Parameter, and xc_type.

                                                                                                                      : m_dataEncoding(encoding), m_items(items), m_parameters(parameters) {
      m_mode=md_Idle;
      xc_Parameter=XMLString::transcode("Parameter");
      xc_Data=XMLString::transcode("Data");
      xc_name=XMLString::transcode("name");
      xc_type=XMLString::transcode("type");
      xc_elements=XMLString::transcode("elements");      
      xc_encoding=XMLString::transcode("encoding");
      m_items.clear();
      m_parameters.clear();
    }
virtual ConfigurationDBHandler::~ConfigurationDBHandler ( ) [inline, virtual]

Member Function Documentation

void ConfigurationDBHandler::characters ( const XMLCh *const  chars,
const unsigned int  length 
) [virtual]

Definition at line 162 of file ConfigurationDatabaseStandardXMLParser.cc.

References i, m_mode, m_text, m_workc, m_workx, md_Idle, and evf::evtn::offset().

                                                                                       {
    if (m_mode==md_Idle) return;
    unsigned int offset=0;
    while (offset<length) {
      unsigned int i=0;
      for (i=0; i<length-offset && i<255; i++) m_workx[i]=chars[i+offset];
      m_workx[i]=0; // terminate string
      XMLString::transcode(m_workx,m_workc,511);
      m_text+=m_workc;
      offset+=i;
    }
  }
virtual void ConfigurationDBHandler::characters ( const XMLCh *const  chars,
const unsigned int  length 
) [virtual]
bool ConfigurationDBHandler::cvt2String ( const XMLCh *  val,
std::string &  ou 
) [inline, private]

Definition at line 69 of file ConfigurationDatabaseStandardXMLParser.cc.

References fetchall_from_DQM_v2::release.

Referenced by startElement().

                                                            {
      if (val==0) return false;
      char* tool=XMLString::transcode(val);
      ou=tool;
      XMLString::release(&tool);
      return true;
    }
bool ConfigurationDBHandler::cvt2String ( const XMLCh *  val,
std::string &  ou 
) [inline, private]

Definition at line 72 of file HcalPatternXMLParser.cc.

References fetchall_from_DQM_v2::release.

                                                            {
      if (val==0) return false;
      char* tool=XMLString::transcode(val);
      ou=tool;
      XMLString::release(&tool);
      return true;
    }
virtual void ConfigurationDBHandler::endElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname 
) [virtual]
void ConfigurationDBHandler::endElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname 
) [virtual]

Definition at line 136 of file ConfigurationDatabaseStandardXMLParser.cc.

References isItemElement(), m_items, m_mode, m_pname, m_text, m_workitem, md_Data, md_Idle, md_Parameter, and lumiQueryAPI::q.

                                                                                                                         {
    if (m_mode==md_Idle) return;

    if (isItemElement(localname)) {
    } else if (m_mode==md_Parameter) {
      m_workitem.parameters[m_pname]=m_text; // ignore the type for now...
    } else if (m_mode==md_Data) {
      // parse the text
      std::string entry;
      for (std::string::iterator q=m_text.begin(); q!=m_text.end(); q++) {
        if (isspace(*q)) {
          if (entry.empty()) continue;
          m_workitem.items.push_back(entry);
          entry="";
        } else entry+=*q;
      }
      if (!entry.empty()) m_workitem.items.push_back(entry);
      m_items.push_back(m_workitem); // save it
    }

    m_mode=md_Idle;
  }
void ConfigurationDBHandler::ignorableWhitespace ( const XMLCh *  chars,
const unsigned int  length 
) [virtual]

Definition at line 158 of file ConfigurationDatabaseStandardXMLParser.cc.

References m_mode, m_text, and md_Idle.

                                                                                                  {
    if (m_mode==md_Idle) return;
    m_text+=' ';
  }
virtual void ConfigurationDBHandler::ignorableWhitespace ( const XMLCh *  chars,
const unsigned int  length 
) [virtual]
bool ConfigurationDBHandler::isItemElement ( const XMLCh *const  localname) [inline, private]

Definition at line 88 of file ConfigurationDatabaseStandardXMLParser.cc.

References i, ITEMELEMENTNAMES, and xc_header.

Referenced by endElement(), and startElement().

                                                     {
      for (int i=0; i<ITEMELEMENTNAMES; i++)
        if (!XMLString::compareIString(localname,xc_header[i])) return true;
      return false;
    }
void ConfigurationDBHandler::startElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname,
const Attributes &  attrs 
) [virtual]

Definition at line 95 of file ConfigurationDatabaseStandardXMLParser.cc.

References cvt2String(), isItemElement(), findQualityFiles::jj, m_mode, m_pname, m_ptype, m_text, m_workitem, md_Data, md_Idle, md_Parameter, n_elements, xc_Data, xc_elements, xc_encoding, xc_name, xc_Parameter, and xc_type.

                                                                                                                                                    {
    if (m_mode!=md_Idle) return; 
    std::string work;
    cvt2String(localname,work);
    if (isItemElement(localname)) {
      m_workitem.parameters.clear();
      m_workitem.items.clear();
      m_workitem.encoding.clear();
    } else if (!XMLString::compareIString(localname,xc_Parameter)) {
      // parameter name
      if (!cvt2String(attrs.getValue(xc_name),m_pname)) return;
      // parameter type
      if (!cvt2String(attrs.getValue(xc_type),m_ptype)) return;
      // switch mode
      m_mode=md_Parameter;
      m_text="";
    } else if (!XMLString::compareIString(localname,xc_Data)) {
      m_workitem.items.clear();
      // elements
      std::string strElements;
      if (!cvt2String(attrs.getValue(xc_elements),strElements)) return;
      n_elements=atoi(strElements.c_str());
      // encoding
      m_workitem.encoding="";
      cvt2String(attrs.getValue(xc_encoding),m_workitem.encoding);
      // switch mode
      m_mode=md_Data;
      m_text="";
      // other attributes
      for (unsigned int jj=0; jj<attrs.getLength(); jj++) {
        if (!XMLString::compareIString(xc_elements,attrs.getValue(jj)) ||
            !XMLString::compareIString(xc_encoding,attrs.getValue(jj))) 
          continue; // already handled these two
        std::string atkey,atvalue;
        cvt2String(attrs.getLocalName(jj),atkey);
        cvt2String(attrs.getValue(jj),atvalue);
        m_workitem.parameters[atkey]=atvalue;
      }
    }
   
  }
virtual void ConfigurationDBHandler::startElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname,
const Attributes &  attrs 
) [virtual]

Member Data Documentation

const int ConfigurationDBHandler::ITEMELEMENTNAMES = 3 [static, private]

Definition at line 82 of file HcalPatternXMLParser.cc.

std::vector<std::string>& ConfigurationDBHandler::m_items [private]

Definition at line 83 of file HcalPatternXMLParser.cc.

std::list<ConfigurationDatabaseStandardXMLParser::Item>& ConfigurationDBHandler::m_items [private]

Definition at line 82 of file ConfigurationDatabaseStandardXMLParser.cc.

Referenced by ConfigurationDBHandler(), and endElement().

enum { ... } ConfigurationDBHandler::m_mode [private]
enum { ... } ConfigurationDBHandler::m_mode [private]
std::map<std::string,std::string>& ConfigurationDBHandler::m_parameters [private]

Definition at line 84 of file HcalPatternXMLParser.cc.

Referenced by ConfigurationDBHandler().

std::string ConfigurationDBHandler::m_pname [private]

Definition at line 79 of file ConfigurationDatabaseStandardXMLParser.cc.

Referenced by endElement(), and startElement().

std::string ConfigurationDBHandler::m_ptype [private]

Definition at line 79 of file ConfigurationDatabaseStandardXMLParser.cc.

Referenced by startElement().

std::string ConfigurationDBHandler::m_text [private]

Definition at line 86 of file ConfigurationDatabaseStandardXMLParser.cc.

Referenced by characters().

ConfigurationDatabaseStandardXMLParser::Item ConfigurationDBHandler::m_workitem [private]

Definition at line 81 of file ConfigurationDatabaseStandardXMLParser.cc.

Referenced by endElement(), and startElement().

Definition at line 87 of file ConfigurationDatabaseStandardXMLParser.cc.

Referenced by characters().

Definition at line 80 of file ConfigurationDatabaseStandardXMLParser.cc.

Referenced by startElement().