1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: composertools.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX
32 #define DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX
34 /** === begin UNO includes === **/
35 /** === end UNO includes === **/
37 #ifndef _RTL_USTRBUF_HXX_
38 #include <rtl/ustrbuf.hxx>
43 //........................................................................
46 //........................................................................
48 //====================================================================
50 //====================================================================
51 struct TokenComposer
: public ::std::unary_function
< ::rtl::OUString
, void >
59 ::rtl::OUStringBuffer m_aBuffer
;
62 ::rtl::OUString
getComposedAndClear()
67 return m_aBuffer
.makeStringAndClear();
75 m_aBuffer
.makeStringAndClear();
86 virtual ~TokenComposer()
90 void operator() (const ::rtl::OUString
& lhs
)
95 void append( const ::rtl::OUString
& lhs
)
98 OSL_ENSURE( !m_bUsed
, "FilterCreator::append: already used up!" );
100 if ( lhs
.getLength() )
102 if ( m_aBuffer
.getLength() )
103 appendNonEmptyToNonEmpty( lhs
);
105 m_aBuffer
.append( lhs
);
109 /// append the given part. Only to be called when both the part and our buffer so far are not empty
110 virtual void appendNonEmptyToNonEmpty( const ::rtl::OUString
& lhs
) = 0;
113 //====================================================================
115 //====================================================================
116 struct FilterCreator
: public TokenComposer
118 virtual void appendNonEmptyToNonEmpty( const ::rtl::OUString
& lhs
)
120 m_aBuffer
.insert( 0, (sal_Unicode
)' ' );
121 m_aBuffer
.insert( 0, (sal_Unicode
)'(' );
122 m_aBuffer
.appendAscii( " ) AND ( " );
123 m_aBuffer
.append( lhs
);
124 m_aBuffer
.appendAscii( " )" );
128 //====================================================================
130 //====================================================================
131 struct OrderCreator
: public TokenComposer
133 virtual void appendNonEmptyToNonEmpty( const ::rtl::OUString
& lhs
)
135 m_aBuffer
.appendAscii( ", " );
136 m_aBuffer
.append( lhs
);
140 //........................................................................
141 } // namespace dbaccess
142 //........................................................................
144 #endif // DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX