Skip to content

Commit

Permalink
More replacing of std::span with pw::span
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Jun 30, 2022
1 parent eeabe4e commit 9904f46
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion examples/common/pigweed/system_rpc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void Init()
{
// Send log messages to HDLC address 1. This prevents logs from interfering
// with pw_rpc communications.
pw::log_basic::SetOutput([](std::string_view log) { pw::hdlc::WriteUIFrame(1, pw::as_bytes(std::span(log)), writer); });
pw::log_basic::SetOutput([](std::string_view log) { pw::hdlc::WriteUIFrame(1, pw::as_bytes(pw::span(log)), writer); });
}

rpc::Server & Server()
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/ameba/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ bool uartInitialised;

void send()
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(pw::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/ameba/pw_sys_io/sys_io_ameba.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(pw::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();
result = WriteBytes(pw::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(pw::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/bouffalolab/bl602/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static char sWriteBuffer[kWriteBufferSize];

static void send(void)
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(pw::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/bouffalolab/bl602/pw_sys_io/sys_io_efr32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(pw::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();
result = WriteBytes(pw::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(pw::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/efr32/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static char sWriteBuffer[kWriteBufferSize];

static void send(void)
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(pw::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/efr32/pw_sys_io/sys_io_efr32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(pw::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();
result = WriteBytes(pw::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(pw::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/esp32/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bool uartInitialised;

void send()
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(pw::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/esp32/pw_sys_io/sys_io_esp32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(pw::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();
result = WriteBytes(pw::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(pw::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
4 changes: 2 additions & 2 deletions examples/platform/mbed/pw_sys_io/sys_io_mbed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(pw::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();

// Write trailing newline.
result = WriteBytes(pw::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(pw::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
4 changes: 2 additions & 2 deletions examples/platform/nrfconnect/pw_sys_io/sys_io_nrfconnect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(pw::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();

// Write trailing newline.
result = WriteBytes(pw::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(pw::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/nrfconnect/util/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bool sIsPanicMode;

void flush()
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(pw::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/platform/qpg/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static char sWriteBuffer[kWriteBufferSize];

static void send(void)
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(pw::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/qpg/pw_sys_io/sys_io_qpg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(pw::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();
result = WriteBytes(pw::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(pw::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
4 changes: 2 additions & 2 deletions src/platform/bouffalolab/BL602/KeyValueStoreManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Delete(const char * key)
// size_t offset_bytes) const
// {
// assert(CHIP_KVS_AVAILABLE);
// auto status_and_size = mKvs.Get(key, std::span<std::byte>(reinterpret_cast<std::byte *>(value), value_size), offset_bytes);
// auto status_and_size = mKvs.Get(key, pw::span<std::byte>(reinterpret_cast<std::byte *>(value), value_size), offset_bytes);
// if (read_bytes_size)
// {
// *read_bytes_size = status_and_size.size();
Expand Down Expand Up @@ -139,7 +139,7 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Delete(const char * key)
// CHIP_ERROR KeyValueStoreManagerImpl::_Put(const char * key, const void * value, size_t value_size)
// {
// assert(CHIP_KVS_AVAILABLE);
// auto status = mKvs.Put(key, std::span<const std::byte>(reinterpret_cast<const std::byte *>(value), value_size));
// auto status = mKvs.Put(key, pw::span<const std::byte>(reinterpret_cast<const std::byte *>(value), value_size));
// switch (status.code())
// {
// case pw::OkStatus().code():
Expand Down

0 comments on commit 9904f46

Please sign in to comment.