diff options
author | Christian Lippka <cl@openoffice.org> | 2001-03-21 09:18:55 +0000 |
---|---|---|
committer | Christian Lippka <cl@openoffice.org> | 2001-03-21 09:18:55 +0000 |
commit | be1246756710bc21fb759c2bdc3d5f93b5fd82ff (patch) | |
tree | 4ede39a78065f0e83499360690c70b19161e1922 /comphelper | |
parent | 652c830068b2db32ba032309598922f938fa46c5 (diff) |
removed use of templates
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/inc/comphelper/namecontainer.hxx | 78 | ||||
-rw-r--r-- | comphelper/source/container/namecontainer.cxx | 132 |
2 files changed, 100 insertions, 110 deletions
diff --git a/comphelper/inc/comphelper/namecontainer.hxx b/comphelper/inc/comphelper/namecontainer.hxx index b466d334cfac..8b9c4d2e91cb 100644 --- a/comphelper/inc/comphelper/namecontainer.hxx +++ b/comphelper/inc/comphelper/namecontainer.hxx @@ -2,9 +2,9 @@ * * $RCSfile: namecontainer.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: cl $ $Date: 2001-03-20 19:51:46 $ + * last change: $Author: cl $ $Date: 2001-03-21 10:18:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,82 +62,18 @@ #ifndef _COMPHELPER_NAMECONTAINER_HXX_ #define _COMPHELPER_NAMECONTAINER_HXX_ -#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ -#include <com/sun/star/container/XNameContainer.hpp> +#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_ +#include <com/sun/star/uno/Type.hxx> #endif -#ifndef _CPPUHELPER_IMPLBASE1_HXX_ -#include <cppuhelper/implbase1.hxx> +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> #endif namespace comphelper { - struct NameContainerBaseImpl; - - /** this is the base helper class for NameContainer thats also declared in this header. */ - class NameContainerBase : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XNameContainer > - { - public: - NameContainerBase(); - virtual ~NameContainerBase(); - - // XNameContainer - virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) - throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, - ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) - throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException); - - // XNameReplace - virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) - throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, - ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - // XNameAccess - virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) - throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) - throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) - throw(::com::sun::star::uno::RuntimeException); - - // XElementAccess - virtual sal_Bool SAL_CALL hasElements( ) - throw(::com::sun::star::uno::RuntimeException); - - private: - NameContainerBaseImpl* mp; - }; - - /** this is a generic name container for a uno type specified by ELEMENT. - No restrictions are made except that all any values must have the exact - type ELEMENT and must have a value. */ - template< typename ELEMENT > - class NameContainer : public NameContainerBase - { - public: - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) - throw(::com::sun::star::uno::RuntimeException); - }; - - - // XElementAccess - template< typename ELEMENT > - ::com::sun::star::uno::Type SAL_CALL NameContainer<ELEMENT>::getElementType( ) - throw(::com::sun::star::uno::RuntimeException) - { - return ::getCppuType((const ELEMENT *)0); - } - - template< typename ELEMENT > ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > - NameContainer_createInstance() - { - return (::com::sun::star::container::XNameContainer*) new NameContainer< ELEMENT >; - } - + NameContainer_createInstance( ::com::sun::star::uno::Type aType ); } #endif // _COMPHELPER_NAMECONTAINER_HXX_ diff --git a/comphelper/source/container/namecontainer.cxx b/comphelper/source/container/namecontainer.cxx index 0114297139e9..a5a2e799c195 100644 --- a/comphelper/source/container/namecontainer.cxx +++ b/comphelper/source/container/namecontainer.cxx @@ -2,9 +2,9 @@ * * $RCSfile: namecontainer.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: cl $ $Date: 2001-03-20 19:52:46 $ + * last change: $Author: cl $ $Date: 2001-03-21 10:18:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,6 +63,10 @@ #include <comphelper/namecontainer.hxx> #endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif + #ifndef _OSL_DIAGNOSE_H_ #include <osl/diagnose.h> #endif @@ -79,11 +83,51 @@ DECLARE_STL_USTRINGACCESS_MAP( ::com::sun::star::uno::Any, SvGenericNameContaine namespace comphelper { - struct NameContainerBaseImpl + class NameContainerImpl { - SvGenericNameContainerMapImpl maProperties; + public: osl::Mutex maMutex; }; + + /** this is the base helper class for NameContainer thats also declared in this header. */ + class NameContainer : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XNameContainer >, private NameContainerImpl + { + public: + NameContainer( ::com::sun::star::uno::Type aType ); + virtual ~NameContainer(); + + // XNameContainer + virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) + throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, + ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) + throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XNameReplace + virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) + throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XNameAccess + virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) + throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) + throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) + throw(::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual sal_Bool SAL_CALL hasElements( ) + throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) + throw(::com::sun::star::uno::RuntimeException); + + private: + SvGenericNameContainerMapImpl maProperties; + const ::com::sun::star::uno::Type maType; + }; } using namespace ::comphelper; @@ -94,58 +138,57 @@ using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; -NameContainerBase::NameContainerBase() +NameContainer::NameContainer( ::com::sun::star::uno::Type aType ) +: maType( aType ) { - mp = new NameContainerBaseImpl; } -NameContainerBase::~NameContainerBase() +NameContainer::~NameContainer() { - delete mp; } // XNameContainer -void SAL_CALL NameContainerBase::insertByName( const rtl::OUString& aName, const Any& aElement ) +void SAL_CALL NameContainer::insertByName( const rtl::OUString& aName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException) { - MutexGuard aGuard( mp->maMutex ); + MutexGuard aGuard( maMutex ); - if( mp->maProperties.find( aName ) != mp->maProperties.end() ) + if( maProperties.find( aName ) != maProperties.end() ) throw ElementExistException(); - if( aElement.getValueType() != getElementType() ) + if( aElement.getValueType() != maType ) throw IllegalArgumentException(); - mp->maProperties[ aName ] = aElement; + maProperties[ aName ] = aElement; } -void SAL_CALL NameContainerBase::removeByName( const ::rtl::OUString& Name ) +void SAL_CALL NameContainer::removeByName( const ::rtl::OUString& Name ) throw(NoSuchElementException, WrappedTargetException, RuntimeException) { - MutexGuard aGuard( mp->maMutex ); + MutexGuard aGuard( maMutex ); - SvGenericNameContainerMapImpl::iterator aIter = mp->maProperties.find( Name ); - if( aIter == mp->maProperties.end() ) + SvGenericNameContainerMapImpl::iterator aIter = maProperties.find( Name ); + if( aIter == maProperties.end() ) throw NoSuchElementException(); - mp->maProperties.erase( aIter ); + maProperties.erase( aIter ); } // XNameReplace -void SAL_CALL NameContainerBase::replaceByName( const ::rtl::OUString& aName, const Any& aElement ) +void SAL_CALL NameContainer::replaceByName( const ::rtl::OUString& aName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException) { - MutexGuard aGuard( mp->maMutex ); + MutexGuard aGuard( maMutex ); - SvGenericNameContainerMapImpl::iterator aIter( mp->maProperties.find( aName ) ); - if( aIter == mp->maProperties.end() ) + SvGenericNameContainerMapImpl::iterator aIter( maProperties.find( aName ) ); + if( aIter == maProperties.end() ) throw NoSuchElementException(); - if( aElement.getValueType() != getElementType() ) + if( aElement.getValueType() != maType ) throw IllegalArgumentException(); (*aIter).second = aElement; @@ -153,28 +196,28 @@ void SAL_CALL NameContainerBase::replaceByName( const ::rtl::OUString& aName, co // XNameAccess -Any SAL_CALL NameContainerBase::getByName( const ::rtl::OUString& aName ) +Any SAL_CALL NameContainer::getByName( const ::rtl::OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException) { - MutexGuard aGuard( mp->maMutex ); + MutexGuard aGuard( maMutex ); - SvGenericNameContainerMapImpl::iterator aIter = mp->maProperties.find( aName ); - if( aIter == mp->maProperties.end() ) + SvGenericNameContainerMapImpl::iterator aIter = maProperties.find( aName ); + if( aIter == maProperties.end() ) throw NoSuchElementException(); return (*aIter).second; } -Sequence< ::rtl::OUString > SAL_CALL NameContainerBase::getElementNames( ) +Sequence< ::rtl::OUString > SAL_CALL NameContainer::getElementNames( ) throw(RuntimeException) { - MutexGuard aGuard( mp->maMutex ); + MutexGuard aGuard( maMutex ); - SvGenericNameContainerMapImpl::iterator aIter = mp->maProperties.begin(); - const SvGenericNameContainerMapImpl::iterator aEnd = mp->maProperties.end(); + SvGenericNameContainerMapImpl::iterator aIter = maProperties.begin(); + const SvGenericNameContainerMapImpl::iterator aEnd = maProperties.end(); - Sequence< rtl::OUString > aNames( mp->maProperties.size() ); + Sequence< rtl::OUString > aNames( maProperties.size() ); rtl::OUString* pNames = aNames.getArray(); while( aIter != aEnd ) @@ -185,19 +228,30 @@ Sequence< ::rtl::OUString > SAL_CALL NameContainerBase::getElementNames( ) return aNames; } -sal_Bool SAL_CALL NameContainerBase::hasByName( const ::rtl::OUString& aName ) +sal_Bool SAL_CALL NameContainer::hasByName( const ::rtl::OUString& aName ) throw(RuntimeException) { - MutexGuard aGuard( mp->maMutex ); + MutexGuard aGuard( maMutex ); - SvGenericNameContainerMapImpl::iterator aIter = mp->maProperties.find( aName ); - return aIter != mp->maProperties.end(); + SvGenericNameContainerMapImpl::iterator aIter = maProperties.find( aName ); + return aIter != maProperties.end(); } -sal_Bool SAL_CALL NameContainerBase::hasElements( ) +sal_Bool SAL_CALL NameContainer::hasElements( ) throw(RuntimeException) { - MutexGuard aGuard( mp->maMutex ); + MutexGuard aGuard( maMutex ); - return mp->maProperties.size() != 0; + return maProperties.size() != 0; +} + +Type SAL_CALL NameContainer::getElementType() + throw( RuntimeException ) +{ + return maType; +} + +Reference< XNameContainer > comphelper::NameContainer_createInstance( Type aType ) +{ + return (XNameContainer*) new NameContainer( aType ); } |