Skip to content

Commit

Permalink
pqxx::binarystring has been deprecated in libpqxx 7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
mmd-osm committed May 5, 2024
1 parent 5a89831 commit 4537af1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 6 additions & 1 deletion src/osmdbt-get-log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ bool app(osmium::VerboseOutput &vout, Config const &config,

for (auto const &row : result) {
std::string message;
pqxx::binarystring binary_string(row[2]);
#if PQXX_VERSION_MAJOR < 7
pqxx::binarystring bin_string(row[2]);
std::basic_string_view<std::byte> binary_string(reinterpret_cast<const std::byte*>(bin_string.data()), bin_string.size());
#else
std::basic_string_view<std::byte> binary_string(row[2]);
#endif

parser.set_row(binary_string);
const auto op = parser.parse_op(); // read pgoutput operation
Expand Down
8 changes: 4 additions & 4 deletions src/pgoutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ namespace pgoutput {
template <typename T>
T row_low_level_parser::read()
{
auto result = read_network_byte_order<T>(m_row.data() + m_offset);
auto result = read_network_byte_order<T>(reinterpret_cast<const char*>(m_row.data() + m_offset));
m_offset += sizeof(T);
return result;
}

std::string row_low_level_parser::read_string()
{
std::string result{m_row.data() + m_offset};
std::string result{reinterpret_cast<const char*>(m_row.data() + m_offset)};
m_offset += result.size() + 1;
return result;
}

std::string row_low_level_parser::read_string(uint32_t len)
{
std::string result{m_row.data() + m_offset, len};
std::string result{reinterpret_cast<const char*>(m_row.data() + m_offset), len};
m_offset += len;
return result;
}
Expand Down Expand Up @@ -74,7 +74,7 @@ T row_low_level_parser::read_network_byte_order(const char *input)
return static_cast<T>(result);
}

void parser::set_row(const pqxx::binarystring &row)
void parser::set_row(std::basic_string_view<std::byte> row)
{
m_msg = row_low_level_parser(row);
}
Expand Down
8 changes: 4 additions & 4 deletions src/pgoutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ struct row_low_level_parser
{
row_low_level_parser() = default;

explicit row_low_level_parser(const pqxx::binarystring &row)
: m_row(row.get(), row.size())
explicit row_low_level_parser(std::basic_string_view<std::byte> row)
: m_row(row)
{
}

Expand All @@ -47,7 +47,7 @@ struct row_low_level_parser
template <typename T>
T read_network_byte_order(const char *input);

std::string_view m_row;
std::basic_string_view<std::byte> m_row;
uint32_t m_offset{};
};

Expand All @@ -62,7 +62,7 @@ struct parser
public:
parser() = default;

void set_row(const pqxx::binarystring &row);
void set_row(std::basic_string_view<std::byte> row);

unsigned char parse_op();

Expand Down

0 comments on commit 4537af1

Please sign in to comment.