|
VariableT is a final class applied through typedefs Variable, Reference and FlexibleVariable. More...
#include <VariableT.h>
Public Types | |
typedef T | varbase_t |
typedef std::pair< const char *, const drain::VariableT< T > > | init_pair_t |
Public Member Functions | |
template<class ... TT> | |
VariableT (const TT &...args) | |
Single constructor template, forwarded to init(args...) defined in base classes. More... | |
template<class D > | |
VariableT (D &arg) | |
C++ bug? : Copy constructor will not catch. More... | |
virtual bool | requestType (const std::type_info &t) |
Sets or changes the type if possible - that is, object is not a Reference. | |
virtual bool | suggestType (const std::type_info &t) |
Sets type, only if unset, and object is not a Reference. More... | |
virtual bool | requestSize (size_t elementCount) |
Change the array size, if For Castable (and Reference) does nothing and returns false. More... | |
VariableT & | operator= (const VariableT< T > &x) |
Assignment of objects of the same class. | |
template<class T2 > | |
VariableT & | operator= (const VariableT< T2 > &x) |
Assignment of objects of similar classes. More... | |
VariableT & | operator= (const T &x) |
Assignment of base classes (VariableLike or Castable) | |
VariableT & | operator= (const Castable &x) |
Assignment of objects of the same class. | |
template<class T2 > | |
VariableT & | operator= (const T2 &x) |
General assignment operator. | |
template<class T2 > | |
VariableT & | operator= (std::initializer_list< T2 > l) |
General assignment operator. | |
VariableT & | operator= (const char *x) |
Assignment of C strings. [Obligatory]. More... | |
template<class T2 , size_t N> | |
VariableT & | operator= (const UniTuple< T2, N > &unituple) |
template<class T2 > | |
bool | operator== (const VariableT< T2 > &v) const |
debugging | |
template<class T2 > | |
bool | operator== (const T2 &x) const |
bool | operator== (const char *s) const |
template<class T2 > | |
bool | operator!= (const VariableT< T2 > &v) const |
template<class T2 > | |
bool | operator!= (const T2 &x) const |
bool | operator!= (const char *x) const |
void | info (std::ostream &ostr=std::cout) const |
Redefine for "ambivalent" FlexibleVariable: indicate if local or ref. | |
VariableT is a final class applied through typedefs Variable, Reference and FlexibleVariable.
Variable | FlexibleVariable | Reference | ||
---|---|---|---|---|
Default constructor | ||||
V variable; | null | null | null | |
Copy constructor | ||||
bool b=true; V var(b); | V variable(var); | true | true | true ® |
char c='Y'; V var(c); | V variable(var); | Y | Y | Y ® |
int i=123; V var(i); | V variable(var); | 123 | 123 | 123 ® |
double d=45.678; V var(d); | V variable(var); | 45.678 | 45.678 | 45.678 ® |
std::string str("Test"); V var(str); | V variable(var); | "Test" © | "Test" © | "Test" ® |
UniTuple2i uni2i(INIT_2i); V var(uni2i); | V variable(var); | 12,34 | 12,34 | 12,34 ® |
UniTuple3d uni3d(INIT_3d); V var(uni3d); | V variable(var); | 5.6,7.8,9 | 5.6,7.8,9 | 5.6,7.8,9 ® |
Copy constructor variants | ||||
int i=123; Variable var(i); | V variable(var); | 123 | 123 | null |
int i=123; FlexibleVariable var(i); | V variable(var); | 123 | 123 | null |
int i=123; FlexibleVariable var; var.link(i); | V variable(var); | 123 | 123 ® | 123 ® |
int i=123; Reference var(i); | V variable(var); | 123 | 123 ® | 123 ® |
std::string str("Test"); Variable var(str); | V variable(var); | "Test" © | "Test" © | null |
std::string str("Test"); FlexibleVariable var(str); | V variable(var); | "Test" © | "Test" © | null |
std::string str("Test"); FlexibleVariable var; var.link(str); | V variable(var); | "Test" © | "Test" ® | "Test" ® |
std::string str("Test"); Reference var(str); | V variable(var); | "Test" © | "Test" ® | "Test" ® |
UniTuple3d uni3d(INIT_3d); Variable var(uni3d); | V variable(var); | 5.6,7.8,9 | 5.6,7.8,9 | null |
UniTuple3d uni3d(INIT_3d); FlexibleVariable var(uni3d); | V variable(var); | 5.6,7.8,9 | 5.6,7.8,9 | null |
UniTuple3d uni3d(INIT_3d); FlexibleVariable var; var.link(uni3d); | V variable(var); | 5.6,7.8,9 | 5.6,7.8,9 ® | 5.6,7.8,9 ® |
UniTuple3d uni3d(INIT_3d); Reference var(uni3d); | V variable(var); | 5.6,7.8,9 | 5.6,7.8,9 ® | 5.6,7.8,9 ® |
Non-const variable arg | ||||
bool b=true; | V variable(b); | true | true | true ® |
char c='Y'; | V variable(c); | Y | Y | Y ® |
int i=123; | V variable(i); | 123 | 123 | 123 ® |
double d=45.678; | V variable(d); | 45.678 | 45.678 | 45.678 ® |
std::string str("Test"); | V variable(str); | "Test" © | "Test" © | "Test" ® |
UniTuple2i uni2i(INIT_2i) | V variable(uni2i); | 12,34 | 12,34 | 12,34 ® |
UniTuple3d uni3d(INIT_3d) | V variable(uni3d); | 5.6,7.8,9 | 5.6,7.8,9 | 5.6,7.8,9 ® |
Type initialisation | ||||
V variable(typeid(bool)); | null | null | × | |
V variable(typeid(char)); | null | null | × | |
V variable(typeid(int)); | null | null | × | |
V variable(typeid(double)); | null | null | × | |
Initial value | ||||
V variable(false); | false | false | × | |
V variable('X'); | X | X | × | |
V variable(12345); | 12345 | 12345 | × | |
V variable(56.789); | 56.789 | 56.789 | × | |
V variable("Hello!"); | "Hello!" © | "Hello!" © | × | |
V variable(std::string("Test")); | "Test" © | "Test" © | × | |
V variable(UniTuple2i(INIT_2i)); | 12,34 | 12,34 | × | |
V variable(UniTuple3d(INIT_3d)); | 5.6,7.8,9 | 5.6,7.8,9 | × | |
Const variable | ||||
const bool b=true; | V variable(b); | true | true | × |
const char c='Y'; | V variable(c); | Y | Y | × |
const int i=123; | V variable(i); | 123 | 123 | × |
const double d=45.678; | V variable(d); | 45.678 | 45.678 | × |
const std::string str("Test"); | V variable(str); | "Test" © | "Test" © | × |
const char *s="123abc"; | V variable(s); | "123abc" © | "123abc" © | × |
UniTuple2i ut(INIT_2i); | V variable(ut); | 12,34 | 12,34 | × |
UniTuple3d ut(INIT_3d); | V variable(ut); | 5.6,7.8,9 | 5.6,7.8,9 | × |
Constructor with assignment | ||||
V variable = true; | true | true | × | |
V variable = 'Z'; | Z | Z | × | |
V variable = 1234; | 1234 | 1234 | × | |
V variable = 345.67; | 345.67 | 345.67 | × | |
V variable = "12.34567"; | "12.34567" © | "12.34567" © | × | |
V variable = INIT_2i; | 12,34 | 12,34 | × | |
V variable = UniTuple3d(INIT_3d); | 5.6,7.8,9 | 5.6,7.8,9 | × |
input | Variable | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
type | value | bool | unsigned char | char | short | int | unsigned long | float | double | char-array |
bool | false | false | 0 | 0 | 0 | 0 | 0 | "0" © | ||
bool | true | true | 1 | 1 | 1 | 1 | 1 | "1" © | ||
int | 123 | true | { | { | 123 | 123 | 123 | 123 | 123 | "123" © |
float | 12.345f | true | 12 | 12 | 12 | 12.345 | 12.345 | "12.345" © | ||
double | 3.14159265358979323846 | true | 3 | 3 | 3 | 3.14159 | 3.14159 | "3.14159" © | ||
double | 314.15926E-02 | true | 3 | 3 | 3 | 3.14159 | 3.14159 | "3.14159" © | ||
std::string | "Hello!" | false | H | 0 | 0 | 0 | 0 | 0 | "Hello!" © | |
std::string | "true" | true | t | 0 | 0 | 0 | 0 | 0 | "true" © | |
std::string | "false" | false | f | 0 | 0 | 0 | 0 | 0 | "false" © | |
std::string | "3141592E-6" | true | Ø | 3 | -4136 | 3141592 | 3141592 | 3.14159 | 3.14159 | "3141592E-6" © |
const char * | "Test" | false | T | 0 | 0 | 0 | 0 | 0 | "Test" © | |
const char * | "true" | true | t | 0 | 0 | 0 | 0 | 0 | "true" © | |
const char * | "false" | false | f | 0 | 0 | 0 | 0 | 0 | "false" © | |
UniTuple<2,int> | uni2i | true,true | ," | ," | 12,34 | 12,34 | 12,34 | 12,34 | 12,34 | "12,34" © |
UniTuple<3,double> | uni3d | true,true,true | ,, | ,, | 5,7,9 | 5,7,9 | 5,7,9 | 5.6,7.8,9 | 5.6,7.8,9 | "5.6,7.8,9" © |
void * | nullptr | false | n | 0 | 0 | 0 | 0 | 0 | "nullptr" © | |
Variables... | ||||||||||
int i=123 | Variable(i) | true | { | { | 123 | 123 | 123 | 123 | 123 | "123" © |
int i=123 | FlexibleVariable(i) | true | { | { | 123 | 123 | 123 | 123 | 123 | "123" © |
int i=123 | Reference(i) | true | { | { | 123 | 123 | 123 | 123 | 123 | "123" © |
std::string s("test") | Variable(s) | false | t | 0 | 0 | 0 | 0 | 0 | "test" © | |
std::string s("test") | FlexibleVariable(s) | false | t | 0 | 0 | 0 | 0 | 0 | "test" © | |
std::string s("test") | Reference(s) | false | t | 0 | 0 | 0 | 0 | 0 | "test" © | |
UniTuple | Variable(uni3d) | true,true,true | ,, | ,, | 5,7,9 | 5,7,9 | 5,7,9 | 5.6,7.8,9 | 5.6,7.8,9 | "5.6,7.8,9" © |
UniTuple | FlexibleVariable(uni3d) | true,true,true | ,, | ,, | 5,7,9 | 5,7,9 | 5,7,9 | 5.6,7.8,9 | 5.6,7.8,9 | "5.6,7.8,9" © |
UniTuple | Reference(uni3d) | true,true,true | ,, | ,, | 5,7,9 | 5,7,9 | 5,7,9 | 5.6,7.8,9 | 5.6,7.8,9 | "5.6,7.8,9" © |
input | FlexibleVariable | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
type | value | bool | unsigned char | char | short | int | unsigned long | float | double | char-array |
bool | false | false | 0 | 0 | 0 | 0 | 0 | "0" © | ||
bool | true | true | 1 | 1 | 1 | 1 | 1 | "1" © | ||
int | 123 | true | { | { | 123 | 123 | 123 | 123 | 123 | "123" © |
float | 12.345f | true | 12 | 12 | 12 | 12.345 | 12.345 | "12.345" © | ||
double | 3.14159265358979323846 | true | 3 | 3 | 3 | 3.14159 | 3.14159 | "3.14159" © | ||
double | 314.15926E-02 | true | 3 | 3 | 3 | 3.14159 | 3.14159 | "3.14159" © | ||
std::string | "Hello!" | false | H | 0 | 0 | 0 | 0 | 0 | "Hello!" © | |
std::string | "true" | true | t | 0 | 0 | 0 | 0 | 0 | "true" © | |
std::string | "false" | false | f | 0 | 0 | 0 | 0 | 0 | "false" © | |
std::string | "3141592E-6" | true | Ø | 3 | -4136 | 3141592 | 3141592 | 3.14159 | 3.14159 | "3141592E-6" © |
const char * | "Test" | false | T | 0 | 0 | 0 | 0 | 0 | "Test" © | |
const char * | "true" | true | t | 0 | 0 | 0 | 0 | 0 | "true" © | |
const char * | "false" | false | f | 0 | 0 | 0 | 0 | 0 | "false" © | |
UniTuple<2,int> | uni2i | true,true | ," | ," | 12,34 | 12,34 | 12,34 | 12,34 | 12,34 | "12,34" © |
UniTuple<3,double> | uni3d | true,true,true | ,, | ,, | 5,7,9 | 5,7,9 | 5,7,9 | 5.6,7.8,9 | 5.6,7.8,9 | "5.6,7.8,9" © |
void * | nullptr | false | n | 0 | 0 | 0 | 0 | 0 | "nullptr" © | |
Variables... | ||||||||||
int i=123 | Variable(i) | true | { | { | 123 | 123 | 123 | 123 | 123 | "123" © |
int i=123 | FlexibleVariable(i) | true | { | { | 123 | 123 | 123 | 123 | 123 | "123" © |
int i=123 | Reference(i) | true | { | { | 123 | 123 | 123 | 123 | 123 | "123" © |
std::string s("test") | Variable(s) | false | t | 0 | 0 | 0 | 0 | 0 | "test" © | |
std::string s("test") | FlexibleVariable(s) | false | t | 0 | 0 | 0 | 0 | 0 | "test" © | |
std::string s("test") | Reference(s) | false | t | 0 | 0 | 0 | 0 | 0 | "test" © | |
UniTuple | Variable(uni3d) | true,true,true | ,, | ,, | 5,7,9 | 5,7,9 | 5,7,9 | 5.6,7.8,9 | 5.6,7.8,9 | "5.6,7.8,9" © |
UniTuple | FlexibleVariable(uni3d) | true,true,true | ,, | ,, | 5,7,9 | 5,7,9 | 5,7,9 | 5.6,7.8,9 | 5.6,7.8,9 | "5.6,7.8,9" © |
UniTuple | Reference(uni3d) | true,true,true | ,, | ,, | 5,7,9 | 5,7,9 | 5,7,9 | 5.6,7.8,9 | 5.6,7.8,9 | "5.6,7.8,9" © |
input | Reference | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
type | value | bool | unsigned char | char | short | int | unsigned long | float | double | std::string |
bool | false | false ® | ® | ® | 0 ® | 0 ® | 0 ® | 0 ® | 0 ® | "0" ® |
bool | true | true ® | ® | ® | 1 ® | 1 ® | 1 ® | 1 ® | 1 ® | "1" ® |
int | 123 | true ® | { ® | { ® | 123 ® | 123 ® | 123 ® | 123 ® | 123 ® | "123" ® |
float | 12.345f | true ® | ® | ® | 12 ® | 12 ® | 12 ® | 12.345 ® | 12.345 ® | "12.345" ® |
double | 3.14159265358979323846 | true ® | ® | ® | 3 ® | 3 ® | 3 ® | 3.14159 ® | 3.14159 ® | "3.14159" ® |
double | 314.15926E-02 | true ® | ® | ® | 3 ® | 3 ® | 3 ® | 3.14159 ® | 3.14159 ® | "3.14159" ® |
std::string | "Hello!" | false ® | ® | H ® | 0 ® | 0 ® | 0 ® | 0 ® | 0 ® | "Hello!" ® |
std::string | "true" | true ® | ® | t ® | 0 ® | 0 ® | 0 ® | 0 ® | 0 ® | "true" ® |
std::string | "false" | false ® | ® | f ® | 0 ® | 0 ® | 0 ® | 0 ® | 0 ® | "false" ® |
std::string | "3141592E-6" | true ® | Ø Â® | 3 ® | -4136 ® | 3141592 ® | 3141592 ® | 3.14159 ® | 3.14159 ® | "3141592E-6" ® |
const char * | "Test" | false ® | ® | T ® | 0 ® | 0 ® | 0 ® | 0 ® | 0 ® | "Test" ® |
const char * | "true" | true ® | ® | t ® | 0 ® | 0 ® | 0 ® | 0 ® | 0 ® | "true" ® |
const char * | "false" | false ® | ® | f ® | 0 ® | 0 ® | 0 ® | 0 ® | 0 ® | "false" ® |
UniTuple<2,int> | uni2i | true ® | ® | ® | 12 ® | 12 ® | 12 ® | 12 ® | 12 ® | "12,34" ® |
UniTuple<3,double> | uni3d | true ® | ® | ® | 5 ® | 5 ® | 5 ® | 5.6 ® | 5.6 ® | "5.6,7.8,9" ® |
void * | nullptr | false ® | ® | n ® | 0 ® | 0 ® | 0 ® | 0 ® | 0 ® | "nullptr" ® |
Variables... | ||||||||||
int i=123 | Variable(i) | true ® | { ® | { ® | 123 ® | 123 ® | 123 ® | 123 ® | 123 ® | "123" ® |
int i=123 | FlexibleVariable(i) | true ® | { ® | { ® | 123 ® | 123 ® | 123 ® | 123 ® | 123 ® | "123" ® |
int i=123 | Reference(i) | true ® | { ® | { ® | 123 ® | 123 ® | 123 ® | 123 ® | 123 ® | "123" ® |
std::string s("test") | Variable(s) | false ® | ® | t ® | 0 ® | 0 ® | 0 ® | 0 ® | 0 ® | "test" ® |
std::string s("test") | FlexibleVariable(s) | false ® | ® | t ® | 0 ® | 0 ® | 0 ® | 0 ® | 0 ® | "test" ® |
std::string s("test") | Reference(s) | false ® | ® | t ® | 0 ® | 0 ® | 0 ® | 0 ® | 0 ® | "test" ® |
UniTuple | Variable(uni3d) | true ® | ® | ® | 5 ® | 5 ® | 5 ® | 5.6 ® | 5.6 ® | "5.6,7.8,9" ® |
UniTuple | FlexibleVariable(uni3d) | true ® | ® | ® | 5 ® | 5 ® | 5 ® | 5.6 ® | 5.6 ® | "5.6,7.8,9" ® |
UniTuple | Reference(uni3d) | true ® | ® | ® | 5 ® | 5 ® | 5 ® | 5.6 ® | 5.6 ® | "5.6,7.8,9" ® |
T | - see typedefs: drain::Reference, drain::Variable, and drain::FlexibleVariable |
|
inline |
Single constructor template, forwarded to init(args...) defined in base classes.
This is the basic design pattern for all the VariableLikes
|
inline |
C++ bug? : Copy constructor will not catch.
Single constructor template, forwarded to init(arg). For a Reference,
|
inline |
Assignment of C strings. [Obligatory].
Assignment from char * and std::string splits the input by separator.
STL strings will be handled by the default operator operator=(const T &x) .
Assignment of objects of similar classes.
Note: this does not remove need of exactly matching type assignment (above).
|
virtual |
Change the array size, if For Castable (and Reference) does nothing and returns false.
Does not apply to std::string .
Could be protected, but requestType() will not be, so for consistency this is also public.
true
, if final the element count is what was requested.
|
virtual |
Sets type, only if unset, and object is not a Reference.
Does not change the current type, if set.
Could be protected, but requestType() will not be, so for consistency this is also public.