dropshell/src/utils/utils.hpp
2025-04-26 22:35:43 +12:00

36 lines
1.1 KiB
C++

#pragma once
#include <string>
#include <vector>
namespace dropshell {
/**
* Prints a formatted title surrounded by a box of dashes.
*
* @param title The title string to display
*/
void maketitle(const std::string& title);
bool replace_line_in_file(const std::string& file_path, const std::string& search_string, const std::string& replacement_line);
// utility functions
std::string trim(std::string str);
std::string dequote(std::string str);
std::string quote(std::string str);
std::string multi2string(std::vector<std::string> values);
std::vector<std::string> string2multi(std::string values);
std::vector<std::string> split(const std::string& str, const std::string& delimiter);
int str2int(const std::string & str);
void recursive_copy(const std::string & source, const std::string & destination);
void ensure_directories_exist(std::vector<std::string> directories);
// KMP algorithm
std::vector<int> search(const std::string &pat, const std::string &txt);
int count_substring(const std::string &substring, const std::string &text);
} // namespace dropshell