22 #include "ns3/abort.h"
23 #include "ns3/unused.h"
25 #include "ns3/nstime.h"
34 int rc = sqlite3_open (name.c_str (), &
m_db);
42 rc = sqlite3_close_v2 (
m_db);
50 SpinExec (
"PRAGMA journal_mode = MEMORY");
104 return sqlite3_column_int (stmt, pos);
111 return static_cast<uint32_t
> (sqlite3_column_int (stmt, pos));
118 return sqlite3_column_double (stmt, pos);
136 if (sqlite3_bind_double (stmt, pos, value.
GetSeconds ()) == SQLITE_OK)
147 if (sqlite3_bind_double (stmt, pos, value) == SQLITE_OK)
158 if (sqlite3_bind_int (stmt, pos,
static_cast<int> (value)) == SQLITE_OK)
169 if (sqlite3_bind_int64 (stmt, pos, value) == SQLITE_OK)
180 if (sqlite3_bind_int64 (stmt, pos, value) == SQLITE_OK)
191 if (sqlite3_bind_int (stmt, pos,
static_cast<int> (value)) == SQLITE_OK)
202 if (sqlite3_bind_int (stmt, pos,
static_cast<int> (value)) == SQLITE_OK)
213 if (sqlite3_bind_int (stmt, pos, value) == SQLITE_OK)
224 if (sqlite3_bind_text (stmt, pos, value.c_str (), -1, SQLITE_STATIC) == SQLITE_OK)
236 sem_t *sem = sem_open (
m_semName.c_str (), O_CREAT, S_IRUSR | S_IWUSR, 1);
239 "FAILED to open system semaphore, errno: " << errno);
241 if (sem_wait (sem) == 0)
243 rc = sqlite3_prepare_v2 (db,
cmd.c_str (),
244 static_cast<int> (
cmd.size ()),
273 rc = sqlite3_prepare_v2 (db,
cmd.c_str (),
274 static_cast<int> (
cmd.size ()),
277 while (rc == SQLITE_BUSY || rc == SQLITE_LOCKED);
287 rc = sqlite3_step (stmt);
289 while (rc == SQLITE_BUSY || rc == SQLITE_LOCKED);
300 rc = sqlite3_finalize (stmt);
302 while (rc == SQLITE_BUSY || rc == SQLITE_LOCKED);
313 rc = sqlite3_reset (stmt);
315 while (rc == SQLITE_BUSY || rc == SQLITE_LOCKED);
328 sem_t *sem,
bool hardExit)
330 if (rc != SQLITE_OK && rc != SQLITE_DONE)
343 std::cerr << sqlite3_errmsg (db) << std::endl;
381 ret =
CheckError (db, rc,
"",
nullptr,
false);
395 int rc = SQLITE_ERROR;
397 sem_t *sem = sem_open (
m_semName.c_str (), O_CREAT, S_IRUSR | S_IWUSR, 1);
400 "FAILED to open system semaphore, errno: " << errno);
402 if (sem_wait (sem) == 0)
431 int rc = SQLITE_ERROR;
433 sem_t *sem = sem_open (
m_semName.c_str (), O_CREAT, S_IRUSR | S_IWUSR, 1);
436 "FAILED to open system semaphore, errno: " << errno);
438 if (sem_wait (sem) == 0)