21 #include "pedigree/kernel/LockGuard.h" 22 #include "pedigree/kernel/Log.h" 23 #include "pedigree/kernel/process/Mutex.h" 24 #include "pedigree/kernel/utilities/utility.h" 26 static Mutex g_sqlLock(
false);
30 extern "C" void free(
void *);
32 Config::Result::Result(
33 char **ppResult,
size_t rows,
size_t cols,
char *error,
int ret)
34 : m_ppResult(ppResult), m_Rows(rows), m_Cols(cols), m_pError(error),
39 Config::Result::~Result()
44 sqlite3_free_table(m_ppResult);
51 char *str = m_ppResult[n];
59 char *str = m_ppResult[(row + 1) * m_Cols + n];
67 if (m_ppResult[(row + 1) * m_Cols + n] == 0)
69 return StringToUnsignedLong(m_ppResult[(row + 1) * m_Cols + n], 0, 10);
74 const char *s = m_ppResult[(row + 1) * m_Cols + n];
77 if (!StringCompare(s,
"true") || !StringCompare(s,
"True") ||
78 !StringCompare(s,
"1"))
86 size_t n = lookupCol(str);
89 char *str2 = m_ppResult[(row + 1) * m_Cols + n];
97 size_t n = lookupCol(str);
100 if (m_ppResult[(row + 1) * m_Cols + n] == 0)
102 return StringToUnsignedLong(m_ppResult[(row + 1) * m_Cols + n], 0, 10);
107 size_t n = lookupCol(str);
110 const char *s = m_ppResult[(row + 1) * m_Cols + n];
113 if (!StringCompare(s,
"true") || !StringCompare(s,
"True") ||
114 !StringCompare(s,
"1"))
120 size_t Config::Result::lookupCol(
const char *str)
122 for (
size_t i = 0; i < m_Cols; i++)
124 if (!StringCompare(str, m_ppResult[i]))
142 ERROR(
"Dud query string passed to Config::query");
151 int ret = sqlite3_get_table(g_pSqlite, sql, &result, &rows, &cols, &error);
153 result, static_cast<size_t>(rows), static_cast<size_t>(cols), error,
std::string getColumnName(size_t col, size_t buffSz=256)
Returns the name of the col'th column.
std::string getStr(size_t row, size_t col, size_t buffSz=256)
Returns the value in column 'col' of the result, in string form.
size_t getNum(size_t row, size_t col)
Returns the value in column 'col' of the result, in number form.
Result * query(const char *sql)
bool getBool(size_t row, size_t col)
Returns the value in column 'col' of the result, in boolean form.