00001 #include "SDXAttribute.h" 00002 #include "SDXContentHandler.h" 00003 00004 using namespace std; 00005 using namespace SDX; 00006 00007 Attribute::Attribute(Attribute& other){ 00008 m_name = other.m_name; 00009 m_value = other.m_value; 00010 m_isNamedAttribute = !m_name.empty(); 00011 } 00012 00013 Attribute::Attribute(Attribute* other){ 00014 m_name = other->m_name; 00015 m_value = other->m_value; 00016 m_isNamedAttribute = !m_name.empty(); 00017 } 00018 00019 Attribute::Attribute(std::string value) : 00020 m_isNamedAttribute(false), 00021 m_value(value) 00022 {} 00023 00024 Attribute::Attribute(string name, string value) : 00025 m_name(name), 00026 m_value(value) 00027 { 00028 m_isNamedAttribute = !m_name.empty(); 00029 } 00030 00031 bool Attribute::isNamedAttribute(){ 00032 return m_isNamedAttribute; 00033 } 00034 00035 std::string Attribute::getName(){ 00036 if(m_isNamedAttribute) 00037 return m_name; 00038 else 00039 return m_value; 00040 } 00041 00042 bool Attribute::getValue(std::string* value){ 00043 if(!value) 00044 return false; 00045 00046 *value = m_value; 00047 return true; 00048 } 00049 00050 void Attribute::sendToContentHandler(ContentHandler* contentHandler){ 00051 contentHandler->writeAttribute(m_name, m_value); 00052 }
1.5.8