strat: use m_ for member variables
This commit is contained in:
@@ -23,7 +23,7 @@ namespace ams::kvdb {
|
||||
class BoundedString {
|
||||
static_assert(N > 0, "BoundedString requires non-zero backing buffer!");
|
||||
private:
|
||||
char buffer[N];
|
||||
char m_buffer[N];
|
||||
private:
|
||||
/* Utility. */
|
||||
static inline void CheckLength(size_t len) {
|
||||
@@ -32,7 +32,7 @@ namespace ams::kvdb {
|
||||
public:
|
||||
/* Constructors. */
|
||||
constexpr BoundedString() {
|
||||
buffer[0] = 0;
|
||||
m_buffer[0] = 0;
|
||||
}
|
||||
|
||||
explicit constexpr BoundedString(const char *s) {
|
||||
@@ -49,8 +49,8 @@ namespace ams::kvdb {
|
||||
|
||||
std::va_list args;
|
||||
va_start(args, format);
|
||||
CheckLength(util::VSNPrintf(string.buffer, N, format, args));
|
||||
string.buffer[N - 1] = 0;
|
||||
CheckLength(util::VSNPrintf(string.m_buffer, N, format, args));
|
||||
string.m_buffer[N - 1] = 0;
|
||||
va_end(args);
|
||||
|
||||
return string;
|
||||
@@ -58,30 +58,30 @@ namespace ams::kvdb {
|
||||
|
||||
/* Getters. */
|
||||
size_t GetLength() const {
|
||||
return util::Strnlen(this->buffer, N);
|
||||
return util::Strnlen(m_buffer, N);
|
||||
}
|
||||
|
||||
const char *Get() const {
|
||||
return this->buffer;
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
operator const char *() const {
|
||||
return this->buffer;
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
/* Setters. */
|
||||
void Set(const char *s) {
|
||||
/* Ensure string can fit in our buffer. */
|
||||
CheckLength(util::Strnlen(s, N));
|
||||
std::strncpy(this->buffer, s, N);
|
||||
this->buffer[N - 1] = 0;
|
||||
std::strncpy(m_buffer, s, N);
|
||||
m_buffer[N - 1] = 0;
|
||||
}
|
||||
|
||||
void SetFormat(const char *format, ...) __attribute__((format (printf, 2, 3))) {
|
||||
/* Format into the buffer, abort if too large. */
|
||||
std::va_list args;
|
||||
va_start(args, format);
|
||||
CheckLength(util::VSNPrintf(this->buffer, N, format, args));
|
||||
CheckLength(util::VSNPrintf(m_buffer, N, format, args));
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
@@ -89,21 +89,21 @@ namespace ams::kvdb {
|
||||
void Append(const char *s) {
|
||||
const size_t length = GetLength();
|
||||
CheckLength(length + util::Strnlen(s, N));
|
||||
std::strncat(this->buffer, s, N - length - 1);
|
||||
std::strncat(m_buffer, s, N - length - 1);
|
||||
}
|
||||
|
||||
void Append(char c) {
|
||||
const size_t length = GetLength();
|
||||
CheckLength(length + 1);
|
||||
this->buffer[length] = c;
|
||||
this->buffer[length + 1] = 0;
|
||||
m_buffer[length] = c;
|
||||
m_buffer[length + 1] = 0;
|
||||
}
|
||||
|
||||
void AppendFormat(const char *format, ...) __attribute__((format (printf, 2, 3))) {
|
||||
const size_t length = GetLength();
|
||||
std::va_list args;
|
||||
va_start(args, format);
|
||||
CheckLength(util::VSNPrintf(this->buffer + length, N - length, format, args) + length);
|
||||
CheckLength(util::VSNPrintf(m_buffer + length, N - length, format, args) + length);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
@@ -113,19 +113,19 @@ namespace ams::kvdb {
|
||||
AMS_ABORT_UNLESS(offset + length <= GetLength());
|
||||
AMS_ABORT_UNLESS(dst_size > length);
|
||||
/* Copy substring to dst. */
|
||||
std::strncpy(dst, this->buffer + offset, length);
|
||||
std::strncpy(dst, m_buffer + offset, length);
|
||||
dst[length] = 0;
|
||||
}
|
||||
|
||||
BoundedString<N> GetSubstring(size_t offset, size_t length) const {
|
||||
BoundedString<N> string;
|
||||
GetSubstring(string.buffer, N, offset, length);
|
||||
GetSubstring(string.m_buffer, N, offset, length);
|
||||
return string;
|
||||
}
|
||||
|
||||
/* Comparison. */
|
||||
constexpr bool operator==(const BoundedString<N> &rhs) const {
|
||||
return std::strncmp(this->buffer, rhs.buffer, N) == 0;
|
||||
return std::strncmp(m_buffer, rhs.m_buffer, N) == 0;
|
||||
}
|
||||
|
||||
constexpr bool operator!=(const BoundedString<N> &rhs) const {
|
||||
@@ -133,7 +133,7 @@ namespace ams::kvdb {
|
||||
}
|
||||
|
||||
bool EndsWith(const char *s, size_t offset) const {
|
||||
return std::strncmp(this->buffer + offset, s, N - offset) == 0;
|
||||
return std::strncmp(m_buffer + offset, s, N - offset) == 0;
|
||||
}
|
||||
|
||||
bool EndsWith(const char *s) const {
|
||||
|
||||
Reference in New Issue
Block a user