Skip to content

Commit 076ba5d

Browse files
author
pi1ot
committed
cleanup waMysqlClient
1 parent c327262 commit 076ba5d

File tree

12 files changed

+44
-42
lines changed

12 files changed

+44
-42
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ SET_TARGET_PROPERTIES( webapp PROPERTIES CLEAN_DIRECT_OUTPUT 1 )
4646
# keep libwebapp.a
4747
SET_TARGET_PROPERTIES( webapp_static PROPERTIES CLEAN_DIRECT_OUTPUT 1 )
4848
# libwebapp.so version and so-name
49-
SET_TARGET_PROPERTIES( webapp PROPERTIES VERSION 1.1.1 SOVERSION 1 )
49+
SET_TARGET_PROPERTIES( webapp PROPERTIES VERSION 1.2 SOVERSION 1 )
5050

5151
# install
5252
INSTALL( TARGETS webapp webapp_static

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2012-11-24
2+
���� waMysqlClient �ڲ�ʵ��
3+
��汾������Ϊ 1.2
4+
15
2012-10-18
26
CMakeLists.txt ��© waCgi ���޸�
37
��汾�Ų���

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
################################################################################
1717
# 当前WEB开发库版本号 $(WEBAPPLIB_VERSION)
18-
WEBAPPLIB_VERSION = 1.1
18+
WEBAPPLIB_VERSION = 1.2
1919
WEBAPPLIB_SONAME = 1
2020

2121
# C++ 编译器命令
@@ -105,8 +105,10 @@ install:
105105
cp -f $(WEBAPPLIB) $(WEBAPPDLL) $(LIBPATH)
106106
ln -fs $(LIBPATH)/$(WEBAPPLIB) $(LIBPATH)/libwebapp.a
107107
ln -fs $(LIBPATH)/$(WEBAPPDLL) $(LIBPATH)/libwebapp.so
108+
ln -fs $(LIBPATH)/$(WEBAPPDLL) $(LIBPATH)/$(WEBAPPSO)
108109
ln -fs $(LIBPATH)/$(WEBAPPLIB) $(SYSLIB)/libwebapp.a
109110
ln -fs $(LIBPATH)/$(WEBAPPDLL) $(SYSLIB)/libwebapp.so
111+
ln -fs $(LIBPATH)/$(WEBAPPDLL) $(SYSLIB)/$(WEBAPPSO)
110112

111113
# 执行删除
112114
uninstall:

help.chm

-1.14 KB
Binary file not shown.

help.pdf

584 Bytes
Binary file not shown.

waCgi.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ string get_env( const string &envname ) {
4848
/// 读取并分析CGI内容
4949
/// \param formdata_maxsize 参数是"multipart/form-data"方式POST时的最大FORM上传数据大小,
5050
/// 超过部分被截断不处理,单位为byte,默认为0即不限制数据大小
51-
Cgi::Cgi( const long formdata_maxsize ) {
51+
Cgi::Cgi( const size_t formdata_maxsize ) {
5252
// get envionment variable REQUEST_METHOD
5353
_method = get_env( "REQUEST_METHOD" );
5454
_method.upper();
@@ -91,7 +91,7 @@ Cgi::Cgi( const long formdata_maxsize ) {
9191

9292
if ( formdata_maxsize > 0 ) {
9393
// max size set
94-
long size = 0;
94+
size_t size = 0;
9595

9696
while ( cin ) {
9797
cin >> c;

waCgi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Cgi {
3333
public:
3434

3535
/// 构造函数
36-
Cgi( const long formdata_maxsize = 0 );
36+
Cgi( const size_t formdata_maxsize = 0 );
3737

3838
/// 析构函数
3939
virtual ~Cgi(){};

waDateTime.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ class DateTime {
116116
inline int sec() const {return _tm.tm_sec;}
117117

118118
/// 返回 1970-1-1 0:0:0 以来的秒数
119-
inline long secs() const {return _time;}
119+
inline time_t secs() const {return _time;}
120120
/// 返回 1970-1-1 0:0:0 以来的分钟数
121-
inline long mins() const {return ( _time/TIME_ONE_MIN );}
121+
inline time_t mins() const {return ( _time/TIME_ONE_MIN );}
122122
/// 返回 1970-1-1 0:0:0 以来的小时数
123-
inline long hours() const {return ( _time/TIME_ONE_HOUR );}
123+
inline time_t hours() const {return ( _time/TIME_ONE_HOUR );}
124124
/// 返回 1970-1-1 0:0:0 以来的天数
125-
inline long days() const {return ( _time/TIME_ONE_DAY );}
125+
inline time_t days() const {return ( _time/TIME_ONE_DAY );}
126126
/// 返回 1970-1-1 0:0:0 以来的周数
127-
inline long weeks() const {return ( _time/TIME_ONE_WEEK );}
127+
inline time_t weeks() const {return ( _time/TIME_ONE_WEEK );}
128128

129129
/// 以当前时间设置对象
130130
void set();

waFileSystem.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ bool make_link( const string &srcfile, const string &destfile ) {
7676
}
7777

7878
/// \ingroup waFileSystem
79-
/// \fn long file_size( const string &file )
79+
/// \fn size_t file_size( const string &file )
8080
/// 取得文件大小
8181
/// \param file 文件路径名
8282
/// \return 若文件存在则返回大小,否则返回-1
83-
long file_size( const string &file ) {
83+
size_t file_size( const string &file ) {
8484
struct stat statbuf;
8585

8686
if( stat(file.c_str(),&statbuf)==0 )
@@ -90,11 +90,11 @@ long file_size( const string &file ) {
9090
}
9191

9292
/// \ingroup waFileSystem
93-
/// \fn long file_time( const string &file )
93+
/// \fn time_t file_time( const string &file )
9494
/// 取得文件更改时间
9595
/// \param file 文件路径名
9696
/// \return 若文件存在则返回其最后更改时间,否则返回-1
97-
long file_time( const string &file ) {
97+
time_t file_time( const string &file ) {
9898
struct stat statbuf;
9999

100100
if( stat(file.c_str(),&statbuf)==0 )

waFileSystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ bool is_dir( const string &file );
2828
bool make_link( const string &srcfile, const string &destfile );
2929

3030
/// 取得文件大小
31-
long file_size( const string &file );
31+
size_t file_size( const string &file );
3232
/// 取得文件更改时间
33-
long file_time( const string &file );
33+
time_t file_time( const string &file );
3434
/// 取得文件路径
3535
string file_path( const string &file );
3636
/// 取得文件名称

waMysqlClient.cpp

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ MysqlData::~MysqlData() {
4242
/// \return 返回数据,不存在则返回空字符串
4343
string MysqlData::get_data( const size_t row, const size_t col ) {
4444
if( _mysqlres!=NULL && row<_rows && col<_cols ) {
45-
if ( static_cast<long>(row) != _fetched ) {
46-
if ( row != _curpos+1 )
45+
if ( row != _fetched ) {
46+
if ( row != _curpos+1 ) {
4747
mysql_data_seek( _mysqlres, row );
48+
}
4849
_mysqlrow = mysql_fetch_row( _mysqlres );
49-
_fetched = static_cast<long>( row );
50+
_fetched = row;
5051
}
5152

5253
if ( _mysqlrow!=NULL && _mysqlrow[col]!=NULL ) {
@@ -70,32 +71,27 @@ string MysqlData::get_data( const size_t row, const string &field ) {
7071
}
7172

7273
/// 返回指定位置的MysqlData数据行
73-
/// \param row 数据行位置,默认为当前纪录位置,
74-
/// 当前纪录位置由first(),prior(),next(),last(),find()函数操纵,默认为0
74+
/// \param row 数据行位置,默认为0即第一行
7575
/// \return 返回值类型为MysqlDataRow,即map<string,string>
76-
MysqlDataRow MysqlData::get_row( const long row ) {
76+
MysqlDataRow MysqlData::get_row( const size_t row ) {
7777
MysqlDataRow datarow;
7878
string field;
79-
size_t rowpos;
80-
81-
if ( row < 0 )
82-
rowpos = _curpos;
83-
else
84-
rowpos = row;
8579

86-
if( _mysqlres!=NULL && rowpos<_rows ) {
87-
if ( rowpos != _curpos ) {
88-
if ( rowpos != _curpos+1 )
89-
mysql_data_seek( _mysqlres, rowpos );
80+
if( _mysqlres!=NULL && row<_rows ) {
81+
if ( row != _curpos ) {
82+
if ( row != _curpos+1 ) {
83+
mysql_data_seek( _mysqlres, row );
84+
}
9085
_mysqlrow = mysql_fetch_row( _mysqlres );
9186
}
9287

9388
if ( _mysqlrow != NULL ) {
94-
_curpos = rowpos; // log current cursor
89+
_curpos = row; // log current cursor
9590
for ( size_t i=0; i<_cols; ++i ) {
9691
field = this->field_name( i );
97-
if ( field!="" && _mysqlrow[i]!=NULL )
92+
if ( field!="" && _mysqlrow[i]!=NULL ) {
9893
datarow.insert( MysqlDataRow::value_type(field,_mysqlrow[i]) );
94+
}
9995
}
10096
}
10197
}
@@ -127,7 +123,8 @@ bool MysqlData::fill_data( MYSQL *mysql ) {
127123

128124
// init first data
129125
mysql_data_seek( _mysqlres, 0 );
130-
_mysqlrow = mysql_fetch_row( _mysqlres );
126+
_mysqlrow = mysql_fetch_row( _mysqlres );
127+
_fetched = 0;
131128

132129
return true;
133130
}
@@ -184,8 +181,7 @@ bool MysqlClient::connect( const string &host, const string &user, const string
184181

185182
if ( mysql_init(&_mysql) ) {
186183
if ( mysql_real_connect( &_mysql, host.c_str(), user.c_str(),
187-
pwd.c_str(), database.c_str(),
188-
port, socket, CLIENT_COMPRESS ) )
184+
pwd.c_str(), database.c_str(), port, socket, CLIENT_COMPRESS ) )
189185
_connected = true;
190186
}
191187

waMysqlClient.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class MysqlData {
3838
bool fill_data( MYSQL *mysql );
3939

4040
size_t _rows, _cols, _curpos;
41-
long _fetched;
41+
size_t _fetched;
4242

4343
MYSQL_RES *_mysqlres;
4444
MYSQL_ROW _mysqlrow;
@@ -50,7 +50,7 @@ class MysqlData {
5050

5151
/// MysqlData构造函数
5252
MysqlData():
53-
_rows(0), _cols(0), _curpos(0), _fetched(-1),
53+
_rows(0), _cols(0), _curpos(0), _fetched(0),
5454
_mysqlres(0), _mysqlfields(0)
5555
{};
5656

@@ -78,7 +78,7 @@ class MysqlData {
7878
string get_data( const size_t row, const string &field );
7979

8080
/// 返回指定位置的MysqlData数据行
81-
MysqlDataRow get_row( const long row = -1 );
81+
MysqlDataRow get_row( const size_t row = 0 );
8282

8383
/// 返回MysqlData数据行数
8484
inline size_t rows() const {
@@ -150,8 +150,8 @@ class MysqlClient {
150150
string query_val( const string &sqlstr,
151151
const size_t row = 0, const size_t col = 0 );
152152

153-
/// 返回查询结果中指定行
154-
MysqlDataRow query_row( const string &sqlstr, const size_t row = 0 );
153+
/// 返回查询结果中指定行
154+
MysqlDataRow query_row( const string &sqlstr, const size_t row = 0 );
155155

156156
/// 上次查询动作所影响的记录条数
157157
size_t affected();

0 commit comments

Comments
 (0)