String.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-14
  6. * Changed: 2020-08-18
  7. *
  8. * */
  9. #ifndef STRING_HPP
  10. #define STRING_HPP
  11. #include "IBoxing.hpp"
  12. #include "../base/Class.hpp"
  13. #include <string>
  14. namespace ls_std {
  15. class String : public Class, IBoxing {
  16. public:
  17. String();
  18. explicit String(std::string _value);
  19. ~String() = default;
  20. // conversion operator
  21. operator const char*() const; // do not make explicit! FIXME: is that save?
  22. operator std::string() const; // do not make explicit!
  23. // assignment operators
  24. String& operator=(std::string _value);
  25. // arithmetic operators
  26. std::string operator+(String _string) const;
  27. std::string operator+(const std::string& _string) const;
  28. std::string operator+(const char* _string) const;
  29. std::string operator-(int _number);
  30. // compound operators
  31. String& operator+=(String _string);
  32. String& operator+=(const std::string& _text);
  33. // comparison operators
  34. bool operator==(String _string);
  35. bool operator==(const std::string& _value);
  36. bool operator==(const char* _value);
  37. bool operator!=(String _string);
  38. bool operator!=(const std::string& _value);
  39. bool operator!=(const char* _value);
  40. // implementation
  41. void parse(std::string _parseText) override;
  42. std::string toString() override;
  43. // additional functionality
  44. bool contains(const std::string& _text);
  45. bool endsWith(const std::string& _text);
  46. bool equalsIgnoreCase(String _string);
  47. bool equalsIgnoreCase(std::string _text);
  48. std::string reverse();
  49. bool startsWith(const std::string& _text);
  50. std::string toLowerCase();
  51. std::string toUpperCase();
  52. private:
  53. std::string value {};
  54. };
  55. }
  56. #endif