76 lines
3.3 KiB
C++
76 lines
3.3 KiB
C++
/*
|
|
* string_utils.h
|
|
*
|
|
* Created by Bob Polis on 27-06-2006.
|
|
* Copyright 2006-2015 Thalictrum. All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#ifndef _string_utils_
|
|
#define _string_utils_
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
#include <map>
|
|
#include <regex>
|
|
|
|
namespace sc {
|
|
|
|
std::vector<std::string> split (const std::string& str,
|
|
const std::string& sep);
|
|
|
|
std::vector<std::string> split (const std::string& str,
|
|
const std::regex& sep);
|
|
|
|
std::string join (const std::vector<std::string>& components,
|
|
const std::string& join);
|
|
|
|
std::string trim (const std::string& str,
|
|
const std::string& del = " ");
|
|
|
|
std::string str_replace (const std::string& what,
|
|
const std::string& replacement,
|
|
const std::string& target);
|
|
|
|
std::wstring replace_all (const std::wstring& what,
|
|
const std::wstring& replacement,
|
|
const std::wstring& target);
|
|
|
|
void replace_all (const std::string& what,
|
|
const std::string& replacement,
|
|
std::string& target);
|
|
|
|
bool file_exists (const std::string& path);
|
|
|
|
std::string file_get_contents (const std::string& path);
|
|
|
|
std::map<std::string, std::string> parse_ini_file (const std::string& path);
|
|
|
|
void create_dir (const std::string& path,
|
|
int mode = 0777);
|
|
|
|
std::string dirname (const std::string& path);
|
|
|
|
std::string basename (const std::string& path, bool remove_extension = false);
|
|
|
|
std::string replace_tilde (const std::string& path);
|
|
|
|
std::string filename_extension (const std::string& path);
|
|
|
|
std::string tool_path (const std::string& name);
|
|
|
|
std::string truncate (const std::string& str, unsigned int maxlen, int how = 0);
|
|
|
|
std::string lowercase (const std::string& str, const std::locale& loc);
|
|
|
|
std::string uppercase (const std::string& str, const std::locale& loc);
|
|
|
|
bool is_valid_utf8 (const std::string& str);
|
|
|
|
std::string real_path (const std::string& path);
|
|
|
|
std::string remove_accents (const std::string& text);
|
|
}
|
|
|
|
#endif // _string_utils_
|