Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scip_indexer/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ cc_library(
cc_library(
name = "scip_indexer",
srcs = [
"Debug.h",
"SCIPIndexer.cc",
],
linkstatic = select({
Expand Down
48 changes: 48 additions & 0 deletions scip_indexer/Debug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <ostream>
#include <string>
#include <vector>

#include "common/common.h"

template <typename K, typename V, typename Fn> std::string map_to_string(const sorbet::UnorderedMap<K, V> m, Fn f) {
std::ostringstream out;
out << "{";
auto i = -1;
for (auto &[k, v] : m) {
i++;
out << f(k, v);
if (i != m.size() - 1) {
out << ", ";
}
}
out << "}";
return out.str();
}

template <typename T, typename Fn> std::string set_to_string(const sorbet::UnorderedSet<T> s, Fn f) {
std::ostringstream out;
out << "{";
auto i = -1;
for (auto &x : s) {
i++;
out << f(x);
if (i != s.size() - 1) {
out << ", ";
}
}
out << "}";
return out.str();
}

template <typename T, typename Fn> std::string vec_to_string(const std::vector<T> v, Fn f) {
std::ostringstream out;
out << "[";
for (auto i = 0; i < v.size(); ++i) {
out << f(v[i]);
if (i != v.size() - 1) {
out << ", ";
}
}
out << "]";
return out.str();
}
Loading