poco/XML/src/ChildNodesList.cpp
Roger Meier b0581433a7 LICENSE: add info about SPDX-License-Identifier usage and use it
fix: remove executable flag and change back to 100644 (was 100755)

Signed-off-by: Roger Meier <r.meier@siemens.com>
2014-05-14 08:38:09 +02:00

73 lines
1.1 KiB
C++

//
// ChildNodesList.cpp
//
// $Id: //poco/1.4/XML/src/ChildNodesList.cpp#1 $
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/ChildNodesList.h"
#include "Poco/DOM/Node.h"
#include "Poco/DOM/Document.h"
namespace Poco {
namespace XML {
ChildNodesList::ChildNodesList(const Node* pParent):
_pParent(pParent)
{
poco_check_ptr (pParent);
_pParent->duplicate();
}
ChildNodesList::~ChildNodesList()
{
_pParent->release();
}
Node* ChildNodesList::item(unsigned long index) const
{
unsigned long n = 0;
Node* pCur = _pParent->firstChild();
while (pCur && n++ < index)
{
pCur = pCur->nextSibling();
}
return pCur;
}
unsigned long ChildNodesList::length() const
{
unsigned long n = 0;
Node* pCur = _pParent->firstChild();
while (pCur)
{
++n;
pCur = pCur->nextSibling();
}
return n;
}
void ChildNodesList::autoRelease()
{
_pParent->ownerDocument()->autoReleasePool().add(this);
}
} } // namespace Poco::XML