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 .
22 #include <rtl/ustrbuf.hxx>
23 #include <osl/diagnose.h>
37 OUStringBuffer m_aBuffer
;
40 OUString
getComposedAndClear()
45 return m_aBuffer
.makeStringAndClear();
53 m_aBuffer
.setLength(0);
64 virtual ~TokenComposer()
68 TokenComposer(TokenComposer
const &) = default;
69 TokenComposer(TokenComposer
&&) = default;
70 TokenComposer
& operator =(TokenComposer
const &) = default;
71 TokenComposer
& operator =(TokenComposer
&&) = default;
73 void operator() (const OUString
& lhs
)
78 void append( const OUString
& lhs
)
81 OSL_ENSURE( !m_bUsed
, "FilterCreator::append: already used up!" );
85 if ( !m_aBuffer
.isEmpty() )
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 OUString
& lhs
) = 0;
97 struct FilterCreator
: public TokenComposer
99 virtual void appendNonEmptyToNonEmpty( const OUString
& lhs
) override
101 m_aBuffer
.insert( 0, ' ' );
102 m_aBuffer
.insert( 0, '(' );
103 m_aBuffer
.append( " ) AND ( " );
104 m_aBuffer
.append( lhs
);
105 m_aBuffer
.append( " )" );
110 struct OrderCreator
: public TokenComposer
112 virtual void appendNonEmptyToNonEmpty( const OUString
& lhs
) override
114 m_aBuffer
.append( ", " );
115 m_aBuffer
.append( lhs
);
119 } // namespace dbaccess
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */