LibreOffice Module comphelper (master) 1
Public Member Functions | Static Public Member Functions | Private Member Functions | Static 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 ()=default
 
 NamedValueCollection (const NamedValueCollection &_rCopySource)=default
 
 NamedValueCollection (NamedValueCollection &&_rCopySource) noexcept=default
 
NamedValueCollectionoperator= (const NamedValueCollection &i_rCopySource)=default
 
NamedValueCollectionoperator= (NamedValueCollection &&i_rCopySource) noexcept=default
 
 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...
 
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 OUString &_rValueName, VALUE_TYPE &_out_rValue) const
 retrieves a value with a given name from the collection, if it is present More...
 
template<typename VALUE_TYPE >
VALUE_TYPE getOrDefault (const OUString &_rValueName, 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...
 
const css::uno::Any & get (const OUString &_rValueName) const
 retrieves a (untyped) value with a given name 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 OUString &_rValueName, const VALUE_TYPE &_rValue)
 puts a value into the collection More...
 
bool put (const OUString &_rValueName, const css::uno::Any &_rValue)
 
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...
 
template<typename VALUE_TYPE >
static VALUE_TYPE getOrDefault (const css::uno::Sequence< css::beans::PropertyValue > &rPropSeq, std::u16string_view _rValueName, const VALUE_TYPE &_rDefault)
 Retrieves a value with a given name, or defaults it to a given value, if it's not present in the collection. More...
 
static const css::uno::Any & get (const css::uno::Sequence< css::beans::PropertyValue > &rPropSeq, std::u16string_view _rValueName)
 retrieves a (untyped) value with a given name. 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
 

Static Private Member Functions

static bool get_ensureType (const css::uno::Sequence< css::beans::PropertyValue > &rPropSeq, std::u16string_view _rValueName, void *_pValueLocation, const css::uno::Type &_rExpectedValueType)
 

Private Attributes

std::unordered_map< OUString, css::uno::Any > maValues
 

Detailed Description

a collection of named values, packed in various formats.

Definition at line 41 of file namedvaluecollection.hxx.

Constructor & Destructor Documentation

◆ NamedValueCollection() [1/7]

comphelper::NamedValueCollection::NamedValueCollection ( )
default

◆ NamedValueCollection() [2/7]

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

◆ NamedValueCollection() [3/7]

comphelper::NamedValueCollection::NamedValueCollection ( NamedValueCollection &&  _rCopySource)
defaultnoexcept

◆ NamedValueCollection() [4/7]

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.

◆ NamedValueCollection() [5/7]

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.

◆ NamedValueCollection() [6/7]

comphelper::NamedValueCollection::NamedValueCollection ( const css::uno::Sequence< css::beans::PropertyValue > &  _rArguments)

constructs a collection

Parameters
_rArgumentsa sequence of PropertyValues's

◆ NamedValueCollection() [7/7]

comphelper::NamedValueCollection::NamedValueCollection ( const css::uno::Sequence< css::beans::NamedValue > &  _rArguments)

constructs a collection

Parameters
_rArgumentsa sequence of NamedValue's

Member Function Documentation

◆ assign()

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

Definition at line 79 of file namedvaluecollection.hxx.

◆ canExtractFrom()

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 71 of file namedvaluecollection.cxx.

References get().

◆ clear()

void comphelper::NamedValueCollection::clear ( )
inline

Definition at line 84 of file namedvaluecollection.hxx.

◆ empty()

bool comphelper::NamedValueCollection::empty ( ) const

determines whether the collection is empty

Definition at line 99 of file namedvaluecollection.cxx.

References maValues.

◆ get() [1/2]

const css::uno::Any & comphelper::NamedValueCollection::get ( const css::uno::Sequence< css::beans::PropertyValue > &  rPropSeq,
std::u16string_view  _rValueName 
)
static

retrieves a (untyped) value with a given name.

For when you only need a single value from a Sequence<PropertyValue>.

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

Definition at line 235 of file namedvaluecollection.cxx.

References Any.

◆ get() [2/2]

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 178 of file namedvaluecollection.hxx.

Referenced by canExtractFrom().

◆ get_ensureType() [1/3]

static bool comphelper::NamedValueCollection::get_ensureType ( const css::uno::Sequence< css::beans::PropertyValue > &  rPropSeq,
std::u16string_view  _rValueName,
void *  _pValueLocation,
const css::uno::Type &  _rExpectedValueType 
)
staticprivate

◆ get_ensureType() [2/3]

template<typename VALUE_TYPE >
bool comphelper::NamedValueCollection::get_ensureType ( const OUString &  _rValueName,
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 144 of file namedvaluecollection.hxx.

◆ get_ensureType() [3/3]

bool comphelper::NamedValueCollection::get_ensureType ( const OUString &  _rValueName,
void *  _pValueLocation,
const css::uno::Type &  _rExpectedValueType 
) const
private

◆ getNamedValues()

css::uno::Sequence< css::beans::NamedValue > comphelper::NamedValueCollection::getNamedValues ( ) const
inline

transforms the collection into a sequence of NamedValues

Definition at line 264 of file namedvaluecollection.hxx.

◆ getNames()

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

returns the names of all elements in the collection

Definition at line 105 of file namedvaluecollection.cxx.

References maValues, and value.

◆ getOrDefault() [1/2]

template<typename VALUE_TYPE >
static VALUE_TYPE comphelper::NamedValueCollection::getOrDefault ( const css::uno::Sequence< css::beans::PropertyValue > &  rPropSeq,
std::u16string_view  _rValueName,
const VALUE_TYPE &  _rDefault 
)
inlinestatic

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

For when you only need a single value from a Sequence<PropertyValue>.

Definition at line 165 of file namedvaluecollection.hxx.

◆ getOrDefault() [2/2]

template<typename VALUE_TYPE >
VALUE_TYPE comphelper::NamedValueCollection::getOrDefault ( const OUString &  _rValueName,
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 153 of file namedvaluecollection.hxx.

◆ getPropertyValues()

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

transforms the collection into a sequence of PropertyValues

Definition at line 238 of file namedvaluecollection.hxx.

◆ getWrappedNamedValues()

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

returns a Sequence< Any >, containing NamedValues

Definition at line 256 of file namedvaluecollection.hxx.

◆ getWrappedPropertyValues()

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

returns a Sequence< Any >, containing PropertyValues

Definition at line 248 of file namedvaluecollection.hxx.

◆ has()

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 191 of file namedvaluecollection.hxx.

◆ impl_assign() [1/4]

void comphelper::NamedValueCollection::impl_assign ( const css::uno::Any &  i_rWrappedElements)
private

◆ impl_assign() [2/4]

void comphelper::NamedValueCollection::impl_assign ( const css::uno::Sequence< css::beans::NamedValue > &  _rArguments)
private

◆ impl_assign() [3/4]

void comphelper::NamedValueCollection::impl_assign ( const css::uno::Sequence< css::beans::PropertyValue > &  _rArguments)
private

◆ impl_assign() [4/4]

void comphelper::NamedValueCollection::impl_assign ( const css::uno::Sequence< css::uno::Any > &  _rArguments)
private

◆ impl_get()

const Any & comphelper::NamedValueCollection::impl_get ( const OUString &  _rValueName) const
private

Definition at line 249 of file namedvaluecollection.cxx.

References Any, maValues, and pos.

◆ impl_has()

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

Definition at line 260 of file namedvaluecollection.cxx.

References maValues, and pos.

Referenced by impl_put(), and merge().

◆ impl_put()

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

Definition at line 267 of file namedvaluecollection.cxx.

References impl_has(), and maValues.

Referenced by merge().

◆ impl_remove()

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

Definition at line 275 of file namedvaluecollection.cxx.

References maValues, and pos.

◆ impl_wrap()

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

Definition at line 300 of file namedvaluecollection.hxx.

References i.

◆ merge()

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 81 of file namedvaluecollection.cxx.

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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator>>=() [1/2]

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

◆ operator>>=() [2/2]

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

◆ put() [1/2]

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

Definition at line 207 of file namedvaluecollection.hxx.

◆ put() [2/2]

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 202 of file namedvaluecollection.hxx.

◆ remove()

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 216 of file namedvaluecollection.hxx.

◆ size()

size_t comphelper::NamedValueCollection::size ( ) const

returns the number of elements in the collection

Definition at line 93 of file namedvaluecollection.cxx.

References maValues.

Member Data Documentation

◆ maValues

std::unordered_map< OUString, css::uno::Any > comphelper::NamedValueCollection::maValues
private

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