本文整理汇总了C++中AutoPtr类的典型用法代码示例。如果您正苦于以下问题:C++ AutoPtr类的具体用法?C++ AutoPtr怎么用?C++ AutoPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AutoPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
AutoPtr<Element>
MeshObj::getXMLElement(AutoPtr<Document> &doc)
{
AutoPtr<Element> aMesh = doc->createElement("MeshObj");
AutoPtr<Element> objectFilePath = doc->createElement("ObjectFilePath");
AutoPtr<Text> pathText = doc->createTextNode(this->ObjectFilePath);
objectFilePath->appendChild(pathText);
aMesh->appendChild(objectFilePath);
AutoPtr<Element> rootDirPath = doc->createElement("RootDirPath");
AutoPtr<Text> rootPath = doc->createTextNode(this->RootDirPath);
rootDirPath->appendChild(rootPath);
aMesh->appendChild(rootDirPath);
AutoPtr<Element> objectFileName = doc->createElement("ObjectFileName");
AutoPtr<Text> fileName = doc->createTextNode(this->ObjectFileName);
objectFileName->appendChild(fileName);
aMesh->appendChild(objectFileName);
AutoPtr<Element> objectFileId = doc->createElement("Id");
AutoPtr<Text> fileId = doc->createTextNode(this->IdAsString);
objectFileId->appendChild(fileId);
aMesh->appendChild(objectFileId);
AutoPtr<Element> meshType = doc->createElement("ModelType");
AutoPtr<Text> type = doc->createTextNode(this->MeshType);
meshType->appendChild(type);
aMesh->appendChild(meshType);
return aMesh;
}
示例2: assert
void ElementTest::testElementsByTagNameNS()
{
AutoPtr<Document> pDoc = new Document;
AutoPtr<Element> pRoot = pDoc->createElementNS("urn:ns1", "root");
AutoPtr<NodeList> pNL1 = pRoot->getElementsByTagNameNS("*", "*");
AutoPtr<NodeList> pNL2 = pRoot->getElementsByTagNameNS("*", "elem");
AutoPtr<NodeList> pNL3 = pRoot->getElementsByTagNameNS("urn:ns1", "elem");
assert (pNL1->length() == 0);
assert (pNL2->length() == 0);
AutoPtr<Element> pElem1 = pDoc->createElementNS("urn:ns1", "elem");
pRoot->appendChild(pElem1);
assert (pNL1->length() == 1);
assert (pNL2->length() == 1);
assert (pNL3->length() == 1);
assert (pNL1->item(0) == pElem1);
assert (pNL2->item(0) == pElem1);
assert (pNL3->item(0) == pElem1);
AutoPtr<Element> pElem2 = pDoc->createElementNS("urn:ns1", "Elem");
pRoot->appendChild(pElem2);
assert (pNL1->length() == 2);
assert (pNL2->length() == 1);
assert (pNL3->length() == 1);
assert (pNL1->item(0) == pElem1);
assert (pNL1->item(1) == pElem2);
assert (pNL2->item(0) == pElem1);
assert (pNL3->item(0) == pElem1);
AutoPtr<Element> pElem3 = pDoc->createElementNS("urn:ns2", "elem");
pRoot->appendChild(pElem3);
assert (pNL1->length() == 3);
assert (pNL2->length() == 2);
assert (pNL3->length() == 1);
assert (pNL1->item(0) == pElem1);
assert (pNL1->item(1) == pElem2);
assert (pNL1->item(2) == pElem3);
assert (pNL2->item(0) == pElem1);
assert (pNL2->item(1) == pElem3);
assert (pNL3->item(0) == pElem1);
AutoPtr<Element> pElem11 = pDoc->createElementNS("urn:ns1", "elem");
pElem1->appendChild(pElem11);
assert (pNL1->length() == 4);
assert (pNL2->length() == 3);
assert (pNL3->length() == 2);
assert (pNL1->item(0) == pElem1);
assert (pNL1->item(1) == pElem11);
assert (pNL1->item(2) == pElem2);
assert (pNL1->item(3) == pElem3);
assert (pNL2->item(0) == pElem1);
assert (pNL2->item(1) == pElem11);
assert (pNL2->item(2) == pElem3);
assert (pNL3->item(0) == pElem1);
assert (pNL3->item(1) == pElem11);
AutoPtr<Element> pElem12 = pDoc->createElementNS("urn:ns1", "Elem");
pElem1->appendChild(pElem12);
assert (pNL1->length() == 5);
assert (pNL2->length() == 3);
assert (pNL3->length() == 2);
assert (pNL1->item(0) == pElem1);
assert (pNL1->item(1) == pElem11);
assert (pNL1->item(2) == pElem12);
assert (pNL1->item(3) == pElem2);
assert (pNL1->item(4) == pElem3);
assert (pNL2->item(0) == pElem1);
assert (pNL2->item(1) == pElem11);
assert (pNL2->item(2) == pElem3);
assert (pNL3->item(0) == pElem1);
assert (pNL3->item(1) == pElem11);
AutoPtr<Element> pElem21 = pDoc->createElementNS("urn:ns1", "elem");
pElem2->appendChild(pElem21);
assert (pNL1->length() == 6);
assert (pNL2->length() == 4);
assert (pNL3->length() == 3);
assert (pNL1->item(0) == pElem1);
assert (pNL1->item(1) == pElem11);
assert (pNL1->item(2) == pElem12);
assert (pNL1->item(3) == pElem2);
assert (pNL1->item(4) == pElem21);
assert (pNL1->item(5) == pElem3);
assert (pNL2->item(0) == pElem1);
assert (pNL2->item(1) == pElem11);
assert (pNL2->item(2) == pElem21);
assert (pNL2->item(3) == pElem3);
assert (pNL3->item(0) == pElem1);
assert (pNL3->item(1) == pElem11);
assert (pNL3->item(2) == pElem21);
}
示例3: testNodeByPath
void ElementTest::testNodeByPath()
{
/*
<root>
<elem1>
<elemA/>
<elemA/>
</elem1>
<elem2>
<elemB attr1="value1"/>
<elemB attr1="value2"/>
<elemB attr1="value3"/>
<elemC attr1="value1">
<elemC1 attr1="value1"/>
<elemC2/>
</elemC>
<elemC attr1="value2"/>
</elem2>
</root>
*/
AutoPtr<Document> pDoc = new Document;
AutoPtr<Element> pRoot = pDoc->createElement("root");
AutoPtr<Element> pElem1 = pDoc->createElement("elem1");
AutoPtr<Element> pElem11 = pDoc->createElement("elemA");
AutoPtr<Element> pElem12 = pDoc->createElement("elemA");
AutoPtr<Element> pElem2 = pDoc->createElement("elem2");
AutoPtr<Element> pElem21 = pDoc->createElement("elemB");
AutoPtr<Element> pElem22 = pDoc->createElement("elemB");
AutoPtr<Element> pElem23 = pDoc->createElement("elemB");
AutoPtr<Element> pElem24 = pDoc->createElement("elemC");
AutoPtr<Element> pElem25 = pDoc->createElement("elemC");
pElem21->setAttribute("attr1", "value1");
pElem22->setAttribute("attr1", "value2");
pElem23->setAttribute("attr1", "value3");
pElem24->setAttribute("attr1", "value1");
pElem25->setAttribute("attr1", "value2");
AutoPtr<Element> pElem241 = pDoc->createElement("elemC1");
AutoPtr<Element> pElem242 = pDoc->createElement("elemC2");
pElem241->setAttribute("attr1", "value1");
pElem24->appendChild(pElem241);
pElem24->appendChild(pElem242);
pElem1->appendChild(pElem11);
pElem1->appendChild(pElem12);
pElem2->appendChild(pElem21);
pElem2->appendChild(pElem22);
pElem2->appendChild(pElem23);
pElem2->appendChild(pElem24);
pElem2->appendChild(pElem25);
pRoot->appendChild(pElem1);
pRoot->appendChild(pElem2);
pDoc->appendChild(pRoot);
Node* pNode = pRoot->getNodeByPath("/");
assert (pNode == pRoot);
pNode = pRoot->getNodeByPath("/elem1");
assert (pNode == pElem1);
pNode = pDoc->getNodeByPath("/root/elem1");
assert (pNode == pElem1);
pNode = pRoot->getNodeByPath("/elem2");
assert (pNode == pElem2);
pNode = pRoot->getNodeByPath("/elem1/elemA");
assert (pNode == pElem11);
pNode = pRoot->getNodeByPath("/elem1/elemA[0]");
assert (pNode == pElem11);
pNode = pRoot->getNodeByPath("/elem1/elemA[1]");
assert (pNode == pElem12);
pNode = pRoot->getNodeByPath("/elem1/elemA[2]");
assert (pNode == 0);
pNode = pRoot->getNodeByPath("/elem2/elemB");
assert (pNode == pElem21);
pNode = pRoot->getNodeByPath("/elem2/elemB[0]");
assert (pNode == pElem21);
pNode = pRoot->getNodeByPath("/elem2/elemB[1]");
assert (pNode == pElem22);
pNode = pRoot->getNodeByPath("/elem2/elemB[2]");
assert (pNode == pElem23);
pNode = pRoot->getNodeByPath("/elem2/elemB[3]");
assert (pNode == 0);
pNode = pRoot->getNodeByPath("/elem2/elemB[@attr1]");
//.........这里部分代码省略.........
示例4: assert
void NodeTest::testAppendFragment3()
{
AutoPtr<Document> pDoc = new Document;
AutoPtr<Element> pRoot = pDoc->createElement("root");
AutoPtr<DocumentFragment> pFrag = pDoc->createDocumentFragment();
AutoPtr<Element> pChild1 = pDoc->createElement("child1");
AutoPtr<Element> pChild2 = pDoc->createElement("child2");
AutoPtr<Element> pChild3 = pDoc->createElement("child3");
pFrag->appendChild(pChild1);
pFrag->appendChild(pChild2);
pFrag->appendChild(pChild3);
pRoot->appendChild(pFrag);
assert (pFrag->firstChild() == 0);
assert (pFrag->lastChild() == 0);
assert (pRoot->firstChild() == pChild1);
assert (pRoot->lastChild() == pChild3);
assert (pChild1->previousSibling() == 0);
assert (pChild1->nextSibling() == pChild2);
assert (pChild2->previousSibling() == pChild1);
assert (pChild2->nextSibling() == pChild3);
assert (pChild3->previousSibling() == pChild2);
assert (pChild3->nextSibling() == 0);
AutoPtr<Element> pChild4 = pDoc->createElement("child4");
AutoPtr<Element> pChild5 = pDoc->createElement("child5");
AutoPtr<Element> pChild6 = pDoc->createElement("child6");
pFrag->appendChild(pChild4);
pFrag->appendChild(pChild5);
pFrag->appendChild(pChild6);
pRoot->appendChild(pFrag);
assert (pRoot->firstChild() == pChild1);
assert (pRoot->lastChild() == pChild6);
assert (pChild1->previousSibling() == 0);
assert (pChild1->nextSibling() == pChild2);
assert (pChild2->previousSibling() == pChild1);
assert (pChild2->nextSibling() == pChild3);
assert (pChild3->previousSibling() == pChild2);
assert (pChild3->nextSibling() == pChild4);
assert (pChild4->previousSibling() == pChild3);
assert (pChild4->nextSibling() == pChild5);
assert (pChild5->previousSibling() == pChild4);
assert (pChild5->nextSibling() == pChild6);
assert (pChild6->previousSibling() == pChild5);
assert (pChild6->nextSibling() == 0);
AutoPtr<Element> pChild7 = pDoc->createElement("child7");
AutoPtr<Element> pChild8 = pDoc->createElement("child8");
AutoPtr<Element> pChild9 = pDoc->createElement("child9");
pFrag->appendChild(pChild7);
pFrag->appendChild(pChild8);
pFrag->appendChild(pChild9);
pRoot->appendChild(pFrag);
assert (pRoot->firstChild() == pChild1);
assert (pRoot->lastChild() == pChild9);
assert (pChild1->previousSibling() == 0);
assert (pChild1->nextSibling() == pChild2);
assert (pChild2->previousSibling() == pChild1);
assert (pChild2->nextSibling() == pChild3);
assert (pChild3->previousSibling() == pChild2);
assert (pChild3->nextSibling() == pChild4);
assert (pChild4->previousSibling() == pChild3);
assert (pChild4->nextSibling() == pChild5);
assert (pChild5->previousSibling() == pChild4);
assert (pChild5->nextSibling() == pChild6);
assert (pChild6->previousSibling() == pChild5);
assert (pChild6->nextSibling() == pChild7);
assert (pChild7->previousSibling() == pChild6);
assert (pChild7->nextSibling() == pChild8);
assert (pChild8->previousSibling() == pChild7);
assert (pChild8->nextSibling() == pChild9);
assert (pChild9->previousSibling() == pChild8);
assert (pChild9->nextSibling() == 0);
}
示例5: testAttributesNS
void ElementTest::testAttributesNS()
{
AutoPtr<Document> pDoc = new Document;
AutoPtr<Element> pElem = pDoc->createElementNS("urn:ns1", "p:elem");
assert (pElem->namespaceURI() == "urn:ns1");
assert (pElem->prefix() == "p");
assert (pElem->tagName() == "p:elem");
assert (pElem->localName() == "elem");
assert (!pElem->hasAttributes());
pElem->setAttributeNS("urn:ns1", "a1", "v1");
assert (pElem->hasAttributes());
assert (pElem->hasAttributeNS("urn:ns1", "a1"));
assert (pElem->getAttributeNS("urn:ns1", "a1") == "v1");
Attr* pAttr1 = pElem->getAttributeNodeNS("urn:ns1", "a1");
assert (pAttr1 != 0);
assert (pAttr1->name() == "a1");
assert (pAttr1->namespaceURI() == "urn:ns1");
assert (pAttr1->prefix().empty());
assert (pAttr1->localName() == "a1");
assert (pAttr1->nodeName() == "a1");
assert (pAttr1->value() == "v1");
assert (pAttr1->nodeValue() == "v1");
assert (pAttr1->ownerElement() == pElem);
pAttr1->setValue("V1");
assert (pElem->getAttributeNS("urn:ns1", "a1") == "V1");
pElem->setAttributeNS("urn:ns1", "a2", "v2");
assert (pElem->hasAttributeNS("urn:ns1", "a1"));
assert (pElem->getAttributeNS("urn:ns1", "a1") == "V1");
assert (pElem->hasAttributeNS("urn:ns1", "a2"));
assert (pElem->getAttributeNS("urn:ns1", "a2") == "v2");
Attr* pAttr2 = pElem->getAttributeNodeNS("urn:ns1", "a2");
assert (pAttr2 != 0);
assert (pAttr2->name() == "a2");
assert (pAttr2->namespaceURI() == "urn:ns1");
assert (pAttr2->prefix().empty());
assert (pAttr2->localName() == "a2");
assert (pAttr2->value() == "v2");
assert (pAttr2->ownerElement() == pElem);
Attr* pAttr3 = pElem->getAttributeNodeNS("urn:ns2", "p:a3");
assert (pAttr3 == 0);
pAttr3 = pDoc->createAttributeNS("urn:ns2", "p:a3");
pAttr3->setValue("v3");
pElem->setAttributeNodeNS(pAttr3);
pAttr3->release();
assert (pElem->hasAttributeNS("urn:ns1", "a1"));
assert (pElem->getAttributeNS("urn:ns1", "a1") == "V1");
assert (pElem->hasAttributeNS("urn:ns1", "a2"));
assert (pElem->getAttributeNS("urn:ns1", "a2") == "v2");
assert (pElem->hasAttributeNS("urn:ns2", "a3"));
assert (pElem->getAttributeNS("urn:ns2", "a3") == "v3");
pAttr2 = pDoc->createAttributeNS("urn:ns1", "a2");
pAttr2->setValue("V2");
pElem->setAttributeNodeNS(pAttr2);
pAttr2->release();
assert (pElem->hasAttributeNS("urn:ns1", "a1"));
assert (pElem->getAttributeNS("urn:ns1", "a1") == "V1");
assert (pElem->hasAttributeNS("urn:ns1", "a2"));
assert (pElem->getAttributeNS("urn:ns1", "a2") == "V2");
assert (pElem->hasAttributeNS("urn:ns2", "a3"));
assert (pElem->getAttributeNS("urn:ns2", "a3") == "v3");
pAttr1 = pDoc->createAttributeNS("urn:ns1", "a1");
pAttr1->setValue("v1");
pElem->setAttributeNodeNS(pAttr1);
pAttr1->release();
assert (pElem->hasAttributeNS("urn:ns1", "a1"));
assert (pElem->getAttributeNS("urn:ns1", "a1") == "v1");
assert (pElem->hasAttributeNS("urn:ns1", "a2"));
assert (pElem->getAttributeNS("urn:ns1", "a2") == "V2");
assert (pElem->hasAttributeNS("urn:ns2", "a3"));
assert (pElem->getAttributeNS("urn:ns2", "a3") == "v3");
pAttr3 = pDoc->createAttributeNS("urn:ns2", "q:a3");
pAttr3->setValue("V3");
pElem->setAttributeNodeNS(pAttr3);
pAttr3->release();
assert (pElem->hasAttributeNS("urn:ns1", "a1"));
assert (pElem->getAttributeNS("urn:ns1", "a1") == "v1");
assert (pElem->hasAttributeNS("urn:ns1", "a2"));
assert (pElem->getAttributeNS("urn:ns1", "a2") == "V2");
assert (pElem->hasAttributeNS("urn:ns2", "a3"));
assert (pElem->getAttributeNS("urn:ns2", "a3") == "V3");
pElem->removeAttributeNode(pAttr3);
assert (!pElem->hasAttributeNS("urn:ns2", "a3"));
//.........这里部分代码省略.........
示例6: perf_log
void Biharmonic::JR::residual_and_jacobian(const NumericVector<Number> &u,
NumericVector<Number> *R,
SparseMatrix<Number> *J,
NonlinearImplicitSystem&)
{
#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
if (!R && !J)
return;
// Declare a performance log. Give it a descriptive
// string to identify what part of the code we are
// logging, since there may be many PerfLogs in an
// application.
PerfLog perf_log ("Biharmonic Residual and Jacobian", false);
// A reference to the \p DofMap object for this system. The \p DofMap
// object handles the index translation from node and element numbers
// to degree of freedom numbers. We will talk more about the \p DofMap
// in future examples.
const DofMap& dof_map = get_dof_map();
// Get a constant reference to the Finite Element type
// for the first (and only) variable in the system.
FEType fe_type = dof_map.variable_type(0);
// Build a Finite Element object of the specified type. Since the
// \p FEBase::build() member dynamically creates memory we will
// store the object as an \p AutoPtr<FEBase>. This can be thought
// of as a pointer that will clean up after itself.
AutoPtr<FEBase> fe (FEBase::build(_biharmonic._dim, fe_type));
// Quadrature rule for numerical integration.
// With 2D triangles, the Clough quadrature rule puts a Gaussian
// quadrature rule on each of the 3 subelements
AutoPtr<QBase> qrule(fe_type.default_quadrature_rule(_biharmonic._dim));
// Tell the finite element object to use our quadrature rule.
fe->attach_quadrature_rule (qrule.get());
// Here we define some references to element-specific data that
// will be used to assemble the linear system.
// We begin with the element Jacobian * quadrature weight at each
// integration point.
const std::vector<Real>& JxW = fe->get_JxW();
// The element shape functions evaluated at the quadrature points.
const std::vector<std::vector<Real> >& phi = fe->get_phi();
// The element shape functions' derivatives evaluated at the quadrature points.
const std::vector<std::vector<RealGradient> >& dphi = fe->get_dphi();
// The element shape functions' second derivatives evaluated at the quadrature points.
const std::vector<std::vector<RealTensor> >& d2phi = fe->get_d2phi();
// For efficiency we will compute shape function laplacians n times,
// not n^2
std::vector<Real> Laplacian_phi_qp;
// Define data structures to contain the element matrix
// and right-hand-side vector contribution. Following
// basic finite element terminology we will denote these
// "Je" and "Re". More detail is in example 3.
DenseMatrix<Number> Je;
DenseVector<Number> Re;
// This vector will hold the degree of freedom indices for
// the element. These define where in the global system
// the element degrees of freedom get mapped.
std::vector<unsigned int> dof_indices;
// Old solution
const NumericVector<Number>& u_old = *old_local_solution;
// Now we will loop over all the elements in the mesh. We will
// compute the element matrix and right-hand-side contribution. See
// example 3 for a discussion of the element iterators.
MeshBase::const_element_iterator el = _biharmonic._mesh->active_local_elements_begin();
const MeshBase::const_element_iterator end_el = _biharmonic._mesh->active_local_elements_end();
for ( ; el != end_el; ++el) {
// Store a pointer to the element we are currently
// working on. This allows for nicer syntax later.
const Elem* elem = *el;
// Get the degree of freedom indices for the
// current element. These define where in the global
// matrix and right-hand-side this element will
// contribute to.
dof_map.dof_indices (elem, dof_indices);
// Compute the element-specific data for the current
// element. This involves computing the location of the
// quadrature points (q_point) and the shape function
// values/derivatives (phi, dphi,d2phi) for the current element.
fe->reinit (elem);
// Zero the element matrix, the right-hand side and the Laplacian matrix
// before summing them.
if (J)
//.........这里部分代码省略.........
示例7: ASSERT_SUCCEEDED
int CTest::test_formatLjava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition(int argc, char* argv[])
{
// Test for method java.lang.StringBuffer
// java.text.MessageFormat.format(java.lang.Object [],
// java.lang.StringBuffer, java.text.FieldPosition)
AutoPtr<IMessageFormat> format;
ASSERT_SUCCEEDED(CMessageFormat::New(String("{1,number,integer}"), (IMessageFormat**)&format));
AutoPtr<IStringBuffer> buffer = new StringBuffer();
AutoPtr< ArrayOf<IInterface*> > objlst = ArrayOf<IInterface*>::Alloc(2);
String zerostr("0");
AutoPtr<ICharSequence> charSeq;
CStringWrapper::New(zerostr, (ICharSequence**)&charSeq);
AutoPtr<IDouble> dinter;
CDouble::New(53.863, (IDouble**)&dinter);
objlst->Set(0, charSeq);
objlst->Set(1, dinter);
AutoPtr<IFieldPosition> sfp;
AutoPtr<IMessageFormatField> ARGUMENT;
CMessageFormatField::New(String("message argument field"), (IMessageFormatField**)&ARGUMENT);
CFieldPosition::New(ARGUMENT, (IFieldPosition**)&sfp);
AutoPtr<IStringBuffer> outbuf;
format->FormatObjects(objlst, buffer, sfp, (IStringBuffer**)&outbuf);
String outstr;
outbuf->ToString(&outstr);
// assertEquals("Wrong result", "54", buffer.toString());
assert(String("54").Equals(outstr));
format->FormatObjects(objlst, buffer, sfp, (IStringBuffer**)&outbuf);
outbuf->ToString(&outstr);
// assertEquals("Wrong result", "5454", buffer.toString());
assert(String("5454").Equals(outstr));
buffer = new StringBuffer();
format->ApplyPattern(String("{0,choice,0#zero|1#one '{1,choice,2#two {2,time}}'}"));
AutoPtr<IDate> date;
CDate::New((IDate**)&date);
AutoPtr<IDateFormatHelper> dfh;
CDateFormatHelper::AcquireSingleton((IDateFormatHelper**)&dfh);
AutoPtr<IDateFormat> df;
dfh->GetTimeInstance((IDateFormat**)&df);
String datestr;
df->FormatDate(date,&datestr);
String expected = String("one two ") + datestr;
CDouble::New(1.6, (IDouble**)&dinter);
AutoPtr<IInteger32> iinter;
CInteger32::New(3, (IInteger32**)&iinter);
objlst = ArrayOf<IInterface*>::Alloc(3);
objlst->Set(0, dinter);
objlst->Set(1, iinter);
objlst->Set(2, date);
format->FormatObjects(objlst, buffer, sfp, (IStringBuffer**)&outbuf);
outbuf->ToString(&outstr);
// assertEquals("Choice not recursive:\n" + expected + "\n" + buffer,
// expected, buffer.toString());
assert(outstr.Equals(expected));
CDouble::New(0.6, (IDouble**)&dinter);
objlst = ArrayOf<IInterface*>::Alloc(2);
objlst->Set(0, dinter);
objlst->Set(1, iinter);
format->FormatObjects(objlst, buffer, NULL, (IStringBuffer**)&outbuf);
// assertEquals(expected + "zero", str.toString());
outbuf->ToString(&outstr);
assert(outstr.Equals(expected + String("zero")));
// assertEquals(expected + "zero", buffer.toString());
buffer->ToString(&outstr);
assert(outstr.Equals(expected + String("zero")));
// try {
objlst = ArrayOf<IInterface*>::Alloc(3);
String nullstr("");
CStringWrapper::New(nullstr, (ICharSequence**)&charSeq);
CDouble::New(1, (IDouble**)&dinter);
objlst->Set(0, (IInterface*)&zerostr);
objlst->Set(1, dinter);
objlst->Set(2, (IInterface*)&charSeq);
ECode ec = format->FormatObjects(objlst, buffer, sfp, (IStringBuffer**)&outbuf);
if (ec != NOERROR)
{
printf("IllegalArgumentException was not thrown.\n");
}
// fail("IllegalArgumentException was not thrown.");
// } catch(IllegalArgumentException iae) {
// //expected
// }
// try {
objlst = ArrayOf<IInterface*>::Alloc(2);
objlst->Set(0, (IInterface*)&charSeq);
objlst->Set(1, iinter);
ec = format->FormatObjects(objlst, buffer, sfp, (IStringBuffer**)&outbuf);
if (ec != NOERROR)
{
printf("IllegalArgumentException was not thrown.\n");
}
// fail("IllegalArgumentException was not thrown.");
// } catch(IllegalArgumentException iae) {
// //expected
// }
return 0;
//.........这里部分代码省略.........
示例8: kDebug
//.........这里部分代码省略.........
*/
// -----------------------------------------------------------------------------------------
kDebug( 51000 ) << "DNGWriter: Formating RAW data to memory" << endl;
std::vector<unsigned short> raw_data;
raw_data.resize(rawData.size());
const unsigned short* dp = (const unsigned short*)rawData.data();
for (uint i = 0; i < raw_data.size()/2; i++)
{
raw_data[i] = *dp;
*dp++;
}
if (d->cancel) return -2;
// -----------------------------------------------------------------------------------------
kDebug( 51000 ) << "DNGWriter: DNG memory allocation and initialization" << endl;
dng_memory_allocator memalloc(gDefaultDNGMemoryAllocator);
dng_memory_stream stream(memalloc);
stream.Put(&raw_data.front(), raw_data.size()*sizeof(unsigned short));
dng_rect rect(height, width);
DNGWriterHost host(d, &memalloc);
// Unprocessed raw data.
host.SetKeepStage1(true);
// Linearized, tone curve processed data.
host.SetKeepStage2(true);
AutoPtr<dng_image> image(new dng_simple_image(rect, 1, ttShort, 1<<pixelRange, memalloc));
if (d->cancel) return -2;
// -----------------------------------------------------------------------------------------
kDebug( 51000 ) << "DNGWriter: DNG IFD structure creation" << endl;
dng_ifd ifd;
ifd.fUsesNewSubFileType = true;
ifd.fNewSubFileType = 0;
ifd.fImageWidth = width;
ifd.fImageLength = height;
ifd.fBitsPerSample[0] = pixelRange;
ifd.fBitsPerSample[1] = 0;
ifd.fBitsPerSample[2] = 0;
ifd.fBitsPerSample[3] = 0;
ifd.fCompression = ccUncompressed;
ifd.fPredictor = 1;
ifd.fCFALayout = 1; // Rectangular (or square) layout.
ifd.fPhotometricInterpretation = piCFA;
ifd.fFillOrder = 1;
ifd.fOrientation = identify.orientation;
ifd.fSamplesPerPixel = 1;
ifd.fPlanarConfiguration = 1;
ifd.fXResolution = 0.0;
ifd.fYResolution = 0.0;
ifd.fResolutionUnit = 0;
ifd.fUsesStrips = true;
ifd.fUsesTiles = false;
示例9: String
int CTest::test_setFormat(int argc, char* argv[])
{
AutoPtr<IMessageFormat> format1;
AutoPtr<ILocale> Locale_US;
CLocale::New(String("en"), String("US"), (ILocale**)&Locale_US);
AutoPtr<ILocaleHelper> lh;
CLocaleHelper::AcquireSingleton((ILocaleHelper**)&lh);
lh->SetDefault(Locale_US);
String pattern("A {3, number, currency} B {2, time} C {0, number, percent} D {4} E {1,choice,0#off|1#on} F {0, date}");
CMessageFormat::New(pattern, (IMessageFormat**)&format1);
AutoPtr<IMessageFormat> f1 = format1;
AutoPtr<IDateFormat> df;
AutoPtr<IDateFormatHelper> dfh;
CDateFormatHelper::AcquireSingleton((IDateFormatHelper **)&dfh);
dfh->GetTimeInstance((IDateFormat **)&df);
AutoPtr<INumberFormat> nf;
AutoPtr<INumberFormatHelper> nfh;
CNumberFormatHelper::AcquireSingleton((INumberFormatHelper **)&nfh);
nfh->GetInstance((INumberFormat **)&nf);
// case 1: Compare getFormats() results after calls to setFormat()
f1->SetFormat(0, df);
f1->SetFormat(1, df);
f1->SetFormat(2, nf);
AutoPtr<IChoiceFormat> cf1, cf2;
CChoiceFormat::New(String("0#off|1#on") , (IChoiceFormat **)&cf1);
CChoiceFormat::New(String("1#few|2#ok|3#a lot") , (IChoiceFormat **)&cf2);
f1->SetFormat(3, cf1);
f1->SetFormat(4, cf2);
f1->SetFormat(5, df);
AutoPtr<ArrayOf<IFormat*> > formats;
f1->GetFormats((ArrayOf<IFormat*> **)&formats);
AutoPtr<ArrayOf<AutoPtr<IFormat> > > correctFormats = ArrayOf<AutoPtr<IFormat> >::Alloc(6);
(*correctFormats)[0] = df;
(*correctFormats)[1] = df;
(*correctFormats)[2] = nf;
(*correctFormats)[3] = cf1;
(*correctFormats)[4] = cf2;
(*correctFormats)[5] = df;
PFL_EX("correctFormats : %d == formats : %d " , correctFormats->GetLength() , formats->GetLength())
assert(correctFormats->GetLength() == formats->GetLength());
for (int i = 0; i < correctFormats->GetLength(); i++) {
PFL_EX("index : %d , correctFormats : %p ,formats : %p " ,i ,(*correctFormats)[i].Get(), (*formats)[i] )
assert( (*correctFormats)[i] == (*formats)[i]);
}
// case 2: Try to setFormat using incorrect index
f1->SetFormat(-1, df);
ECode ec = f1->GetFormats((ArrayOf<IFormat*> **)&formats);
if (ec != NOERROR)
{
PFL_EX("Expected ArrayIndexOutOfBoundsException was not thrown");
}
AutoPtr<IDateFormat> df2;
dfh->GetDateTimeInstance((IDateFormat **)&df2);
ec = f1->SetFormat(formats->GetLength(), df2);
if (ec != NOERROR)
{
PFL_EX("Expected ArrayIndexOutOfBoundsException was not thrown")
}
}
示例10: toXMLString
std::string MDHistoDimension::toXMLString() const {
using namespace Poco::XML;
// Create the root element for this fragment.
AutoPtr<Document> pDoc = new Document;
AutoPtr<Element> pDimensionElement = pDoc->createElement("Dimension");
pDoc->appendChild(pDimensionElement);
// Set the id.
AutoPtr<Attr> idAttribute = pDoc->createAttribute("ID");
idAttribute->setNodeValue(this->getDimensionId());
pDimensionElement->setAttributeNode(idAttribute);
// Set the name.
AutoPtr<Element> nameElement = pDoc->createElement("Name");
AutoPtr<Text> nameText = pDoc->createTextNode(this->getName());
nameElement->appendChild(nameText);
pDimensionElement->appendChild(nameElement);
// Set the units.
AutoPtr<Element> unitsElement = pDoc->createElement("Units");
AutoPtr<Text> unitsText = pDoc->createTextNode(this->getUnits());
unitsElement->appendChild(unitsText);
pDimensionElement->appendChild(unitsElement);
// Set the frame.
AutoPtr<Element> frameElement = pDoc->createElement("Frame");
AutoPtr<Text> frameText = pDoc->createTextNode(this->getMDFrame().name());
frameElement->appendChild(frameText);
pDimensionElement->appendChild(frameElement);
// Set the upper bounds
AutoPtr<Element> upperBoundsElement = pDoc->createElement("UpperBounds");
AutoPtr<Text> upperBoundsText = pDoc->createTextNode(
boost::str(boost::format("%.4f") % this->getMaximum()));
upperBoundsElement->appendChild(upperBoundsText);
pDimensionElement->appendChild(upperBoundsElement);
// Set the lower bounds
AutoPtr<Element> lowerBoundsElement = pDoc->createElement("LowerBounds");
AutoPtr<Text> lowerBoundsText = pDoc->createTextNode(
boost::str(boost::format("%.4f") % this->getMinimum()));
lowerBoundsElement->appendChild(lowerBoundsText);
pDimensionElement->appendChild(lowerBoundsElement);
// Set the number of bins
AutoPtr<Element> numberOfBinsElement = pDoc->createElement("NumberOfBins");
AutoPtr<Text> numberOfBinsText = pDoc->createTextNode(
boost::str(boost::format("%.4d") % this->getNBins()));
numberOfBinsElement->appendChild(numberOfBinsText);
pDimensionElement->appendChild(numberOfBinsElement);
// Provide upper and lower limits for integrated dimensions.
if (this->getIsIntegrated()) {
AutoPtr<Element> integratedElement = pDoc->createElement("Integrated");
// Set the upper limit
AutoPtr<Element> upperLimitElement = pDoc->createElement("UpperLimit");
AutoPtr<Text> upperLimitText = pDoc->createTextNode(boost::str(
boost::format("%.4f") % this->getMaximum())); // Dimension does not yet
// provide integration
// ranges.
upperLimitElement->appendChild(upperLimitText);
integratedElement->appendChild(upperLimitElement);
// Set the lower limit
AutoPtr<Element> lowerLimitElement = pDoc->createElement("LowerLimit");
AutoPtr<Text> lowerLimitText = pDoc->createTextNode(boost::str(
boost::format("%.4f") % this->getMinimum())); // Dimension does not yet
// provide integration
// ranges.
lowerLimitElement->appendChild(lowerLimitText);
integratedElement->appendChild(lowerLimitElement);
pDimensionElement->appendChild(integratedElement);
}
// Create a string representation of the DOM tree.
std::stringstream xmlstream;
DOMWriter writer;
writer.writeNode(xmlstream, pDoc);
return xmlstream.str().c_str();
}
示例11: assemble_elasticity
void assemble_elasticity(EquationSystems& es,
const std::string& system_name)
{
libmesh_assert (system_name == "Elasticity");
const MeshBase& mesh = es.get_mesh();
const unsigned int dim = mesh.mesh_dimension();
LinearImplicitSystem& system = es.get_system<LinearImplicitSystem>("Elasticity");
const unsigned int u_var = system.variable_number ("u");
const unsigned int v_var = system.variable_number ("v");
const unsigned int lambda_var = system.variable_number ("lambda");
const DofMap& dof_map = system.get_dof_map();
FEType fe_type = dof_map.variable_type(0);
AutoPtr<FEBase> fe (FEBase::build(dim, fe_type));
QGauss qrule (dim, fe_type.default_quadrature_order());
fe->attach_quadrature_rule (&qrule);
AutoPtr<FEBase> fe_face (FEBase::build(dim, fe_type));
QGauss qface(dim-1, fe_type.default_quadrature_order());
fe_face->attach_quadrature_rule (&qface);
const std::vector<Real>& JxW = fe->get_JxW();
const std::vector<std::vector<RealGradient> >& dphi = fe->get_dphi();
DenseMatrix<Number> Ke;
DenseVector<Number> Fe;
DenseSubMatrix<Number>
Kuu(Ke), Kuv(Ke),
Kvu(Ke), Kvv(Ke);
DenseSubMatrix<Number> Klambda_v(Ke), Kv_lambda(Ke);
DenseSubVector<Number>
Fu(Fe),
Fv(Fe);
std::vector<unsigned int> dof_indices;
std::vector<unsigned int> dof_indices_u;
std::vector<unsigned int> dof_indices_v;
std::vector<unsigned int> dof_indices_lambda;
MeshBase::const_element_iterator el = mesh.active_local_elements_begin();
const MeshBase::const_element_iterator end_el = mesh.active_local_elements_end();
for ( ; el != end_el; ++el)
{
const Elem* elem = *el;
dof_map.dof_indices (elem, dof_indices);
dof_map.dof_indices (elem, dof_indices_u, u_var);
dof_map.dof_indices (elem, dof_indices_v, v_var);
dof_map.dof_indices (elem, dof_indices_lambda, lambda_var);
const unsigned int n_dofs = dof_indices.size();
const unsigned int n_u_dofs = dof_indices_u.size();
const unsigned int n_v_dofs = dof_indices_v.size();
const unsigned int n_lambda_dofs = dof_indices_lambda.size();
fe->reinit (elem);
Ke.resize (n_dofs, n_dofs);
Fe.resize (n_dofs);
Kuu.reposition (u_var*n_u_dofs, u_var*n_u_dofs, n_u_dofs, n_u_dofs);
Kuv.reposition (u_var*n_u_dofs, v_var*n_u_dofs, n_u_dofs, n_v_dofs);
Kvu.reposition (v_var*n_v_dofs, u_var*n_v_dofs, n_v_dofs, n_u_dofs);
Kvv.reposition (v_var*n_v_dofs, v_var*n_v_dofs, n_v_dofs, n_v_dofs);
// Also, add a row and a column to enforce the constraint
Kv_lambda.reposition (v_var*n_u_dofs, v_var*n_u_dofs+n_v_dofs, n_v_dofs, 1);
Klambda_v.reposition (v_var*n_v_dofs+n_v_dofs, v_var*n_v_dofs, 1, n_v_dofs);
Fu.reposition (u_var*n_u_dofs, n_u_dofs);
Fv.reposition (v_var*n_u_dofs, n_v_dofs);
for (unsigned int qp=0; qp<qrule.n_points(); qp++)
{
for (unsigned int i=0; i<n_u_dofs; i++)
for (unsigned int j=0; j<n_u_dofs; j++)
{
// Tensor indices
unsigned int C_i, C_j, C_k, C_l;
C_i=0, C_k=0;
C_j=0, C_l=0;
Kuu(i,j) += JxW[qp]*(eval_elasticity_tensor(C_i,C_j,C_k,C_l) * dphi[i][qp](C_j)*dphi[j][qp](C_l));
C_j=1, C_l=0;
Kuu(i,j) += JxW[qp]*(eval_elasticity_tensor(C_i,C_j,C_k,C_l) * dphi[i][qp](C_j)*dphi[j][qp](C_l));
C_j=0, C_l=1;
Kuu(i,j) += JxW[qp]*(eval_elasticity_tensor(C_i,C_j,C_k,C_l) * dphi[i][qp](C_j)*dphi[j][qp](C_l));
C_j=1, C_l=1;
//.........这里部分代码省略.........
示例12: AutoPtr
AutoPtr (AutoPtr& that) :
m_p (that.release ()) {}
示例13: THIS_PROBE
ECode ActionBarContextView::InitForMode(
/* [in] */ IActionMode* mode)
{
AutoPtr<IViewParent> vp;
if (mClose == NULL) {
AutoPtr<ILayoutInflater> inflater;
LayoutInflater::From(mContext, (ILayoutInflater**)&inflater);
inflater->Inflate(R::layout::action_mode_close_item,
THIS_PROBE(IViewGroup), FALSE, (IView**)&mClose);
AddView(mClose);
} else if ((mClose->GetParent((IViewParent**)&vp), vp) == NULL) {
AddView(mClose);
}
AutoPtr<IView> closeButton;
mClose->FindViewById(R::id::action_mode_close_button, (IView**)&closeButton);
AutoPtr<IViewOnClickListener> l = new CloseButtonListener(mode);
closeButton->SetOnClickListener(l);
AutoPtr<IMenuBuilder> menu;
mode->GetMenu((IMenu**)&menu);
if (mActionMenuPresenter != NULL) {
Boolean res = FALSE;
mActionMenuPresenter->DismissPopupMenus(&res);
}
CActionMenuPresenter::New(mContext, (IActionMenuPresenter**)&mActionMenuPresenter);
mActionMenuPresenter->SetReserveOverflow(TRUE);
AutoPtr<IViewGroupLayoutParams> layoutParams;
CViewGroupLayoutParams::New(IViewGroupLayoutParams::WRAP_CONTENT,
IViewGroupLayoutParams::MATCH_PARENT, (IViewGroupLayoutParams**)&layoutParams);
if (!mSplitActionBar) {
menu->AddMenuPresenter(mActionMenuPresenter.Get());
AutoPtr<IMenuView> view;
mActionMenuPresenter->GetMenuView(THIS_PROBE(IViewGroup), (IMenuView**)&view);
mMenuView = IActionMenuView::Probe(view);
mMenuView->SetBackgroundDrawable(NULL);
AddView(mMenuView, layoutParams);
} else {
AutoPtr<IResources> rs;
GetContext()->GetResources((IResources**)&rs);
AutoPtr<IDisplayMetrics> dm;
rs->GetDisplayMetrics((IDisplayMetrics**)&dm);
// Allow full screen width in split mode.
mActionMenuPresenter->SetWidthLimit(
((CDisplayMetrics*)dm.Get())->mWidthPixels, TRUE);
// No limit to the item count; use whatever will fit.
mActionMenuPresenter->SetItemLimit(Elastos::Core::Math::INT32_MAX_VALUE);
// Span the whole width
layoutParams->SetWidth(IViewGroupLayoutParams::MATCH_PARENT);
layoutParams->SetHeight(mContentHeight);
menu->AddMenuPresenter(mActionMenuPresenter.Get());
AutoPtr<IMenuView> view;
mActionMenuPresenter->GetMenuView(THIS_PROBE(IViewGroup), (IMenuView**)&view);
mMenuView = IActionMenuView::Probe(view);
mMenuView->SetBackgroundDrawable(mSplitBackground);
mSplitView->AddView(mMenuView, layoutParams);
}
mAnimateInOnLayout = TRUE;
return NOERROR;
}
示例14: VALIDATE_NOT_NULL
ECode CSession::PerformDrag(
/* [in] */ IIWindow* window,
/* [in] */ IBinder* dragToken,
/* [in] */ Float touchX,
/* [in] */ Float touchY,
/* [in] */ Float thumbCenterX,
/* [in] */ Float thumbCenterY,
/* [in] */ IClipData* data,
/* [out] */ Boolean* result)
{
VALIDATE_NOT_NULL(result);
// if (WindowManagerService.DEBUG_DRAG) {
// Slog.d(WindowManagerService.TAG, "perform drag: win=" + window + " data=" + data);
// }
AutoLock lock(mService->mWindowMapLock);
if (mService->mDragState == NULL) {
Slogger::W(CWindowManagerService::TAG, "No drag prepared");
*result = false;
return E_ILLEGAL_STATE_EXCEPTION;
// throw new IllegalStateException("performDrag() without prepareDrag()");
}
if (dragToken != mService->mDragState->mToken) {
Slogger::W(CWindowManagerService::TAG, "Performing mismatched drag");
*result = false;
return E_ILLEGAL_STATE_EXCEPTION;
// throw new IllegalStateException("performDrag() does not match prepareDrag()");
}
AutoPtr<WindowState> callingWin;
mService->WindowForClientLocked(NULL, window, FALSE, (WindowState**)&callingWin);
if (callingWin == NULL) {
Slogger::W(CWindowManagerService::TAG, "Bad requesting window %p", window);
*result = false;
return NOERROR; // !!! TODO: throw here?
}
// !!! TODO: if input is not still focused on the initiating window, fail
// the drag initiation (e.g. an alarm window popped up just as the application
// called performDrag()
mService->mH->RemoveMessages(
CWindowManagerService::H::DRAG_START_TIMEOUT, window);
// !!! TODO: extract the current touch (x, y) in screen coordinates. That
// will let us eliminate the (touchX,touchY) parameters from the API.
// !!! FIXME: put all this heavy stuff onto the mH looper, as well as
// the actual drag event dispatch stuff in the dragstate
AutoPtr<IDisplay> display = callingWin->mDisplayContent->GetDisplay();
mService->mDragState->Register(display);
mService->mInputMonitor->UpdateInputWindowsLw(TRUE /*force*/);
if (!mService->mInputManager->TransferTouchFocus(callingWin->mInputChannel,
mService->mDragState->mServerChannel)) {
Slogger::E(CWindowManagerService::TAG, "Unable to transfer touch focus");
mService->mDragState->Unregister();
mService->mDragState = NULL;
mService->mInputMonitor->UpdateInputWindowsLw(TRUE /*force*/);
*result = FALSE;
return NOERROR;
}
mService->mDragState->mData = data;
mService->mDragState->mCurrentX = touchX;
mService->mDragState->mCurrentY = touchY;
mService->mDragState->BroadcastDragStartedLw(touchX, touchY);
// remember the thumb offsets for later
mService->mDragState->mThumbOffsetX = thumbCenterX;
mService->mDragState->mThumbOffsetY = thumbCenterY;
// Make the surface visible at the proper location
AutoPtr<ISurface> surface = mService->mDragState->mSurface;
if (CWindowManagerService::SHOW_LIGHT_TRANSACTIONS) {
Slogger::I(CWindowManagerService::TAG, ">>> OPEN TRANSACTION performDrag");
}
AutoPtr<ISurfaceHelper> helper;
CSurfaceHelper::AcquireSingleton((ISurfaceHelper**)&helper);
helper->OpenTransaction();
// try {
surface->SetPosition(touchX - thumbCenterX,
touchY - thumbCenterY);
surface->SetAlpha(0.7071);
surface->SetLayer(mService->mDragState->GetDragLayerLw());
Int32 layerStack;
display->GetLayerStack(&layerStack);
surface->SetLayerStack(layerStack);
ECode ec = surface->Show();
if (FAILED(ec)) {
*result = FALSE;
helper->CloseTransaction();
return ec;
}
// } finally {
helper->CloseTransaction();
if (CWindowManagerService::SHOW_LIGHT_TRANSACTIONS) {
Slogger::I(CWindowManagerService::TAG, "<<< CLOSE TRANSACTION performDrag");
}
//.........这里部分代码省略.........
示例15: GetPaddingTop
void ActionBarContextView::OnMeasure(
/* [in] */ Int32 widthMeasureSpec,
/* [in] */ Int32 heightMeasureSpec)
{
Int32 widthMode = MeasureSpec::GetMode(widthMeasureSpec);
if (widthMode != MeasureSpec::EXACTLY) {
/*throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
"with android:layout_width=\"match_parent\" (or fill_parent)");*/
}
Int32 heightMode = MeasureSpec::GetMode(heightMeasureSpec);
if (heightMode == MeasureSpec::UNSPECIFIED) {
/*throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
"with android:layout_height=\"wrap_content\"");*/
}
Int32 contentWidth = MeasureSpec::GetSize(widthMeasureSpec);
Int32 maxHeight = mContentHeight > 0 ? mContentHeight : MeasureSpec::GetSize(heightMeasureSpec);
Int32 verticalPadding = GetPaddingTop() + GetPaddingBottom();
Int32 availableWidth = contentWidth - GetPaddingLeft() - GetPaddingRight();
Int32 height = maxHeight - verticalPadding;
Int32 childSpecHeight = MeasureSpec::MakeMeasureSpec(height, MeasureSpec::AT_MOST);
if (mClose != NULL) {
availableWidth = MeasureChildView(mClose, availableWidth, childSpecHeight, 0);
AutoPtr<IViewGroupMarginLayoutParams> lp;
mClose->GetLayoutParams((IViewGroupLayoutParams**)&lp);
availableWidth -= ((CViewGroupMarginLayoutParams*)lp.Get())->mLeftMargin +
((CViewGroupMarginLayoutParams*)lp.Get())->mRightMargin;
}
AutoPtr<IViewParent> vp;
if (mMenuView != NULL && (mMenuView->GetParent((IViewParent**)&vp), vp.Get()) == THIS_PROBE(IViewParent)) {
availableWidth = MeasureChildView(mMenuView, availableWidth,
childSpecHeight, 0);
}
if (mTitleLayout != NULL && mCustomView == NULL) {
if (mTitleOptional) {
Int32 titleWidthSpec = MeasureSpec::MakeMeasureSpec(0, MeasureSpec::UNSPECIFIED);
mTitleLayout->Measure(titleWidthSpec, childSpecHeight);
Int32 titleWidth;
mTitleLayout->GetMeasuredWidth(&titleWidth);
Boolean titleFits = titleWidth <= availableWidth;
if (titleFits) {
availableWidth -= titleWidth;
}
mTitleLayout->SetVisibility(titleFits ? IView::VISIBLE : IView::GONE);
} else {
availableWidth = MeasureChildView(mTitleLayout, availableWidth, childSpecHeight, 0);
}
}
if (mCustomView != NULL) {
AutoPtr<IViewGroupLayoutParams> lp;
mCustomView->GetLayoutParams((IViewGroupLayoutParams**)&lp);
Int32 w;
lp->GetWidth(&w);
Int32 customWidthMode = w != IViewGroupLayoutParams::WRAP_CONTENT ?
MeasureSpec::EXACTLY : MeasureSpec::AT_MOST;
Int32 customWidth = w >= 0 ? Elastos::Core::Math::Min(w, availableWidth) : availableWidth;
Int32 h;
lp->GetHeight(&h);
Int32 customHeightMode = h != IViewGroupLayoutParams::WRAP_CONTENT ?
MeasureSpec::EXACTLY : MeasureSpec::AT_MOST;
Int32 customHeight = h >= 0 ? Elastos::Core::Math::Min(h, height) : height;
mCustomView->Measure(MeasureSpec::MakeMeasureSpec(customWidth, customWidthMode),
MeasureSpec::MakeMeasureSpec(customHeight, customHeightMode));
}
if (mContentHeight <= 0) {
Int32 measuredHeight = 0;
Int32 count = GetChildCount();
for (Int32 i = 0; i < count; i++) {
AutoPtr<IView> v = GetChildAt(i);
Int32 paddedViewHeight;
v->GetMeasuredHeight(&paddedViewHeight);
paddedViewHeight += verticalPadding;
if (paddedViewHeight > measuredHeight) {
measuredHeight = paddedViewHeight;
}
}
SetMeasuredDimension(contentWidth, measuredHeight);
} else {
SetMeasuredDimension(contentWidth, maxHeight);
}
}