aboutsummaryrefslogtreecommitdiff
path: root/include/StringUtils.hpp
blob: 6df16dbfe1526e8698cd3016c7a738513e0778df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#pragma once

#include <string>
#include <functional>

namespace QuickMedia {
    // Return false to stop iterating
    using StringSplitCallback = std::function<bool(const char *str, size_t size)>;

    void string_split(const std::string &str, char delimiter, StringSplitCallback callback_func);
    // Returns the number of replaced substrings
    size_t string_replace_all(std::string &str, char old_char, char new_char);
    // Returns the number of replaced substrings
    size_t string_replace_all(std::string &str, char old_char, const std::string &new_str);
    // Returns the number of replaced substrings
    size_t string_replace_all(std::string &str, const std::string &old_str, const std::string &new_str);
    std::string strip(const std::string &str);
    bool string_starts_with(const std::string &str, const char *sub);
    bool string_ends_with(const std::string &str, const std::string &ends_with_str);
}