mardi 28 avril 2020

How switch char* on std::string in my implementation of func?

How convert my function from const char* to string? I need it withot templates. Just rebuild my function pattern_founder(const char*, const char*) on pattern_founder(std::string, std::string). I trying to do it with iterators, but something went wrong. Thank you.

 static bool pattern_founder(const char* file_path_ptr, const char* pattern) noexcept
    {
        const char* supp_file_path_ptr = nullptr;
        const char* supp_pattern = nullptr;
        while (true) 
            if (*pattern == '*') {
                supp_file_path_ptr = file_path_ptr;
                supp_pattern = ++pattern;
            }
            else if (!*file_path_ptr)
                return !*pattern;
            else if (*file_path_ptr == *pattern || *pattern == '?') {
                ++file_path_ptr;
                ++pattern;
            }
            else if (supp_file_path_ptr) {
                file_path_ptr = ++supp_file_path_ptr;
                pattern = supp_pattern;
            }
            else 
                return false;
    }

Aucun commentaire:

Enregistrer un commentaire