コード例 #1
0
ファイル: XMLLib.cpp プロジェクト: markisme/healthcare
const char * XmlNode::GetAttribute( const char * attName ) const
{
	const TiXmlElement * element = ToElement();
	if( element == NULL )
	{
		return NULL;
	}

	return element->Attribute( attName );
}
コード例 #2
0
ファイル: SettingControl.cpp プロジェクト: FLyrfors/xbmc
bool CSettingControlFormattedRange::Deserialize(const TiXmlNode *node, bool update /* = false */)
{
  if (!ISettingControl::Deserialize(node, update))
    return false;

  if (m_format == "string")
  {
    XMLUtils::GetInt(node, SETTING_XML_ELM_CONTROL_FORMATLABEL, m_formatLabel);

    // get the minimum label from <setting><constraints><minimum label="X" />
    auto settingNode = node->Parent();
    if (settingNode != nullptr)
    {
      auto constraintsNode = settingNode->FirstChild(SETTING_XML_ELM_CONSTRAINTS);
      if (constraintsNode != nullptr)
      {
        auto minimumNode = constraintsNode->FirstChild(SETTING_XML_ELM_MINIMUM);
        if (minimumNode != nullptr)
        {
          auto minimumElem = minimumNode->ToElement();
          if (minimumElem != nullptr)
          {
            if (minimumElem->QueryIntAttribute(SETTING_XML_ATTR_LABEL, &m_minimumLabel) != TIXML_SUCCESS)
              m_minimumLabel = -1;
          }
        }
      }
    }

    if (m_minimumLabel < 0)
    {
      std::string strFormat;
      if (XMLUtils::GetString(node, SETTING_XML_ATTR_FORMAT, strFormat) && !strFormat.empty())
        m_formatString = strFormat;
    }
  }

  return true;
}
コード例 #3
0
bool XMLTransformationReader::readOperations(TiXmlElement* element, std::vector<DimensionDesc>& dimensions)
{
  const char *tagName = element->Value();
//  const char *name = element->Attribute("name");

  if (!tagName || strcmp("operations", tagName) != 0)
  {
    _log->error("Invalid tag '%v' for operations tag", tagName);

    return false;
  }

  for (TiXmlElement* cElement = element->FirstChildElement(); cElement; cElement = cElement->NextSiblingElement())
  {

    const char *child = cElement->Value();
    if (!child)
    {
      _log->error("Invalid child '%v' of operations", child);
      return nullptr;
    }
    else if (strcmp("dimension", child) == 0)
    {
      auto e = cElement->FirstChildElement();
      const char *eName = e->Value();

      DimensionDesc desc;
      desc.name = std::string(cElement->Attribute("name"));

      if (strcmp("use", eName) == 0)
      {
        desc.type = XMLDimensionOperations::XML_USE;
        desc.sourceId = std::stoi(e->Attribute("id"));
        desc.path = std::string(e->Attribute("path"));
      }
      else if (strcmp("default", eName) == 0)
      {
        desc.type = XMLDimensionOperations::XML_DEFAULT;
        desc.value = std::string(e->Attribute("value"));
      }
      else if (strcmp("formula", eName) == 0)
      {
        desc.type = XMLDimensionOperations::XML_FORMULA;
        desc.formula = std::string(e->Attribute("formula"));

	const auto fc = e->FirstChild();
	if (fc != nullptr) { /* If there are multiple variables defined */
          for (auto velem = fc; velem != nullptr; velem = velem->NextSiblingElement()) {
            auto e = velem->ToElement();
            desc.varmap[std::string(e->Attribute("name"))] =
              std::make_pair(std::string(e->Attribute("path")),
                             std::stoi(e->Attribute("id"))); 
          }
	} else {
          desc.varmap[std::string(e->Attribute("varname"))] =
            std::make_pair(std::string(e->Attribute("path")),
                           std::stoi(e->Attribute("id"))); 
	}
      }
      else if (strcmp("operations", eName) == 0)
      {
        desc.type = XMLDimensionOperations::XML_COMPLEX;
        bool result = this->readOperations(e, desc.dims);

        if (false == result)
          return false;
      }
      else
      {
        _log->warn("Unknown child '%v' in dimension '%v', will be ignored", child, desc.name);
      }

      dimensions.push_back(desc);
    }
  }

  return true;
}
コード例 #4
0
ファイル: XMLLib.cpp プロジェクト: markisme/healthcare
void XmlNode::SetAttribute( const char * attName, const char * attValue )
{
	TiXmlElement * element = ToElement();
	element->SetAttribute( attName, attValue );
}
コード例 #5
0
ファイル: NodeFile.cpp プロジェクト: EQ4/neonv2
//---------------------------------------------------------------------------//
// AttrAsBool
//
//---------------------------------------------------------------------------//  
bool CNodeFile::CNode::AttrAsBool(const string &sName, bool bDefault)
{
  const char *pData = ToElement()->Attribute(sName.c_str());
  return (pData ? (atoi(pData) == 0 ? false : true) : bDefault);
}
コード例 #6
0
ファイル: NodeFile.cpp プロジェクト: EQ4/neonv2
//---------------------------------------------------------------------------//
// AttrAsFloat
//
//---------------------------------------------------------------------------//  
float CNodeFile::CNode::AttrAsFloat(const string &sName, float fDefault)
{
  const char *pData = ToElement()->Attribute(sName.c_str());
  return (pData ? (float)strtofloat(pData) : fDefault);
}
コード例 #7
0
ファイル: NodeFile.cpp プロジェクト: EQ4/neonv2
//---------------------------------------------------------------------------//
// AttrAsInt
//
//---------------------------------------------------------------------------//  
int CNodeFile::CNode::AttrAsInt(const string &sName, int iDefault)
{
  const char *pData = ToElement()->Attribute(sName.c_str());
  return (pData ? atoi(pData) : iDefault);
}
コード例 #8
0
ファイル: NodeFile.cpp プロジェクト: EQ4/neonv2
//---------------------------------------------------------------------------//
// AttrAsString
//
//---------------------------------------------------------------------------//  
string CNodeFile::CNode::AttrAsString(const string &sName, const string &sDefault)
{
  const char *pData = ToElement()->Attribute(sName.c_str());
  return (pData ? pData : sDefault);
}