This commit is contained in:
Steffen Gaisser 2020-07-21 15:15:53 +02:00
parent e1c17409d9
commit be9d0a61f4
4 changed files with 9 additions and 9 deletions

View File

@ -78,9 +78,9 @@ int ServiceInterfaceBuffer::sync(void) {
}
size_t preambleSize = 0;
auto preamble = getPreamble(&preambleSize);
std::string* preamble = getPreamble(&preambleSize);
// Write logMessage and time
this->putChars(preamble.data(), preamble.data() + preambleSize);
this->putChars(preamble->data(), preamble->data() + preambleSize);
// Handle output
this->putChars(pbase(), pptr());
// This tells that buffer is empty again
@ -92,7 +92,7 @@ bool ServiceInterfaceBuffer::isBuffered() const {
return buffered;
}
std::string ServiceInterfaceBuffer::getPreamble(size_t * preambleSize) {
std::string* ServiceInterfaceBuffer::getPreamble(size_t * preambleSize) {
Clock::TimeOfDay_t loggerTime;
Clock::getDateAndTime(&loggerTime);
size_t currentSize = 0;
@ -110,18 +110,18 @@ std::string ServiceInterfaceBuffer::getPreamble(size_t * preambleSize) {
loggerTime.usecond /1000);
if(charCount < 0) {
printf("ServiceInterfaceBuffer: Failure parsing preamble\r\n");
return "";
return &preamble;
}
if(charCount > MAX_PREAMBLE_SIZE) {
printf("ServiceInterfaceBuffer: Char count too large for maximum "
"preamble size");
return "";
return &preamble;
}
currentSize += charCount;
if(preambleSize != nullptr) {
*preambleSize = currentSize;
}
return preamble;
return &preamble;
}

View File

@ -60,7 +60,7 @@ private:
//! In this function, the characters are parsed.
void putChars(char const* begin, char const* end);
std::string getPreamble(size_t * preambleSize = nullptr);
std::string* getPreamble(size_t * preambleSize = nullptr);
};
#endif

View File

@ -9,7 +9,7 @@ void ServiceInterfaceStream::setActive( bool myActive) {
this->streambuf.isActive = myActive;
}
std::string ServiceInterfaceStream::getPreamble() {
std::string* ServiceInterfaceStream::getPreamble() {
return streambuf.getPreamble();
}

View File

@ -33,7 +33,7 @@ public:
* the unbuffered mode.
* @return Preamle consisting of log message and timestamp.
*/
std::string getPreamble();
std::string* getPreamble();
/**
* This prints an error with a preamble. Useful if using the unbuffered