XMLDeclaration.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-29
  6. * Changed: 2020-11-06
  7. *
  8. * */
  9. #include "../../../../include/ls_std/io/xml/XMLDeclaration.hpp"
  10. ls_std::XMLDeclaration::XMLDeclaration(std::string _version) :
  11. Class("XMLDeclaration")
  12. {
  13. this->version.setValue(std::move(_version));
  14. }
  15. std::string ls_std::XMLDeclaration::getEncoding()
  16. {
  17. return this->encoding.getValue();
  18. }
  19. std::string ls_std::XMLDeclaration::getStandalone()
  20. {
  21. return this->standalone.getValue();
  22. }
  23. std::string ls_std::XMLDeclaration::getVersion()
  24. {
  25. return this->version.getValue();
  26. }
  27. void ls_std::XMLDeclaration::setEncoding(std::string _encoding)
  28. {
  29. this->encoding.setValue(std::move(_encoding));
  30. }
  31. void ls_std::XMLDeclaration::setStandalone(std::string _standalone)
  32. {
  33. this->standalone.setValue(std::move(_standalone));
  34. }
  35. void ls_std::XMLDeclaration::setVersion(std::string _version)
  36. {
  37. this->version.setValue(std::move(_version));
  38. }
  39. std::string ls_std::XMLDeclaration::toXML()
  40. {
  41. std::string declaration = "<?xml";
  42. declaration += ls_std::XMLDeclaration::_toXMLAttribute(this->version);
  43. declaration += ls_std::XMLDeclaration::_toXMLAttribute(this->encoding);
  44. declaration += ls_std::XMLDeclaration::_toXMLAttribute(this->standalone);
  45. return declaration + " ?>";
  46. }
  47. std::string ls_std::XMLDeclaration::_toXMLAttribute(ls_std::XMLAttribute _attribute)
  48. {
  49. std::string xmlString {};
  50. if(!_attribute.getValue().empty()) {
  51. xmlString = " " + _attribute.toXML();
  52. }
  53. return xmlString;
  54. }