34#ifndef OR_TOOLS_BASE_CONTAINER_LOGGING_H_
35#define OR_TOOLS_BASE_CONTAINER_LOGGING_H_
74 template <
typename ElementT>
75 void Log(std::ostream& out,
const ElementT& element)
const {
92 void LogClosing(std::ostream& out)
const { out <<
"\n]"; }
116 explicit LogShortUpToN(int64_t max_elements) : max_elements_(max_elements) {}
120 int64_t max_elements_;
144 : max_elements_(max_elements) {}
148 int64_t max_elements_;
171template <
typename IteratorT,
typename PolicyT>
173 IteratorT begin, IteratorT end,
174 const PolicyT& policy) {
175 policy.LogOpening(out);
176 for (int64_t i = 0; begin != end && i < policy.MaxElements(); ++i, ++begin) {
178 policy.LogFirstSeparator(out);
180 policy.LogSeparator(out);
182 policy.Log(out, *begin);
185 policy.LogSeparator(out);
186 policy.LogEllipsis(out);
188 policy.LogClosing(out);
199template <
typename IteratorT,
typename PolicyT>
203 const PolicyT& policy)
204 : begin_(begin), end_(end), policy_(policy) {}
207 gtl::LogRangeToStream<IteratorT, PolicyT>(out, range.begin_, range.end_,
215 std::stringstream ss;
232 using I =
typename std::underlying_type<E>::type;
233 return out << static_cast<I>(v.e_);
248template <
typename IteratorT,
typename PolicyT>
250 const IteratorT& end,
251 const PolicyT& policy) {
261template <
typename IteratorT>
263 const IteratorT& end) {
273template <
typename ContainerT,
typename PolicyT>
275 ->
decltype(
gtl::LogRange(container.begin(), container.end(), policy)) {
276 return gtl::LogRange(container.begin(), container.end(), policy);
285template <
typename ContainerT>
LogMultilineUpToN(int64_t max_elements)
int64_t MaxElements() const
LogShortUpToN(int64_t max_elements)
int64_t MaxElements() const
friend std::ostream & operator<<(std::ostream &out, const EnumLogger &v)
RangeLogger(const IteratorT &begin, const IteratorT &end, const PolicyT &policy)
friend std::ostream & operator<<(std::ostream &out, const RangeLogger &range)
auto LogContainer(const ContainerT &container, const PolicyT &policy) -> decltype(gtl::LogRange(container.begin(), container.end(), policy))
LogShortUpTo100 LogDefault
detail::EnumLogger< E > LogEnum(E e)
detail::RangeLogger< IteratorT, PolicyT > LogRange(const IteratorT &begin, const IteratorT &end, const PolicyT &policy)
void LogRangeToStream(std::ostream &out, IteratorT begin, IteratorT end, const PolicyT &policy)
int64_t MaxElements() const
int64_t MaxElements() const
int64_t MaxElements() const
int64_t MaxElements() const
void LogEllipsis(std::ostream &out) const
void Log(std::ostream &out, const ElementT &element) const
void LogClosing(std::ostream &out) const
void LogSeparator(std::ostream &out) const
void LogFirstSeparator(std::ostream &out) const
void LogOpening(std::ostream &out) const
void LogClosing(std::ostream &out) const
void LogSeparator(std::ostream &out) const
void LogFirstSeparator(std::ostream &out) const
void LogOpening(std::ostream &out) const
void LogClosing(std::ostream &out) const
void LogSeparator(std::ostream &out) const
void LogFirstSeparator(std::ostream &out) const
void LogOpening(std::ostream &out) const