1 #ifndef OPENMW_ESM_COMMON_H
2 #define OPENMW_ESM_COMMON_H
20 template<
template<
size_t>
class DERIVED,
size_t SIZE>
30 template<
size_t OTHER_SIZE>
33 size_t other_len = strnlen(str, OTHER_SIZE);
34 if (other_len != this->
length())
36 return std::strncmp(
self()->ro_data(), str,
size) == 0;
40 char const*
const data =
self()->ro_data();
41 for(
size_t i = 0; i <
size; ++i)
43 if(data[i] != str[i])
return false;
44 else if(data[i] ==
'\0')
return true;
46 return str[
size] ==
'\0';
48 bool operator!=(
const char*
const str)
const {
return !( (*this) == str ); }
52 return (*
this) == str.c_str();
54 bool operator!=(
const std::string& str)
const {
return !( (*this) == str ); }
57 size_t length()
const {
return strnlen(
self()->ro_data(),
size); }
58 std::string
toString()
const {
return std::string(
self()->ro_data(), this->
length()); }
60 void assign(
const std::string& value) { std::strncpy(
self()->rw_data(), value.c_str(),
size); }
63 DERIVED<size>
const*
self()
const
65 return static_cast<DERIVED<size> const*
>(
this);
72 return const_cast<DERIVED<size>*
>(
static_cast<FIXED_STRING_BASE const*
>(
this)->
self());
77 template <
size_t SIZE>
96 using FIXED_STRING_BASE::operator==;
97 using FIXED_STRING_BASE::operator!=;
99 bool operator==(uint32_t v)
const {
return v == intval; }
FIXED_STRING< 256 > NAME256
Definition: esmcommon.hpp:109
bool operator!=(const std::string &str) const
Definition: esmcommon.hpp:54
FIXED_STRING< 4 > NAME
Definition: esmcommon.hpp:106
Definition: esmcommon.hpp:89
bool operator!=(const char *const str) const
Definition: esmcommon.hpp:48
FIXED_STRING< 32 > NAME32
Definition: esmcommon.hpp:107
Definition: esmcommon.hpp:78
Version
Definition: esmcommon.hpp:12
uint32_t leftRec
Definition: esmcommon.hpp:119
size_t length() const
Definition: esmcommon.hpp:57
FIXED_STRING< 64 > NAME64
Definition: esmcommon.hpp:108
bool operator!=(uint32_t v) const
Definition: esmcommon.hpp:100
char data[SIZE]
Definition: esmcommon.hpp:80
NAME recName
Definition: esmcommon.hpp:121
char * rw_data()
Definition: esmcommon.hpp:103
bool operator==(const char *const str) const
Definition: esmcommon.hpp:38
Definition: esmcommon.hpp:21
std::string filename
Definition: esmcommon.hpp:118
size_t data_size() const
Definition: esmcommon.hpp:56
char const * ro_data() const
Definition: esmcommon.hpp:82
bool subCached
Definition: esmcommon.hpp:128
std::string toString() const
Definition: esmcommon.hpp:58
Definition: esmcommon.hpp:116
Definition: esmcommon.hpp:15
NAME subName
Definition: esmcommon.hpp:121
int index
Definition: esmcommon.hpp:125
Definition: esmcommon.hpp:28
uint32_t leftSub
Definition: esmcommon.hpp:119
size_t leftFile
Definition: esmcommon.hpp:120
char const * ro_data() const
Definition: esmcommon.hpp:102
Definition: esmcommon.hpp:14
bool operator==(uint32_t v) const
Definition: esmcommon.hpp:99
uint32_t intval
Definition: esmcommon.hpp:93
size_t filePos
Definition: esmcommon.hpp:132
void assign(const std::string &value)
Definition: esmcommon.hpp:60
bool operator==(char const (&str)[OTHER_SIZE]) const
Definition: esmcommon.hpp:31
char * rw_data()
Definition: esmcommon.hpp:83
void clear()
Definition: esmcommon.hpp:61
bool operator==(const std::string &str) const
Definition: esmcommon.hpp:50