00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "nsql.h"
00023
00028 NSql::NSql(void)
00029 : NObject(),
00030 m_user(),
00031 m_password(),
00032 m_host(),
00033 m_port(0),
00034 m_database()
00035 {
00036
00037 }
00038
00039
00040 NSql::NSql(const NString &user, const NString &password,
00041 const NHostAddress &host)
00042 : NObject(),
00043 m_user(user),
00044 m_password(password),
00045 m_host(host),
00046 m_port(0),
00047 m_database()
00048 {
00049
00050 }
00051
00052
00053 NSql::NSql(const NString &user, const NString &password,
00054 const NHostAddress &host, nint16 port)
00055 : NObject(),
00056 m_user(user),
00057 m_password(password),
00058 m_host(host),
00059 m_port(port),
00060 m_database()
00061 {
00062
00063 }
00064
00065
00066 NSql::~NSql(void) {
00067
00068 }
00069
00070
00071 void NSql::setUser(const NString &user) {
00072 m_user = user;
00073 }
00074
00075
00076 void NSql::setPassword(const NString &password) {
00077 m_password = password;
00078 }
00079
00080
00081 void NSql::setHost(const NHostAddress &host) {
00082 NDebug::print() << "Setting the host";
00083 m_host = host;
00084 }
00085
00086
00087 void NSql::setPort(nint16 port) {
00088 if (port == 0) {
00089 NString msg = "Port number ";
00090
00091 msg = msg + port + " is not valid";
00092
00093 throw NException(msg, NException::DBAL);
00094 }
00095
00096 m_port = port;
00097 NDebug::print() << "Setting the port to " << m_port;
00098 }
00099
00100
00101 void NSql::setDatabase(const NString &database) {
00102 m_database = database;
00103 }
00104
00105
00106 NString NSql::getUser(void) const {
00107 return m_user;
00108 }
00109
00110 NString NSql::getPassword(void) const {
00111 return m_password;
00112 }
00113
00114 NHostAddress NSql::getHost(void) const {
00115 return m_host;
00116 }
00117
00118 nint16 NSql::getPort(void) const {
00119 return m_port;
00120 }
00121
00122 NString NSql::getDatabase(void) const {
00123 return m_database;
00124 }
00125
00126 void NSql::setRecordData(NSqlRecord *record, const NString &rowName,
00127 const NVtype &rowData)
00128 {
00129 assert(record);
00130
00131 record->add(rowName, rowData);
00132 }