KHTML
variablereference.cpp
Go to the documentation of this file.
00001 /* 00002 * variablereference.cc - Copyright 2005 Frerich Raabe <raabe@kde.org> 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions 00006 * are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 00014 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00015 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00016 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00017 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 00018 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00019 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00020 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00021 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00022 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00023 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 */ 00025 #include "variablereference.h" 00026 #include <dom_stringimpl.h> 00027 using namespace khtml; 00028 using namespace khtml::XPath; 00029 00030 VariableReference::VariableReference( const DOM::DOMString &name ) 00031 : m_name( name ) 00032 { 00033 } 00034 00035 bool VariableReference::isConstant() const 00036 { 00037 return false; 00038 } 00039 00040 QString VariableReference::dump() const 00041 { 00042 return QString() + "<variablereference name=\"" + m_name.string() + "\"/>"; 00043 } 00044 00045 Value VariableReference::doEvaluate() const 00046 { 00047 QHash<DOM::DOMString, DOM::DOMString>& bindings = evaluationContext().variableBindings; 00048 if ( !bindings.contains( m_name ) ) { 00049 // XXX What to do if an unknown variable is referenced? 00050 return Value( DOMString() ); 00051 } 00052 return Value( bindings[ m_name ] ); 00053 } 00054
KDE 4.6 API Reference