bool CComponentInstance::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) { // Context CXmlParameterSerializingContext& parameterBuildContext = static_cast<CXmlParameterSerializingContext&>(serializingContext); const CComponentLibrary* pComponentLibrary = parameterBuildContext.getComponentLibrary(); std::string strComponentType = xmlElement.getAttributeString("Type"); _pComponentType = pComponentLibrary->getComponentType(strComponentType); if (!_pComponentType) { serializingContext.setError("Unable to create Component " + xmlElement.getPath() + ". ComponentType " + strComponentType + " not found!"); return false; } if (_pComponentType == getParent()) { serializingContext.setError("Recursive definition of " + _pComponentType->getName() + " due to " + xmlElement.getPath() + " referring to one of its own type."); return false; } return base::fromXml(xmlElement, serializingContext); }
// From IXmlSink bool CSelectionCriterionRule::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) { // Retrieve actual context CXmlDomainImportContext& xmlDomainImportContext = static_cast<CXmlDomainImportContext&>(serializingContext); // Get selection criterion string strSelectionCriterion = xmlElement.getAttributeString("SelectionCriterion"); _pSelectionCriterion = xmlDomainImportContext.getSelectionCriteriaDefinition()->getSelectionCriterion(strSelectionCriterion); // Check existence if (!_pSelectionCriterion) { xmlDomainImportContext.setError("Couldn't find selection criterion " + strSelectionCriterion + " in " + getKind() + " " + xmlElement.getPath()); return false; } // Get MatchesWhen string strMatchesWhen = xmlElement.getAttributeString("MatchesWhen"); string strError; if (!setMatchesWhen(strMatchesWhen, strError)) { xmlDomainImportContext.setError("Wrong MatchesWhen attribute " + strMatchesWhen + " in " + getKind() + " " + xmlElement.getPath() + ": " + strError); return false; } // Get Value string strValue = xmlElement.getAttributeString("Value"); if (!_pSelectionCriterion->getCriterionType()->getNumericalValue(strValue, _iMatchValue)) { xmlDomainImportContext.setError("Wrong Value attribute value " + strValue + " in " + getKind() + " " + xmlElement.getPath()); return false; } // Done return true; }
bool CFixedPointParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) { // Size uint32_t uiSizeInBits = xmlElement.getAttributeInteger("Size"); // Q notation _uiIntegral = xmlElement.getAttributeInteger("Integral"); _uiFractional = xmlElement.getAttributeInteger("Fractional"); // Size vs. Q notation integrity check if (uiSizeInBits < getUtilSizeInBits()) { serializingContext.setError("Inconsistent Size vs. Q notation for " + getKind() + " " + xmlElement.getPath() + ": Summing (Integral + _uiFractional + 1) should not exceed given Size (" + xmlElement.getAttributeString("Size") + ")"); return false; } // Set the size setSize(uiSizeInBits / 8); return base::fromXml(xmlElement, serializingContext); }