ConstString

This commit is contained in:
Henrik Rydgard 2012-08-13 20:11:24 +02:00
parent b8cafe1561
commit 45949ac008
2 changed files with 23 additions and 0 deletions

View File

@ -34,3 +34,22 @@ inline void StringToHexString(const std::string &data, std::string *output) {
// highly unsafe and not recommended.
unsigned int parseHex(const char* _szValue);
// Suitable for inserting into maps, unlike char*, and cheaper than std::string.
// Strings must be constant and preferably be stored in the read-only part
// of the binary.
class ConstString {
public:
ConstString(const char *ptr) {
ptr_ = ptr;
}
bool operator <(const ConstString &other) const {
return strcmp(ptr_, other.ptr_) < 0;
}
bool operator ==(const ConstString &other) const {
return ptr_ == other.ptr_ || !strcmp(ptr_, other.ptr_);
}
private:
const char *ptr_;
};

View File

@ -16,6 +16,7 @@
#endif
#endif
#include <map>
#include <time.h>
#include "gfx/gl_lost_manager.h"
@ -54,6 +55,9 @@ struct GLSLProgram : public GfxResourceHolder {
void GLLost();
};
// C API, old skool
GLSLProgram *glsl_create(const char *vshader_file, const char *fshader_file);
void glsl_destroy(GLSLProgram *program);