 |
OR-Tools
8.1
|
Go to the documentation of this file.
35 #ifndef OR_TOOLS_BASE_CONTAINER_LOGGING_H_
36 #define OR_TOOLS_BASE_CONTAINER_LOGGING_H_
42 #include <type_traits>
75 template <
typename ElementT>
76 void Log(std::ostream& out,
const ElementT& element)
const {
93 void LogClosing(std::ostream& out)
const { out <<
"\n]"; }
145 : max_elements_(max_elements) {}
172 template <
typename IteratorT,
typename PolicyT>
174 IteratorT begin, IteratorT end,
175 const PolicyT& policy) {
176 policy.LogOpening(out);
177 for (
int64 i = 0; begin != end && i < policy.MaxElements(); ++i, ++begin) {
179 policy.LogFirstSeparator(out);
181 policy.LogSeparator(out);
183 policy.Log(out, *begin);
186 policy.LogSeparator(out);
187 policy.LogEllipsis(out);
189 policy.LogClosing(out);
200 template <
typename IteratorT,
typename PolicyT>
204 const PolicyT& policy)
205 : begin_(begin), end_(end), policy_(policy) {}
208 gtl::LogRangeToStream<IteratorT, PolicyT>(out, range.begin_, range.end_,
216 std::stringstream ss;
227 template <
typename E>
233 using I =
typename std::underlying_type<E>::type;
234 return out << static_cast<I>(v.e_);
249 template <
typename IteratorT,
typename PolicyT>
251 const IteratorT& end,
252 const PolicyT& policy) {
262 template <
typename IteratorT>
264 const IteratorT& end) {
274 template <
typename ContainerT,
typename PolicyT>
276 -> decltype(
gtl::LogRange(container.begin(), container.end(), policy)) {
277 return gtl::LogRange(container.begin(), container.end(), policy);
286 template <
typename ContainerT>
296 template <
typename E>
304 #endif // OR_TOOLS_BASE_CONTAINER_LOGGING_H_
int64 MaxElements() const
LogShortUpTo100 LogDefault
int64 MaxElements() const
void LogFirstSeparator(std::ostream &out) const
void LogFirstSeparator(std::ostream &out) const
int64 MaxElements() const
void LogClosing(std::ostream &out) const
auto LogContainer(const ContainerT &container, const PolicyT &policy) -> decltype(gtl::LogRange(container.begin(), container.end(), policy))
detail::EnumLogger< E > LogEnum(E e)
detail::RangeLogger< IteratorT, PolicyT > LogRange(const IteratorT &begin, const IteratorT &end, const PolicyT &policy)
friend std::ostream & operator<<(std::ostream &out, const EnumLogger &v)
void LogOpening(std::ostream &out) const
void LogSeparator(std::ostream &out) const
void LogClosing(std::ostream &out) const
LogShortUpToN(int64 max_elements)
void LogOpening(std::ostream &out) const
void Log(std::ostream &out, const ElementT &element) const
void LogOpening(std::ostream &out) const
void LogFirstSeparator(std::ostream &out) const
void LogSeparator(std::ostream &out) const
LogMultilineUpToN(int64 max_elements)
void LogClosing(std::ostream &out) const
friend std::ostream & operator<<(std::ostream &out, const RangeLogger &range)
void LogSeparator(std::ostream &out) const
int64 MaxElements() const
int64 MaxElements() const
void LogRangeToStream(std::ostream &out, IteratorT begin, IteratorT end, const PolicyT &policy)
RangeLogger(const IteratorT &begin, const IteratorT &end, const PolicyT &policy)
int64 MaxElements() const
void LogEllipsis(std::ostream &out) const