// 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 CStringParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) { // MaxLength _uiMaxLength = xmlElement.getAttributeInteger("MaxLength"); // Base return base::fromXml(xmlElement, serializingContext); }
bool CEnumParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) { // Size in bits uint32_t uiSizeInBits = xmlElement.getAttributeInteger("Size"); // Size setSize(uiSizeInBits / 8); // Base return base::fromXml(xmlElement, serializingContext); }
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); }