LibreOffice Module comphelper (master)  1
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
comphelper::NamedValueCollection Class Reference

a collection of named values, packed in various formats. More...

#include <namedvaluecollection.hxx>

Public Member Functions

 NamedValueCollection ()
 
 NamedValueCollection (const NamedValueCollection &_rCopySource)
 
 NamedValueCollection (NamedValueCollection &&_rCopySource) noexcept
 
NamedValueCollectionoperator= (const NamedValueCollection &i_rCopySource)
 
NamedValueCollectionoperator= (NamedValueCollection &&i_rCopySource) noexcept
 
 NamedValueCollection (const css::uno::Any &_rElements)
 constructs a collection More...
 
 NamedValueCollection (const css::uno::Sequence< css::uno::Any > &_rArguments)
 constructs a collection More...
 
 NamedValueCollection (const css::uno::Sequence< css::beans::PropertyValue > &_rArguments)
 constructs a collection More...
 
 NamedValueCollection (const css::uno::Sequence< css::beans::NamedValue > &_rArguments)
 constructs a collection More...
 
 ~NamedValueCollection ()
 
void assign (const css::uno::Sequence< css::uno::Any > &_rArguments)
 
void clear ()
 
size_t size () const
 returns the number of elements in the collection More...
 
bool empty () const
 determines whether the collection is empty More...
 
::std::vector< OUString > getNames () const
 returns the names of all elements in the collection More...
 
NamedValueCollectionmerge (const NamedValueCollection &_rAdditionalValues, bool _bOverwriteExisting)
 merges the content of another collection into this More...
 
template<typename VALUE_TYPE >
bool get_ensureType (const sal_Char *_pAsciiValueName, VALUE_TYPE &_out_rValue) const
 retrieves a value with a given name from the collection, if it is present More...
 
template<typename VALUE_TYPE >
void get_ensureType (const OUString &_rValueName, VALUE_TYPE &_out_rValue) const
 
template<typename VALUE_TYPE >
VALUE_TYPE getOrDefault (const sal_Char *_pAsciiValueName, const VALUE_TYPE &_rDefault) const
 retrieves a value with a given name, or defaults it to a given value, if it's not present in the collection More...
 
template<typename VALUE_TYPE >
VALUE_TYPE getOrDefault (const OUString &_rValueName, const VALUE_TYPE &_rDefault) const
 
const css::uno::Any & get (const sal_Char *_pAsciiValueName) const
 retrieves a (untyped) value with a given name More...
 
const css::uno::Any & get (const OUString &_rValueName) const
 retrieves a (untyped) value with a given name More...
 
bool has (const sal_Char *_pAsciiValueName) const
 determines whether a value with a given name is present in the collection More...
 
bool has (const OUString &_rValueName) const
 determines whether a value with a given name is present in the collection More...
 
template<typename VALUE_TYPE >
bool put (const sal_Char *_pAsciiValueName, const VALUE_TYPE &_rValue)
 puts a value into the collection More...
 
template<typename VALUE_TYPE >
bool put (const OUString &_rValueName, const VALUE_TYPE &_rValue)
 puts a value into the collection More...
 
bool put (const sal_Char *_pAsciiValueName, const css::uno::Any &_rValue)
 
bool put (const OUString &_rValueName, const css::uno::Any &_rValue)
 
bool remove (const sal_Char *_pAsciiValueName)
 removes the value with the given name from the collection More...
 
bool remove (const OUString &_rValueName)
 removes the value with the given name from the collection More...
 
sal_Int32 operator>>= (css::uno::Sequence< css::beans::PropertyValue > &_out_rValues) const
 transforms the collection to a sequence of PropertyValues More...
 
sal_Int32 operator>>= (css::uno::Sequence< css::beans::NamedValue > &_out_rValues) const
 transforms the collection to a sequence of NamedValues More...
 
css::uno::Sequence< css::beans::PropertyValue > getPropertyValues () const
 transforms the collection into a sequence of PropertyValues More...
 
css::uno::Sequence< css::uno::Any > getWrappedPropertyValues () const
 returns a Sequence< Any >, containing PropertyValues More...
 
css::uno::Sequence< css::uno::Any > getWrappedNamedValues () const
 returns a Sequence< Any >, containing NamedValues More...
 
css::uno::Sequence< css::beans::NamedValue > getNamedValues () const
 transforms the collection into a sequence of NamedValues More...
 

Static Public Member Functions

static bool canExtractFrom (css::uno::Any const &i_value)
 determines whether or not named values can be extracted from the given value More...
 

Private Member Functions

void impl_assign (const css::uno::Any &i_rWrappedElements)
 
void impl_assign (const css::uno::Sequence< css::uno::Any > &_rArguments)
 
void impl_assign (const css::uno::Sequence< css::beans::PropertyValue > &_rArguments)
 
void impl_assign (const css::uno::Sequence< css::beans::NamedValue > &_rArguments)
 
bool get_ensureType (const OUString &_rValueName, void *_pValueLocation, const css::uno::Type &_rExpectedValueType) const
 
const css::uno::Any & impl_get (const OUString &_rValueName) const
 
bool impl_has (const OUString &_rValueName) const
 
bool impl_put (const OUString &_rValueName, const css::uno::Any &_rValue)
 
bool impl_remove (const OUString &_rValueName)
 
template<class VALUE_TYPE >
css::uno::Sequence< css::uno::Any > impl_wrap () const
 

Private Attributes

::std::unique_ptr< NamedValueCollection_Implm_pImpl
 

Detailed Description

a collection of named values, packed in various formats.

Definition at line 42 of file namedvaluecollection.hxx.

Constructor & Destructor Documentation

comphelper::NamedValueCollection::NamedValueCollection ( )

Definition at line 55 of file namedvaluecollection.cxx.

comphelper::NamedValueCollection::NamedValueCollection ( const NamedValueCollection _rCopySource)

Definition at line 61 of file namedvaluecollection.cxx.

comphelper::NamedValueCollection::NamedValueCollection ( NamedValueCollection &&  _rCopySource)
noexcept

Definition at line 67 of file namedvaluecollection.cxx.

comphelper::NamedValueCollection::NamedValueCollection ( const css::uno::Any &  _rElements)

constructs a collection

Parameters
_rElementsthe wrapped elements of the collection. The Any might contain a sequence of property values, a sequence of named values, or directly a property value or named value. All other cases are worth an assertion in non-product builds.
comphelper::NamedValueCollection::NamedValueCollection ( const css::uno::Sequence< css::uno::Any > &  _rArguments)

constructs a collection

Parameters
_rArgumentsa sequence of Any's containing either PropertyValue's or NamedValue's.
comphelper::NamedValueCollection::NamedValueCollection ( const css::uno::Sequence< css::beans::PropertyValue > &  _rArguments)

constructs a collection

Parameters
_rArgumentsa sequence of PropertyValues's
comphelper::NamedValueCollection::NamedValueCollection ( const css::uno::Sequence< css::beans::NamedValue > &  _rArguments)

constructs a collection

Parameters
_rArgumentsa sequence of NamedValue's
comphelper::NamedValueCollection::~NamedValueCollection ( )

Definition at line 112 of file namedvaluecollection.cxx.

Member Function Documentation

void comphelper::NamedValueCollection::assign ( const css::uno::Sequence< css::uno::Any > &  _rArguments)
inline

Definition at line 84 of file namedvaluecollection.hxx.

bool comphelper::NamedValueCollection::canExtractFrom ( css::uno::Any const &  i_value)
static

determines whether or not named values can be extracted from the given value

Returns
true if and only if the given Any contains a NamedValue, a PropertyValue, or a sequence thereof.

Definition at line 117 of file namedvaluecollection.cxx.

void comphelper::NamedValueCollection::clear ( )
inline

Definition at line 89 of file namedvaluecollection.hxx.

bool comphelper::NamedValueCollection::empty ( ) const

determines whether the collection is empty

Definition at line 145 of file namedvaluecollection.cxx.

References m_pImpl.

const css::uno::Any& comphelper::NamedValueCollection::get ( const sal_Char _pAsciiValueName) const
inline

retrieves a (untyped) value with a given name

If the collection does not contain a value with the given name, an empty Any is returned.

Definition at line 182 of file namedvaluecollection.hxx.

const css::uno::Any& comphelper::NamedValueCollection::get ( const OUString &  _rValueName) const
inline

retrieves a (untyped) value with a given name

If the collection does not contain a value with the given name, an empty Any is returned.

Definition at line 192 of file namedvaluecollection.hxx.

template<typename VALUE_TYPE >
bool comphelper::NamedValueCollection::get_ensureType ( const sal_Char _pAsciiValueName,
VALUE_TYPE &  _out_rValue 
) const
inline

retrieves a value with a given name from the collection, if it is present

Parameters
_pAsciiValueNamethe ASCII name of the value to retrieve
_out_rValueis the output parameter taking the desired value upon successful return. If a value with the given name is not present in the collection, or if a wrong-typed value is present, then this parameter will not be touched.
Return values
trueif there is a value with the given name, which could successfully be extracted. In this case, _out_rValue will contain the requested value.
false,ifthere is no value with the given name.
Exceptions
IllegalArgumentExceptionin case there is a value with the given name, but it cannot legally assigned to _out_rValue.

Definition at line 149 of file namedvaluecollection.hxx.

Referenced by comphelper::OPropertyBag::initialize().

template<typename VALUE_TYPE >
void comphelper::NamedValueCollection::get_ensureType ( const OUString &  _rValueName,
VALUE_TYPE &  _out_rValue 
) const
inline

Definition at line 155 of file namedvaluecollection.hxx.

bool comphelper::NamedValueCollection::get_ensureType ( const OUString &  _rValueName,
void _pValueLocation,
const css::uno::Type &  _rExpectedValueType 
) const
private
css::uno::Sequence< css::beans::NamedValue > comphelper::NamedValueCollection::getNamedValues ( ) const
inline

transforms the collection into a sequence of NamedValues

Definition at line 302 of file namedvaluecollection.hxx.

std::vector< OUString > comphelper::NamedValueCollection::getNames ( ) const

returns the names of all elements in the collection

Definition at line 151 of file namedvaluecollection.cxx.

References m_pImpl, and value.

template<typename VALUE_TYPE >
VALUE_TYPE comphelper::NamedValueCollection::getOrDefault ( const sal_Char _pAsciiValueName,
const VALUE_TYPE &  _rDefault 
) const
inline

retrieves a value with a given name, or defaults it to a given value, if it's not present in the collection

Definition at line 164 of file namedvaluecollection.hxx.

template<typename VALUE_TYPE >
VALUE_TYPE comphelper::NamedValueCollection::getOrDefault ( const OUString &  _rValueName,
const VALUE_TYPE &  _rDefault 
) const
inline

Definition at line 170 of file namedvaluecollection.hxx.

css::uno::Sequence< css::beans::PropertyValue > comphelper::NamedValueCollection::getPropertyValues ( ) const
inline

transforms the collection into a sequence of PropertyValues

Definition at line 276 of file namedvaluecollection.hxx.

css::uno::Sequence< css::uno::Any > comphelper::NamedValueCollection::getWrappedNamedValues ( ) const
inline

returns a Sequence< Any >, containing NamedValues

Definition at line 294 of file namedvaluecollection.hxx.

css::uno::Sequence< css::uno::Any > comphelper::NamedValueCollection::getWrappedPropertyValues ( ) const
inline

returns a Sequence< Any >, containing PropertyValues

Definition at line 286 of file namedvaluecollection.hxx.

bool comphelper::NamedValueCollection::has ( const sal_Char _pAsciiValueName) const
inline

determines whether a value with a given name is present in the collection

Definition at line 198 of file namedvaluecollection.hxx.

bool comphelper::NamedValueCollection::has ( const OUString &  _rValueName) const
inline

determines whether a value with a given name is present in the collection

Definition at line 204 of file namedvaluecollection.hxx.

void comphelper::NamedValueCollection::impl_assign ( const css::uno::Any &  i_rWrappedElements)
private
void comphelper::NamedValueCollection::impl_assign ( const css::uno::Sequence< css::uno::Any > &  _rArguments)
private
void comphelper::NamedValueCollection::impl_assign ( const css::uno::Sequence< css::beans::PropertyValue > &  _rArguments)
private
void comphelper::NamedValueCollection::impl_assign ( const css::uno::Sequence< css::beans::NamedValue > &  _rArguments)
private
const Any & comphelper::NamedValueCollection::impl_get ( const OUString &  _rValueName) const
private

Definition at line 267 of file namedvaluecollection.cxx.

References Any, and m_pImpl.

bool comphelper::NamedValueCollection::impl_has ( const OUString &  _rValueName) const
private

Definition at line 277 of file namedvaluecollection.cxx.

References m_pImpl.

Referenced by impl_put(), and merge().

bool comphelper::NamedValueCollection::impl_put ( const OUString &  _rValueName,
const css::uno::Any &  _rValue 
)
private

Definition at line 284 of file namedvaluecollection.cxx.

References impl_has(), and m_pImpl.

Referenced by merge().

bool comphelper::NamedValueCollection::impl_remove ( const OUString &  _rValueName)
private

Definition at line 292 of file namedvaluecollection.cxx.

References m_pImpl.

template<class VALUE_TYPE >
css::uno::Sequence< css::uno::Any > comphelper::NamedValueCollection::impl_wrap ( ) const
inlineprivate

Definition at line 331 of file namedvaluecollection.hxx.

References i.

NamedValueCollection & comphelper::NamedValueCollection::merge ( const NamedValueCollection _rAdditionalValues,
bool  _bOverwriteExisting 
)

merges the content of another collection into this

Parameters
_rAdditionalValuesthe collection whose values are to be merged
_bOverwriteExistingdefines whether or not elements which are already present in this should be overwritten (true) or preserved (false).
Returns
*this

Definition at line 127 of file namedvaluecollection.cxx.

References impl_has(), impl_put(), m_pImpl, and value.

NamedValueCollection & comphelper::NamedValueCollection::operator= ( const NamedValueCollection i_rCopySource)

Definition at line 72 of file namedvaluecollection.cxx.

References m_pImpl.

NamedValueCollection & comphelper::NamedValueCollection::operator= ( NamedValueCollection &&  i_rCopySource)
noexcept

Definition at line 78 of file namedvaluecollection.cxx.

References m_pImpl.

sal_Int32 comphelper::NamedValueCollection::operator>>= ( css::uno::Sequence< css::beans::PropertyValue > &  _out_rValues) const

transforms the collection to a sequence of PropertyValues

Returns
the number of elements in the sequence
sal_Int32 comphelper::NamedValueCollection::operator>>= ( css::uno::Sequence< css::beans::NamedValue > &  _out_rValues) const

transforms the collection to a sequence of NamedValues

Returns
the number of elements in the sequence
template<typename VALUE_TYPE >
bool comphelper::NamedValueCollection::put ( const sal_Char _pAsciiValueName,
const VALUE_TYPE &  _rValue 
)
inline

puts a value into the collection

Returns
true if and only if a value was already present previously, in which case it has been overwritten.

Definition at line 215 of file namedvaluecollection.hxx.

template<typename VALUE_TYPE >
bool comphelper::NamedValueCollection::put ( const OUString &  _rValueName,
const VALUE_TYPE &  _rValue 
)
inline

puts a value into the collection

Returns
true if and only if a value was already present previously, in which case it has been overwritten.

Definition at line 226 of file namedvaluecollection.hxx.

bool comphelper::NamedValueCollection::put ( const sal_Char _pAsciiValueName,
const css::uno::Any &  _rValue 
)
inline

Definition at line 231 of file namedvaluecollection.hxx.

bool comphelper::NamedValueCollection::put ( const OUString &  _rValueName,
const css::uno::Any &  _rValue 
)
inline

Definition at line 236 of file namedvaluecollection.hxx.

bool comphelper::NamedValueCollection::remove ( const sal_Char _pAsciiValueName)
inline

removes the value with the given name from the collection

Returns
true if and only if a value with the given name existed in the collection.

Definition at line 245 of file namedvaluecollection.hxx.

bool comphelper::NamedValueCollection::remove ( const OUString &  _rValueName)
inline

removes the value with the given name from the collection

Returns
true if and only if a value with the given name existed in the collection.

Definition at line 254 of file namedvaluecollection.hxx.

size_t comphelper::NamedValueCollection::size ( ) const

returns the number of elements in the collection

Definition at line 139 of file namedvaluecollection.cxx.

References m_pImpl.

Member Data Documentation

::std::unique_ptr< NamedValueCollection_Impl > comphelper::NamedValueCollection::m_pImpl
private

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