void CXMLTextEncoderStream::put_utf8v ( llrp_utf8v_t Value, const CFieldDescriptor * pFieldDescriptor) { const char * pFieldName = pFieldDescriptor->m_pName; appendOpenTag(pFieldName); for(int i = 0; i < Value.m_nValue; i++) { int c = Value.m_pValue[i]; if(0 == c && i+1 == Value.m_nValue) { continue; } if(' ' <= c && c < 0x7F) { appendFormat("%c", c); } else { appendFormat("\\%03o", c); } } appendCloseTag(pFieldName); }
void CXMLTextEncoderStream::put_enum ( int eValue, const CFieldDescriptor * pFieldDescriptor) { const char * pFieldName = pFieldDescriptor->m_pName; const SEnumTableEntry * pEntry; appendOpenTag(pFieldName); for(pEntry = pFieldDescriptor->m_pEnumTable; NULL != pEntry->pName; pEntry++) { if(pEntry->Value == eValue) { break; } } if(NULL != pEntry->pName) { appendFormat("%s", pEntry->pName); } else { appendFormat("%d", eValue); } appendCloseTag(pFieldName); }
void CXMLTextEncoderStream::put_s64 ( llrp_s64_t Value, const CFieldDescriptor * pFieldDescriptor) { const char * pFieldName = pFieldDescriptor->m_pName; appendOpenTag(pFieldName); switch(pFieldDescriptor->m_eFieldFormat) { case CFieldDescriptor::FMT_NORMAL: case CFieldDescriptor::FMT_DEC: default: #ifdef WIN32 appendFormat("%I64d", Value); #else appendFormat("%lld", Value); #endif break; case CFieldDescriptor::FMT_HEX: #ifdef WIN32 appendFormat("%016I64X", Value); #else appendFormat("%016llX", Value); #endif break; } appendCloseTag(pFieldName); }
void CXMLTextEncoderStream::put_s32v ( llrp_s32v_t Value, const CFieldDescriptor * pFieldDescriptor) { const char * pFieldName = pFieldDescriptor->m_pName; appendOpenTag(pFieldName); for(int i = 0; i < Value.m_nValue; i++) { if(0 < i) { appendFormat(" "); } switch(pFieldDescriptor->m_eFieldFormat) { case CFieldDescriptor::FMT_NORMAL: case CFieldDescriptor::FMT_DEC: default: appendFormat("%d", Value.m_pValue[i]); break; case CFieldDescriptor::FMT_HEX: appendFormat("%08X", Value.m_pValue[i]); break; } } appendCloseTag(pFieldName); }
void CXMLTextEncoderStream::put_u2 ( llrp_u2_t Value, const CFieldDescriptor * pFieldDescriptor) { const char * pFieldName = pFieldDescriptor->m_pName; appendOpenTag(pFieldName); appendFormat("%d", Value & 3); appendCloseTag(pFieldName); }
void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element, bool addDisplayInline) { const bool documentIsHTML = element.document().isHTMLDocument(); appendOpenTag(out, element, 0); const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldAnnotate() || addDisplayInline); const bool shouldOverrideStyleAttr = shouldAnnotateOrForceInline || shouldApplyWrappingStyle(element); AttributeCollection attributes = element.attributes(); AttributeCollection::iterator end = attributes.end(); for (AttributeCollection::iterator it = attributes.begin(); it != end; ++it) { // We'll handle the style attribute separately, below. if (it->name() == HTMLNames::styleAttr && shouldOverrideStyleAttr) continue; appendAttribute(out, element, *it, 0); } if (shouldOverrideStyleAttr) { RefPtr<EditingStyle> newInlineStyle = nullptr; if (shouldApplyWrappingStyle(element)) { newInlineStyle = m_wrappingStyle->copy(); newInlineStyle->removePropertiesInElementDefaultStyle(&element); newInlineStyle->removeStyleConflictingWithStyleOfElement(&element); } else newInlineStyle = EditingStyle::create(); if (element.isStyledElement() && element.inlineStyle()) newInlineStyle->overrideWithStyle(element.inlineStyle()); if (shouldAnnotateOrForceInline) { if (shouldAnnotate()) newInlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element)); if (&element == m_highestNodeToBeSerialized && m_shouldAnnotate == AnnotateForNavigationTransition) newInlineStyle->addAbsolutePositioningFromElement(element); if (addDisplayInline) newInlineStyle->forceInline(); } if (!newInlineStyle->isEmpty()) { out.appendLiteral(" style=\""); appendAttributeValue(out, newInlineStyle->style()->asText(), documentIsHTML); out.append('\"'); } } appendCloseTag(out, element); }
void MarkupAccumulator::appendElement(StringBuilder& result, const Element& element, Namespaces* namespaces) { appendOpenTag(result, element, namespaces); if (element.hasAttributes()) { for (const Attribute& attribute : element.attributesIterator()) appendAttribute(result, element, attribute, namespaces); } // Give an opportunity to subclasses to add their own attributes. appendCustomAttributes(result, element, namespaces); appendCloseTag(result, element); }
void CXMLTextEncoderStream::put_bytesToEnd ( llrp_bytesToEnd_t Value, const CFieldDescriptor * pFieldDescriptor) { const char * pFieldName = pFieldDescriptor->m_pName; appendOpenTag(pFieldName); for(int i = 0; i < Value.m_nValue; i++) { appendFormat("%02X", Value.m_pValue[i]); } appendCloseTag(pFieldName); }
void MarkupAccumulator::appendElement(StringBuilder& out, Element* element, Namespaces* namespaces) { appendOpenTag(out, element, namespaces); if (element->hasAttributes()) { unsigned length = element->attributeCount(); for (unsigned int i = 0; i < length; i++) appendAttribute(out, element, *element->attributeItem(i), namespaces); } // Give an opportunity to subclasses to add their own attributes. appendCustomAttributes(out, element, namespaces); appendCloseTag(out, element); }
void MarkupAccumulator::appendElement(StringBuilder& result, const Element& element, Namespaces* namespaces) { appendOpenTag(result, element, namespaces); if (element.hasAttributes()) { unsigned length = element.attributeCount(); for (unsigned int i = 0; i < length; i++) appendAttribute(result, element, element.attributeAt(i), namespaces); } // Give an opportunity to subclasses to add their own attributes. appendCustomAttributes(result, element, namespaces); appendCloseTag(result, element); }
void CXMLTextEncoderStream::put_u64 ( llrp_u64_t Value, const CFieldDescriptor * pFieldDescriptor) { const char * pFieldName = pFieldDescriptor->m_pName; appendOpenTag(pFieldName); switch(pFieldDescriptor->m_eFieldFormat) { case CFieldDescriptor::FMT_NORMAL: case CFieldDescriptor::FMT_DEC: default: #ifdef WIN32 appendFormat("%I64u", Value); #else appendFormat("%llu", Value); #endif break; case CFieldDescriptor::FMT_HEX: #ifdef WIN32 appendFormat("%016I64X", Value); #else appendFormat("%016llX", Value); #endif break; case CFieldDescriptor::FMT_DATETIME: { char aBuf[64]; time_t CurSec = (time_t)(Value / 1000000u); llrp_u32_t CurUSec = (llrp_u32_t)(Value % 1000000u); struct tm * pGMTime; pGMTime = gmtime(&CurSec); strftime(aBuf, sizeof aBuf, "%Y-%m-%dT%H:%M:%S", pGMTime); appendFormat("%s.%06dZ", aBuf, CurUSec); } break; } appendCloseTag(pFieldName); }
void CXMLTextEncoderStream::put_e8v ( llrp_u8v_t Value, const CFieldDescriptor * pFieldDescriptor) { const char * pFieldName = pFieldDescriptor->m_pName; appendOpenTag(pFieldName); for(int i = 0; i < Value.m_nValue; i++) { int eValue = Value.m_pValue[i]; const SEnumTableEntry * pEntry; for(pEntry = pFieldDescriptor->m_pEnumTable; NULL != pEntry->pName; pEntry++) { if(pEntry->Value == eValue) { break; } } if(0 < i) { appendFormat(" "); } if(NULL != pEntry->pName) { appendFormat("%s", pEntry->pName); } else { appendFormat("%d", eValue); } } appendCloseTag(pFieldName); }
void CXMLTextEncoderStream::put_u1 ( llrp_u1_t Value, const CFieldDescriptor * pFieldDescriptor) { const char * pFieldName = pFieldDescriptor->m_pName; appendOpenTag(pFieldName); switch(pFieldDescriptor->m_eFieldFormat) { case CFieldDescriptor::FMT_NORMAL: default: appendFormat("%s", (Value & 1) ? "true" : "false"); break; case CFieldDescriptor::FMT_DEC: case CFieldDescriptor::FMT_HEX: appendFormat("%d", Value & 1); break; } appendCloseTag(pFieldName); }
void CXMLTextEncoderStream::put_s32 ( llrp_s32_t Value, const CFieldDescriptor * pFieldDescriptor) { const char * pFieldName = pFieldDescriptor->m_pName; appendOpenTag(pFieldName); switch(pFieldDescriptor->m_eFieldFormat) { case CFieldDescriptor::FMT_NORMAL: case CFieldDescriptor::FMT_DEC: default: appendFormat("%d", Value); break; case CFieldDescriptor::FMT_HEX: appendFormat("%08X", Value); break; } appendCloseTag(pFieldName); }
void CXMLTextEncoderStream::put_s64v ( llrp_s64v_t Value, const CFieldDescriptor * pFieldDescriptor) { const char * pFieldName = pFieldDescriptor->m_pName; appendOpenTag(pFieldName); for(int i = 0; i < Value.m_nValue; i++) { if(0 < i) { appendFormat(" "); } switch(pFieldDescriptor->m_eFieldFormat) { case CFieldDescriptor::FMT_NORMAL: case CFieldDescriptor::FMT_DEC: default: #ifdef WIN32 appendFormat("%I64d", Value.m_pValue[i]); #else appendFormat("%lld", Value.m_pValue[i]); #endif break; case CFieldDescriptor::FMT_HEX: #ifdef WIN32 appendFormat("%016I64X", Value.m_pValue[i]); #else appendFormat("%016llX", Value.m_pValue[i]); #endif break; } } appendCloseTag(pFieldName); }