blob: 71fccf287579b9766d9c735a0a8f2850128d53e5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "printable.h"
#include <vespa/vespalib/stllike/asciistream.h>
namespace vespalib {
template<typename T>
void print(const std::vector<T> & v, vespalib::asciistream& out, const AsciiPrintable::PrintProperties& p) {
if (v.empty()) {
out << "[]";
return;
}
vespalib::asciistream ost;
ost << v[0];
bool newLineBetweenEntries = (ost.str().size() > 15);
out << "[";
for (size_t i=0; i<v.size(); ++i) {
if (i != 0) out << ",";
if (newLineBetweenEntries) {
out << "\n" << p.indent(1);
} else {
if (i != 0) { out << " "; }
}
out << v[i];
}
if (newLineBetweenEntries) {
out << "\n" << p.indent();
}
out << "]";
}
} // vespalib
|