JSON file changes
This commit is contained in:
1 parent
9cd8381845
commit
a87ce0bab7
5 files changed
+105
-46
No files matched your search
+38
-13
@@ -107,27 +107,31 @@ namespace coreutils {
|
||||
setSize(value.getLength());
|
||||
memcpy(data, value.getData(), value.getLength());
|
||||
length = value.getLength();
|
||||
onChange();
|
||||
return *this;
|
||||
}
|
||||
|
||||
MString &MString::operator=(coreutils::ZString value) {
|
||||
setSize(value.getLength());
|
||||
memcpy(data, value.getData(), value.getLength());
|
||||
length = value.getLength();
|
||||
return *this;
|
||||
}
|
||||
|
||||
MString &MString::operator=(std::string value) {
|
||||
setSize(value.length());
|
||||
memcpy(data, value.c_str(), value.length());
|
||||
length = value.length();
|
||||
return *this;
|
||||
MString &MString::operator=(coreutils::ZString value) {
|
||||
setSize(value.getLength());
|
||||
memcpy(data, value.getData(), value.getLength());
|
||||
length = value.getLength();
|
||||
onChange();
|
||||
return *this;
|
||||
}
|
||||
|
||||
MString &MString::operator=(std::string value) {
|
||||
setSize(value.length());
|
||||
memcpy(data, value.c_str(), value.length());
|
||||
length = value.length();
|
||||
onChange();
|
||||
return *this;
|
||||
}
|
||||
|
||||
MString &MString::operator=(const char *value) {
|
||||
int len = strlen(value);
|
||||
setSize(len);
|
||||
memcpy(data, value, len);
|
||||
onChange();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -135,6 +139,7 @@ namespace coreutils {
|
||||
int len = 1;
|
||||
setSize(1);
|
||||
*data = value;
|
||||
onChange();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -146,6 +151,7 @@ namespace coreutils {
|
||||
setSize(temp.length());
|
||||
memcpy(this->data, (char *)temp.data(), temp.length());
|
||||
cursor = this->data;
|
||||
onChange();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -154,6 +160,7 @@ namespace coreutils {
|
||||
setSize(temp.length());
|
||||
memcpy(this->data, (char *)temp.data(), temp.length());
|
||||
cursor = this->data;
|
||||
onChange();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -162,6 +169,7 @@ namespace coreutils {
|
||||
int len = strlen(value);
|
||||
setSize(len + length);
|
||||
memcpy(data + temp, value, len);
|
||||
onChange();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -170,6 +178,7 @@ namespace coreutils {
|
||||
temp << value;
|
||||
MString temp2 = temp.str();
|
||||
write(temp2);
|
||||
onChange();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -186,12 +195,14 @@ namespace coreutils {
|
||||
int len = length + zstring.getLength();
|
||||
setSize(len);
|
||||
memcpy(data + temp, zstring.getData(), zstring.getLength());
|
||||
onChange();
|
||||
return *this;
|
||||
}
|
||||
|
||||
MString &MString::operator<<(char value) {
|
||||
setSize(length + 1);
|
||||
data[length - 1] = value;
|
||||
onChange();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -204,12 +215,17 @@ namespace coreutils {
|
||||
std::cout << "xxx" << std::endl;
|
||||
return *this;
|
||||
}
|
||||
|
||||
MString &operator<<(std::ostream &out) {
|
||||
*this << out;
|
||||
}
|
||||
|
||||
void MString::insert(char ch, int offset) {
|
||||
setSize(length + 1);
|
||||
for (int ix = length; ix >= offset; ix--)
|
||||
getData()[ix + 1] = getData()[ix];
|
||||
data[offset] = ch;
|
||||
onChange();
|
||||
}
|
||||
|
||||
void MString::insert(ZString value, int offset) {
|
||||
@@ -217,6 +233,7 @@ namespace coreutils {
|
||||
for (int ix = length; ix >= offset; ix--)
|
||||
getData()[ix] = getData()[ix - value.getLength()];
|
||||
std::memcpy(data + offset, value.getData(), value.getLength());
|
||||
onChange();
|
||||
}
|
||||
|
||||
// void MString::insert(std::string value, int offset) {
|
||||
@@ -240,17 +257,20 @@ namespace coreutils {
|
||||
for (int ix = 0; ix < len; ix++)
|
||||
cursor[ix] = cursor[ix + length];
|
||||
setSize(this->length - length);
|
||||
onChange();
|
||||
}
|
||||
|
||||
void MString::remove(int offset, int length) {
|
||||
for (int ix = offset; ix < this->length; ix++)
|
||||
getData()[ix] = getData()[ix + length];
|
||||
setSize(this->length - length);
|
||||
onChange();
|
||||
}
|
||||
|
||||
MString &MString::write(char ch) {
|
||||
setSize(length + 1);
|
||||
*(data + length - 1) = ch;
|
||||
onChange();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -258,6 +278,7 @@ namespace coreutils {
|
||||
int len = length;
|
||||
setSize(length + value.getLength());
|
||||
memcpy(data + len, value.getData(), value.getLength());
|
||||
onChange();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -276,6 +297,7 @@ namespace coreutils {
|
||||
char ch;
|
||||
while(::read(fd, &ch, 1))
|
||||
write(ch);
|
||||
onChange();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -283,6 +305,7 @@ namespace coreutils {
|
||||
char ch;
|
||||
while(count-- && ::read(fd, &ch, 1))
|
||||
write(ch);
|
||||
onChange();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -418,5 +441,7 @@ namespace coreutils {
|
||||
c += 7;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
void MString::onChange() {}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user