Bump version to 5.0-14
[LibreOffice.git] / dbaccess / source / ui / inc / TypeInfo.hxx
blob42ada9d07062a9d72dd9658bfef18a6f0a1779a9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_TYPEINFO_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_INC_TYPEINFO_HXX
22 #include <rtl/ustring.hxx>
23 #include <com/sun/star/sdbc/DataType.hpp>
24 #include <com/sun/star/sdbc/ColumnSearch.hpp>
25 #include <com/sun/star/sdbc/ColumnValue.hpp>
26 #include <boost/shared_ptr.hpp>
27 #include <map>
29 namespace dbaui
31 // Based on these ids the language dependent OUString are fetched from the resource
32 const sal_uInt16 TYPE_UNKNOWN = 0;
33 const sal_uInt16 TYPE_TEXT = 1;
34 const sal_uInt16 TYPE_NUMERIC = 2;
35 const sal_uInt16 TYPE_DATETIME = 3;
36 const sal_uInt16 TYPE_DATE = 4;
37 const sal_uInt16 TYPE_TIME = 5;
38 const sal_uInt16 TYPE_BOOL = 6;
39 const sal_uInt16 TYPE_CURRENCY = 7;
40 const sal_uInt16 TYPE_MEMO = 8;
41 const sal_uInt16 TYPE_COUNTER = 9;
42 const sal_uInt16 TYPE_IMAGE = 10;
43 const sal_uInt16 TYPE_CHAR = 11;
44 const sal_uInt16 TYPE_DECIMAL = 12;
45 const sal_uInt16 TYPE_BINARY = 13;
46 const sal_uInt16 TYPE_VARBINARY = 14;
47 const sal_uInt16 TYPE_BIGINT = 15;
48 const sal_uInt16 TYPE_DOUBLE = 16;
49 const sal_uInt16 TYPE_FLOAT = 17;
50 const sal_uInt16 TYPE_REAL = 18;
51 const sal_uInt16 TYPE_INTEGER = 19;
52 const sal_uInt16 TYPE_SMALLINT = 20;
53 const sal_uInt16 TYPE_TINYINT = 21;
54 const sal_uInt16 TYPE_SQLNULL = 22;
55 const sal_uInt16 TYPE_OBJECT = 23;
56 const sal_uInt16 TYPE_DISTINCT = 24;
57 const sal_uInt16 TYPE_STRUCT = 25;
58 const sal_uInt16 TYPE_ARRAY = 26;
59 const sal_uInt16 TYPE_BLOB = 27;
60 const sal_uInt16 TYPE_CLOB = 28;
61 const sal_uInt16 TYPE_REF = 29;
62 const sal_uInt16 TYPE_OTHER = 30;
63 const sal_uInt16 TYPE_BIT = 31;
65 class OTypeInfo
67 public:
68 OUString aUIName; // the name which is the user see (a combination of resource text and aTypeName)
69 OUString aTypeName; // name of type in database
70 OUString aLiteralPrefix; // prefix for quoting
71 OUString aLiteralSuffix; // suffix for quoting
72 OUString aCreateParams; // parameter for creation
73 OUString aLocalTypeName;
75 sal_Int32 nPrecision; // length of type
76 sal_Int32 nNumPrecRadix; // indicating the radix, which is usually 2 or 10
77 sal_Int32 nType; // database type
79 sal_Int16 nMaximumScale; // decimal places after decimal point
80 sal_Int16 nMinimumScale; // min decimal places after decimal point
82 sal_Int16 nSearchType; // if it is possible to search for type
84 bool bCurrency : 1, // currency
85 bAutoIncrement : 1, // if automatic incrementing field
86 bNullable : 1, // if field can be NULL
87 bCaseSensitive : 1, // if type is case sensitive
88 bUnsigned : 1; // if type is unsigned
90 OTypeInfo()
91 :nPrecision(0)
92 ,nNumPrecRadix(10)
93 ,nType(::com::sun::star::sdbc::DataType::OTHER)
94 ,nMaximumScale(0)
95 ,nMinimumScale(0)
96 ,nSearchType(::com::sun::star::sdbc::ColumnSearch::FULL)
97 ,bCurrency(false)
98 ,bAutoIncrement(false)
99 ,bNullable(true)
100 ,bCaseSensitive(false)
101 ,bUnsigned(false)
103 bool operator == (const OTypeInfo& lh) const { return lh.nType == nType; }
104 bool operator != (const OTypeInfo& lh) const { return lh.nType != nType; }
105 inline OUString getDBName() const { return aTypeName; }
109 typedef ::boost::shared_ptr<OTypeInfo> TOTypeInfoSP;
110 typedef ::std::multimap<sal_Int32,TOTypeInfoSP> OTypeInfoMap;
111 /** return the most suitable typeinfo for a requested type
112 @param _rTypeInfo contains a map of type to typeinfo
113 @param _nType the requested type
114 @param _sTypeName the typename
115 @param _sCreateParams the create params
116 @param _nPrecision the precision
117 @param _nScale the scale
118 @param _bAutoIncrement if it is a auto increment
119 @param _brForceToType true when type was found which has some differenes
121 TOTypeInfoSP getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo,
122 sal_Int32 _nType,
123 const OUString& _sTypeName,
124 const OUString& _sCreateParams,
125 sal_Int32 _nPrecision,
126 sal_Int32 _nScale,
127 bool _bAutoIncrement,
128 bool& _brForceToType);
131 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_TYPEINFO_HXX
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */