ppsspp/base/stringutil.h

29 lines
577 B
C
Raw Normal View History

2012-03-24 23:39:19 +01:00
#pragma once
#include <stdlib.h>
#include <stdio.h>
#include <string>
2012-04-27 00:48:30 +02:00
#ifdef _MSC_VER
#pragma warning (disable:4996)
#endif
2012-03-31 11:16:13 +02:00
// Dumb wrapper around itoa, providing a buffer. Declare this on the stack.
2012-03-24 23:39:19 +01:00
class ITOA {
public:
2012-05-08 22:04:24 +02:00
char buffer[16];
const char *p(int i) {
sprintf(buffer, "%i", i);
return &buffer[0];
}
2012-03-24 23:39:19 +01:00
};
2012-03-31 11:16:13 +02:00
// Other simple string utilities.
2012-03-24 23:39:19 +01:00
inline bool endsWith(const std::string &str, const std::string &what) {
2012-05-08 22:04:24 +02:00
return str.substr(str.size() - what.size()) == what;
2012-03-31 11:16:13 +02:00
}
2012-03-27 22:54:58 +02:00
// highly unsafe and not recommended.
unsigned int parseHex(const char* _szValue);