1*079eb577SAndrew Rist /**************************************************************
2*079eb577SAndrew Rist *
3*079eb577SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*079eb577SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*079eb577SAndrew Rist * distributed with this work for additional information
6*079eb577SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*079eb577SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*079eb577SAndrew Rist * "License"); you may not use this file except in compliance
9*079eb577SAndrew Rist * with the License. You may obtain a copy of the License at
10*079eb577SAndrew Rist *
11*079eb577SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*079eb577SAndrew Rist *
13*079eb577SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*079eb577SAndrew Rist * software distributed under the License is distributed on an
15*079eb577SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*079eb577SAndrew Rist * KIND, either express or implied. See the License for the
17*079eb577SAndrew Rist * specific language governing permissions and limitations
18*079eb577SAndrew Rist * under the License.
19*079eb577SAndrew Rist *
20*079eb577SAndrew Rist *************************************************************/
21cdf0e10cSrcweir
22cdf0e10cSrcweir #ifndef _OSL_DIAGNOSE_H_
23cdf0e10cSrcweir #include <osl/diagnose.h>
24cdf0e10cSrcweir #endif
25cdf0e10cSrcweir #include "mysqlc_propertyids.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir using ::rtl::OUString;
28cdf0e10cSrcweir
29cdf0e10cSrcweir namespace connectivity
30cdf0e10cSrcweir {
31cdf0e10cSrcweir namespace mysqlc
32cdf0e10cSrcweir {
getPROPERTY_QUERYTIMEOUT()33cdf0e10cSrcweir const sal_Char* getPROPERTY_QUERYTIMEOUT() { return "QueryTimeOut"; }
getPROPERTY_MAXFIELDSIZE()34cdf0e10cSrcweir const sal_Char* getPROPERTY_MAXFIELDSIZE() { return "MaxFieldSize"; }
getPROPERTY_MAXROWS()35cdf0e10cSrcweir const sal_Char* getPROPERTY_MAXROWS() { return "MaxRows"; }
getPROPERTY_CURSORNAME()36cdf0e10cSrcweir const sal_Char* getPROPERTY_CURSORNAME() { return "CursorName"; }
getPROPERTY_RESULTSETCONCURRENCY()37cdf0e10cSrcweir const sal_Char* getPROPERTY_RESULTSETCONCURRENCY() { return "ResultSetConcurrency"; }
getPROPERTY_RESULTSETTYPE()38cdf0e10cSrcweir const sal_Char* getPROPERTY_RESULTSETTYPE() { return "ResultSetType"; }
getPROPERTY_FETCHDIRECTION()39cdf0e10cSrcweir const sal_Char* getPROPERTY_FETCHDIRECTION() { return "FetchDirection"; }
getPROPERTY_FETCHSIZE()40cdf0e10cSrcweir const sal_Char* getPROPERTY_FETCHSIZE() { return "FetchSize"; }
getPROPERTY_ESCAPEPROCESSING()41cdf0e10cSrcweir const sal_Char* getPROPERTY_ESCAPEPROCESSING() { return "EscapeProcessing"; }
getPROPERTY_USEBOOKMARKS()42cdf0e10cSrcweir const sal_Char* getPROPERTY_USEBOOKMARKS() { return "UseBookmarks"; }
43cdf0e10cSrcweir
getPROPERTY_NAME()44cdf0e10cSrcweir const sal_Char* getPROPERTY_NAME() { return "Name"; }
getPROPERTY_TYPE()45cdf0e10cSrcweir const sal_Char* getPROPERTY_TYPE() { return "Type"; }
getPROPERTY_TYPENAME()46cdf0e10cSrcweir const sal_Char* getPROPERTY_TYPENAME() { return "TypeName"; }
getPROPERTY_PRECISION()47cdf0e10cSrcweir const sal_Char* getPROPERTY_PRECISION() { return "Precision"; }
getPROPERTY_SCALE()48cdf0e10cSrcweir const sal_Char* getPROPERTY_SCALE() { return "Scale"; }
getPROPERTY_ISNULLABLE()49cdf0e10cSrcweir const sal_Char* getPROPERTY_ISNULLABLE() { return "IsNullable"; }
getPROPERTY_ISAUTOINCREMENT()50cdf0e10cSrcweir const sal_Char* getPROPERTY_ISAUTOINCREMENT() { return "IsAutoIncrement"; }
getPROPERTY_ISROWVERSION()51cdf0e10cSrcweir const sal_Char* getPROPERTY_ISROWVERSION() { return "IsRowVersion"; }
getPROPERTY_DESCRIPTION()52cdf0e10cSrcweir const sal_Char* getPROPERTY_DESCRIPTION() { return "Description"; }
getPROPERTY_DEFAULTVALUE()53cdf0e10cSrcweir const sal_Char* getPROPERTY_DEFAULTVALUE() { return "DefaultValue"; }
54cdf0e10cSrcweir
getPROPERTY_REFERENCEDTABLE()55cdf0e10cSrcweir const sal_Char* getPROPERTY_REFERENCEDTABLE() { return "ReferencedTable"; }
getPROPERTY_UPDATERULE()56cdf0e10cSrcweir const sal_Char* getPROPERTY_UPDATERULE() { return "UpdateRule"; }
getPROPERTY_DELETERULE()57cdf0e10cSrcweir const sal_Char* getPROPERTY_DELETERULE() { return "DeleteRule"; }
getPROPERTY_CATALOG()58cdf0e10cSrcweir const sal_Char* getPROPERTY_CATALOG() { return "Catalog"; }
getPROPERTY_ISUNIQUE()59cdf0e10cSrcweir const sal_Char* getPROPERTY_ISUNIQUE() { return "IsUnique"; }
getPROPERTY_ISPRIMARYKEYINDEX()60cdf0e10cSrcweir const sal_Char* getPROPERTY_ISPRIMARYKEYINDEX() { return "IsPrimaryKeyIndex"; }
getPROPERTY_ISCLUSTERED()61cdf0e10cSrcweir const sal_Char* getPROPERTY_ISCLUSTERED() { return "IsClustered"; }
getPROPERTY_ISASCENDING()62cdf0e10cSrcweir const sal_Char* getPROPERTY_ISASCENDING() { return "IsAscending"; }
getPROPERTY_SCHEMANAME()63cdf0e10cSrcweir const sal_Char* getPROPERTY_SCHEMANAME() { return "SchemaName"; }
getPROPERTY_CATALOGNAME()64cdf0e10cSrcweir const sal_Char* getPROPERTY_CATALOGNAME() { return "CatalogName"; }
getPROPERTY_COMMAND()65cdf0e10cSrcweir const sal_Char* getPROPERTY_COMMAND() { return "Command"; }
getPROPERTY_CHECKOPTION()66cdf0e10cSrcweir const sal_Char* getPROPERTY_CHECKOPTION() { return "CheckOption"; }
getPROPERTY_PASSWORD()67cdf0e10cSrcweir const sal_Char* getPROPERTY_PASSWORD() { return "Password"; }
getPROPERTY_RELATEDCOLUMN()68cdf0e10cSrcweir const sal_Char* getPROPERTY_RELATEDCOLUMN() { return "RelatedColumn"; }
69cdf0e10cSrcweir
getSTAT_INVALID_INDEX()70cdf0e10cSrcweir const sal_Char* getSTAT_INVALID_INDEX() { return "Invalid descriptor index"; }
71cdf0e10cSrcweir
getPROPERTY_FUNCTION()72cdf0e10cSrcweir const sal_Char* getPROPERTY_FUNCTION() { return "Function"; }
getPROPERTY_TABLENAME()73cdf0e10cSrcweir const sal_Char* getPROPERTY_TABLENAME() { return "TableName"; }
getPROPERTY_REALNAME()74cdf0e10cSrcweir const sal_Char* getPROPERTY_REALNAME() { return "RealName"; }
getPROPERTY_DBASEPRECISIONCHANGED()75cdf0e10cSrcweir const sal_Char* getPROPERTY_DBASEPRECISIONCHANGED() { return "DbasePrecisionChanged"; }
getPROPERTY_ISCURRENCY()76cdf0e10cSrcweir const sal_Char* getPROPERTY_ISCURRENCY() { return "IsCurrency"; }
getPROPERTY_ISBOOKMARKABLE()77cdf0e10cSrcweir const sal_Char* getPROPERTY_ISBOOKMARKABLE() { return "IsBookmarkable"; }
78cdf0e10cSrcweir
getPROPERTY_FORMATKEY()79cdf0e10cSrcweir const sal_Char* getPROPERTY_FORMATKEY() { return "FormatKey"; }
getPROPERTY_LOCALE()80cdf0e10cSrcweir const sal_Char* getPROPERTY_LOCALE() { return "Locale"; }
81cdf0e10cSrcweir
getPROPERTY_AUTOINCREMENTCREATION()82cdf0e10cSrcweir const sal_Char* getPROPERTY_AUTOINCREMENTCREATION() { return "AutoIncrementCreation"; }
getPROPERTY_PRIVILEGES()83cdf0e10cSrcweir const sal_Char* getPROPERTY_PRIVILEGES() { return "Privileges"; }
84cdf0e10cSrcweir //============================================================
85cdf0e10cSrcweir //= error messages
86cdf0e10cSrcweir //============================================================
getERRORMSG_SEQUENCE()87cdf0e10cSrcweir const sal_Char* getERRORMSG_SEQUENCE() { return "Function sequence error"; }
getSQLSTATE_SEQUENCE()88cdf0e10cSrcweir const sal_Char* getSQLSTATE_SEQUENCE() { return "HY010"; }
getSQLSTATE_GENERAL()89cdf0e10cSrcweir const sal_Char* getSQLSTATE_GENERAL() { return "HY0000"; }
getSTR_DELIMITER()90cdf0e10cSrcweir const sal_Char* getSTR_DELIMITER() { return "/"; }
91cdf0e10cSrcweir
92cdf0e10cSrcweir
93cdf0e10cSrcweir
94cdf0e10cSrcweir /* {{{ OPropertyMap::~OPropertyMap() -I- */
~OPropertyMap()95cdf0e10cSrcweir OPropertyMap::~OPropertyMap()
96cdf0e10cSrcweir {
97cdf0e10cSrcweir ::std::map<sal_Int32 , rtl_uString*>::iterator aIter = m_aPropertyMap.begin();
98cdf0e10cSrcweir for(; aIter != m_aPropertyMap.end(); ++aIter) {
99cdf0e10cSrcweir if (aIter->second) {
100cdf0e10cSrcweir rtl_uString_release(aIter->second);
101cdf0e10cSrcweir }
102cdf0e10cSrcweir }
103cdf0e10cSrcweir }
104cdf0e10cSrcweir /* }}} */
105cdf0e10cSrcweir
106cdf0e10cSrcweir
107cdf0e10cSrcweir /* {{{ OPropertyMap::getNameByIndex() -I- */
getNameByIndex(sal_Int32 idx) const108cdf0e10cSrcweir OUString OPropertyMap::getNameByIndex(sal_Int32 idx) const
109cdf0e10cSrcweir {
110cdf0e10cSrcweir OUString sRet;
111cdf0e10cSrcweir ::std::map<sal_Int32 , rtl_uString*>::const_iterator aIter = m_aPropertyMap.find(idx);
112cdf0e10cSrcweir if (aIter == m_aPropertyMap.end()) {
113cdf0e10cSrcweir sRet = const_cast<OPropertyMap*>(this)->fillValue(idx);
114cdf0e10cSrcweir } else {
115cdf0e10cSrcweir sRet = aIter->second;
116cdf0e10cSrcweir }
117cdf0e10cSrcweir return sRet;
118cdf0e10cSrcweir }
119cdf0e10cSrcweir /* }}} */
120cdf0e10cSrcweir
121cdf0e10cSrcweir typedef const sal_Char * (*property_callback)();
122cdf0e10cSrcweir
123cdf0e10cSrcweir static const property_callback property_callbacks[PROPERTY_ID_LAST] =
124cdf0e10cSrcweir {
125cdf0e10cSrcweir NULL, /* PROPERTY_ID_FIRST */
126cdf0e10cSrcweir getPROPERTY_QUERYTIMEOUT,
127cdf0e10cSrcweir getPROPERTY_MAXFIELDSIZE,
128cdf0e10cSrcweir getPROPERTY_MAXROWS,
129cdf0e10cSrcweir getPROPERTY_CURSORNAME,
130cdf0e10cSrcweir getPROPERTY_RESULTSETCONCURRENCY,
131cdf0e10cSrcweir getPROPERTY_RESULTSETTYPE,
132cdf0e10cSrcweir getPROPERTY_FETCHDIRECTION,
133cdf0e10cSrcweir getPROPERTY_FETCHSIZE,
134cdf0e10cSrcweir getPROPERTY_ESCAPEPROCESSING,
135cdf0e10cSrcweir getPROPERTY_USEBOOKMARKS,
136cdf0e10cSrcweir // Column
137cdf0e10cSrcweir getPROPERTY_NAME,
138cdf0e10cSrcweir getPROPERTY_TYPE,
139cdf0e10cSrcweir getPROPERTY_TYPENAME,
140cdf0e10cSrcweir getPROPERTY_PRECISION,
141cdf0e10cSrcweir getPROPERTY_SCALE,
142cdf0e10cSrcweir getPROPERTY_ISNULLABLE,
143cdf0e10cSrcweir getPROPERTY_ISAUTOINCREMENT,
144cdf0e10cSrcweir getPROPERTY_ISROWVERSION,
145cdf0e10cSrcweir getPROPERTY_DESCRIPTION,
146cdf0e10cSrcweir getPROPERTY_DEFAULTVALUE,
147cdf0e10cSrcweir
148cdf0e10cSrcweir getPROPERTY_REFERENCEDTABLE,
149cdf0e10cSrcweir getPROPERTY_UPDATERULE,
150cdf0e10cSrcweir getPROPERTY_DELETERULE,
151cdf0e10cSrcweir getPROPERTY_CATALOG,
152cdf0e10cSrcweir getPROPERTY_ISUNIQUE,
153cdf0e10cSrcweir getPROPERTY_ISPRIMARYKEYINDEX,
154cdf0e10cSrcweir getPROPERTY_ISCLUSTERED,
155cdf0e10cSrcweir getPROPERTY_ISASCENDING,
156cdf0e10cSrcweir getPROPERTY_SCHEMANAME,
157cdf0e10cSrcweir getPROPERTY_CATALOGNAME,
158cdf0e10cSrcweir
159cdf0e10cSrcweir getPROPERTY_COMMAND,
160cdf0e10cSrcweir getPROPERTY_CHECKOPTION,
161cdf0e10cSrcweir getPROPERTY_PASSWORD,
162cdf0e10cSrcweir getPROPERTY_RELATEDCOLUMN,
163cdf0e10cSrcweir
164cdf0e10cSrcweir getPROPERTY_FUNCTION,
165cdf0e10cSrcweir getPROPERTY_TABLENAME,
166cdf0e10cSrcweir getPROPERTY_REALNAME,
167cdf0e10cSrcweir getPROPERTY_DBASEPRECISIONCHANGED,
168cdf0e10cSrcweir getPROPERTY_ISCURRENCY,
169cdf0e10cSrcweir getPROPERTY_ISBOOKMARKABLE,
170cdf0e10cSrcweir getSTAT_INVALID_INDEX,
171cdf0e10cSrcweir getERRORMSG_SEQUENCE,
172cdf0e10cSrcweir getSQLSTATE_SEQUENCE,
173cdf0e10cSrcweir getSQLSTATE_GENERAL,
174cdf0e10cSrcweir getSTR_DELIMITER,
175cdf0e10cSrcweir getPROPERTY_FORMATKEY,
176cdf0e10cSrcweir getPROPERTY_LOCALE,
177cdf0e10cSrcweir getPROPERTY_AUTOINCREMENTCREATION,
178cdf0e10cSrcweir getPROPERTY_PRIVILEGES,
179cdf0e10cSrcweir };
180cdf0e10cSrcweir
181cdf0e10cSrcweir
182cdf0e10cSrcweir /* {{{ OPropertyMap::fillValue() -I- */
fillValue(sal_Int32 idx)183cdf0e10cSrcweir OUString OPropertyMap::fillValue(sal_Int32 idx)
184cdf0e10cSrcweir {
185cdf0e10cSrcweir rtl_uString* pStr = NULL;
186cdf0e10cSrcweir rtl_uString_newFromAscii(&pStr, property_callbacks[idx]());
187cdf0e10cSrcweir m_aPropertyMap[idx] = pStr;
188cdf0e10cSrcweir return pStr;
189cdf0e10cSrcweir }
190cdf0e10cSrcweir /* }}} */
191cdf0e10cSrcweir
192cdf0e10cSrcweir } /* mysqlc */
193cdf0e10cSrcweir } /* connectivity */
194cdf0e10cSrcweir
195cdf0e10cSrcweir /*
196cdf0e10cSrcweir * Local variables:
197cdf0e10cSrcweir * tab-width: 4
198cdf0e10cSrcweir * c-basic-offset: 4
199cdf0e10cSrcweir * End:
200cdf0e10cSrcweir * vim600: noet sw=4 ts=4 fdm=marker
201cdf0e10cSrcweir * vim<600: noet sw=4 ts=4
202cdf0e10cSrcweir */
203