11#ifndef OPENXLSX_XLROWDATA_HPP
12#define OPENXLSX_XLROWDATA_HPP
16# pragma warning(disable : 4251)
17# pragma warning(disable : 4275)
28#include "OpenXLSX-Exports.hpp"
132 std::unique_ptr<XLRowDataRange> m_dataRange;
182 uint16_t
size()
const;
204 typename = std::enable_if_t<
205 std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> ||
206 std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>,
const char*> ||
207 std::is_same_v<std::decay_t<T>,
char*> or std::is_same_v<T, XLDateTime>>>
211 for (
auto it =
begin(); it !=
end(); ++it) it->value() = value;
230 std::unique_ptr<XMLNode> m_rowNode;
231 uint16_t m_firstCol{1};
232 uint16_t m_lastCol{1};
240 class OPENXLSX_EXPORT XLRowDataProxy
255 XLRowDataProxy&
operator=(
const XLRowDataProxy& other);
262 XLRowDataProxy&
operator=(
const std::vector<XLCellValue>& values);
269 XLRowDataProxy&
operator=(
const std::vector<bool>& values);
279 typename = std::enable_if_t<!std::is_same_v<T, XLRowDataProxy> &&
280 std::is_base_of_v<std::bidirectional_iterator_tag,
281 typename std::iterator_traits<typename T::iterator>::iterator_category>,
286 if (values.size() == 0)
return *
this;
289 if constexpr (std::is_same_v<typename T::value_type, XLCellValue>) {
291 deleteCellValues(
static_cast<uint16_t
>(values.size()));
294 auto colNo = values.size();
295 for (
auto value = values.rbegin(); value != values.rend(); ++value) {
296 prependCellValue(*value,
297 static_cast<uint16_t
>(colNo));
305 auto range =
XLRowDataRange(*m_rowNode, 1,
static_cast<uint16_t
>(values.size()), getSharedStrings());
306 auto dst = range.begin();
308 auto src = values.begin();
313 if (src == values.end())
break;
343 operator std::vector<XLCellValue>()
const;
349 operator std::deque<XLCellValue>()
const;
355 operator std::list<XLCellValue>()
const;
365 template<
typename Container,
367 std::enable_if_t<!std::is_same_v<Container, XLRowDataProxy> &&
368 std::is_base_of_v<std::bidirectional_iterator_tag,
369 typename std::iterator_traits<typename Container::iterator>::iterator_category>,
371 explicit operator Container()
const
372 {
return convertContainer<Container>(); }
415 std::vector<XLCellValue> getValues()
const;
428 void deleteCellValues(uint16_t count);
435 void prependCellValue(
const XLCellValue& value, uint16_t col);
446 template<
typename Container,
448 std::enable_if_t<!std::is_same_v<Container, XLRowDataProxy> &&
449 std::is_base_of_v<std::bidirectional_iterator_tag,
450 typename std::iterator_traits<typename Container::iterator>::iterator_category>,
452 Container convertContainer() const
455 auto it = std::inserter(c, c.end());
456 for (
const auto& v : getValues()) {
458 if constexpr (std::is_same_v<typename Container::value_type, XLCellValue>) *it++ = v;
464 *it++ = v.get<
typename Container::value_type>();
471 XLRow* m_row{
nullptr};
Class encapsulating a cell value.
Definition XLCellValue.hpp:89
An implementation class encapsulating the properties and behaviours of a spreadsheet cell.
Definition XLCell.hpp:51
Definition XLException.hpp:42
std::forward_iterator_tag iterator_category
Definition XLRowData.hpp:49
bool operator!=(const XLRowDataIterator &rhs) const
Non-equality operator.
Definition XLRowData.cpp:77
XLCell value_type
Definition XLRowData.hpp:50
~XLRowDataIterator()
Destructor.
XLRowDataIterator(const XLRowDataIterator &other)
Copy constructor.
Definition XLRowData.cpp:26
friend class XLRowDataRange
Definition XLRowData.hpp:46
XLRowDataIterator & operator=(const XLRowDataIterator &other)
Copy assignment operator.
Definition XLRowData.cpp:32
XLRowDataIterator & operator++()
Pre-increment of the iterator.
Definition XLRowData.cpp:41
XLCell & reference
Definition XLRowData.hpp:53
pointer operator->()
Arrow operator.
Definition XLRowData.cpp:70
reference operator*()
Dereferencing operator.
Definition XLRowData.cpp:69
int64_t difference_type
Definition XLRowData.hpp:51
bool operator==(const XLRowDataIterator &rhs) const
Equality operator.
Definition XLRowData.cpp:71
XLRowDataIterator(XLRowDataIterator &&other) noexcept
Move constructor.
XLRowDataIterator & operator=(XLRowDataIterator &&other) noexcept
Move assignment operator.
XLCell * pointer
Definition XLRowData.hpp:52
The XLRowDataProxy is used as a proxy object when getting or setting row data. The class facilitates ...
Definition XLRowData.hpp:241
~XLRowDataProxy()
Destructor.
XLRowDataProxy & operator=(const XLRowDataProxy &other)
Copy assignment operator.
Definition XLRowData.cpp:124
friend class XLRow
Definition XLRowData.hpp:242
XLRowDataProxy & operator=(const T &values)
Templated assignment operator taking any container supporting bidirectional iterators.
Definition XLRowData.hpp:283
This class encapsulates the concept of a contiguous range of cells in a row.
Definition XLRowData.hpp:141
XLRowDataRange(const XLRowDataRange &other)
Copy constructor.
Definition XLRowData.cpp:99
XLRowDataRange(XLRowDataRange &&other) noexcept
Move constructor.
~XLRowDataRange()
Destructor.
XLRowDataIterator begin()
Get an iterator to the first element.
Definition XLRowData.cpp:117
XLRowDataRange & operator=(T value)
Templated assignment operator - assign value to all existing cells in the row.
Definition XLRowData.hpp:208
uint16_t size() const
Get the size (length) of the range.
Definition XLRowData.cpp:116
XLRowDataRange & operator=(XLRowDataRange &&other) noexcept
Move assignment operator.
XLRowDataRange & operator=(const XLRowDataRange &other)
Copy assignment operator.
Definition XLRowData.cpp:107
XLRowDataIterator end()
Get an iterator to (one-past) the last element.
Definition XLRowData.cpp:119
friend class XLRowDataIterator
Definition XLRowData.hpp:142
friend class XLRow
Definition XLRowData.hpp:144
friend class XLRowDataProxy
Definition XLRowData.hpp:143
The XLRow class represent a row in an Excel spreadsheet. Using XLRow objects, various row formatting ...
Definition XLRow.hpp:34
This class encapsulate the Excel concept of Shared Strings. In Excel, instead of havig individual str...
Definition XLSharedStrings.hpp:78
Definition IXLCellProvider.hpp:24
XLIteratorLocation
Definition XLIterator.hpp:17
constexpr uint16_t MAX_COLS
Definition XLConstants.hpp:18
OpenXLSX_xml_node XMLNode
Definition XLXmlParser.hpp:64
std::reference_wrapper< const XLSharedStrings > XLSharedStringsRef
Definition XLSharedStrings.hpp:67