34 #ifndef DRAIN_VARIABLE_BASE
35 #define DRAIN_VARIABLE_BASE
38 #include "CastableIterator.h"
40 #include "VariableT.h"
76 if (caster.
ptr ==
nullptr){
79 else if (data.empty()){
83 return (caster.
ptr != (
void *) &data[0]);
128 template <
class T,
class ...TT>
129 VariableBase & append(
const T &x,
const TT& ...rest){
130 Castable::operator<<(x);
135 template <
class T,
class ...TT>
136 VariableBase & set(
const T &x,
const TT& ...rest){
139 return append(rest...);
159 void setType(
const std::type_info & t);
225 std::vector<char> data;
233 void updateIterators();
273 this->assignCastable(value);
281 if (value.isLinking() && this->isLinkable()){
285 this->assignCastable(value);
298 void init(
const std::type_info &t =
typeid(
void)) {
306 void init(
const T & value) {
317 void init(
const T & value,
const std::type_info &t) {
318 std::cerr << __FILE__ <<
':' << __LINE__ <<
':' << __FUNCTION__ <<
" " << value <<
'[' << t.name() <<
']' << std::endl;
320 std::cerr << __LINE__ <<
" reset: " << std::endl;
322 std::cerr << __LINE__ <<
" setType: " << std::endl;
324 std::cerr << __LINE__ <<
" assign: " << std::endl;
326 std::cerr << __LINE__ <<
" ...done " << std::endl;
334 std::cerr << __FILE__ <<
':' << __LINE__ << __FUNCTION__ <<
" " << v << std::endl;
338 this->assignCastable(v);
344 std::cerr << __FILE__ <<
':' << __LINE__ << __FUNCTION__ <<
" " << c << std::endl;
348 this->assignCastable(c);
356 this->assignString(s);
362 void init(std::initializer_list<T> l,
const std::type_info &t =
typeid(
void)) {
366 this->assignContainer(l,
true);
369 template <
class ...TT>
370 void init(
const TT& ...args){
371 std::cerr << __FILE__ <<
':' << __LINE__ << __FUNCTION__ <<
" (variadic args)" << std::endl;
373 this->append(args...);
Definition: CastableIterator.h:57
Definition: Castable.h:76
size_t elementCount
Pointer to the data variable.
Definition: Castable.h:1209
char outputSeparator
Element separator usein in writing and reading character strings (streams).
Definition: Castable.h:1215
char inputSeparator
Element separator usein in reading a char sequence to an (numeric) array.
Definition: Castable.h:1212
void clear()
Clears strings, or for scalars and arrays, sets all the values to zero. Does not change type.
Definition: Castable.cpp:81
void setType()
Sets the storage type. If a target value is available, use setPtr() directly.
Definition: Castable.h:849
void * ptr
Future member: enables setting Caster type.
Definition: Caster.h:247
Base class for variables: Variable, Reference and FlexibleVariable.
Definition: VariableBase.h:56
virtual bool isLinking() const
Tells if the pointer points to an external variable.
Definition: VariableBase.h:75
const CastableIterator & end() const
Like with std::iterator.
Definition: VariableBase.h:189
virtual bool setSize(size_t elementCount)
Extends the array to include elementCount elements of current type.
Definition: VariableBase.h:201
virtual bool isVariable() const
Tells if internal memory exists.
Definition: VariableBase.h:105
VariableBase & operator<<(const T &x)
Extends the array by one element.
Definition: VariableBase.h:169
virtual bool isLinkable() const
Tells if the internal pointer can point to an external variable.
Definition: VariableBase.h:115
const CastableIterator & begin() const
Like with std::iterator.
Definition: VariableBase.h:182
Definition: VariableBase.h:246
void init(const Castable &c)
Copies type, data and separator char.
Definition: VariableBase.h:343
void init(const char *s)
Copies type, data and separator char.
Definition: VariableBase.h:353
void init(std::initializer_list< T > l, const std::type_info &t=typeid(void))
Initialisation with type of the first element or explicit type argument.
Definition: VariableBase.h:362
void init(const std::type_info &t=typeid(void))
Default constructor generates an empty array.
Definition: VariableBase.h:298
void init(const VariableBase &v)
Copies type, data and separator char.
Definition: VariableBase.h:333
void init(const VariableT< T > &value)
Copy constructor handler.
Definition: VariableBase.h:269
VariableT is a final class applied through typedefs Variable, Reference and FlexibleVariable.
Definition: VariableT.h:87
Definition: DataSelector.cpp:1277