mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Code modernization: subfolders (#6283)
* Code modernization: subfolders Modernize various code on subfolders client, network, script, threading, unittests, util * empty function * default constructor/destructor * for range-based loops * use emplace_back instead of push_back * C++ STL header style * Make connection.cpp readable in a pointed place + typo
This commit is contained in:
parent
7528986e44
commit
88b436e6a9
49 changed files with 398 additions and 518 deletions
|
@ -156,8 +156,8 @@ std::string serializeWideString(const std::wstring &plain)
|
|||
writeU16((u8 *)buf, plain.size());
|
||||
s.append(buf, 2);
|
||||
|
||||
for (u32 i = 0; i < plain.size(); i++) {
|
||||
writeU16((u8 *)buf, plain[i]);
|
||||
for (wchar_t i : plain) {
|
||||
writeU16((u8 *)buf, i);
|
||||
s.append(buf, 2);
|
||||
}
|
||||
return s;
|
||||
|
@ -246,8 +246,7 @@ std::string serializeJsonString(const std::string &plain)
|
|||
std::ostringstream os(std::ios::binary);
|
||||
os << "\"";
|
||||
|
||||
for (size_t i = 0; i < plain.size(); i++) {
|
||||
char c = plain[i];
|
||||
for (char c : plain) {
|
||||
switch (c) {
|
||||
case '"':
|
||||
os << "\\\"";
|
||||
|
@ -308,7 +307,9 @@ std::string deSerializeJsonString(std::istream &is)
|
|||
|
||||
if (c == '"') {
|
||||
return os.str();
|
||||
} else if (c == '\\') {
|
||||
}
|
||||
|
||||
if (c == '\\') {
|
||||
c2 = is.get();
|
||||
if (is.eof())
|
||||
throw SerializationError("JSON string ended prematurely");
|
||||
|
@ -390,17 +391,18 @@ std::string deSerializeJsonStringIfNeeded(std::istream &is)
|
|||
// Found end of word
|
||||
is.unget();
|
||||
break;
|
||||
} else {
|
||||
tmp_os << c;
|
||||
}
|
||||
|
||||
tmp_os << c;
|
||||
}
|
||||
expect_initial_quote = false;
|
||||
}
|
||||
if (is_json) {
|
||||
std::istringstream tmp_is(tmp_os.str(), std::ios::binary);
|
||||
return deSerializeJsonString(tmp_is);
|
||||
} else
|
||||
return tmp_os.str();
|
||||
}
|
||||
|
||||
return tmp_os.str();
|
||||
}
|
||||
|
||||
////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue