2013-05-05 09:21:30 +00:00
|
|
|
#ifdef NALL_STRING_INTERNAL_HPP
|
|
|
|
|
|
|
|
namespace nall {
|
|
|
|
|
|
|
|
struct stringref {
|
|
|
|
operator const char*() const {
|
|
|
|
return _data;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* data() const {
|
|
|
|
return _data;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned size() const {
|
|
|
|
if(!_initialized) {
|
2013-07-29 09:42:45 +00:00
|
|
|
_initialized = true;
|
2013-05-05 09:21:30 +00:00
|
|
|
_size = strlen(_data);
|
|
|
|
}
|
|
|
|
return _size;
|
|
|
|
}
|
|
|
|
|
|
|
|
stringref() = delete;
|
|
|
|
stringref(const stringref& source) = delete;
|
|
|
|
stringref(stringref&& source) = delete;
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
stringref(const char* source) {
|
|
|
|
_data = source;
|
|
|
|
_initialized = false;
|
2013-05-05 09:21:30 +00:00
|
|
|
}
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
stringref(const string& source) {
|
|
|
|
_data = source.data();
|
|
|
|
_size = source.size();
|
|
|
|
_initialized = true;
|
2013-05-05 09:21:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
const char* _data;
|
|
|
|
mutable unsigned _size;
|
|
|
|
mutable bool _initialized;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|