// From IXmlSink bool CBitParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) { // Pos _uiBitPos = xmlElement.getAttributeInteger("Pos"); // Size _uiBitSize = xmlElement.getAttributeInteger("Size"); // Validate bit pos and size still fit into parent type const CBitParameterBlockType* pBitParameterBlockType = static_cast<const CBitParameterBlockType*>(getParent()); uint32_t uiParentBlockBitSize = pBitParameterBlockType->getSize() * 8; if (_uiBitPos + _uiBitSize > uiParentBlockBitSize) { // Range exceeded std::ostringstream strStream; strStream << "Pos and Size attributes inconsistent with maximum container element size (" << uiParentBlockBitSize << " bits) for " + getKind(); serializingContext.setError(strStream.str()); return false; } // Max if (xmlElement.hasAttribute("Max")) { _uiMax = xmlElement.getAttributeInteger("Max"); if (_uiMax > getMaxEncodableValue()) { // Max value exceeded std::ostringstream strStream; strStream << "Max attribute inconsistent with maximum encodable size (" << getMaxEncodableValue() << ") for " + getKind(); serializingContext.setError(strStream.str()); return false; } } else { _uiMax = getMaxEncodableValue(); } // Base return base::fromXml(xmlElement, serializingContext); }
// From IXmlSink bool CParameterAdaptation::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) { // Get offset if (xmlElement.hasAttribute("Offset")) { _iOffset = xmlElement.getAttributeSignedInteger("Offset"); } else { // Default _iOffset = 0; } // Base return base::fromXml(xmlElement, serializingContext); }
bool CComponentType::fromXml(const CXmlElement &xmlElement, CXmlSerializingContext &serializingContext) { // Context CXmlParameterSerializingContext ¶meterBuildContext = static_cast<CXmlParameterSerializingContext &>(serializingContext); const CComponentLibrary *pComponentLibrary = parameterBuildContext.getComponentLibrary(); // Populate children if (!base::fromXml(xmlElement, serializingContext)) { return false; } // Check for Extends attribute (extensions will be populated after and not before) if (xmlElement.hasAttribute("Extends")) { std::string strExtendsType; xmlElement.getAttribute("Extends", strExtendsType); _pExtendsComponentType = pComponentLibrary->getComponentType(strExtendsType); if (!_pExtendsComponentType) { serializingContext.setError("ComponentType " + strExtendsType + " referred to by " + xmlElement.getPath() + " not found!"); return false; } if (_pExtendsComponentType == this) { serializingContext.setError("Recursive ComponentType definition of " + xmlElement.getPath()); return false; } } return true; }
// XML Serialization value space handling // Value space handling for configuration import void CFixedPointParameterType::handleValueSpaceAttribute(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const { // Direction? if (!configurationAccessContext.serializeOut()) { // Get Value space from XML if (xmlConfigurableElementSettingsElement.hasAttribute("ValueSpace")) { configurationAccessContext.setValueSpaceRaw(xmlConfigurableElementSettingsElement.getAttributeBoolean("ValueSpace", "Raw")); } else { configurationAccessContext.setValueSpaceRaw(false); } } else { // Provide value space only if not the default one if (configurationAccessContext.valueSpaceIsRaw()) { xmlConfigurableElementSettingsElement.setAttributeString("ValueSpace", "Raw"); } } }