00001 // 00002 // File: src/odbcpp.cpp 00003 // Object: Main Documentation of the odbcpp library 00004 // Project: http://www.m2osw.com/odbcpp 00005 // Author: alexis_wilke@sourceforge.net 00006 // 00007 // Copyright (C) 2008 Made to Order Software Corp. 00008 // 00009 // This program is free software: you can redistribute it and/or modify 00010 // it under the terms of the GNU General Public License as published by 00011 // the Free Software Foundation, either version 3 of the License, or 00012 // (at your option) any later version. 00013 // 00014 // This program is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU General Public License 00020 // along with this program. If not, see <http://www.gnu.org/licenses/> 00021 // or <http://gpl3.m2osw.com/>. 00022 // 00023 00024 00111 #include "odbcpp/odbcpp.h" 00112 00113 // we get a warning if sizeof(ptr) == sizeof(integer) 00114 #ifdef _MSC_VER 00115 #pragma warning(disable: 4318) 00116 #endif 00117 00118 00120 namespace odbcpp 00121 { 00122 00123 00129 const char *get_version() 00130 { 00131 return PACKAGE_VERSION; 00132 } 00133 00134 00143 SQLPOINTER int_to_ptr(SQLINTEGER integer) 00144 { 00145 SQLPOINTER ptr; 00146 00147 if(sizeof(ptr) < sizeof(integer)) { 00148 diagnostic d(odbcpp_error::ODBCPP_INTERNAL, std::string("the size of an SQLINTEGER is larger than SQLPOINTER?!")); 00149 throw odbcpp_error(d); 00150 } 00151 #if BYTE_ORDER == LITTLE_ENDIAN 00152 // in this case, little endian works great 00153 memcpy(&ptr, &integer, sizeof(integer)); 00154 if(sizeof(ptr) > sizeof(integer)) { 00155 memset(reinterpret_cast<char *>(&ptr) + sizeof(ptr) - sizeof(integer), 00156 0, sizeof(ptr) - sizeof(integer)); 00157 } 00158 #else 00159 memcpy(reinterpret_cast<char *>(&ptr) + sizeof(ptr) - sizeof(integer), 00160 &integer, 00161 sizeof(integer)); 00162 if(sizeof(ptr) > sizeof(integer)) { 00163 memset(&ptr, 0, sizeof(ptr) - sizeof(integer)); 00164 } 00165 #endif 00166 00167 return ptr; 00168 } 00169 00170 00171 00172 } // namespace odbcpp 00173