Skip to content

Commit

Permalink
Replace infix_ostream_iterator by fmt::join
Browse files Browse the repository at this point in the history
  • Loading branch information
mmd-osm committed Jan 3, 2024
1 parent 6fca95c commit 54a2c2e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 82 deletions.
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ cgimap_include_HEADERS = \
include/cgimap/data_update.hpp \
include/cgimap/handler.hpp \
include/cgimap/http.hpp \
include/cgimap/infix_ostream_iterator.hpp \
include/cgimap/logger.hpp \
include/cgimap/mime_types.hpp \
include/cgimap/basicauth.hpp \
Expand Down
12 changes: 5 additions & 7 deletions include/cgimap/backend/apidb/pqxx_string_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
#include <set>
#include <sstream>
#include <vector>

#include <fmt/core.h>
#include <fmt/format.h>

#include <pqxx/pqxx>

#include "cgimap/types.hpp"
#include "cgimap/infix_ostream_iterator.hpp"

namespace pqxx {

Expand All @@ -43,12 +46,7 @@ namespace pqxx {
} \
static void from_string(const char[], type &) {} \
static std::string to_string(const type &ids) { \
std::stringstream ostr; \
ostr << "{"; \
std::copy(ids.begin(), ids.end(), \
infix_ostream_iterator<type::value_type>(ostr, ",")); \
ostr << "}"; \
return ostr.str(); \
return fmt::format("{{{}}}", fmt::join(ids, ",")); \
} \
}

Expand Down
68 changes: 0 additions & 68 deletions include/cgimap/infix_ostream_iterator.hpp

This file was deleted.

8 changes: 3 additions & 5 deletions include/cgimap/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#ifndef UTIL_HPP
#define UTIL_HPP

#include "infix_ostream_iterator.hpp"
#include "cgimap/http.hpp"
#include "cgimap/logger.hpp"
#include "cgimap/options.hpp"
Expand All @@ -26,6 +25,8 @@
#include <string>
#include <type_traits>

#include <fmt/core.h>
#include <fmt/format.h>


inline size_t unicode_strlen(const std::string & s)
Expand Down Expand Up @@ -78,10 +79,7 @@ inline std::string friendly_name(const std::string & input)

template <typename T>
inline std::string to_string(const std::set<T> &ids) {
std::stringstream ostr;
std::copy(ids.begin(), ids.end(),
infix_ostream_iterator<T>(ostr, ","));
return ostr.str();
return fmt::format("{}", fmt::join(ids, ","));
}


Expand Down
1 change: 0 additions & 1 deletion src/backend/apidb/readonly_pgsql_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "cgimap/logger.hpp"
#include "cgimap/options.hpp"
#include "cgimap/backend/apidb/quad_tile.hpp"
#include "cgimap/infix_ostream_iterator.hpp"

#include <functional>
#include <set>
Expand Down

0 comments on commit 54a2c2e

Please sign in to comment.