34 #ifndef OR_TOOLS_BASE_CONTAINER_LOGGING_H_ 35 #define OR_TOOLS_BASE_CONTAINER_LOGGING_H_ 41 #include <type_traits> 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_;
171 template <
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);
199 template <
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;
226 template <
typename E>
232 using I =
typename std::underlying_type<E>::type;
233 return out << static_cast<I>(v.e_);
248 template <
typename IteratorT,
typename PolicyT>
250 const IteratorT& end,
251 const PolicyT& policy) {
261 template <
typename IteratorT>
263 const IteratorT& end) {
273 template <
typename ContainerT,
typename PolicyT>
275 -> decltype(
gtl::LogRange(container.begin(), container.end(), policy)) {
276 return gtl::LogRange(container.begin(), container.end(), policy);
285 template <
typename ContainerT>
295 template <
typename E>
303 #endif // OR_TOOLS_BASE_CONTAINER_LOGGING_H_
void LogOpening(std::ostream &out) const
RangeLogger(const IteratorT &begin, const IteratorT &end, const PolicyT &policy)
LogMultilineUpToN(int64_t max_elements)
LogShortUpTo100 LogDefault
void LogRangeToStream(std::ostream &out, IteratorT begin, IteratorT end, const PolicyT &policy)
int64_t MaxElements() const
void LogClosing(std::ostream &out) const
void LogSeparator(std::ostream &out) const
friend std::ostream & operator<<(std::ostream &out, const EnumLogger &v)
int64_t MaxElements() const
void LogFirstSeparator(std::ostream &out) const
void LogOpening(std::ostream &out) const
void LogClosing(std::ostream &out) const
friend std::ostream & operator<<(std::ostream &out, const RangeLogger &range)
void LogFirstSeparator(std::ostream &out) const
auto LogContainer(const ContainerT &container, const PolicyT &policy) -> decltype(gtl::LogRange(container.begin(), container.end(), policy))
void LogSeparator(std::ostream &out) const
void LogFirstSeparator(std::ostream &out) const
void LogEllipsis(std::ostream &out) const
void Log(std::ostream &out, const ElementT &element) const
LogShortUpToN(int64_t max_elements)
int64_t MaxElements() const
int64_t MaxElements() const
void LogSeparator(std::ostream &out) const
void LogClosing(std::ostream &out) const
detail::EnumLogger< E > LogEnum(E e)
detail::RangeLogger< IteratorT, PolicyT > LogRange(const IteratorT &begin, const IteratorT &end, const PolicyT &policy)
void LogOpening(std::ostream &out) const
int64_t MaxElements() const
int64_t MaxElements() const