more literals, use some in PIP, small refactor PIThread::start (clang-format mistakes)

This commit is contained in:
2023-07-02 14:02:10 +03:00
parent 54d0ba1876
commit ccae1a7311
15 changed files with 530 additions and 294 deletions

View File

@@ -21,6 +21,7 @@
#include "piconfig.h"
#include "piconnection.h"
#include "piliterals.h"
#include "pipropertystorage.h"
@@ -311,7 +312,7 @@ void PIIODevice::_init() {
#ifdef MICRO_PIP
threaded_read_buffer_size = 512;
#else
threaded_read_buffer_size = 4096;
threaded_read_buffer_size = 4_KiB;
#endif
read_thread.setName("__S__.PIIODevice.read_thread");
write_thread.setName("__S__.PIIODevice.write_thread");
@@ -471,7 +472,7 @@ bool PIIODevice::configure(const PIString & config_file, const PIString & sectio
PIString PIIODevice::constructFullPath() const {
return fullPathPrefix().toString() + PIStringAscii("://") + constructFullPathDevice() + fullPathOptions();
return fullPathPrefix().toString() + "://"_a + constructFullPathDevice() + fullPathOptions();
}
@@ -511,18 +512,12 @@ void PIIODevice::splitFullPath(PIString fpwm, PIString * full_path, DeviceMode *
PIStringList opts(dms.split(","));
piForeachC(PIString & o, opts) {
// piCout << dms;
if (o == PIStringAscii("r") || o == PIStringAscii("ro") || o == PIStringAscii("read") || o == PIStringAscii("readonly"))
dm |= ReadOnly;
if (o == PIStringAscii("w") || o == PIStringAscii("wo") || o == PIStringAscii("write") || o == PIStringAscii("writeonly"))
dm |= WriteOnly;
if (o == PIStringAscii("br") || o == PIStringAscii("blockr") || o == PIStringAscii("blockread") ||
o == PIStringAscii("blockingread"))
op |= BlockingRead;
if (o == PIStringAscii("bw") || o == PIStringAscii("blockw") || o == PIStringAscii("blockwrite") ||
o == PIStringAscii("blockingwrite"))
op |= BlockingWrite;
if (o == PIStringAscii("brw") || o == PIStringAscii("bwr") || o == PIStringAscii("blockrw") || o == PIStringAscii("blockwr") ||
o == PIStringAscii("blockreadrite") || o == PIStringAscii("blockingreadwrite"))
if (o == "r"_a || o == "ro"_a || o == "read"_a || o == "readonly"_a) dm |= ReadOnly;
if (o == "w"_a || o == "wo"_a || o == "write"_a || o == "writeonly"_a) dm |= WriteOnly;
if (o == "br"_a || o == "blockr"_a || o == "blockread"_a || o == "blockingread"_a) op |= BlockingRead;
if (o == "bw"_a || o == "blockw"_a || o == "blockwrite"_a || o == "blockingwrite"_a) op |= BlockingWrite;
if (o == "brw"_a || o == "bwr"_a || o == "blockrw"_a || o == "blockwr"_a || o == "blockreadrite"_a ||
o == "blockingreadwrite"_a)
op |= BlockingRead | BlockingWrite;
}
fpwm.cutRight(fpwm.length() - fpwm.findLast('(')).trim();
@@ -565,29 +560,29 @@ void PIIODevice::registerDevice(PIConstChars prefix, PIConstChars classname, PII
PIString PIIODevice::fullPathOptions() const {
if (mode_ == ReadWrite && options_ == 0) return PIString();
PIString ret(" (");
PIString ret(" ("_a);
bool f = true;
if (mode_ == ReadOnly) {
if (!f) ret += ",";
if (!f) ret += ","_a;
f = false;
ret += "ro";
ret += "ro"_a;
}
if (mode_ == WriteOnly) {
if (!f) ret += ",";
if (!f) ret += ","_a;
f = false;
ret += "wo";
ret += "wo"_a;
}
if (options_[BlockingRead]) {
if (!f) ret += ",";
if (!f) ret += ","_a;
f = false;
ret += "br";
ret += "br"_a;
}
if (options_[BlockingWrite]) {
if (!f) ret += ",";
if (!f) ret += ","_a;
f = false;
ret += "bw";
ret += "bw"_a;
}
return ret + ")";
return ret + ")"_a;
}