Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
a9039660
Commit
a9039660
authored
Jun 19, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(SQLxxxInterface): функции as_xxx() внесены в классы xxResult.
parent
5d5064d2
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
68 additions
and
59 deletions
+68
-59
MySQLInterface.cc
extensions/DBServer-MySQL/MySQLInterface.cc
+7
-7
MySQLInterface.h
extensions/DBServer-MySQL/MySQLInterface.h
+14
-11
test.cc
extensions/DBServer-MySQL/test.cc
+1
-1
PostgreSQLInterface.cc
extensions/DBServer-PostgreSQL/PostgreSQLInterface.cc
+8
-8
PostgreSQLInterface.h
extensions/DBServer-PostgreSQL/PostgreSQLInterface.h
+14
-11
test.cc
extensions/DBServer-PostgreSQL/test.cc
+1
-1
SQLiteInterface.cc
extensions/DBServer-SQLite/SQLiteInterface.cc
+8
-8
SQLiteInterface.h
extensions/DBServer-SQLite/SQLiteInterface.h
+14
-11
test.cc
extensions/DBServer-SQLite/test.cc
+1
-1
No files found.
extensions/DBServer-MySQL/MySQLInterface.cc
View file @
a9039660
...
@@ -173,39 +173,39 @@ string MySQLInterface::addslashes( const string& str )
...
@@ -173,39 +173,39 @@ string MySQLInterface::addslashes( const string& str )
return
tmp
.
str
();
return
tmp
.
str
();
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
int
num_cols
(
MySQLResult
::
iterator
&
it
)
int
MySQLResult
::
num_cols
(
const
MySQLResult
::
iterator
&
it
)
{
{
return
it
->
size
();
return
it
->
size
();
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
int
as_int
(
MySQLResult
::
iterator
&
it
,
int
col
)
int
MySQLResult
::
as_int
(
const
MySQLResult
::
iterator
&
it
,
int
col
)
{
{
// if( col<0 || col >it->size() )
// if( col<0 || col >it->size() )
// return 0;
// return 0;
return
uni_atoi
(
(
*
it
)[
col
]
);
return
uni_atoi
(
(
*
it
)[
col
]
);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
double
as_double
(
MySQLResult
::
iterator
&
it
,
int
col
)
double
as_double
(
const
MySQLResult
::
iterator
&
it
,
int
col
)
{
{
return
atof
(
((
*
it
)[
col
]).
c_str
()
);
return
atof
(
((
*
it
)[
col
]).
c_str
()
);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
string
as_string
(
MySQLResult
::
iterator
&
it
,
int
col
)
string
MySQLResult
::
as_string
(
const
MySQLResult
::
iterator
&
it
,
int
col
)
{
{
return
((
*
it
)[
col
]);
return
((
*
it
)[
col
]);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
int
as_int
(
MySQLResult
::
COL
::
iterator
&
it
)
int
MySQLResult
::
as_int
(
const
MySQLResult
::
COL
::
iterator
&
it
)
{
{
return
uni_atoi
(
(
*
it
)
);
return
uni_atoi
(
(
*
it
)
);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
double
as_double
(
MySQLResult
::
COL
::
iterator
&
it
)
double
MySQLResult
::
as_double
(
const
MySQLResult
::
COL
::
iterator
&
it
)
{
{
return
atof
(
(
*
it
).
c_str
()
);
return
atof
(
(
*
it
).
c_str
()
);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
std
::
string
as_string
(
MySQLResult
::
COL
::
iterator
&
it
)
std
::
string
MySQLResult
::
as_string
(
const
MySQLResult
::
COL
::
iterator
&
it
)
{
{
return
(
*
it
);
return
(
*
it
);
}
}
...
...
extensions/DBServer-MySQL/MySQLInterface.h
View file @
a9039660
...
@@ -116,20 +116,23 @@ class MySQLResult
...
@@ -116,20 +116,23 @@ class MySQLResult
return
res
.
empty
();
return
res
.
empty
();
}
}
// ----------------------------------------------------------------------------
// ROW
static
int
as_int
(
const
MySQLResult
::
iterator
&
,
int
col
);
static
double
as_double
(
const
MySQLResult
::
iterator
&
,
int
col
);
static
std
::
string
as_string
(
const
MySQLResult
::
iterator
&
,
int
col
);
// ----------------------------------------------------------------------------
// COL
static
int
num_cols
(
const
MySQLResult
::
iterator
&
);
static
int
as_int
(
const
MySQLResult
::
COL
::
iterator
&
);
static
double
as_double
(
const
MySQLResult
::
COL
::
iterator
&
);
static
std
::
string
as_string
(
const
MySQLResult
::
COL
::
iterator
&
);
// ----------------------------------------------------------------------------
protected
:
protected
:
ROW
res
;
ROW
res
;
};
};
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
int
num_cols
(
MySQLResult
::
iterator
&
);
// ROW
int
as_int
(
MySQLResult
::
iterator
&
,
int
col
);
double
as_double
(
MySQLResult
::
iterator
&
,
int
col
);
std
::
string
as_text
(
MySQLResult
::
iterator
&
,
int
col
);
// ----------------------------------------------------------------------------
// COL
int
as_int
(
MySQLResult
::
COL
::
iterator
&
);
double
as_double
(
MySQLResult
::
COL
::
iterator
&
);
std
::
string
as_string
(
MySQLResult
::
COL
::
iterator
&
);
// ----------------------------------------------------------------------------
#endif
#endif
extensions/DBServer-MySQL/test.cc
View file @
a9039660
...
@@ -41,7 +41,7 @@ int main(int argc, char** argv)
...
@@ -41,7 +41,7 @@ int main(int argc, char** argv)
MySQLResult
::
COL
col
(
*
it
);
MySQLResult
::
COL
col
(
*
it
);
for
(
MySQLResult
::
COL
::
iterator
cit
=
it
->
begin
();
cit
!=
it
->
end
();
cit
++
)
for
(
MySQLResult
::
COL
::
iterator
cit
=
it
->
begin
();
cit
!=
it
->
end
();
cit
++
)
cout
<<
as_string
(
cit
)
<<
"("
<<
as_double
(
cit
)
<<
") | "
;
cout
<<
MySQLResult
::
as_string
(
cit
)
<<
"("
<<
MySQLResult
::
as_double
(
cit
)
<<
") | "
;
cout
<<
endl
;
cout
<<
endl
;
}
}
...
...
extensions/DBServer-PostgreSQL/PostgreSQLInterface.cc
View file @
a9039660
...
@@ -152,45 +152,45 @@ bool PostgreSQLInterface::isConnection()
...
@@ -152,45 +152,45 @@ bool PostgreSQLInterface::isConnection()
return
(
db
&&
db
->
is_open
());
return
(
db
&&
db
->
is_open
());
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
int
num_cols
(
PostgreSQLResult
::
iterator
&
it
)
int
PostgreSQLResult
::
num_cols
(
const
PostgreSQLResult
::
iterator
&
it
)
{
{
return
it
->
size
();
return
it
->
size
();
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
int
as_int
(
PostgreSQLResult
::
iterator
&
it
,
int
col
)
int
PostgreSQLResult
::
as_int
(
const
PostgreSQLResult
::
iterator
&
it
,
int
col
)
{
{
// if( col<0 || col >it->size() )
// if( col<0 || col >it->size() )
// return 0;
// return 0;
return
uni_atoi
(
(
*
it
)[
col
]
);
return
uni_atoi
(
(
*
it
)[
col
]
);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
double
as_double
(
PostgreSQLResult
::
iterator
&
it
,
int
col
)
double
PostgreSQLResult
::
as_double
(
const
PostgreSQLResult
::
iterator
&
it
,
int
col
)
{
{
return
atof
(
((
*
it
)[
col
]).
c_str
()
);
return
atof
(
((
*
it
)[
col
]).
c_str
()
);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
st
ring
as_string
(
PostgreSQLResult
::
iterator
&
it
,
int
col
)
st
d
::
string
PostgreSQLResult
::
as_string
(
const
PostgreSQLResult
::
iterator
&
it
,
int
col
)
{
{
return
((
*
it
)[
col
]);
return
((
*
it
)[
col
]);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
int
as_int
(
PostgreSQLResult
::
COL
::
iterator
&
it
)
int
PostgreSQLResult
::
as_int
(
const
PostgreSQLResult
::
COL
::
iterator
&
it
)
{
{
return
uni_atoi
(
(
*
it
)
);
return
uni_atoi
(
(
*
it
)
);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
double
as_double
(
PostgreSQLResult
::
COL
::
iterator
&
it
)
double
PostgreSQLResult
::
as_double
(
const
PostgreSQLResult
::
COL
::
iterator
&
it
)
{
{
return
atof
(
(
*
it
).
c_str
()
);
return
atof
(
(
*
it
).
c_str
()
);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
std
::
string
as_string
(
PostgreSQLResult
::
COL
::
iterator
&
it
)
std
::
string
PostgreSQLResult
::
as_string
(
const
PostgreSQLResult
::
COL
::
iterator
&
it
)
{
{
return
(
*
it
);
return
(
*
it
);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
#if 0
#if 0
PostgreSQLResult::COL
get_col(
PostgreSQLResult::ROW::iterator& it )
PostgreSQLResult::COL
PostgreSQLResult::get_col( const
PostgreSQLResult::ROW::iterator& it )
{
{
return (*it);
return (*it);
}
}
...
...
extensions/DBServer-PostgreSQL/PostgreSQLInterface.h
View file @
a9039660
...
@@ -78,21 +78,24 @@ class PostgreSQLResult
...
@@ -78,21 +78,24 @@ class PostgreSQLResult
return
row
.
empty
();
return
row
.
empty
();
}
}
// ----------------------------------------------------------------------------
// ROW
static
int
as_int
(
const
PostgreSQLResult
::
iterator
&
,
int
col
);
static
double
as_double
(
const
PostgreSQLResult
::
iterator
&
,
int
col
);
static
std
::
string
as_string
(
const
PostgreSQLResult
::
iterator
&
,
int
col
);
// ----------------------------------------------------------------------------
// COL
static
int
num_cols
(
const
PostgreSQLResult
::
iterator
&
);
static
int
as_int
(
const
PostgreSQLResult
::
COL
::
iterator
&
);
static
double
as_double
(
const
PostgreSQLResult
::
COL
::
iterator
&
);
static
std
::
string
as_string
(
const
PostgreSQLResult
::
COL
::
iterator
&
);
//----------------------------------------------------------------------------
protected
:
protected
:
ROW
row
;
ROW
row
;
};
};
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
int
num_cols
(
PostgreSQLResult
::
iterator
&
);
// ROW
int
as_int
(
PostgreSQLResult
::
iterator
&
,
int
col
);
double
as_double
(
PostgreSQLResult
::
iterator
&
,
int
col
);
std
::
string
as_text
(
PostgreSQLResult
::
iterator
&
,
int
col
);
// ----------------------------------------------------------------------------
// COL
int
as_int
(
PostgreSQLResult
::
COL
::
iterator
&
);
double
as_double
(
PostgreSQLResult
::
COL
::
iterator
&
);
std
::
string
as_string
(
PostgreSQLResult
::
COL
::
iterator
&
);
//----------------------------------------------------------------------------
#endif
#endif
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
extensions/DBServer-PostgreSQL/test.cc
View file @
a9039660
...
@@ -41,7 +41,7 @@ int main(int argc, char** argv)
...
@@ -41,7 +41,7 @@ int main(int argc, char** argv)
PostgreSQLResult
::
COL
col
(
*
it
);
PostgreSQLResult
::
COL
col
(
*
it
);
for
(
PostgreSQLResult
::
COL
::
iterator
cit
=
it
->
begin
();
cit
!=
it
->
end
();
cit
++
)
for
(
PostgreSQLResult
::
COL
::
iterator
cit
=
it
->
begin
();
cit
!=
it
->
end
();
cit
++
)
cout
<<
as_string
(
cit
)
<<
"("
<<
as_double
(
cit
)
<<
") | "
;
cout
<<
PostgreSQLResult
::
as_string
(
cit
)
<<
"("
<<
PostgreSQLResult
::
as_double
(
cit
)
<<
") | "
;
cout
<<
endl
;
cout
<<
endl
;
}
}
...
...
extensions/DBServer-SQLite/SQLiteInterface.cc
View file @
a9039660
...
@@ -201,45 +201,45 @@ bool SQLiteInterface::isConnection()
...
@@ -201,45 +201,45 @@ bool SQLiteInterface::isConnection()
return
connected
;
return
connected
;
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
int
num_cols
(
SQLiteResult
::
iterator
&
it
)
int
SQLiteResult
::
num_cols
(
const
SQLiteResult
::
iterator
&
it
)
{
{
return
it
->
size
();
return
it
->
size
();
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
int
as_int
(
SQLiteResult
::
iterator
&
it
,
int
col
)
int
SQLiteResult
::
as_int
(
const
SQLiteResult
::
iterator
&
it
,
int
col
)
{
{
// if( col<0 || col >it->size() )
// if( col<0 || col >it->size() )
// return 0;
// return 0;
return
uni_atoi
(
(
*
it
)[
col
]
);
return
uni_atoi
(
(
*
it
)[
col
]
);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
double
as_double
(
SQLiteResult
::
iterator
&
it
,
int
col
)
double
SQLiteResult
::
as_double
(
const
SQLiteResult
::
iterator
&
it
,
int
col
)
{
{
return
atof
(
((
*
it
)[
col
]).
c_str
()
);
return
atof
(
((
*
it
)[
col
]).
c_str
()
);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
string
as_string
(
SQLiteResult
::
iterator
&
it
,
int
col
)
string
SQLiteResult
::
as_string
(
const
SQLiteResult
::
iterator
&
it
,
int
col
)
{
{
return
((
*
it
)[
col
]);
return
((
*
it
)[
col
]);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
int
as_int
(
SQLiteResult
::
COL
::
iterator
&
it
)
int
SQLiteResult
::
as_int
(
const
SQLiteResult
::
COL
::
iterator
&
it
)
{
{
return
uni_atoi
(
(
*
it
)
);
return
uni_atoi
(
(
*
it
)
);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
double
as_double
(
SQLiteResult
::
COL
::
iterator
&
it
)
double
SQLiteResult
::
as_double
(
const
SQLiteResult
::
COL
::
iterator
&
it
)
{
{
return
atof
(
(
*
it
).
c_str
()
);
return
atof
(
(
*
it
).
c_str
()
);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
std
::
string
as_string
(
SQLiteResult
::
COL
::
iterator
&
it
)
std
::
string
SQLiteResult
::
as_string
(
const
SQLiteResult
::
COL
::
iterator
&
it
)
{
{
return
(
*
it
);
return
(
*
it
);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
#if 0
#if 0
SQLiteResult::COL get_col( SQLiteResult::ROW::iterator& it )
SQLiteResult::COL
SQLiteResult::
get_col( SQLiteResult::ROW::iterator& it )
{
{
return (*it);
return (*it);
}
}
...
...
extensions/DBServer-SQLite/SQLiteInterface.h
View file @
a9039660
...
@@ -59,7 +59,7 @@
...
@@ -59,7 +59,7 @@
cout << "ROW: ";
cout << "ROW: ";
SQLiteResult::COL col(*it);
SQLiteResult::COL col(*it);
for( SQLiteResult::COL::iterator cit = it->begin(); cit!=it->end(); cit++ )
for( SQLiteResult::COL::iterator cit = it->begin(); cit!=it->end(); cit++ )
cout << as_string(cit) << "(" <<
as_double(cit) << ") | ";
cout << SQLiteResult::as_string(cit) << "(" << SQLiteResult::
as_double(cit) << ") | ";
cout << endl;
cout << endl;
}
}
...
@@ -172,21 +172,24 @@ class SQLiteResult
...
@@ -172,21 +172,24 @@ class SQLiteResult
return
res
.
empty
();
return
res
.
empty
();
}
}
// ----------------------------------------------------------------------------
static
int
num_cols
(
const
SQLiteResult
::
iterator
&
);
// ROW
static
int
as_int
(
const
SQLiteResult
::
iterator
&
,
int
col
);
static
double
as_double
(
const
SQLiteResult
::
iterator
&
,
int
col
);
static
std
::
string
as_string
(
const
SQLiteResult
::
iterator
&
,
int
col
);
// ----------------------------------------------------------------------------
// COL
static
int
as_int
(
const
SQLiteResult
::
COL
::
iterator
&
);
static
double
as_double
(
const
SQLiteResult
::
COL
::
iterator
&
);
static
std
::
string
as_string
(
const
SQLiteResult
::
COL
::
iterator
&
);
protected
:
protected
:
ROW
res
;
ROW
res
;
};
};
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
int
num_cols
(
SQLiteResult
::
iterator
&
);
// ROW
int
as_int
(
SQLiteResult
::
iterator
&
,
int
col
);
double
as_double
(
SQLiteResult
::
iterator
&
,
int
col
);
std
::
string
as_string
(
SQLiteResult
::
iterator
&
,
int
col
);
// ----------------------------------------------------------------------------
// COL
int
as_int
(
SQLiteResult
::
COL
::
iterator
&
);
double
as_double
(
SQLiteResult
::
COL
::
iterator
&
);
std
::
string
as_string
(
SQLiteResult
::
COL
::
iterator
&
);
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
#endif
#endif
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
extensions/DBServer-SQLite/test.cc
View file @
a9039660
...
@@ -35,7 +35,7 @@ int main(int argc, char** argv)
...
@@ -35,7 +35,7 @@ int main(int argc, char** argv)
SQLiteResult
::
COL
col
(
*
it
);
SQLiteResult
::
COL
col
(
*
it
);
for
(
SQLiteResult
::
COL
::
iterator
cit
=
it
->
begin
();
cit
!=
it
->
end
();
cit
++
)
for
(
SQLiteResult
::
COL
::
iterator
cit
=
it
->
begin
();
cit
!=
it
->
end
();
cit
++
)
cout
<<
as_string
(
cit
)
<<
"("
<<
as_double
(
cit
)
<<
") | "
;
cout
<<
SQLiteResult
::
as_string
(
cit
)
<<
"("
<<
SQLiteResult
::
as_double
(
cit
)
<<
") | "
;
cout
<<
endl
;
cout
<<
endl
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment