LibreOffice Module unotools (master) 1
Public Member Functions | Protected Types | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
utl::OConfigurationNode Class Reference

a small wrapper around a configuration node. More...

#include <confignode.hxx>

Inheritance diagram for utl::OConfigurationNode:
[legend]
Collaboration diagram for utl::OConfigurationNode:
[legend]

Public Member Functions

 OConfigurationNode ()
 constructs an empty and invalid node object More...
 
 OConfigurationNode (const OConfigurationNode &_rSource)
 copy ctor More...
 
 OConfigurationNode (OConfigurationNode &&_rSource)
 move ctor More...
 
OConfigurationNodeoperator= (const OConfigurationNode &_rSource)
 assignment More...
 
OConfigurationNodeoperator= (OConfigurationNode &&_rSource)
 
OUString getLocalName () const
 returns the local name of the node More...
 
OConfigurationNode openNode (const OUString &_rPath) const noexcept
 open a sub node More...
 
OConfigurationNode openNode (const char *_pAsciiPath) const
 
OConfigurationNode createNode (const OUString &_rName) const noexcept
 create a new child node More...
 
bool removeNode (const OUString &_rName) const noexcept
 remove an existent child nod More...
 
css::uno::Any getNodeValue (const OUString &_rPath) const noexcept
 retrieves the content of a descendant More...
 
css::uno::Any getNodeValue (const char *_pAsciiPath) const
 
bool setNodeValue (const OUString &_rPath, const css::uno::Any &_rValue) const noexcept
 write a node valueThe value given is written into the node specified by the given relative path. More...
 
bool setNodeValue (const char *_pAsciiPath, const css::uno::Any &_rValue) const
 
css::uno::Sequence< OUString > getNodeNames () const noexcept
 return the names of the existing children More...
 
virtual void clear () noexcept
 invalidate the object More...
 
bool isSetNode () const
 checks whether or not the object represents a set node. More...
 
bool hasByName (const OUString &_rName) const noexcept
 checks whether or not a direct child with a given name exists More...
 
bool hasByHierarchicalName (const OUString &_rName) const noexcept
 checks whether or not a descendent (no matter if direct or indirect) with the given name exists More...
 
bool isValid () const
 check if the objects represents a valid configuration node More...
 
bool isReadonly () const
 check whether the object is read-only of updatable More...
 

Protected Types

enum  NAMEORIGIN {
  NO_CONFIGURATION ,
  NO_CALLER
}
 

Protected Member Functions

 OConfigurationNode (const css::uno::Reference< css::uno::XInterface > &_rxNode)
 constructs a node object with an interface representing a node More...
 
const css::uno::Reference< css::container::XNameAccess > & getUNONode () const
 
virtual void _disposing (const css::lang::EventObject &_rSource) override
 
OUString normalizeName (const OUString &_rName, NAMEORIGIN _eOrigin) const
 
- Protected Member Functions inherited from utl::OEventListenerAdapter
 OEventListenerAdapter ()
 
virtual ~OEventListenerAdapter ()
 
void startComponentListening (const css::uno::Reference< css::lang::XComponent > &_rxComp)
 
void stopComponentListening (const css::uno::Reference< css::lang::XComponent > &_rxComp)
 
void stopAllComponentListening ()
 
virtual void _disposing (const css::lang::EventObject &_rSource)=0
 

Private Member Functions

OConfigurationNode insertNode (const OUString &_rName, const css::uno::Reference< css::uno::XInterface > &_xNode) const noexcept
 escape names before accessing children ? More...
 

Private Attributes

css::uno::Reference< css::container::XHierarchicalNameAccess > m_xHierarchyAccess
 
css::uno::Reference< css::container::XNameAccess > m_xDirectAccess
 accessing children grandchildren (mandatory interface of our UNO object) More...
 
css::uno::Reference< css::container::XNameReplace > m_xReplaceAccess
 accessing children (mandatory interface of our UNO object) More...
 
css::uno::Reference< css::container::XNameContainer > m_xContainerAccess
 replacing child values More...
 
bool m_bEscapeNames
 modifying set nodes (optional interface of our UNO object) More...
 

Detailed Description

a small wrapper around a configuration node.

Nodes in the terminology used herein are inner nodes of a configuration tree, which means no leafs.

Definition at line 40 of file confignode.hxx.

Member Enumeration Documentation

◆ NAMEORIGIN

Enumerator
NO_CONFIGURATION 
NO_CALLER 

the name came from a configuration node

the name came from a client of this class

Definition at line 162 of file confignode.hxx.

Constructor & Destructor Documentation

◆ OConfigurationNode() [1/4]

utl::OConfigurationNode::OConfigurationNode ( const css::uno::Reference< css::uno::XInterface > &  _rxNode)
protected

constructs a node object with an interface representing a node

◆ OConfigurationNode() [2/4]

utl::OConfigurationNode::OConfigurationNode ( )
inline

constructs an empty and invalid node object

Definition at line 66 of file confignode.hxx.

◆ OConfigurationNode() [3/4]

utl::OConfigurationNode::OConfigurationNode ( const OConfigurationNode _rSource)

copy ctor

Definition at line 78 of file confignode.cxx.

References m_xDirectAccess, and utl::OEventListenerAdapter::startComponentListening().

◆ OConfigurationNode() [4/4]

utl::OConfigurationNode::OConfigurationNode ( OConfigurationNode &&  _rSource)

move ctor

Definition at line 91 of file confignode.cxx.

References m_xDirectAccess, and utl::OEventListenerAdapter::startComponentListening().

Member Function Documentation

◆ _disposing()

void utl::OConfigurationNode::_disposing ( const css::lang::EventObject &  _rSource)
overrideprotectedvirtual

Implements utl::OEventListenerAdapter.

Definition at line 138 of file confignode.cxx.

References clear(), and m_xDirectAccess.

◆ clear()

void utl::OConfigurationNode::clear ( )
virtualnoexcept

invalidate the object

Reimplemented in utl::OConfigurationTreeRoot.

Definition at line 430 of file confignode.cxx.

References m_xContainerAccess, m_xDirectAccess, m_xHierarchyAccess, and m_xReplaceAccess.

Referenced by _disposing(), and utl::OConfigurationTreeRoot::clear().

◆ createNode()

OConfigurationNode utl::OConfigurationNode::createNode ( const OUString &  _rName) const
noexcept

create a new child node

If the object represents a set node, this method may be used to create a new child. For non-set-nodes, the method will fail.
Unless the respective operations on the pure configuration API, the to-be-created node immediately becomes a part of its hierarchy, no explicit insertion is necessary.

Parameters
_rNamename for the new child. Must be level-1-depth.

Definition at line 255 of file confignode.cxx.

References DBG_UNHANDLED_EXCEPTION, and Exception.

◆ getLocalName()

OUString utl::OConfigurationNode::getLocalName ( ) const

returns the local name of the node

Definition at line 146 of file confignode.cxx.

References DBG_UNHANDLED_EXCEPTION, Exception, and m_xDirectAccess.

◆ getNodeNames()

Sequence< OUString > utl::OConfigurationNode::getNodeNames ( ) const
noexcept

return the names of the existing children

Definition at line 185 of file confignode.cxx.

References Exception, m_xDirectAccess, and TOOLS_WARN_EXCEPTION.

◆ getNodeValue() [1/2]

css::uno::Any utl::OConfigurationNode::getNodeValue ( const char *  _pAsciiPath) const
inline

Definition at line 115 of file confignode.hxx.

◆ getNodeValue() [2/2]

Any utl::OConfigurationNode::getNodeValue ( const OUString &  _rPath) const
noexcept

retrieves the content of a descendant

the returned value may contain anything from an interface (if <arg>_rPath</arg> refers to inner node of the configuration tree) to any explicit value (e.g. string, integer) or even void.
Unfortunately, this implies that if a void value is returned, you won't have a clue if this means "the path does not exist" (besides the assertion made :), or if the value is really void.

Definition at line 406 of file confignode.cxx.

References Any, and DBG_UNHANDLED_EXCEPTION.

◆ getUNONode()

const css::uno::Reference< css::container::XNameAccess > & utl::OConfigurationNode::getUNONode ( ) const
inlineprotected

Definition at line 62 of file confignode.hxx.

◆ hasByHierarchicalName()

bool utl::OConfigurationNode::hasByHierarchicalName ( const OUString &  _rName) const
noexcept

checks whether or not a descendent (no matter if direct or indirect) with the given name exists

Definition at line 327 of file confignode.cxx.

References Exception, and sName.

◆ hasByName()

bool utl::OConfigurationNode::hasByName ( const OUString &  _rName) const
noexcept

checks whether or not a direct child with a given name exists

Definition at line 344 of file confignode.cxx.

References Exception, and sName.

◆ insertNode()

OConfigurationNode utl::OConfigurationNode::insertNode ( const OUString &  _rName,
const css::uno::Reference< css::uno::XInterface > &  _xNode 
) const
privatenoexcept

escape names before accessing children ?

Definition at line 230 of file confignode.cxx.

References Any, DBG_UNHANDLED_EXCEPTION, Exception, and sName.

◆ isReadonly()

bool utl::OConfigurationNode::isReadonly ( ) const
inline

check whether the object is read-only of updatable

Definition at line 155 of file confignode.hxx.

◆ isSetNode()

bool utl::OConfigurationNode::isSetNode ( ) const

checks whether or not the object represents a set node.

Definition at line 315 of file confignode.cxx.

References Exception, and m_xHierarchyAccess.

◆ isValid()

bool utl::OConfigurationNode::isValid ( ) const
inline

check if the objects represents a valid configuration node

Definition at line 152 of file confignode.hxx.

Referenced by utl::OConfigurationTreeRoot::commit().

◆ normalizeName()

OUString utl::OConfigurationNode::normalizeName ( const OUString &  _rName,
NAMEORIGIN  _eOrigin 
) const
protected

◆ openNode() [1/2]

OConfigurationNode utl::OConfigurationNode::openNode ( const char *  _pAsciiPath) const
inline

Definition at line 84 of file confignode.hxx.

◆ openNode() [2/2]

OConfigurationNode utl::OConfigurationNode::openNode ( const OUString &  _rPath) const
noexcept

open a sub node

Parameters
_rPathaccess path of the to-be-opened sub node. May be a hierarchical path.

Definition at line 277 of file confignode.cxx.

References Exception, SAL_WARN, and TOOLS_WARN_EXCEPTION.

◆ operator=() [1/2]

OConfigurationNode & utl::OConfigurationNode::operator= ( const OConfigurationNode _rSource)

◆ operator=() [2/2]

OConfigurationNode & utl::OConfigurationNode::operator= ( OConfigurationNode &&  _rSource)

◆ removeNode()

bool utl::OConfigurationNode::removeNode ( const OUString &  _rName) const
noexcept

remove an existent child nod

If the object represents a set node, this method may be used to delete an existent child. For non-set-nodes, the method will fail.

Definition at line 207 of file confignode.cxx.

References Exception, SAL_WARN, sName, and TOOLS_WARN_EXCEPTION.

◆ setNodeValue() [1/2]

bool utl::OConfigurationNode::setNodeValue ( const char *  _pAsciiPath,
const css::uno::Any &  _rValue 
) const
inline

Definition at line 128 of file confignode.hxx.

◆ setNodeValue() [2/2]

bool utl::OConfigurationNode::setNodeValue ( const OUString &  _rPath,
const css::uno::Any &  _rValue 
) const
noexcept

write a node valueThe value given is written into the node specified by the given relative path.


In opposite to <method>getNodeValue</method>, _rName must refer to a leaf in the configuration tree, not an inner node.

Returns
sal_True if and only if the write was successful.

Member Data Documentation

◆ m_bEscapeNames

bool utl::OConfigurationNode::m_bEscapeNames
private

modifying set nodes (optional interface of our UNO object)

Definition at line 51 of file confignode.hxx.

Referenced by normalizeName(), and operator=().

◆ m_xContainerAccess

css::uno::Reference< css::container::XNameContainer > utl::OConfigurationNode::m_xContainerAccess
private

replacing child values

Definition at line 50 of file confignode.hxx.

Referenced by clear(), and operator=().

◆ m_xDirectAccess

css::uno::Reference< css::container::XNameAccess > utl::OConfigurationNode::m_xDirectAccess
private

accessing children grandchildren (mandatory interface of our UNO object)

Definition at line 46 of file confignode.hxx.

Referenced by _disposing(), clear(), getLocalName(), getNodeNames(), normalizeName(), OConfigurationNode(), and operator=().

◆ m_xHierarchyAccess

css::uno::Reference< css::container::XHierarchicalNameAccess > utl::OConfigurationNode::m_xHierarchyAccess
private

Definition at line 44 of file confignode.hxx.

Referenced by clear(), isSetNode(), and operator=().

◆ m_xReplaceAccess

css::uno::Reference< css::container::XNameReplace > utl::OConfigurationNode::m_xReplaceAccess
private

accessing children (mandatory interface of our UNO object)

Definition at line 48 of file confignode.hxx.

Referenced by clear(), and operator=().


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