diff options
author | Kurt Zenker <kz@openoffice.org> | 2008-04-04 15:14:50 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2008-04-04 15:14:50 +0000 |
commit | 46efe8d2060687fada952b64fe723a271823f755 (patch) | |
tree | 6fbb1f3e033e2742d0b0a9dbe8bc024671428905 /comphelper | |
parent | ce4dcfd233a93c23fffa45199dc9f1a1c47554c5 (diff) |
INTEGRATION: CWS pdfimport (1.11.68); FILE MERGED
2008/01/25 08:30:20 akhva 1.11.68.1: #i80825# resync
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/inc/comphelper/sequence.hxx | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/comphelper/inc/comphelper/sequence.hxx b/comphelper/inc/comphelper/sequence.hxx index 03f909b32ea9..78f77a589198 100644 --- a/comphelper/inc/comphelper/sequence.hxx +++ b/comphelper/inc/comphelper/sequence.hxx @@ -4,9 +4,9 @@ * * $RCSfile: sequence.hxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: rt $ $Date: 2007-07-06 10:19:13 $ + * last change: $Author: kz $ $Date: 2008-04-04 16:14:50 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -343,7 +343,7 @@ namespace comphelper @param i_Sequence Reference to a Sequence of SrcType elements - @return a pointer to the generated container + @return the generated container @attention this function always performs a copy. Furthermore, when copying from e.g. a Sequence<double> to a vector<int>, no @@ -358,6 +358,44 @@ namespace comphelper ::std::copy( i_Sequence.getConstArray(), i_Sequence.getConstArray()+i_Sequence.getLength(), result.begin() ); return result; } + //------------------------------------------------------------------------- + /** Copy from a Sequence into an existing container + + This potentially saves a needless extra copy operation over + the whole container, as it passes the target object by + reference. + + @tpl SrcType + Sequence element type. Must be assignable to SrcType's + elements + + @tpl DstType + Container type. This type must fulfill the STL container and + sequence concepts, in particular, the begin(), end() and + resize(int) methods must be available and have the usual + semantics. + + @param o_Output + Reference to the target container + + @param i_Sequence + Reference to a Sequence of SrcType elements + + @return a non-const reference to the given container + + @attention this function always performs a copy. Furthermore, + when copying from e.g. a Sequence<double> to a vector<int>, no + proper rounding will be performed, but the values will be + truncated. There's currently no measure to prevent or detect + precision loss, overflow or truncation. + */ + template < typename DstType, typename SrcType > + DstType& sequenceToContainer( DstType& o_Output, const ::com::sun::star::uno::Sequence< SrcType >& i_Sequence ) + { + o_Output.resize( i_Sequence.getLength() ); + ::std::copy( i_Sequence.getConstArray(), i_Sequence.getConstArray()+i_Sequence.getLength(), o_Output.begin() ); + return o_Output; + } //......................................................................... } // namespace comphelper |