Object Class Reference

Node of the tree structure associated with a file. More...

#include <object.h>

List of all members.

Classes

class  Parsing
 RAII object used to lock parsing to avoid reentrency. More...

Public Types

typedef std::vector< Object * > container
typedef container::iterator iterator
typedef container::const_iterator const_iterator
typedef container::reverse_iterator reverse_iterator
typedef
container::const_reverse_iterator 
const_reverse_iterator

Public Member Functions

Filefile ()
 Access the file associated.
const Filefile () const
 Access the file associated.
std::streampos beginningPos () const
 Access the begining file position of the object.
std::streamoff size () const
 Access the size occupied by the object in the file.
void setSize (std::streamoff size)
bool isSetToExpandOnAddition () const
void setToExpandOnAddition ()
std::streamoff pos () const
 Access the current position of the file relative to the beginning position of the file.
void setPos (std::streamoff pos)
void seekBeginning ()
 Move the file current position to the beginning position of the object.
void seekEnd ()
 Move the file current position to the ending position of the object.
void seekObjectEnd ()
 Move the file current position to the ending position of the last child.
void explore (int depth=1)
 Use the parsers to add the children of the object.
bool exploreSome (int hint)
 Use the parsers to add a limited number of children of the object.
void addParser (Parser *parser)
 Add a parser at the end of the parser list.
bool parsed ()
 Check if the parsing is done.
const ObjectTypetype () const
 Type used by the module to generate parsers for the object.
ObjectTypetype ()
void setType (const ObjectType &type)
const std::string & name () const
 Name.
void setName (const std::string &name)
const Variantvalue () const
 Value of the object set during parsing.
Variantvalue ()
void setValue (const Variant &value)
bool hasLinkTo () const
 Object links to a point in file.
std::streamoff linkTo () const
void setLinkTo (std::streamoff linkTo)
void removeLinkTo ()
VariantattributeValue (const Variant &key)
 Attributes values.
const VariantattributeValue (const Variant &key) const
VariantsetAttributeValue (const Variant &key, const Variant &value)
int maxAttributeNumber () const
const std::vector< std::string > & showcasedAttributes () const
VariantcontextValue (const Variant &key)
 Context values.
const VariantcontextValue (const Variant &key) const
VariantsetContextValue (const Variant &key, const Variant &value)
std::ostream & display (std::ostream &out, std::string prefix="") const
 Standard representation for the object in an out stream.
Objectparent ()
 Pointer to the object parent returns nullptr if the object is top level.
const Objectparent () const
Objectroot ()
 Reference to the root parent.
const Objectroot () const
int64_t rank () const
 Index of the object as a child of its parent.
int numberOfChildren () const
 Number of children.
iterator begin ()
 Iterator pointing to the beginning of the children container.
iterator end ()
 Iterator pointing to the end of the children container.
iterator last ()
 Iterator pointing to the last member of the children container.
const_iterator begin () const
const_iterator end () const
const_iterator last () const
reverse_iterator rbegin ()
reverse_iterator rend ()
const_reverse_iterator rbegin () const
const_reverse_iterator rend () const
Objectaccess (int64_t index, bool forceParse=false)
 Access a child by its index.
ObjectlookUp (const std::string &name, bool forceParse=false)
 Access a child by its name.
ObjectlookForType (const ObjectType &type, bool forceParse=false)
 Access a child by its type.
void dump (std::ostream &outStream) const
void dumpToFile (const std::string &path) const
bool hasStream () const
void dumpStream (std::ostream &outStream)
void dumpStreamToFile (const std::string &path)

Friends

class Parsing
class Module
class ContainerParser

Detailed Description

Node of the tree structure associated with a file.

The object correspond to a contiguous memory area in the file represented by a beginning position and a size.

It is given an object type and a name, a module can then use the object type to associate a series of parsers that will extract all the information from the file to construct the object.

It is part of a tree structure, it can threfore have a parent and be subdivided into children. The children can be access through iteration of the object or by using access functions. It can also have a value.


Member Typedef Documentation

typedef container::const_iterator Object::const_iterator
typedef container::const_reverse_iterator Object::const_reverse_iterator
typedef std::vector<Object*> Object::container
typedef container::iterator Object::iterator
typedef container::reverse_iterator Object::reverse_iterator

Member Function Documentation

Object* Object::access ( int64_t  index,
bool  forceParse = false 
)

Access a child by its index.

If the index is too large, the parsing is not done and forceParse is set then the object will be parsed progressively until the index is reached or the parsing is done

void Object::addParser ( Parser parser)

Add a parser at the end of the parser list.

Parsers are executed in the order they have been added. If the parser have a head (i.e. a part that must be parsed as soon as possible, then every parsers added previously execute fully their parsing and then the new parser parses the head of its parsing

Attributes values.

const Variant* Object::attributeValue ( const Variant key) const

Iterator pointing to the beginning of the children container.

std::streampos Object::beginningPos ( ) const

Access the begining file position of the object.

Context values.

const Variant* Object::contextValue ( const Variant key) const
std::ostream& Object::display ( std::ostream &  out,
std::string  prefix = "" 
) const

Standard representation for the object in an out stream.

void Object::dump ( std::ostream &  outStream) const
void Object::dumpStream ( std::ostream &  outStream)
void Object::dumpStreamToFile ( const std::string &  path)
void Object::dumpToFile ( const std::string &  path) const

Iterator pointing to the end of the children container.

void Object::explore ( int  depth = 1)

Use the parsers to add the children of the object.

Parameters:
depthis the recursive depth of the exploration. If it is set to -1 the exploration won't stop until all is explored.
bool Object::exploreSome ( int  hint)

Use the parsers to add a limited number of children of the object.

Parameters:
hintis the desired number of children to add. The actual number of children added depends on the parser's implementation.
Returns:
true if the exploration is done

Access the file associated.

const File& Object::file ( ) const

Access the file associated.

bool Object::hasLinkTo ( ) const

Object links to a point in file.

bool Object::hasStream ( ) const

Iterator pointing to the last member of the children container.

std::streamoff Object::linkTo ( ) const
Object* Object::lookForType ( const ObjectType type,
bool  forceParse = false 
)

Access a child by its type.

Return the first object whose type extends directly the type given. If the type is not found, the parsing is not done and forceParse is set then the object will be parsed progressively until the type is found or the parsing is done.

Object* Object::lookUp ( const std::string &  name,
bool  forceParse = false 
)

Access a child by its name.

If conflict returns the last parsed. If the name is not found, the parsing is not done and forceParse is set then the object will be parsed progressively until the name is found or the parsing is done.

const std::string& Object::name ( ) const

Name.

int Object::numberOfChildren ( ) const

Number of children.

Pointer to the object parent returns nullptr if the object is top level.

const Object* Object::parent ( ) const
bool Object::parsed ( )

Check if the parsing is done.

std::streamoff Object::pos ( ) const

Access the current position of the file relative to the beginning position of the file.

int64_t Object::rank ( ) const

Index of the object as a child of its parent.

Reference to the root parent.

const Object& Object::root ( ) const

Move the file current position to the beginning position of the object.

void Object::seekEnd ( )

Move the file current position to the ending position of the object.

The size should be known to use this function.

Move the file current position to the ending position of the last child.

Variant& Object::setAttributeValue ( const Variant key,
const Variant value 
)
Variant& Object::setContextValue ( const Variant key,
const Variant value 
)
void Object::setLinkTo ( std::streamoff  linkTo)
void Object::setName ( const std::string &  name)
void Object::setPos ( std::streamoff  pos)
void Object::setSize ( std::streamoff  size)
void Object::setType ( const ObjectType type)
void Object::setValue ( const Variant value)
const std::vector<std::string>& Object::showcasedAttributes ( ) const
std::streamoff Object::size ( ) const

Access the size occupied by the object in the file.

If the size is yet unknown then -1 will be returned.

const ObjectType& Object::type ( ) const

Type used by the module to generate parsers for the object.

const Variant& Object::value ( ) const

Value of the object set during parsing.


Friends And Related Function Documentation

friend class ContainerParser [friend]
friend class Module [friend]
friend class Parsing [friend]

The documentation for this class was generated from the following file: