JSON Parser Stack. More...
Public Member Functions | |
| size_t | size () const |
| template<typename T > | |
| void | push_back (const std::string &, T) |
| void | pop_back (size_t count=1) |
| int | rhas (const std::string &) const |
| template<typename T > | |
| T | as (const std::string &) const |
| template<typename T > | |
| T | as (int) const |
| void | push_back_dbo (DBo *) |
| void | pop_back_dbo () |
| DBo * | back_dbo () const |
| vector< JsonObject * > & | jobjects () |
| template<typename T > | |
| T | getEntity (unsigned int) const |
| void | addEntity (unsigned int jsonId, Entity *) |
| void | print (std::ostream &) const |
JSON Parser Stack.
The JSON parser stack contains three separate stacks and a lookup table:
attribute stack. Objects that have been translated from JSON to the Hurricane database (or POD objects).dbo stack, similar to the previous one, but contains only objects whose base class is DBo.id and the JSON id.
|
inline |
Returns: The size of the attribute stack.
| key | Key associated to hobject |
| hobject | The attribute object. |
Push back (on top) an element on the attribute stack.
References Hurricane::demangle().
| count | The number of element to pop. |
Remove count element(s) from the top of the stack.
| key | The key element's to look for. |
The function name's stands for "Reverse HAS". Search from the top of the attribute stack downward an element with key. Return an index from the top of the stack, that is, the end of the vector. The returned index is a negative value, for exemple the element on top of the stack has an index of -1. If no element with a matching key is found, returns 0.
References Hurricane::demangle().
| key | The key's element to search. |
Search an element with key matching key, from the top of the stack. If found, returns the element casted as type T. As the cast operation uses boost::any_cast<>, the exact type T must be used (not a base class of T), otherwise the cast will fail and an exception will be thrown.
References Hurricane::demangle().
| index | the position of the element to convert. |
Cast the element at index into type T. As the cast operation uses boost::any_cast<>, the exact type T must be used (not a base class of T), otherwise the cast will fail and an exception will be thrown.
A positive or null index means the element must be taken from the bottom of the stack and a stictly negative one means from the top of the stack.
| dbo | The DataBase object to push back. |
Dedicated stack to push objects after they had been casted into the DBo* base class. We need to create this separate stack from the attribute stack due to the inability of boost::any_cast<> to use a base class.
|
inline |
Remove one element from the top of the DBo* stack.
|
inline |
Returns: The elemet at the top of the DBo* stack.
|
inline |
Returns: the stack of JSON objects, for direct manipulation by the involded parties.
Returns: The entity, casted as type T.
Find an Entity with the JSON id jsonId and cast it into type T.
Obviously, this Entity must have been registered with a call to addEntity() before.
When parsing a DataBase object not in blob mode, we cannot restore the ids of the Entities as they are in the file. Thus when an Entity is re-created, it comes with a different id. So we have to keep track of the association between this newbox id (in the Hurricane database) and the one in the JSON file.
This function adds such an association.
| void Hurricane::JsonStack::print | ( | std::ostream & | o | ) | const |
Dump the contents of the attribute stack int the stream o. For debugging purposes.
| Generated by doxygen 1.10.0 on Fri Sep 27 2024 | Return to top of page |
| Hurricane VLSI Database | Copyright © 2000-2020 Bull S.A. All rights reserved |