XmlAttribute.cpp 1.3 KB

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