tbx  0.7.5
Public Types | Public Member Functions | List of all members
tbx::res::ResEditor Class Reference

Class to allow creation, loading, editing and saving of a toolbox resource file. More...

#include <reseditor.h>

Public Types

typedef std::vector< ResObject >::const_iterator const_iterator
 Constant iterator to iterate through the objects being edited.
 
typedef std::vector< ResObject >::iterator iterator
 Iterator to iterate through the objects being edited.
 

Public Member Functions

 ResEditor ()
 Construct an empty resource file.
 
const ResFileHeaderheader () const
 Return header details of the file.
 
const_iterator begin () const
 Get constant iterator to first object. More...
 
const_iterator end () const
 Get constant iterator to the end of the objects. More...
 
const_iterator find (std::string name) const
 Find object with given name. More...
 
iterator begin ()
 Get iterator to first object. More...
 
iterator end ()
 Get iterator to the end of the objects. More...
 
iterator find (std::string name)
 Find object with given name. More...
 
unsigned int count () const
 Return number of objects.
 
bool contains (std::string name) const
 Check if editor contains the named object. More...
 
const ResObjectobject (std::string name) const
 Get object. More...
 
void clear ()
 Remove all objects from the editor.
 
void add (ResObject obj)
 Add a new object. More...
 
void replace (ResObject obj)
 Replace object with same name as object given. More...
 
void erase (std::string name)
 Erase object with given name. More...
 
iterator insert (iterator before, ResObject obj)
 Insert object before given object. More...
 
iterator erase (iterator where)
 Erase object at iterator.
 
void replace (iterator where, ResObject obj)
 Replace object at location. More...
 
bool load (std::string file_name)
 Load resources from a file. More...
 
bool save (std::string file_name)
 Save resources to the name file. More...
 

Detailed Description

Class to allow creation, loading, editing and saving of a toolbox resource file.

Member Function Documentation

◆ add()

void tbx::res::ResEditor::add ( ResObject  obj)

Add a new object.

Parameters
objobject to add
Exceptions
ResObjectExistsif name is already used for an object

◆ begin() [1/2]

const_iterator tbx::res::ResEditor::begin ( ) const
inline

Get constant iterator to first object.

Returns
constant iterator to first object or end() if no objects

◆ begin() [2/2]

iterator tbx::res::ResEditor::begin ( )
inline

Get iterator to first object.

Returns
iterator to first object or end() if no objects

◆ contains()

bool tbx::res::ResEditor::contains ( std::string  name) const

Check if editor contains the named object.

Parameters
nameto check for
Returns
true if object is in this editor

◆ end() [1/2]

const_iterator tbx::res::ResEditor::end ( ) const
inline

Get constant iterator to the end of the objects.

Returns
constant iterator referencing the object after the last object

◆ end() [2/2]

iterator tbx::res::ResEditor::end ( )
inline

Get iterator to the end of the objects.

Returns
iterator referencing the object after the last object

◆ erase()

void tbx::res::ResEditor::erase ( std::string  name)

Erase object with given name.

Exceptions
ResObjectNotFoundif object with name doesn't exists

◆ find() [1/2]

ResEditor::const_iterator tbx::res::ResEditor::find ( std::string  name) const

Find object with given name.

Parameters
nameto find
Returns
const_iterator for found object or end() if not found

◆ find() [2/2]

ResEditor::iterator tbx::res::ResEditor::find ( std::string  name)

Find object with given name.

Parameters
nameto find
Returns
iterator for found object or end() if not found

◆ insert()

ResEditor::iterator tbx::res::ResEditor::insert ( iterator  before,
ResObject  obj 
)

Insert object before given object.

Exceptions
ResObjectExistsif name is already used for an object

◆ load()

bool tbx::res::ResEditor::load ( std::string  file_name)

Load resources from a file.

Parameters
file_name- name of file for load
Returns
true if load succeeded

◆ object()

const ResObject & tbx::res::ResEditor::object ( std::string  name) const

Get object.

Parameters
namename of the object
Returns
ResObject with the given name
Exceptions
ResObjectNotFoundif object with name doesn't exists

◆ replace() [1/2]

void tbx::res::ResEditor::replace ( ResObject  obj)

Replace object with same name as object given.

Parameters
objto replace.
Exceptions
ResObjectNotFoundif object with name doesn't exists

◆ replace() [2/2]

void tbx::res::ResEditor::replace ( iterator  where,
ResObject  obj 
)

Replace object at location.

It is recommend this is used instead of just *where = obj as this routine checks that the name is unique in the editor

Exceptions
ResObjectExistsif name is already used for an object other than the one that is being replaced

◆ save()

bool tbx::res::ResEditor::save ( std::string  file_name)

Save resources to the name file.

Parameters
file_namename of file to save to
Returns
true if save was successful

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