XmlAttribute.cpp 1.2 KB

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