Choreonoid  1.5
Public Member Functions | Friends | List of all members
cnoid::Archive Class Reference

#include <Archive.h>

Inheritance diagram for cnoid::Archive:
cnoid::Mapping cnoid::ValueNode cnoid::Referenced

Public Member Functions

 Archive ()
 
 Archive (int line, int column)
 
virtual ~Archive ()
 
void initSharedInfo (bool useHomeRelativeDirectories=false)
 
void initSharedInfo (const std::string &projectFile, bool useHomeRelativeDirectories=false)
 
void inheritSharedInfoFrom (Archive &archive)
 
void addPostProcess (const boost::function< void()> &func, int priority=0) const
 
ArchivefindSubArchive (const std::string &name)
 
const ArchivefindSubArchive (const std::string &name) const
 
bool forSubArchive (const std::string &name, boost::function< bool(const Archive &archive)> func) const
 
ArchiveopenSubArchive (const std::string &name)
 
ValueNodePtr getItemId (Item *item) const
 
ItemfindItem (ValueNodePtr id) const
 
int getViewId (View *view) const
 
ViewfindView (int id) const
 
void clearIds ()
 
template<class ItemType >
ItemType * findItem (ValueNodePtr id) const
 
void writeItemId (const std::string &key, Item *item)
 
template<class ItemType >
ItemType * findItem (const std::string &key) const
 
std::string expandPathVariables (const std::string &path) const
 
std::string resolveRelocatablePath (const std::string &relocatable) const
 
bool readRelocatablePath (const std::string &key, std::string &out_value) const
 
std::string getRelocatablePath (const std::string &path) const
 
void writeRelocatablePath (const std::string &key, const std::string &path)
 
ItemcurrentParentItem () const
 
boost::filesystem::path getProjectDir () const
 
- Public Member Functions inherited from cnoid::Mapping
 Mapping ()
 
 Mapping (int line, int column)
 
virtual ~Mapping ()
 
virtual ValueNodeclone () const
 
bool empty () const
 
int size () const
 
void clear ()
 
void setFlowStyle (bool isFlowStyle=true)
 
bool isFlowStyle () const
 
void setDoubleFormat (const char *format)
 
const char * doubleFormat ()
 
void setKeyQuoteStyle (StringStyle style)
 
ValueNodefind (const std::string &key) const
 
MappingfindMapping (const std::string &key) const
 
ListingfindListing (const std::string &key) const
 
ValueNodePtr extract (const std::string &key)
 
ValueNodeget (const std::string &key) const
 
ValueNodeoperator[] (const std::string &key) const
 
void insert (const std::string &key, ValueNode *node)
 
void insert (const Mapping *other)
 
MappingopenMapping (const std::string &key)
 
MappingopenFlowStyleMapping (const std::string &key)
 
MappingcreateMapping (const std::string &key)
 
MappingcreateFlowStyleMapping (const std::string &key)
 
ListingopenListing (const std::string &key)
 
ListingopenFlowStyleListing (const std::string &key)
 
ListingcreateListing (const std::string &key)
 
ListingcreateFlowStyleListing (const std::string &key)
 
bool remove (const std::string &key)
 
bool read (const std::string &key, std::string &out_value) const
 
bool readUTF8 (const std::string &key, std::string &out_value) const
 
bool read (const std::string &key, bool &out_value) const
 
bool read (const std::string &key, int &out_value) const
 
bool read (const std::string &key, double &out_value) const
 
template<class T >
read (const std::string &key) const
 
template<class T >
get (const std::string &key, const T &defaultValue) const
 
std::string get (const std::string &key, const char *defaultValue) const
 
void writeUTF8 (const std::string &key, const std::string &value, StringStyle stringStyle=PLAIN_STRING)
 
void write (const std::string &key, const std::string &value, StringStyle stringStyle=PLAIN_STRING)
 
void writeUTF8 (const std::string &key, const char *value, StringStyle stringStyle=PLAIN_STRING)
 
void write (const std::string &key, const char *value, StringStyle stringStyle=PLAIN_STRING)
 
void write (const std::string &key, bool value)
 
void write (const std::string &key, int value)
 
void write (const std::string &key, double value)
 
void writePath (const std::string &key, const std::string &value)
 
void setAssignMode (AssignMode mode)
 
template<class T >
void assign (const std::string &key, T &io_value, const T &defaultValue)
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
void throwKeyNotFoundException (const std::string &key) const
 
- Public Member Functions inherited from cnoid::ValueNode
bool isValid () const
 
TypeBit LFType () const
 
TypeBit nodeType () const
 
int toInt () const
 
double toDouble () const
 
bool toBool () const
 
bool isScalar () const
 
bool isString () const
 
const std::string & toString () const
 
const std::string & toUTF8String () const
 
 operator const std::string & () const
 
template<typename T >
to () const
 
bool isMapping () const
 
const MappingtoMapping () const
 
MappingtoMapping ()
 
bool isListing () const
 
const ListingtoListing () const
 
ListingtoListing ()
 
bool read (int &out_value) const
 
bool read (double &out_value) const
 
bool read (bool &out_value) const
 
bool read (std::string &out_value) const
 
bool readUTF8String (std::string &out_value) const
 
bool hasLineInfo () const
 
int line () const
 
int column () const
 
void throwException (const std::string &message) const
 
template<>
double to () const
 
template<>
int to () const
 
- Public Member Functions inherited from cnoid::Referenced
virtual ~Referenced ()
 
void addRef ()
 
void releaseRef ()
 

Friends

class ItemTreeArchiverImpl
 
class ViewManager
 
class ProjectManagerImpl
 

Additional Inherited Members

- Public Types inherited from cnoid::Mapping
enum  AssignMode { READ_MODE, WRITE_MODE }
 
typedef Container::iterator iterator
 
typedef Container::const_iterator const_iterator
 
- Public Types inherited from cnoid::ValueNode
enum  TypeBit {
  INVALID_NODE = 0, SCALAR = 1, MAPPING = 2, LISTING = 4,
  INSERT_LF = 8, APPEND_LF = 16
}
 
- Protected Member Functions inherited from cnoid::ValueNode
 ValueNode ()
 
 ValueNode (TypeBit type)
 
virtual ~ValueNode ()
 
void throwNotScalrException () const
 
void throwNotMappingException () const
 
void throwNotListingException () const
 
- Protected Member Functions inherited from cnoid::Referenced
 Referenced ()
 
 Referenced (const Referenced &org)
 
int refCount () const
 
- Protected Attributes inherited from cnoid::ValueNode
int typeBits
 

Constructor & Destructor Documentation

◆ Archive() [1/2]

Archive::Archive ( )

◆ Archive() [2/2]

Archive::Archive ( int  line,
int  column 
)

◆ ~Archive()

Archive::~Archive ( )
virtual

Member Function Documentation

◆ addPostProcess()

void Archive::addPostProcess ( const boost::function< void()> &  func,
int  priority = 0 
) const

◆ clearIds()

void Archive::clearIds ( )

◆ currentParentItem()

Item * Archive::currentParentItem ( ) const

◆ expandPathVariables()

std::string Archive::expandPathVariables ( const std::string &  path) const

◆ findItem() [1/3]

Item * Archive::findItem ( ValueNodePtr  id) const

◆ findItem() [2/3]

template<class ItemType >
ItemType* cnoid::Archive::findItem ( ValueNodePtr  id) const
inline

◆ findItem() [3/3]

template<class ItemType >
ItemType* cnoid::Archive::findItem ( const std::string &  key) const
inline

◆ findSubArchive() [1/2]

Archive * Archive::findSubArchive ( const std::string &  name)

◆ findSubArchive() [2/2]

const Archive * Archive::findSubArchive ( const std::string &  name) const

◆ findView()

View * Archive::findView ( int  id) const

◆ forSubArchive()

bool Archive::forSubArchive ( const std::string &  name,
boost::function< bool(const Archive &archive)>  func 
) const

◆ getItemId()

ValueNodePtr Archive::getItemId ( Item item) const

◆ getProjectDir()

boost::filesystem::path cnoid::Archive::getProjectDir ( ) const
inline

◆ getRelocatablePath()

std::string Archive::getRelocatablePath ( const std::string &  orgPathString) const
Todo:
Use integated nested map whose node is a single path element to be more efficient.

◆ getViewId()

int Archive::getViewId ( View view) const
Returns
-1 if item does not belong to the archive

◆ inheritSharedInfoFrom()

void Archive::inheritSharedInfoFrom ( Archive archive)

◆ initSharedInfo() [1/2]

void Archive::initSharedInfo ( bool  useHomeRelativeDirectories = false)

◆ initSharedInfo() [2/2]

void Archive::initSharedInfo ( const std::string &  projectFile,
bool  useHomeRelativeDirectories = false 
)

◆ openSubArchive()

Archive * Archive::openSubArchive ( const std::string &  name)

◆ readRelocatablePath()

bool Archive::readRelocatablePath ( const std::string &  key,
std::string &  out_value 
) const

◆ resolveRelocatablePath()

std::string Archive::resolveRelocatablePath ( const std::string &  relocatable) const

This method expands path variables and adds the path to the project file if the path is relative one

◆ writeItemId()

void Archive::writeItemId ( const std::string &  key,
Item item 
)

◆ writeRelocatablePath()

void Archive::writeRelocatablePath ( const std::string &  key,
const std::string &  path 
)

Friends And Related Function Documentation

◆ ItemTreeArchiverImpl

friend class ItemTreeArchiverImpl
friend

◆ ProjectManagerImpl

friend class ProjectManagerImpl
friend

◆ ViewManager

friend class ViewManager
friend

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