30 #include <boost/regex.hpp> 32 using boost::regex_match;
33 #include <boost/algorithm/string/join.hpp> 37 #if BOOST_VERSION < 105600 38 #include <boost/units/detail/utility.hpp> 39 using boost::units::detail::demangle;
41 using boost::core::demangle;
47 std::ostream& operator<< (std::ostream& s, const std::vector<T>& v) {
52 while (++it != v.end()) {
60 template std::ostream& operator<< <std::int64_t> (std::ostream&
s,
const std::vector<std::int64_t>& v);
61 template std::ostream& operator<< <std::int32_t> (std::ostream&
s,
const std::vector<std::int32_t>& v);
62 template std::ostream&
operator<< <bool> (std::ostream&
s,
const std::vector<bool>& v);
69 Row::Row(std::vector<cell_type> values, std::shared_ptr<ColumnInfo> column_info)
70 : m_values(
std::move(values)), m_column_info{column_info} {
74 if (m_values.size() != m_column_info->size()) {
76 <<
" instead of " << m_column_info->size();
78 for (std::size_t i=0; i<m_values.size(); ++i) {
79 auto& value_type = m_values[i].type();
80 auto& column_type = column_info->getDescription(i).type;
81 auto& column_name = column_info->getDescription(i).name;
82 if (std::type_index{value_type} != column_type) {
83 throw Elements::Exception() <<
"Incompatible cell type for " << column_name <<
": expected " 84 << demangle(column_type.name())
85 <<
", got " << demangle(value_type.name());
88 regex vertical_whitespace {
".*\\v.*"};
89 for (
auto cell : m_values) {
90 if (cell.type() ==
typeid(std::string)) {
91 std::string value = boost::get<std::string>(cell);
95 if (regex_match(value, vertical_whitespace)) {
97 <<
"vertical whitespace characters";
std::vector< cell_type > m_values
template std::ostream & operator<<< bool >(std::ostream &s, const std::vector< bool > &v)
boost::variant< bool, int32_t, int64_t, float, double, std::string, std::vector< bool >, std::vector< int32_t >, std::vector< int64_t >, std::vector< float >, std::vector< double >, NdArray::NdArray< bool >, NdArray::NdArray< int32_t >, NdArray::NdArray< int64_t >, NdArray::NdArray< float >, NdArray::NdArray< double > > cell_type
The possible cell types.
size_t size() const
Returns the number of cells in the row.
const_iterator end() const
Returns a const iterator to the past-the-end cell of the row.
const_iterator begin() const
Returns a const iterator to the first cell of the row.
std::vector< cell_type >::const_iterator const_iterator
std::shared_ptr< ColumnInfo > m_column_info
const cell_type & operator[](const size_t index) const
Returns the value of the column with the given index (zero based)
template std::ostream & operator<<< float >(std::ostream &s, const std::vector< float > &v)
std::shared_ptr< ColumnInfo > getColumnInfo() const
Returns a ColumnInfo object describing the columns of the Row.
template std::ostream & operator<<< double >(std::ostream &s, const std::vector< double > &v)