const char* GnSQLiteTable::GetStringField(const char* szField, const char* szNullValue/*=""*/) { if ( FieldIsNull(szField) ) { return szNullValue; } else { return FieldValue(szField); } }
double GnSQLiteTable::GetFloatField(const char* szField, double fNullValue/*=0.0*/) { if ( FieldIsNull(szField) ) { return fNullValue; } else { return atof( FieldValue(szField) ); } }
double GnSQLiteTable::GetFloatField(int nField, double fNullValue/*=0.0*/) { if ( FieldIsNull( nField ) ) { return fNullValue; } else { return atof( FieldValue( nField ) ); } }
int GnSQLiteTable::GetIntField(const char* szField, int nNullValue/*=0*/) { if ( FieldIsNull( szField ) ) { return nNullValue; } else { return atoi( FieldValue( szField ) ); } }
int GnSQLiteTable::GetIntField(int nField, int nNullValue/*=0*/) { if ( FieldIsNull( nField ) ) { return nNullValue; } else { return atoi( FieldValue( nField ) ); } }
bool CppSQLite3Table::GetStringField(const char *szField, char *&rDset) { if (FieldIsNull(szField)) { return false; } else { rDset = const_cast<char *>(ValueOfField(szField)); return true; } }
bool CppSQLite3Table::GetStringField(int nField, char *&rDest) { if (FieldIsNull(nField)) { return false; } else { rDest = const_cast<char *>(ValueOfField(nField)); return true; } }
bool CppSQLite3Table::GetFloatField(const char *szField, double &rDest) { if (FieldIsNull(szField)) { return false; } else { rDest = atof(ValueOfField(szField)); return true; } }
bool CppSQLite3Table::GetIntField(const char *szField, int &rDest) { if (FieldIsNull(szField)) { return false; } else { rDest = atoi(ValueOfField(szField)); return true; } }
bool CppSQLite3Table::GetFloatField(int nField, double &rDest) { if (FieldIsNull(nField)) { return false; } else { //C库函数,将数值型字符串转换为浮点数 rDest = atof(ValueOfField(nField)); return true; } }
//这里的获取具体类型数值函数,需要用户对数据库中的表有一定的了解,知道哪些字段存储的是什么内容 //并且使用的是外部传递引用的形式 bool CppSQLite3Table::GetIntField(int nField, int &rDest) { if (FieldIsNull(nField)) { return false; } else { //atoi()函数是C库函数,讲数值型字符串转换为整型值 rDest = atoi(ValueOfField(nField)); return true; } }