pelican/utility/src/Config.cpp
/**
 * @details
 * Sets and creates the specified address in the configuration document.
 *
 * @param[in] address The address of the configuration node element to be set.
 *
 * @return A QDomElement at the address specified in the argument.
 */
@details
Sets and creates the specified address in the configuration document.

@param[in] address The address of the configuration node element to be set.

@return A QDomElement at the address specified in the argument.
@details Sets and creates the specified address in the configuration document . @param [ in ] address The address of the configuration node element to be set . @return A QDomElement at the address specified in the argument .
QDomElement Config::_set(const TreeAddress &address)
{
    QDomElement parent = _document.documentElement();
    if (parent.isNull()) {
        QDomElement e = _document.createElement(QString("config"));
        _document.appendChild(e);
        parent = e;
    }
    for (int a = 0; a < address.size(); a++) {
        QString tag  = address.at(a).first;
        QString name = address.at(a).second;
        QDomNodeList children = parent.childNodes();
        QList<QDomNode> nodes;
        for (int i = 0; i < children.size(); i++) {
            if (children.at(i).toElement().tagName() == tag) {
                nodes << children.at(i);
            }
        }
        if (nodes.isEmpty()) {
            _createChildNode(parent, tag, name);
            parent = parent.lastChild().toElement();
        }
        else {
            int iNode = -1;
            for (int n = 0; n < nodes.size(); n++) {
                QString nodeName = nodes.at(n).toElement().attribute(QString("name"));
                if (nodeName == name) {
                    iNode = n;
                }
            }
            if (iNode == -1) {
                _createChildNode(parent, tag, name);
                parent = parent.lastChild().toElement();
            }
            else {
                parent = nodes.at(iNode).toElement();
            }
        }
    }
    return parent;
}
QDomElement Config :: _set ( const TreeAddress & address ) { QDomElement parent = _document . documentElement ( ) ; if ( parent . isNull ( ) ) { QDomElement e = _document . createElement ( QString ( " " ) ) ; _document . appendChild ( e ) ; parent = e ; } for ( int a = 0 ; a < address . size ( ) ; a ++ ) { QString tag = address . at ( a ) . first ; QString name = address . at ( a ) . second ; QDomNodeList children = parent . childNodes ( ) ; QList < QDomNode > nodes ; for ( int i = 0 ; i < children . size ( ) ; i ++ ) { if ( children . at ( i ) . toElement ( ) . tagName ( ) == tag ) { nodes << children . at ( i ) ; } } if ( nodes . isEmpty ( ) ) { _createChildNode ( parent , tag , name ) ; parent = parent . lastChild ( ) . toElement ( ) ; } else { int iNode = -1 ; for ( int n = 0 ; n < nodes . size ( ) ; n ++ ) { QString nodeName = nodes . at ( n ) . toElement ( ) . attribute ( QString ( " " ) ) ; if ( nodeName == name ) { iNode = n ; } } if ( iNode == -1 ) { _createChildNode ( parent , tag , name ) ; parent = parent . lastChild ( ) . toElement ( ) ; } else { parent = nodes . at ( iNode ) . toElement ( ) ; } } } return parent ; }
@details
 Sets and creates the specified address in the configuration document.
@details Sets and creates the specified address in the configuration document .
// Find child nodes of the specified tag type. // No node exists of the specified tag - create one... // Nodes exist of the specified tag - do we need a new one? // Find if the tag already exists with the name // No tag exists with the unique name - append one to the end. // Tag exists - move the parent pointer.