summaryrefslogtreecommitdiff
path: root/bot/src/utils/string.hpp
blob: c1f012125f108edddf23f2d678edf679483928c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once

#include <sstream>
#include <string>
#include <vector>

namespace bot {
  namespace utils {
    namespace string {
      std::vector<std::string> split_text(const std::string &text,
                                          char delimiter);
      std::string join_vector(const std::vector<std::string> &vec,
                              char delimiter);
      std::string join_vector(const std::vector<std::string> &vec);

      template <typename T>
      std::string str(T begin, T end, char delimiter) {
        std::stringstream ss;
        bool first = true;

        for (; begin != end; begin++) {
          if (!first) ss << delimiter;
          ss << *begin;
          first = false;
        }
        return ss.str();
      }

      bool string_contains_sql_injection(const std::string &input);

      std::vector<std::vector<std::string>> separate_by_length(
          const std::vector<std::string> &vector, const int &max_length);
    }
  }
}