Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
S3PTableInfoCatch.cpp
Package: SwordOnline.rar [view]
Upload User: dzyhzl
Upload Date: 2019-04-29
Package Size: 56270k
Code Size: 2k
Category:
Game Server Simulator
Development Platform:
C/C++
- // S3PTableInfoCatch.cpp: implementation of the S3PTableInfoCatch class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "S3PTableInfoCatch.h"
- #include "S3PDBConnection.h"
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- S3PTableInfoCatch * S3PTableInfoCatch::m_pInstance = NULL;
- S3PTableInfoCatch::S3PTableInfoCatch()
- {
- }
- S3PTableInfoCatch::~S3PTableInfoCatch()
- {
- std::map<std::string,std::map<std::string, std::string> *>::iterator i;
- for(i=m_initedMap.begin(); i!=m_initedMap.end(); i++)
- {
- delete i->second;
- }
- m_initedMap.clear();
- }
- S3PTableInfoCatch * S3PTableInfoCatch::Instance()
- {
- if (m_pInstance==NULL)
- {
- m_pInstance = new S3PTableInfoCatch;
- }
- return m_pInstance;
- }
- void S3PTableInfoCatch::Release()
- {
- if (m_pInstance != NULL)
- {
- delete m_pInstance;
- m_pInstance = NULL;
- }
- }
- std::map<std::string, std::string> *
- S3PTableInfoCatch::GetColumnInfo(std::string tableName, S3PDBConnection * pConn)
- {
- std::map<std::string,std::map<std::string, std::string> *>::iterator i;
- i = m_initedMap.find(tableName);
- if(i != m_initedMap.end() )
- {
- return i->second;
- }
- else
- {
- std::string strQuery;
- strQuery = "select * from " + tableName + " where 1<>1";
- if ( pConn->QueryBySql(strQuery.c_str()) )
- {
- Result * pResult = (Result*)(pConn->GetRes());
- if (pResult)
- {
- int col_count = pResult->num_fields();
- if (col_count>0)
- {
- std::map<std::string, std::string> * columnInfoMap =
- new std::map<std::string, std::string>;
- //Question no delete up! must delete in somewhere ,romandou
- for (unsigned int i = 0; i < col_count; i++)
- {
- std::string column = pResult->names(i);
- std::string type = pResult->types(i).sql_name();
- columnInfoMap->insert(std::map<std::string, std::string>::value_type(column,type));
- }
- m_initedMap[tableName] = columnInfoMap;
- return columnInfoMap;
- }
- else
- {
- return NULL;
- }
- }
- else
- {
- // Error
- return NULL;
- }
- }
- else
- {
- //失败
- return NULL;
- }
- }
- return NULL;
- }