Browse Source

Add CarlaPipeCommon::readNextLineAsString() variant

Signed-off-by: falkTX <falktx@falktx.com>
pull/1775/head
falkTX 2 years ago
parent
commit
3ec0eb2eb8
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 15 additions and 3 deletions
  1. +8
    -1
      source/utils/CarlaPipeUtils.cpp
  2. +7
    -2
      source/utils/CarlaPipeUtils.hpp

+ 8
- 1
source/utils/CarlaPipeUtils.cpp View File

@@ -1,6 +1,6 @@
/* /*
* Carla Pipe Utilities * Carla Pipe Utilities
* Copyright (C) 2013-2022 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2013-2023 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -870,6 +870,13 @@ bool CarlaPipeCommon::readNextLineAsString(const char*& value, const bool alloca
return false; return false;
} }


char* CarlaPipeCommon::readNextLineAsString() const noexcept
{
CARLA_SAFE_ASSERT_RETURN(pData->isReading, nullptr);

return const_cast<char*>(_readlineblock(true, 0));
}

// ------------------------------------------------------------------- // -------------------------------------------------------------------
// must be locked before calling // must be locked before calling




+ 7
- 2
source/utils/CarlaPipeUtils.hpp View File

@@ -1,6 +1,6 @@
/* /*
* Carla Pipe utils * Carla Pipe utils
* Copyright (C) 2013-2018 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2013-2023 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -140,10 +140,15 @@ public:


/*! /*!
* Read the next line as a string. * Read the next line as a string.
* @note: @a value must be deleted if valid.
* @note: @a value must be freed if valid and allocateString is true.
*/ */
bool readNextLineAsString(const char*& value, bool allocateString, uint32_t size = 0) const noexcept; bool readNextLineAsString(const char*& value, bool allocateString, uint32_t size = 0) const noexcept;


/*!
* Read the next line as a string, returning an allocated copy that needs to be freed.
*/
char* readNextLineAsString() const noexcept;

// ------------------------------------------------------------------- // -------------------------------------------------------------------
// write messages, must be locked before calling // write messages, must be locked before calling




Loading…
Cancel
Save