#include <rlbussignaldatabase.h>
|
| rlBussignalDatabase () |
|
virtual | ~rlBussignalDatabase () |
|
int | openDatabase (const char *database, const char *table) |
|
int | writeDatabaseInt (const char *item, int val) |
|
int | writeDatabaseIntArray (const char *item, int *val, int len) |
|
int | writeDatabaseFloat (const char *item, float val) |
|
int | writeDatabaseFloatArray (const char *item, float *val, int len) |
|
int | writeDatabaseString (const char *item, char *val) |
|
int | readDatabase (const char *item, char *type, char *value) |
|
int | closeDatabase () |
|
Definition at line 21 of file rlbussignaldatabase.h.
◆ rlBussignalDatabase()
rlBussignalDatabase::rlBussignalDatabase |
( |
| ) |
|
◆ ~rlBussignalDatabase()
rlBussignalDatabase::~rlBussignalDatabase |
( |
| ) |
|
|
virtual |
◆ closeDatabase()
int rlBussignalDatabase::closeDatabase |
( |
| ) |
|
◆ myquery()
int rlBussignalDatabase::myquery |
( |
const char * |
query | ) |
|
|
private |
◆ openDatabase()
int rlBussignalDatabase::openDatabase |
( |
const char * |
database, |
|
|
const char * |
table |
|
) |
| |
◆ readDatabase()
int rlBussignalDatabase::readDatabase |
( |
const char * |
item, |
|
|
char * |
type, |
|
|
char * |
value |
|
) |
| |
Definition at line 165 of file rlbussignaldatabase.cpp.
172 *type = *value =
'\0';
173 sprintf(query,
"select * from bus where name = '%s'",item);
175 state = mysql_query((MYSQL *)
connection, query);
181 num_rows = mysql_affected_rows((MYSQL *)
connection);
182 result = mysql_store_result((MYSQL *)
connection);
185 row = mysql_fetch_row(result);
188 if(row[1] != NULL) strcpy(type ,row[1]);
189 if(row[2] != NULL) strcpy(value,row[2]);
191 mysql_free_result(result);
◆ writeDatabaseFloat()
int rlBussignalDatabase::writeDatabaseFloat |
( |
const char * |
item, |
|
|
float |
val |
|
) |
| |
Definition at line 89 of file rlbussignaldatabase.cpp.
91 sprintf(
buf,
"%f",val);
char buf[rl_PRINTF_LENGTH]
int writeDatabaseString(const char *item, char *val)
◆ writeDatabaseFloatArray()
int rlBussignalDatabase::writeDatabaseFloatArray |
( |
const char * |
item, |
|
|
float * |
val, |
|
|
int |
len |
|
) |
| |
Definition at line 96 of file rlbussignaldatabase.cpp.
104 sprintf(vbuf,
"%f,",val[i]);
105 if(strlen(
buf)+strlen(vbuf) >=
sizeof(
buf)-1)
return -1;
char buf[rl_PRINTF_LENGTH]
int writeDatabaseString(const char *item, char *val)
◆ writeDatabaseInt()
int rlBussignalDatabase::writeDatabaseInt |
( |
const char * |
item, |
|
|
int |
val |
|
) |
| |
Definition at line 66 of file rlbussignaldatabase.cpp.
68 sprintf(
buf,
"%d",val);
char buf[rl_PRINTF_LENGTH]
int writeDatabaseString(const char *item, char *val)
◆ writeDatabaseIntArray()
int rlBussignalDatabase::writeDatabaseIntArray |
( |
const char * |
item, |
|
|
int * |
val, |
|
|
int |
len |
|
) |
| |
Definition at line 73 of file rlbussignaldatabase.cpp.
81 sprintf(vbuf,
"%d,",val[i]);
82 if(strlen(
buf)+strlen(vbuf) >=
sizeof(
buf)-1)
return -1;
char buf[rl_PRINTF_LENGTH]
int writeDatabaseString(const char *item, char *val)
◆ writeDatabaseString() [1/2]
int rlBussignalDatabase::writeDatabaseString |
( |
const char * |
item, |
|
|
char * |
val |
|
) |
| |
Definition at line 112 of file rlbussignaldatabase.cpp.
114 sprintf(
typebuf,
"S%d",strlen(val));
char buf[rl_PRINTF_LENGTH]
int writeDatabaseString(const char *item, char *val)
char * rlstrncpy(char *dest, const char *source, int n)
◆ writeDatabaseString() [2/2]
int rlBussignalDatabase::writeDatabaseString |
( |
const char * |
item | ) |
|
|
private |
Definition at line 119 of file rlbussignaldatabase.cpp.
125 ret = snprintf(sqlbuf,
sizeof(sqlbuf)-1,
"UPDATE %s SET datatype='%s', datavalue='%s' WHERE name='%s'",
tableName,
typebuf,
buf,item);
128 printf(
"sqlbuf too small in writeDatabaseString\n");
132 if(ret > 0)
return 0;
135 ret = snprintf(sqlbuf,
sizeof(sqlbuf)-1,
"INSERT INTO %s VALUES ('%s','%s','%s')",
tableName,item,
typebuf,
buf);
138 printf(
"sqlbuf too small in writeDatabaseString\n");
142 if(ret >= 0)
return 0;
char buf[rl_PRINTF_LENGTH]
int myquery(const char *query)
◆ buf
◆ connection
void* rlBussignalDatabase::connection |
|
private |
◆ database
void* rlBussignalDatabase::database |
|
private |
◆ databaseName
char* rlBussignalDatabase::databaseName |
|
private |
◆ tableName
char* rlBussignalDatabase::tableName |
|
private |
◆ typebuf
char rlBussignalDatabase::typebuf[16] |
|
private |
The documentation for this class was generated from the following files: