Auto-Remove newline-char
This commit is contained in:
parent
1ed9c84802
commit
16028daf10
@ -9,16 +9,20 @@ using namespace std::string_literals;
|
|||||||
|
|
||||||
std::vector<std::string> buffer;
|
std::vector<std::string> buffer;
|
||||||
void bufHandler(const char *buf){
|
void bufHandler(const char *buf){
|
||||||
|
std::string line = buf;
|
||||||
|
// Remove last char which is \n
|
||||||
|
line = line.substr(0, line.size()-1);
|
||||||
|
|
||||||
// When first char of buf has text (no tab), we got a new packet
|
// When first char of buf has text (no tab), we got a new packet
|
||||||
if(buf[0] != '\t'){
|
if(buf[0] != '\t'){
|
||||||
// Submit the just-read text-packet in a new thread
|
// Submit the just-read text-packet in a new thread
|
||||||
if(buffer.size() != 0) {
|
if(buffer.size() != 0) {
|
||||||
(void)std::async(std::launch::async, textPacketHandler, buffer);
|
(void)std::async(std::launch::async, textPacketHandler, buffer);
|
||||||
}
|
}
|
||||||
buffer = {std::string(buf)};
|
buffer = {line};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
buffer.push_back(std::string(buf)); // Append part-packet
|
buffer.push_back(line); // Append part-packet
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* C251BA62_6D80_4033_86B6_61F184E6F250 */
|
#endif /* C251BA62_6D80_4033_86B6_61F184E6F250 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user