Rename bstring to BString for consistency
This commit is contained in:
parent
690cee7199
commit
fc9726b3ec
4
deps/ox/src/ox/mc/read.hpp
vendored
4
deps/ox/src/ox/mc/read.hpp
vendored
@ -51,7 +51,7 @@ class MetalClawReader {
|
||||
int op(const char*, T *val);
|
||||
|
||||
template<size_t L>
|
||||
int op(const char*, ox::bstring<L> *val);
|
||||
int op(const char*, ox::BString<L> *val);
|
||||
|
||||
size_t arrayLength(const char*);
|
||||
|
||||
@ -82,7 +82,7 @@ int MetalClawReader::op(const char*, T *val) {
|
||||
};
|
||||
|
||||
template<size_t L>
|
||||
int MetalClawReader::op(const char*, ox::bstring<L> *val) {
|
||||
int MetalClawReader::op(const char*, ox::BString<L> *val) {
|
||||
int err = 0;
|
||||
if (m_fieldPresence.get(m_field)) {
|
||||
// read the length
|
||||
|
4
deps/ox/src/ox/mc/test/tests.cpp
vendored
4
deps/ox/src/ox/mc/test/tests.cpp
vendored
@ -20,7 +20,7 @@ using namespace ox;
|
||||
struct TestStructNest {
|
||||
bool Bool = false;
|
||||
uint32_t Int = 0;
|
||||
bstring<32> String = "";
|
||||
BString<32> String = "";
|
||||
};
|
||||
|
||||
struct TestStruct {
|
||||
@ -34,7 +34,7 @@ struct TestStruct {
|
||||
int32_t Int6 = 0;
|
||||
int32_t Int7 = 0;
|
||||
int32_t Int8 = 0;
|
||||
bstring<32> String = "";
|
||||
BString<32> String = "";
|
||||
uint32_t List[4] = {0, 0, 0 , 0};
|
||||
TestStructNest EmptyStruct;
|
||||
TestStructNest Struct;
|
||||
|
4
deps/ox/src/ox/mc/write.hpp
vendored
4
deps/ox/src/ox/mc/write.hpp
vendored
@ -45,7 +45,7 @@ class MetalClawWriter {
|
||||
int op(const char*, T *val, size_t len);
|
||||
|
||||
template<size_t L>
|
||||
int op(const char*, ox::bstring<L> *val);
|
||||
int op(const char*, ox::BString<L> *val);
|
||||
|
||||
template<typename T>
|
||||
int op(const char*, T *val);
|
||||
@ -64,7 +64,7 @@ class MetalClawWriter {
|
||||
};
|
||||
|
||||
template<size_t L>
|
||||
int MetalClawWriter::op(const char*, ox::bstring<L> *val) {
|
||||
int MetalClawWriter::op(const char*, ox::BString<L> *val) {
|
||||
int err = 0;
|
||||
bool fieldSet = false;
|
||||
if (val->len()) {
|
||||
|
30
deps/ox/src/ox/std/string.hpp
vendored
30
deps/ox/src/ox/std/string.hpp
vendored
@ -16,20 +16,20 @@ namespace ox {
|
||||
|
||||
// Bounded String
|
||||
template<size_t buffLen>
|
||||
class bstring {
|
||||
class BString {
|
||||
private:
|
||||
uint8_t m_buff[buffLen];
|
||||
|
||||
public:
|
||||
bstring();
|
||||
BString();
|
||||
|
||||
bstring(const char *str);
|
||||
BString(const char *str);
|
||||
|
||||
const bstring &operator=(const char *str);
|
||||
const BString &operator=(const char *str);
|
||||
|
||||
const bstring &operator=(char *str);
|
||||
const BString &operator=(char *str);
|
||||
|
||||
bool operator==(const bstring &other);
|
||||
bool operator==(const BString &other);
|
||||
|
||||
char *data();
|
||||
|
||||
@ -50,17 +50,17 @@ class bstring {
|
||||
};
|
||||
|
||||
template<size_t size>
|
||||
bstring<size>::bstring() {
|
||||
BString<size>::BString() {
|
||||
m_buff[0] = 0;
|
||||
}
|
||||
|
||||
template<size_t size>
|
||||
bstring<size>::bstring(const char *str) {
|
||||
BString<size>::BString(const char *str) {
|
||||
*this = str;
|
||||
}
|
||||
|
||||
template<size_t size>
|
||||
const bstring<size> &bstring<size>::operator=(const char *str) {
|
||||
const BString<size> &BString<size>::operator=(const char *str) {
|
||||
size_t strLen = ox_strlen(str) + 1;
|
||||
if (cap() < strLen) {
|
||||
strLen = cap();
|
||||
@ -72,12 +72,12 @@ const bstring<size> &bstring<size>::operator=(const char *str) {
|
||||
}
|
||||
|
||||
template<size_t size>
|
||||
const bstring<size> &bstring<size>::operator=(char *str) {
|
||||
const BString<size> &BString<size>::operator=(char *str) {
|
||||
return *this = (const char*) str;
|
||||
}
|
||||
|
||||
template<size_t buffLen>
|
||||
bool bstring<buffLen>::operator==(const bstring<buffLen> &other) {
|
||||
bool BString<buffLen>::operator==(const BString<buffLen> &other) {
|
||||
bool retval = true;
|
||||
size_t i = 0;
|
||||
while (i < buffLen && (m_buff[i] || other.m_buff[i])) {
|
||||
@ -91,12 +91,12 @@ bool bstring<buffLen>::operator==(const bstring<buffLen> &other) {
|
||||
}
|
||||
|
||||
template<size_t buffLen>
|
||||
char *bstring<buffLen>::data() {
|
||||
char *BString<buffLen>::data() {
|
||||
return (char*) m_buff;
|
||||
}
|
||||
|
||||
template<size_t buffLen>
|
||||
size_t bstring<buffLen>::len() {
|
||||
size_t BString<buffLen>::len() {
|
||||
size_t length = 0;
|
||||
for (size_t i = 0; i < buffLen; i++) {
|
||||
uint8_t b = m_buff[i];
|
||||
@ -114,14 +114,14 @@ size_t bstring<buffLen>::len() {
|
||||
}
|
||||
|
||||
template<size_t buffLen>
|
||||
size_t bstring<buffLen>::size() {
|
||||
size_t BString<buffLen>::size() {
|
||||
size_t i;
|
||||
for (i = 0; i < buffLen && m_buff[i]; i++);
|
||||
return i + 1; // add one for null terminator
|
||||
}
|
||||
|
||||
template<size_t buffLen>
|
||||
size_t bstring<buffLen>::cap() {
|
||||
size_t BString<buffLen>::cap() {
|
||||
return buffLen;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user