| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/drivers/ado/TeAdoSqlServer.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright © 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    00006 This library is free software; you can redistribute it and/or
    00007 modify it under the terms of the GNU Lesser General Public
    00008 License as published by the Free Software Foundation; either
    00009 version 2.1 of the License, or (at your option) any later version.
    00010
    00011 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00026 #ifndef  __TERRALIB_INTERNAL_ADOSQLSERVER_H
    00027 #define  __TERRALIB_INTERNAL_ADOSQLSERVER_H
    00028
    00029 #include <TeDatabaseFactory.h>
    00030
    00031 #ifdef WIN32
    00032 #pragma warning ( disable: 4192 )
    00033 #pragma warning ( disable: 4146 )
    00034 #include <atldbcli.h>
    00035 #include <iostream>
    00036 #include <comdef.h>
    00037
    00038 /*
    00039  *   Lets use the import directive to create some smart pointers for us
    00040  */
    00041 #import "msado26.tlb"  rename("EOF", "IsEOF") rename("BOF", "IsBOF")
    00042 #import <msadox.dll>
    00043 #import <oledb32.dll> rename_namespace("OLEDB")
    00044 #else
    00045 #error ONLY FOR WINDOWS OPERATIONAL SYSTEM
    00046 #endif
    00047
    00048 #include <TeDatabase.h>
    00049 #include <TeAdoDB.h>
    00050
    00051
    00052 #ifdef AFX_DLL
    00053 #define EXPORT_WIN __declspec( dllexport )
    00054 #else
    00055 #define EXPORT_WIN
    00056 #endif
    00057
    00059 class  TLADO_DLL  TeSqlServer : public TeAdo
    00060 {
    00061 friend class TeSqlServerPortal;
    00062
    00063 public:
    00064
    00065            TeSqlServer();
    00066            ~TeSqlServer();
    00067
    00068            // Methods to create and connect to a ADO database
    00069                       virtual bool newDatabase(const string& database, const string& user, const string& password, const string& host, const int &port=-1, bool terralibModel=true, const std::string& characterSet = "");
    00070                       virtual bool connect (const string& host, const string& user, const string& password, const string& database, int port = -1);
    00071
    00072            // Methods to manipulate a table
    00073                       virtual bool tableExist(const string& table);
    00074            virtual bool columnExist(const string& table, const string& column, TeAttribute& attr);
    00075                       virtual bool getAttributeList(const string& tableName,TeAttributeList& attList);
    00076            virtual bool createTable(const string& table, TeAttributeList &attr);
    00077                       virtual bool alterTable (const string& table, TeAttributeRep &rep, const string& oldColName="");
    00078                       virtual bool alterTable(const string& oldTableName, const string& newTablename);
    00079
    00080            virtual bool addColumn(const string& table,TeAttributeRep &rep);
    00081                       virtual bool deleteTable (const string& table);
    00082            virtual bool createRelation (const string& name, const string& table, const string& fieldName, const string& relatedTable, const string& relatedField, bool cascadeDeletion);
    00083
    00084                       virtual bool deleteLayer(int layerId);
    00085                       virtual bool deleteTheme(int themeId);
    00086                       virtual bool deleteView (int viewId);
    00087
    00088                       virtual TeDBRelationType existRelation(const string& tableName, const string& relName);
    00089
    00091                       virtual bool listDatabases(std::vector<std::string> & /*databaseList*/);
    00093                       virtual bool dropDatabase(const std::string & /*databaseName*/);
    00094
    00095
    00096                       // Insert an attribute table
    00097                       virtual bool insertTable(TeTable &table);
    00098            virtual bool insertTheme (TeAbstractTheme *theme);
    00099                       virtual bool generateLabelPositions (TeTheme *theme, const std::string& objectId = "");
    00100
    00101                       virtual bool insertPolygonSet (const string& table, TePolygonSet &ps);
    00102            virtual bool insertPolygon (const string& table, TePolygon &p);
    00103
    00104                virtual bool insertLineSet(const string& table, TeLineSet &ls);
    00105                       virtual bool insertLine(const string& table, TeLine2D &l);
    00106
    00107                virtual bool insertPointSet(const string& table, TePointSet &ps);
    00108                       virtual bool insertPoint(const string& table, TePoint &p);
    00109
    00110                       virtual bool insertTextSet(const string& table, TeTextSet &ts);
    00111                       virtual bool insertText(const string& table, TeText &t);
    00112
    00113
    00114            virtual TeDatabasePortal* getPortal ();
    00115            virtual string        getNameTrigger(const string &tableName);
    00116
    00117                       virtual string getSQLTime(const TeTime& time) const;
    00118
    00119                       virtual string toUpper(const string& value);
    00120 };
    00121
    00123 class  TLADO_DLL  TeSqlServerPortal : public TeAdoPortal
    00124 {
    00125
    00126 public :
    00127
    00128            // Constructor / Destructor
    00129            TeSqlServerPortal ();
    00130            TeSqlServerPortal (TeDatabase* pDatabase);
    00131            ~TeSqlServerPortal ();
    00132
    00133            TeTime getDate (int i);
    00134            TeTime getDate (const string& s);
    00135
    00136            string getDateAsString(int i);
    00137            string getDateAsString(const string& s);
    00138 };
    00139
    00140
    00146 class TLADO_DLL TeSqlServerFactory : public TeDatabaseFactory
    00147 {
    00148   public :
    00149
    00153     TeSqlServerFactory() : TeDatabaseFactory(
    00154       std::string( "SqlServerAdo" ) ) {};
    00155
    00159     ~TeSqlServerFactory() {};
    00160
    00161   protected :
    00162
    00170     TeDatabase* build( const TeDatabaseFactoryParams& arg )
    00171     {
    00172       TeSqlServer* instance_ptr = new TeSqlServer();
    00173
    00174       if( arg.host_ != "" ) {
    00175         instance_ptr->connect( arg.host_, arg.user_, arg.password_,
    00176           arg.database_, arg.port_ );
    00177       }
    00178
    00179       return (TeDatabase*)instance_ptr;
    00180     }
    00181 };
    00182
    00183 namespace {
    00184   static TeSqlServerFactory TeSqlServerFactory_instance;
    00185 };
    00186
    00187
    00188 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines