XmlAttribute.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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-04
  7. *
  8. * */
  9. #include <ls-std/core/exception/IllegalArgumentException.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() = 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. if (_name.empty())
  39. {
  40. throw ls::std::core::IllegalArgumentException{};
  41. }
  42. this->name = _name;
  43. }
  44. void ls::std::io::XmlAttribute::_assignValue(const ::std::string &_value)
  45. {
  46. if (_value.empty())
  47. {
  48. throw ls::std::core::IllegalArgumentException{};
  49. }
  50. this->value = _value;
  51. }