Digitalisierte Elektroverteilung zur permanenten Verbraucherüberwachung
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CustomStringUtilities.cpp 690B

123456789101112131415161718192021
  1. #include "CustomStringUtilities.h"
  2. #include <iostream>
  3. const char* CustomStringUtilities::typeOfWhitespacesReturn = " \t\n\r\f\v";
  4. const char* CustomStringUtilities::typeOfWhitespaces = " \t\r\f\v";
  5. void CustomStringUtilities::removeAllWhitespaces(std::string& str, bool trimReturn) {
  6. const char* whitespaces = trimReturn ? typeOfWhitespacesReturn : typeOfWhitespaces;
  7. size_t pos, offset = 0;
  8. while ((pos = str.find_first_of(whitespaces, offset)) != std::string::npos) {
  9. str.erase(pos, 1);
  10. offset = pos;
  11. }
  12. }
  13. void CustomStringUtilities::trim(std::string& str) {
  14. str.erase(str.find_last_not_of(typeOfWhitespaces) + 1);
  15. str.erase(0, str.find_first_not_of(typeOfWhitespaces));
  16. }