Support for JSON export. More...
Public Member Functions | |
| JsonObject (unsigned long flags) | |
| virtual bool | isDummy () const |
| virtual std::string | getTypeName () const =0 |
| std::string | getStackName () const |
| bool | check (JsonStack &, std::string fname) const |
| bool | has (const std::string &key) const |
| void | add (const std::string &key, std::type_index tid) |
| void | remove (const std::string &key) |
| template<typename T> | |
| T | get (JsonStack &, const std::string &key) const |
| template<typename T> | |
| T * | jget (JsonStack &) const |
| void | copyAttrs (const JsonObject *, bool reset=false) |
| void | clear () |
| std::string | getName () const |
| void | setName (const std::string &) |
| template<typename T> | |
| T | getObject () const |
| template<typename T> | |
| void | setObject (T) |
| bool | isBound () const |
| virtual JsonObject * | clone (unsigned long flags) const =0 |
| virtual void | toData (JsonStack &) |
| unsigned int | presetId (JsonStack &) |
| template<typename T> | |
| void | update (JsonStack &, T) |
| JsonObject * | setFlags (unsigned long mask) |
| JsonObject * | resetFlags (unsigned long mask) |
| bool | issetFlags (unsigned long mask) const |
Support for JSON export.
| Hurricane::JsonObject::JsonObject | ( | unsigned long | flags | ) |
| flags | Flags sets by derived classes. |
Base object to be used by all JSON parsers. Provides helpers functions. Store three separated lists of requirements/attributes needes to build the object.
stackeds : thoses are not attributes of the current object, but other objects that are expected to be already in the stack. They are needed to build the current object. Their key must start with a '.' character.attributes : the simple attributes of the object. Their key must start with a '_'.collections : any container, collection or whatever set of other objects part of the current object. Their key must start with a '+' character.For adding a requirement/attribute, see JsonObject::add().
References JsonObject().
Referenced by clone(), copyAttrs(), JsonObject(), presetId(), remove(), resetFlags(), and setFlags().
|
virtual |
Returns: true if the concrete object is of type JsonDummy, false otherwise.
|
pure virtual |
Returns: The typename of the concrete object, that is, the value of the @typename key of the JSON object.
References getStackName().
Referenced by getStackName().
|
inline |
Returns: The key with which the DataBase object will be pushed on the parser stack.
If the current object is associated to an attribute (that is, a key in JSON), then the name attribute of the JsonObject should have been set, and it will be returned here.
If the name attribute has not been set (for example, because we are in an array). Then the typename (JsonObject::getTypeName()), prefixed by a '.' character will be returned.
If the JsonObject is, for instance, a JsonBox (typename: "Box") :
name is set to "_abutmentBox", the box will be stacked with that key.name is not set, then the key will be ".Box". References getStackName(), and getTypeName().
Referenced by getStackName(), getTypeName(), and update().
| bool Hurricane::JsonObject::check | ( | JsonStack & | , |
| std::string | fname ) const |
| stack | Where the objects already parsed are stored. |
| fname | The function name on behalf of which the check is performed. |
Check that the stack actually contains all the objects (i.e. attributes) needed to build the current object. The list of attributes is built using the JsonObject::add() function. If an attribute is missing, a warning is issued, but the parser will try to continue.
| bool Hurricane::JsonObject::has | ( | const std::string & | key | ) | const |
| key | The key name to search for. |
| void Hurricane::JsonObject::add | ( | const std::string & | key, |
| std::type_index | tid ) |
| key | The requirement/attribute to add. |
| tid | The type index of the attribute. |
Adds a new requirement or attribute to the object. The first character of the key tells which kind it is:
'.' : a requirement (not part of the object) that must be present in the stack.'_' : a simple attribute of the object.'+' : belongs to a collection or container.A more detailed description could be found in JsonObject::JsonObject().
| void Hurricane::JsonObject::remove | ( | const std::string & | key | ) |
| key | The key of the requirement/attribute to remove. |
Removes an attribute from the current object.
References clear(), copyAttrs(), get(), getName(), getObject(), isBound(), jget(), JsonObject(), setName(), and setObject().
|
inline |
| stack | The object stack of the parser. |
| key | The key of the requested object. |
key, starting from the top of the stack.Retrieve requirements or attributes from the parser stack.
T is returned (by calling the default T constructor).T, an exception from any_cast<> will be thrown. References Hurricane::JsonStack::as(), and Hurricane::JsonStack::rhas().
Referenced by remove().
|
inline |
| stack | The parser stack. Returns: the first JsonObject that can be cast into type T*. |
Search the JsonObject stack, from the top, the first object that can be cast into type T*. Base classes can be used here, as the dynamic_cast<> operator is used to perform the casts.
This function always return a pointer (never a value).
References Hurricane::JsonStack::jobjects().
Referenced by remove().
|
inline |
| other | The object from which to copy attributes. |
| reset | Whether to keep or erase the original attributes of the object. |
Copy the attributes from other into the current object. Only the attributes are copied. Neither the requirements, nor the collections. By default, the attributes are added to the existing one of the object, but if reset is true, the original ones will be suppresseds.
References copyAttrs(), and JsonObject().
Referenced by copyAttrs(), and remove().
|
inline |
|
inline |
Returns: The name of the whole object as attribute.
During the parsing of the JSON structure, excepted when in an array, an object is associated with a key. This is the string returned by this function. It is called getName() instead of getKey() to avoid confusing with the attributes keys.
References getName().
|
inline |
| name | Set the key associated to this object. |
See JsonObject::getName() for the meaning of the name (key).
References setName().
|
inline |
Returns: The associated DataBase object.
Once all the attributes have been gathered, the creation of the DataBase object is triggered by calling JsonObject::toData(). We keep track of that DataBase object by storing it (or a pointer to it) in an boost::any field of the JsonObject.
References getObject().
Referenced by getObject(), and remove().
|
inline |
| T | The DataBase object. |
Associate the constructed DataBase object T to the JSON object (for later access).
References setObject().
Referenced by remove(), setObject(), and update().
|
inline |
Returns: true if a DataBase object is associated to the JSON object (see JsonObject::setObject()).
References isBound().
|
pure virtual |
Returns: a new empty object of the same dynamic type as the source one.
This is not a true clone operation in the sense that the datas of the original object are not copied. The cloning is about the type, and is the result of a call to the new operator.
\Important This method must be overloaded in each concrete derived class.
References JsonObject().
|
virtual |
| unsigned int Hurricane::JsonObject::presetId | ( | JsonStack & | stack | ) |
| stack | The parser object stack. Returns: the next id that has been set. |
\Remark This is a helper for JsonStack::toData().
In blob mode, the DataBase must be restored as is, including the ids of all the Entities (see Entity). This function read from the stack the _id attribute and sets it so that the next Entity created will use it.
References issetFlags(), JsonObject(), resetFlags(), setFlags(), and update().
|
inline |
| stack | parser object stack. |
| hobject | the newly created DataBase object. |
\Remark This is a helper for JsonStack::toData().
Pop the attributes from the stack. Push the newly created object and bind it to the JsonObject.
References getStackName(), Hurricane::JsonStack::pop_back(), Hurricane::JsonStack::push_back(), and setObject().
Referenced by presetId().
|
inline |
| mask | Flag(s) to be raised. |
References JsonObject(), and setFlags().
Referenced by presetId(), and setFlags().
|
inline |
| mask | Flag(s) to be lowered. |
References JsonObject(), and resetFlags().
Referenced by presetId(), and resetFlags().
|
inline |
| mask | The combination of flags to be checked. |
mask are sets. References issetFlags().
Referenced by issetFlags(), and presetId().
| Generated by doxygen 1.16.1 on | Return to top of page |
| Hurricane VLSI Database | Copyright © 2000-2020 Bull S.A. All rights reserved |