#ifndef Attribute_h
#define Attribute_h
#include "QualifiedName.h"
namespace WebCore {
class Attribute {
public:
Attribute(const QualifiedName& name, const AtomicString& value)
: m_name(name)
, m_value(value)
{
}
const AtomicString& value() const { return m_value; }
static ptrdiff_t valueMemoryOffset() { return OBJECT_OFFSETOF(Attribute, m_value); }
const AtomicString& prefix() const { return m_name.prefix(); }
const AtomicString& localName() const { return m_name.localName(); }
const AtomicString& namespaceURI() const { return m_name.namespaceURI(); }
const QualifiedName& name() const { return m_name; }
static ptrdiff_t nameMemoryOffset() { return OBJECT_OFFSETOF(Attribute, m_name); }
bool isEmpty() const { return m_value.isEmpty(); }
static bool nameMatchesFilter(const QualifiedName&, const AtomicString& filterPrefix, const AtomicString& filterLocalName, const AtomicString& filterNamespaceURI);
bool matches(const AtomicString& prefix, const AtomicString& localName, const AtomicString& namespaceURI) const;
void setValue(const AtomicString& value) { m_value = value; }
void setPrefix(const AtomicString& prefix) { m_name.setPrefix(prefix); }
void parserSetName(const QualifiedName& name) { m_name = name; }
#if COMPILER(MSVC)
Attribute();
#endif
private:
QualifiedName m_name;
AtomicString m_value;
};
inline bool Attribute::nameMatchesFilter(const QualifiedName& name, const AtomicString& filterPrefix, const AtomicString& filterLocalName, const AtomicString& filterNamespaceURI)
{
if (filterLocalName != name.localName())
return false;
return filterPrefix == starAtom || filterNamespaceURI == name.namespaceURI();
}
inline bool Attribute::matches(const AtomicString& prefix, const AtomicString& localName, const AtomicString& namespaceURI) const
{
return nameMatchesFilter(m_name, prefix, localName, namespaceURI);
}
}
#endif // Attribute_h