1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX
21 #define DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX
24 #include <rtl/ustrbuf.hxx>
31 //====================================================================
33 //====================================================================
34 struct TokenComposer
: public ::std::unary_function
< ::rtl::OUString
, void >
42 ::rtl::OUStringBuffer m_aBuffer
;
45 ::rtl::OUString
getComposedAndClear()
50 return m_aBuffer
.makeStringAndClear();
58 m_aBuffer
.makeStringAndClear();
69 virtual ~TokenComposer()
73 void operator() (const ::rtl::OUString
& lhs
)
78 void append( const ::rtl::OUString
& lhs
)
81 OSL_ENSURE( !m_bUsed
, "FilterCreator::append: already used up!" );
85 if ( m_aBuffer
.getLength() )
86 appendNonEmptyToNonEmpty( lhs
);
88 m_aBuffer
.append( lhs
);
92 /// append the given part. Only to be called when both the part and our buffer so far are not empty
93 virtual void appendNonEmptyToNonEmpty( const ::rtl::OUString
& lhs
) = 0;
96 //====================================================================
98 //====================================================================
99 struct FilterCreator
: public TokenComposer
101 virtual void appendNonEmptyToNonEmpty( const ::rtl::OUString
& lhs
)
103 m_aBuffer
.insert( 0, (sal_Unicode
)' ' );
104 m_aBuffer
.insert( 0, (sal_Unicode
)'(' );
105 m_aBuffer
.appendAscii( " ) AND ( " );
106 m_aBuffer
.append( lhs
);
107 m_aBuffer
.appendAscii( " )" );
111 //====================================================================
113 //====================================================================
114 struct OrderCreator
: public TokenComposer
116 virtual void appendNonEmptyToNonEmpty( const ::rtl::OUString
& lhs
)
118 m_aBuffer
.appendAscii( ", " );
119 m_aBuffer
.append( lhs
);
123 } // namespace dbaccess
125 #endif // DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */