MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / str

Method str

cpp/dolfinx/common/Table.cpp:200–281  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

198}
199//-----------------------------------------------------------------------------
200std::string Table::str() const
201{
202 std::stringstream s;
203 std::vector<std::vector<std::string>> tvalues;
204 std::vector<std::size_t> col_sizes;
205
206 // Format values and compute column sizes
207 col_sizes.push_back(name.size());
208 for (std::size_t j = 0; j < _cols.size(); j++)
209 col_sizes.push_back(_cols[j].size());
210 for (std::size_t i = 0; i < _rows.size(); i++)
211 {
212 tvalues.emplace_back();
213 col_sizes[0] = std::max(col_sizes[0], _rows[i].size());
214 for (std::size_t j = 0; j < _cols.size(); j++)
215 {
216 const std::string value = to_str(get(_rows[i], _cols[j]));
217 tvalues[i].push_back(value);
218 col_sizes[j + 1] = std::max(col_sizes[j + 1], value.size());
219 }
220 }
221 std::size_t row_size = 2 * col_sizes.size() + 1;
222 for (std::size_t j = 0; j < col_sizes.size(); j++)
223 row_size += col_sizes[j];
224
225 // Stay silent if no data
226 if (tvalues.empty())
227 return "";
228
229 // Write table
230 s << name;
231 for (std::size_t k = 0; k < col_sizes[0] - name.size(); k++)
232 s << " ";
233 s << " |";
234 for (std::size_t j = 0; j < _cols.size(); j++)
235 {
236 if (_right_justify)
237 {
238 for (std::size_t k = 0; k < col_sizes[j + 1] - _cols[j].size(); k++)
239 s << " ";
240 s << " " << _cols[j];
241 }
242 else
243 {
244 s << " " << _cols[j];
245 for (std::size_t k = 0; k < col_sizes[j + 1] - _cols[j].size(); k++)
246 s << " ";
247 }
248 }
249 s << "\n";
250 for (std::size_t k = 0; k < row_size; k++)
251 s << "-";
252 for (std::size_t i = 0; i < _rows.size(); i++)
253 {
254 s << "\n";
255 s << _rows[i];
256 for (std::size_t k = 0; k < col_sizes[0] - _rows[i].size(); k++)
257 s << " ";

Callers 8

build_basic_dofmapsFunction · 0.45
create_geometryFunction · 0.45
add_data_floatFunction · 0.45
add_meshFunction · 0.45
add_data_itemFunction · 0.45
VTXWriterMethod · 0.45
list_timingsMethod · 0.45
mainFunction · 0.45

Calls 2

to_strFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected