XmlAttribute.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-23
  6. * Changed: 2023-05-17
  7. *
  8. * */
  9. #include <ls-std/core/evaluator/EmptyStringArgumentEvaluator.hpp>
  10. #include <ls-std/io/xml/XmlAttribute.hpp>
  11. using ls::std::core::Class;
  12. using ls::std::core::EmptyStringArgumentEvaluator;
  13. using ls::std::io::XmlAttribute;
  14. using std::string;
  15. XmlAttribute::XmlAttribute(const string &_name) : Class("XmlAttribute")
  16. {
  17. this->_assignName(_name);
  18. }
  19. XmlAttribute::~XmlAttribute() noexcept = default;
  20. string XmlAttribute::getName() const
  21. {
  22. return this->name;
  23. }
  24. string XmlAttribute::getValue() const
  25. {
  26. return this->value;
  27. }
  28. void XmlAttribute::setName(const string &_name)
  29. {
  30. this->_assignName(_name);
  31. }
  32. void XmlAttribute::setValue(const string &_value)
  33. {
  34. this->_assignValue(_value);
  35. }
  36. string XmlAttribute::toXml() const
  37. {
  38. return this->name + "=\"" + this->value + "\"";
  39. }
  40. void XmlAttribute::_assignName(const string &_name)
  41. {
  42. EmptyStringArgumentEvaluator{_name, "xml attribute name is empty!"}.evaluate();
  43. this->name = _name;
  44. }
  45. void XmlAttribute::_assignValue(const string &_value)
  46. {
  47. EmptyStringArgumentEvaluator{_value, "xml attribute value is empty!"}.evaluate();
  48. this->value = _value;
  49. }