1 /*==========================================================================
2 * Copyright (c) 2004 University of Massachusetts. All Rights Reserved.
4 * Use of the Lemur Toolkit for Language Modeling and Information Retrieval
5 * is subject to the terms of the software license set forth in the LICENSE
6 * file included with this software, and also available at
7 * http://www.lemurproject.org/license.html
9 *==========================================================================
16 // 8 October 2003 - tds
19 #include "indri/XMLNode.hpp"
21 indri::xml::XMLNode::XMLNode( const std::string
& name
) : _name(name
)
25 indri::xml::XMLNode::XMLNode( const std::string
& name
, const std::string
& value
) : _name(name
), _value(value
)
29 indri::xml::XMLNode::XMLNode( const std::string
& name
, const MAttributes
& attributes
) : _name(name
), _attributes(attributes
)
33 indri::xml::XMLNode::XMLNode( const std::string
& name
, const MAttributes
& attributes
, const std::string
& value
) : _name(name
), _attributes(attributes
), _value(value
)
37 indri::xml::XMLNode::~XMLNode() {
38 for( unsigned int i
=0; i
<_children
.size(); i
++ )
42 void indri::xml::XMLNode::addChild( XMLNode
* child
) {
43 _children
.push_back(child
);
46 void indri::xml::XMLNode::addAttribute( const std::string
& key
, const std::string
& value
) {
47 _attributes
.insert( std::make_pair( key
, value
) );
50 const std::string
& indri::xml::XMLNode::getName() const {
54 const std::string
& indri::xml::XMLNode::getValue() const {
58 const indri::xml::XMLNode::MAttributes
& indri::xml::XMLNode::getAttributes() const {
62 std::string
indri::xml::XMLNode::getAttribute( const std::string
& name
) const {
63 MAttributes::const_iterator iter
;
64 iter
= _attributes
.find( name
);
66 if( iter
!= _attributes
.end() ) {
73 const std::vector
<indri::xml::XMLNode
*>& indri::xml::XMLNode::getChildren() const {
77 const indri::xml::XMLNode
* indri::xml::XMLNode::getChild( const std::string
& name
) const {
78 for( unsigned int i
=0; i
<_children
.size(); i
++ ) {
79 if( _children
[i
]->getName() == name
)
86 std::string
indri::xml::XMLNode::getChildValue( const std::string
& name
) const {
87 const indri::xml::XMLNode
* child
= getChild(name
);
90 return child
->getValue();
96 void indri::xml::XMLNode::setValue( const std::string
& value
) {