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: 2022-05-11
  7. *
  8. * */
  9. #include <ls_std/io/xml/XmlAttribute.hpp>
  10. #include <ls_std/core/exception/IllegalArgumentException.hpp>
  11. ls::std::io::XmlAttribute::XmlAttribute(const ::std::string& _name) : ls::std::core::Class("XmlAttribute")
  12. {
  13. this->_assignName(_name);
  14. }
  15. std::string ls::std::io::XmlAttribute::getName()
  16. {
  17. return this->name;
  18. }
  19. std::string ls::std::io::XmlAttribute::getValue()
  20. {
  21. return this->value;
  22. }
  23. void ls::std::io::XmlAttribute::setName(const ::std::string& _name)
  24. {
  25. this->_assignName(_name);
  26. }
  27. void ls::std::io::XmlAttribute::setValue(const ::std::string& _value)
  28. {
  29. this->_assignValue(_value);
  30. }
  31. std::string ls::std::io::XmlAttribute::toXml()
  32. {
  33. return this->name + "=\"" + this->value + "\"";
  34. }
  35. void ls::std::io::XmlAttribute::_assignName(const ::std::string &_name)
  36. {
  37. if (_name.empty())
  38. {
  39. throw ls::std::core::IllegalArgumentException{};
  40. }
  41. this->name = _name;
  42. }
  43. void ls::std::io::XmlAttribute::_assignValue(const ::std::string &_value)
  44. {
  45. if (_value.empty())
  46. {
  47. throw ls::std::core::IllegalArgumentException{};
  48. }
  49. this->value = _value;
  50. }