iw4x-client/src/Utils/Utils.hpp

51 lines
1.2 KiB
C++
Raw Normal View History

2015-12-23 08:45:53 -05:00
namespace Utils
{
const char *VA(const char *fmt, ...);
std::string StrToLower(std::string input);
2015-12-24 08:28:08 -05:00
bool EndsWith(const char* heystack, const char* needle);
2015-12-25 15:42:35 -05:00
std::vector<std::string> Explode(const std::string& str, char delim);
2015-12-24 11:30:36 -05:00
void Replace(std::string &string, std::string find, std::string replace);
unsigned int OneAtATime(char *key, size_t len);
2016-01-01 14:01:19 -05:00
std::string &LTrim(std::string &s);
std::string &RTrim(std::string &s);
std::string &Trim(std::string &s);
2015-12-24 11:30:36 -05:00
class InfoString
{
public:
InfoString() {};
InfoString(std::string buffer) :InfoString() { this->Parse(buffer); };
2015-12-27 22:02:30 -05:00
InfoString(const InfoString &obj) { this->KeyValuePairs = obj.KeyValuePairs; };
2015-12-24 11:30:36 -05:00
void Set(std::string key, std::string value);
std::string Get(std::string key);
std::string Build();
2015-12-25 15:42:35 -05:00
void Dump();
2015-12-24 11:30:36 -05:00
private:
std::map<std::string, std::string> KeyValuePairs;
void Parse(std::string buffer);
};
2015-12-30 09:37:53 -05:00
2016-01-01 22:51:08 -05:00
template <typename T> void Merge(std::vector<T> &target, T* source, size_t length)
{
if (source)
{
for (size_t i = 0; i < length; i++)
{
target.push_back(source[i]);
}
}
}
2015-12-30 09:37:53 -05:00
template <typename T> void Merge(std::vector<T> &target, std::vector<T> &source)
{
for (auto &entry : source)
{
target.push_back(entry);
}
}
2015-12-23 08:45:53 -05:00
}