All element structure descriptions are stored in content
(value
in C++)
For primitive types it hold final value (number, string, bool) For complex types there is stored definitions:
- object: members (can be leaf (primitive type) or branch (another level of complex type)
- array: there are stored all values which user define
In both cases there is stored complet definition of object
For Enum there were "array" and in API Elemements spec was written
Enumeration type. Exclusive list of possible elements. The elements in content's array MUST be interpreted as mutually exclusive.
After longer discussion we decide to move array of possible values into attribute enumerations and content
use to store for value choosed by user
There is a few problems which I found while implementation in C++
IElement
has method bool empty() const
. It is typicaly used for check if it shold be rendered as empty element or we shoud render conten
But this does not work for EnumElement
since it has enumerations
attribute.
There are two ways how to solve it:
- change
empty()
to make additional check forenumerations
attribute (inconsistent with behavior of other elements) - everywhere where is it required make check
if (!e.empty() || hasEnumerationAttr(e)) {...}
As I mention above
In general EnumElement is kind of One of
MSON definition. It is mutual exclusive set of values.
One of hold members. In refrect it is tored in following way
- object
- select
- option
- m1: v1
- m2: v2
- option:
- m3: v3
- m4: v4
There is used select
elment to store MSON definition.
...the
select
element is provided to give multiple possibilities for a given content.
In other word it mean it is mutial exclusive by definition
We can use already existing behavior of refract spec
If we mirror this beavior to Enum we can present Enum in following way:
- select
- option
- notrh
- option
- south
- option
- west
- option
- east
We have two possible ways how to implement proposed behavior
- enum
- content
- option
- notrh
- option
- south
- option
- west
- option
- east
- enum
- content
- select
- option
- notrh
- option
- south
- option
- west
- option
- east
There is same problem like select
element has. There is no way to say what which option
is picked by user.
Typicaly:
- A: north (enum)
- south
- west
- east
There is a few ways how to implement it.
- enum
- option (attr[value])
- notrh
- option
- south
- option
- west
- option
- east
- enum (attr[value]:ref(option/0))
- option
- notrh
- option
- south
- option
- west
- option
- east