16#if CSV_EXCEPTIONS_ENABLED
33 edit_context_(other.edit_context_),
34 col_index_(other.col_index_),
35 can_mutate_(other.can_mutate_),
36 frame_bound_(other.frame_bound_),
37 owned_value_(other.owned_value_) {
38 this->refresh_value();
44 edit_context_(other.edit_context_),
45 col_index_(other.col_index_),
46 can_mutate_(other.can_mutate_),
47 frame_bound_(other.frame_bound_),
48 owned_value_(std::move(other.owned_value_)) {
49 this->refresh_value();
58 edit_context_(_row_overlay),
59 col_index_(_col_index),
61 this->refresh_value(_row_overlay);
70 edit_context_(_row_overlay),
71 col_index_(_col_index),
73 this->refresh_value(_row_overlay);
79 edit_context_ = other.edit_context_;
80 col_index_ = other.col_index_;
81 can_mutate_ = other.can_mutate_;
82 owned_value_ = other.owned_value_;
83 frame_bound_ = other.frame_bound_;
84 this->refresh_value();
93 edit_context_ = other.edit_context_;
94 col_index_ = other.col_index_;
95 can_mutate_ = other.can_mutate_;
96 owned_value_ = std::move(other.owned_value_);
97 frame_bound_ = other.frame_bound_;
98 this->refresh_value();
104#if CSV_EXCEPTIONS_ENABLED
108 internals::throw_dataframe_error(error);
116 if (!can_mutate_ || !edit_context_)
118 this->assign(std::string(value));
123#if CSV_EXCEPTIONS_ENABLED
124 template<
typename T = std::
string>
126 return CSVField::template get<T>();
130 bool is_null() const noexcept {
134 bool is_str() const noexcept {
138 bool is_num() const noexcept {
142 bool is_int() const noexcept {
146 bool is_float() const noexcept {
155 bool try_get(T& out)
const noexcept {
156 return CSVField::template try_get<T>(out);
161 return CSVField::template try_get<T>(out, error);
165 template<
typename KeyType>
friend class DataFrame;
170 const CSVRow* source,
const RowOverlay* overlay,
size_t column,
171 const internals::data_frame::DataFrameStorage* storage,
174 edit_context_(mutable_access ? static_cast<const void*>(storage) : static_cast<const void*>(overlay)),
175 col_index_(column), can_mutate_(mutable_access), frame_bound_(mutable_access) {
176 this->refresh_value(overlay);
179 const internals::data_frame::DataFrameStorage* storage()
const {
180 return static_cast<const internals::data_frame::DataFrameStorage*
>(edit_context_);
183 const RowOverlay* find_overlay()
const {
185 return this->storage()->find_edits(row_);
187 return static_cast<const RowOverlay*
>(edit_context_);
190 void refresh_value() {
191 this->refresh_value(this->find_overlay());
194 void refresh_value(
const RowOverlay* overlay) {
200 if (overlay && overlay->try_get_copy(col_index_, owned_value_)) {
205 owned_value_.clear();
206 CSVField::operator=(
CSVField(internals::data_frame::RowViewAccessor::view(*row_, col_index_)));
209 DataFrameCell& assign(std::string stored) {
210 owned_value_ = stored;
211 auto* state = frame_bound_
212 ?
const_cast<internals::data_frame::DataFrameStorage*
>(this->storage()) : nullptr;
213 RowOverlay* overlay = state ? state->ensure_edits(row_)
214 :
const_cast<RowOverlay*
>(
static_cast<const RowOverlay*
>(edit_context_));
215 overlay->set(col_index_, std::move(stored));
224 const void* edit_context_;
227 bool frame_bound_ =
false;
228 std::string owned_value_;