本文整理汇总了C++中DOMDocumentImpl::getMemoryManager方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMDocumentImpl::getMemoryManager方法的具体用法?C++ DOMDocumentImpl::getMemoryManager怎么用?C++ DOMDocumentImpl::getMemoryManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMDocumentImpl
的用法示例。
在下文中一共展示了DOMDocumentImpl::getMemoryManager方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setPrefix
void DOMElementNSImpl::setPrefix(const XMLCh *prefix)
{
if (fNode.isReadOnly())
throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMNodeMemoryManager);
if (fNamespaceURI == 0 || fNamespaceURI[0] == chNull)
throw DOMException(DOMException::NAMESPACE_ERR, 0, GetDOMNodeMemoryManager);
if (prefix == 0 || *prefix == 0) {
fPrefix = 0;
fName = fLocalName;
return;
}
DOMDocumentImpl* doc = (DOMDocumentImpl*) fParent.fOwnerDocument;
if(!doc->isXMLName(prefix))
throw DOMException(DOMException::INVALID_CHARACTER_ERR,0, GetDOMNodeMemoryManager);
const XMLCh * xml = DOMNodeImpl::getXmlString();
const XMLCh * xmlURI = DOMNodeImpl::getXmlURIString();
if (XMLString::equals(prefix, xml) &&
!XMLString::equals(fNamespaceURI, xmlURI))
throw DOMException(DOMException::NAMESPACE_ERR, 0, GetDOMNodeMemoryManager);
if (XMLString::indexOf(prefix, chColon) != -1) {
throw DOMException(DOMException::NAMESPACE_ERR, 0, GetDOMNodeMemoryManager);
}
this-> fPrefix = doc->getPooledString(prefix);
XMLSize_t prefixLen = XMLString::stringLen(prefix);
XMLSize_t newQualifiedNameLen = prefixLen+1+XMLString::stringLen(fLocalName);
XMLCh *newName;
XMLCh temp[256];
if (newQualifiedNameLen >= 255)
newName = (XMLCh*) doc->getMemoryManager()->allocate
(
newQualifiedNameLen * sizeof(XMLCh)
);//new XMLCh[newQualifiedNameLen];
else
newName = temp;
// newName = prefix + chColon + fLocalName;
XMLString::copyString(newName, prefix);
newName[prefixLen] = chColon;
XMLString::copyString(&newName[prefixLen+1], fLocalName);
fName = doc->getPooledString(newName);
if (newQualifiedNameLen >= 255)
doc->getMemoryManager()->deallocate(newName);//delete[] newName;
}
示例2: buf
const XMLCh * DOMAttrImpl::getValue() const
{
if (fParent.fFirstChild == 0) {
return XMLUni::fgZeroLenString; // return "";
}
// Simple case where attribute value is just a single text node
DOMNode *node = castToChildImpl(fParent.fFirstChild)->nextSibling;
if (node == 0 && fParent.fFirstChild->getNodeType() == DOMNode::TEXT_NODE) {
return fParent.fFirstChild->getNodeValue();
}
//
// Complicated case where attribute value is a DOM tree
//
// According to the spec, the child nodes of the Attr node may be either
// Text or EntityReference nodes.
//
// The parser will not create such thing, this is for those created by users.
//
// In such case, we have to visit each child to retrieve the text
//
DOMDocumentImpl* doc = (DOMDocumentImpl*)fParent.fOwnerDocument;
XMLBuffer buf(1023, doc->getMemoryManager());
for (node = fParent.fFirstChild; node != 0; node = castToChildImpl(node)->nextSibling)
getTextValue(node, buf);
return doc->getPooledString(buf.getRawBuffer());
}
示例3: setName
void DOMElementNSImpl::setName(const XMLCh *namespaceURI,
const XMLCh *qualifiedName)
{
DOMDocumentImpl* ownerDoc = (DOMDocumentImpl *) getOwnerDocument();
this->fName = ownerDoc->getPooledString(qualifiedName);
int index = DOMDocumentImpl::indexofQualifiedName(qualifiedName);
if (index < 0)
throw DOMException(DOMException::NAMESPACE_ERR, 0);
if (index == 0) { //qualifiedName contains no ':'
this -> fPrefix = 0;
this -> fLocalName = this -> fName;
} else { //0 < index < this->name.length()-1
XMLCh* newName;
XMLCh temp[4000];
if (index >= 3999)
newName = (XMLCh*) ownerDoc->getMemoryManager()->allocate
(
(XMLString::stringLen(qualifiedName) + 1) * sizeof(XMLCh)
);//new XMLCh[XMLString::stringLen(qualifiedName)+1];
else
newName = temp;
XMLString::copyNString(newName, fName, index);
newName[index] = chNull;
this-> fPrefix = ownerDoc->getPooledString(newName);
this -> fLocalName = ownerDoc->getPooledString(fName+index+1);
if (index >= 3999)
ownerDoc->getMemoryManager()->deallocate(newName);//delete[] newName;
// Before we carry on, we should check if the prefix or localName are valid XMLName
if (!((DOMDocumentImpl *)this->getOwnerDocument())->isXMLName(fPrefix) || !((DOMDocumentImpl *)this->getOwnerDocument())->isXMLName(fLocalName))
throw DOMException(DOMException::NAMESPACE_ERR, 0);
}
// DOM Level 3: namespace URI is never empty string.
const XMLCh * URI = DOMNodeImpl::mapPrefix
(
fPrefix,
(!namespaceURI || !*namespaceURI) ? 0 : namespaceURI,
DOMNode::ELEMENT_NODE
);
this -> fNamespaceURI = (URI == 0) ? 0 : ownerDoc->getPooledString(URI);
}
示例4: getBaseURI
const XMLCh* DOMElementImpl::getBaseURI() const
{
const XMLCh* baseURI = fNode.fOwnerNode->getBaseURI();
if (fAttributes) {
const XMLCh baseString[] =
{
chLatin_b, chLatin_a, chLatin_s, chLatin_e, chNull
};
DOMNode* attrNode = fAttributes->getNamedItemNS(DOMNodeImpl::getXmlURIString(), baseString);
if (attrNode==NULL) {
const XMLCh xmlBaseString[] =
{
chLatin_x, chLatin_m, chLatin_l, chColon, chLatin_b, chLatin_a, chLatin_s, chLatin_e, chNull
};
attrNode = fAttributes->getNamedItem(xmlBaseString);
}
if (attrNode) {
const XMLCh* uri = attrNode->getNodeValue();
if (uri && *uri) {// attribute value is always empty string
// if there is a base URI for the parent node, use it to resolve relative URI
if(baseURI)
{
try {
DOMDocumentImpl* doc = (DOMDocumentImpl *)fParent.fOwnerDocument;
XMLUri temp(baseURI, doc->getMemoryManager());
XMLUri temp2(&temp, uri, doc->getMemoryManager());
uri = doc->cloneString(temp2.getUriText());
}
catch(const OutOfMemoryException&)
{
throw;
}
catch (...){
// REVISIT: what should happen in this case?
return 0;
}
}
return uri;
}
}
}
return baseURI;
}
示例5: DOMException
const XMLCh * DOMCharacterDataImpl::substringData(const DOMNode *node, XMLSize_t offset,
XMLSize_t count) const
{
// Note: the C++ XMLCh * operation throws the correct DOMExceptions
// when parameter values are bad.
//
XMLSize_t len = fDataBuf->getLen();
if (offset > len)
throw DOMException(DOMException::INDEX_SIZE_ERR, 0, GetDOMCharacterDataImplMemoryManager);
DOMDocumentImpl *doc = (DOMDocumentImpl *)node->getOwnerDocument();
XMLCh* newString;
XMLCh temp[4096];
if (len >= 4095)
newString = (XMLCh*) doc->getMemoryManager()->allocate
(
(len + 1) * sizeof(XMLCh)
);//new XMLCh[len+1];
else
newString = temp;
XMLString::copyNString(newString, fDataBuf->getRawBuffer()+offset, count);
newString[count] = chNull;
const XMLCh* retString = doc->getPooledString(newString);
if (len >= 4095)
doc->getMemoryManager()->deallocate(newString);//delete[] newString;
return retString;
}