conditionalexpression.hxx 3.56 KB
Newer Older
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
Michael Meeks's avatar
Michael Meeks committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
19

20 21
#ifndef INCLUDED_REPORTDESIGN_INC_CONDITIONALEXPRESSION_HXX
#define INCLUDED_REPORTDESIGN_INC_CONDITIONALEXPRESSION_HXX
22 23 24 25 26

#include "dllapi.h"

#include <rtl/ustring.hxx>
#include <map>
Caolán McNamara's avatar
Caolán McNamara committed
27
#include <memory>
28

29 30 31
namespace rptui
{

32

33
    // = ConditionalExpression
34

35 36 37
    class REPORTDESIGN_DLLPUBLIC ConditionalExpression
    {
    private:
38
        const OUString       m_sPattern;
39 40 41 42 43 44

    public:
        ConditionalExpression( const sal_Char* _pAsciiPattern );

        /** assembles an expression string from a field data source, and one or two operands
        */
45
        OUString     assembleExpression( const OUString& _rFieldDataSource, const OUString& _rLHS, const OUString& _rRHS ) const;
46 47 48 49 50 51 52 53 54 55 56 57 58 59

        /** matches the given expression string to the expression pattern represented by the object
            @param  _rExpression
                the expression to match
            @param  _rFieldDataSource
                the field data source
            @param  _out_rLHS
                output parameter taking the left hand side operand, if successful
            @param  _out_rRHS
                output parameter taking the right hand side operand, if successful
            @return
                <TRUE/> if and only if the expression string could be successfully matched to
                the pattern.
        */
60
        bool                matchExpression( const OUString& _rExpression, const OUString& _rFieldDataSource, OUString& _out_rLHS, OUString& _out_rRHS ) const;
61 62
    };

63

64
    //= ConditionType
65

66 67 68 69 70 71
    enum ConditionType
    {
        eFieldValueComparison   = 0,
        eExpression             = 1
    };

72

73
    //= ComparisonOperation
74

75 76 77 78 79 80 81 82 83 84 85 86
    enum ComparisonOperation
    {
        eBetween        = 0,
        eNotBetween     = 1,
        eEqualTo        = 2,
        eNotEqualTo     = 3,
        eGreaterThan    = 4,
        eLessThan       = 5,
        eGreaterOrEqual = 6,
        eLessOrEqual    = 7
    };

Caolán McNamara's avatar
Caolán McNamara committed
87
    typedef std::shared_ptr< ConditionalExpression >                PConditionalExpression;
88 89
    typedef ::std::map< ComparisonOperation, PConditionalExpression >   ConditionalExpressions;

90

91
    // = ConditionalExpressionFactory
92

93 94 95 96 97 98 99
    class REPORTDESIGN_DLLPUBLIC ConditionalExpressionFactory
    {
    public:
        /// fills the given map with all ConditionalExpressions which we know
        static size_t  getKnownConditionalExpressions( ConditionalExpressions& _out_rCondExp );

    private:
100 101
        ConditionalExpressionFactory( const ConditionalExpressionFactory& ) = delete;
        ConditionalExpressionFactory& operator=( const ConditionalExpressionFactory& ) = delete;
102
    };
103

104
} // namespace rptui
105

106

107
#endif // INCLUDED_REPORTDESIGN_INC_CONDITIONALEXPRESSION_HXX
108 109

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */