2 * Copyright 2001-2009 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * AbstractSimpleElement.cpp
20 * Extension of AbstractXMLObject that implements simple elements
24 #include "AbstractSimpleElement.h"
26 using namespace xmltooling;
27 using xercesc::XMLString;
30 // shared "empty" list of children for childless objects
32 list<XMLObject*> AbstractSimpleElement::m_no_children;
34 AbstractSimpleElement::AbstractSimpleElement() : m_value(NULL)
38 AbstractSimpleElement::AbstractSimpleElement(const AbstractSimpleElement& src)
39 : AbstractXMLObject(src), m_value(XMLString::replicate(src.m_value))
43 AbstractSimpleElement::~AbstractSimpleElement()
45 XMLString::release(&m_value);
48 bool AbstractSimpleElement::hasChildren() const
53 const list<XMLObject*>& AbstractSimpleElement::getOrderedChildren() const
58 void AbstractSimpleElement::removeChild(XMLObject* child)
60 throw XMLObjectException("Cannot remove child from a childless object.");
63 const XMLCh* AbstractSimpleElement::getTextContent(unsigned int position) const
65 return (position==0) ? m_value : NULL;
68 void AbstractSimpleElement::setTextContent(const XMLCh* value, unsigned int position)
71 throw XMLObjectException("Cannot set text content in simple element at position > 0.");
72 m_value=prepareForAssignment(m_value,value);