funcs.cpp 921 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "funcs.h"
  2. #include "HTTPheaders.h"
  3. QString http::HTML_PAGE;
  4. void funcs::createHtmlPage(bool no_favicon)
  5. {
  6. http::HTML_PAGE = http::HTML_PAGE_SRC_1;
  7. if (no_favicon) {
  8. http::HTML_PAGE += http::NO_FAVICON;
  9. } else {
  10. http::HTML_PAGE += http::FAVICON;
  11. }
  12. http::HTML_PAGE += http::HTML_PAGE_SRC_2;
  13. }
  14. QString funcs::getValue(const QString &string, const QString &key)
  15. {
  16. if (key.isEmpty())
  17. return QString();
  18. const QString keyPattern = key + "=";
  19. size_t valueStart = string.indexOf(keyPattern);
  20. if (valueStart == std::string::npos) {
  21. return QString();
  22. }
  23. valueStart += keyPattern.length();
  24. size_t valueEnd = string.indexOf(' ', valueStart);
  25. if (valueEnd == std::string::npos) {
  26. valueEnd = string.size();
  27. }
  28. std::string result = string.toStdString().substr(valueStart, valueEnd - valueStart);
  29. return result.c_str();
  30. }