summaryrefslogtreecommitdiff
path: root/dbaccess/source/filter/hsqldb/createparser.hxx
blob: 327cab869f01d273c61b763df66ddf001daacd05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * 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/.
 */

#ifndef INCLUDED_DBACCESS_SOURCE_FILTER_HSQLDB_CREATEPARSER_HXX
#define INCLUDED_DBACCESS_SOURCE_FILTER_HSQLDB_CREATEPARSER_HXX

#include <vector>
#include "columndef.hxx"

namespace dbahsql
{
class SAL_DLLPUBLIC_EXPORT CreateStmtParser
{
private:
    std::vector<ColumnDefinition> m_aColumns;
    std::vector<OUString> m_aForeignParts;
    std::vector<OUString> m_PrimaryKeys;
    OUString m_sTableName;

protected:
    void parseColumnPart(const OUString& sColumnPart);
    void parsePrimaryKeys(const OUString& sPrimaryPart);

public:
    CreateStmtParser();
    virtual ~CreateStmtParser() {}

    /**
     * @return name of the table which is to be created.
     */
    OUString const& getTableName() const { return m_sTableName; }

    /**
     * @return primary keys of parsed table.
     */
    std::vector<OUString> const& getPrimaryKeys() const { return m_PrimaryKeys; }

    /**
     * @return a vector of column descriptors, representing the columns of the
     * parsed statement.
     */
    const std::vector<ColumnDefinition>& getColumnDef() const { return m_aColumns; }

    /**
     * @return a vector of words.
     */
    const std::vector<OUString>& getForeignParts() const { return m_aForeignParts; }

    /**
     * Parses a create statement.
     *
     * @param SQL "CREATE" statement
     */
    void parse(const OUString& sSql);

    /**
     * Recreate the sql statement.
     */
    virtual OUString compose() const = 0;
};
}

#endif // INCLUDED_DBACCESS_SOURCE_FILTER_HSQLDB_CREATEPARSER_HXX

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