[darwinbuild-changes] [718] branches/PR-7489777/darwinup
source_changes at macosforge.org
source_changes at macosforge.org
Wed Feb 24 08:18:54 PST 2010
Revision: 718
http://trac.macosforge.org/projects/darwinbuild/changeset/718
Author: wsiegrist at apple.com
Date: 2010-02-24 08:18:52 -0800 (Wed, 24 Feb 2010)
Log Message:
-----------
Cleanup Column class. Set the initial table allocation to 2 in Database
Modified Paths:
--------------
branches/PR-7489777/darwinup/Column.cpp
branches/PR-7489777/darwinup/Column.h
branches/PR-7489777/darwinup/Database.cpp
Modified: branches/PR-7489777/darwinup/Column.cpp
===================================================================
--- branches/PR-7489777/darwinup/Column.cpp 2010-02-24 16:03:53 UTC (rev 717)
+++ branches/PR-7489777/darwinup/Column.cpp 2010-02-24 16:18:52 UTC (rev 718)
@@ -35,15 +35,6 @@
#include <stdlib.h>
#include "Column.h"
-Column::Column() {
- m_name = strdup("unnamed_column");
- m_create_sql = NULL;
- m_type = SQLITE_INTEGER;
- m_is_index = false;
- m_is_pk = false;
- m_is_unique = false;
-}
-
Column::Column(const char* name, uint32_t type) {
m_name = strdup(name);
m_create_sql = NULL;
@@ -76,6 +67,19 @@
return m_type;
}
+const bool Column::is_index() {
+ return m_is_index;
+}
+
+const bool Column::is_pk() {
+ return m_is_pk;
+}
+
+const bool Column::is_unique() {
+ return m_is_unique;
+}
+
+
const char* Column::typestr() {
switch(m_type) {
case SQLITE_INTEGER:
@@ -104,23 +108,6 @@
return m_offset;
}
-const bool Column::is_index() {
- return m_is_index;
-}
-
-const bool Column::is_pk() {
- return m_is_pk;
-}
-
-const bool Column::is_unique() {
- return m_is_unique;
-}
-
-/**
- * Returns string of sql.
- * Columns will deallocate the string in dtor.
- *
- */
const char* Column::create() {
if (!m_create_sql) {
asprintf(&m_create_sql, "%s %s%s%s", m_name, this->typestr(),
Modified: branches/PR-7489777/darwinup/Column.h
===================================================================
--- branches/PR-7489777/darwinup/Column.h 2010-02-24 16:03:53 UTC (rev 717)
+++ branches/PR-7489777/darwinup/Column.h 2010-02-24 16:18:52 UTC (rev 718)
@@ -35,10 +35,15 @@
#include <stdint.h>
#include <sqlite3.h>
+
#include "Utils.h"
+/**
+ * Column objects represent a column in a database table. They store
+ * type information and chunks of sql for their Table to build
+ * queries with.
+ */
struct Column {
- Column();
Column(const char* name, uint32_t type);
Column(const char* name, uint32_t type,
bool is_index, bool is_pk, bool is_unique);
@@ -46,18 +51,24 @@
const char* name();
uint32_t type();
- const char* typestr();
- uint32_t size();
- const char* create();
- const char* index();
- int offset();
-
-
const bool is_index();
const bool is_pk();
const bool is_unique();
+
+ // return size of this column when packed into a result record
+ uint32_t size();
+
+protected:
+ // return a string representation of this columns type suitable
+ // for sql queries
+ const char* typestr();
-protected:
+ // return the offset of this column in the Table's result record
+ int offset();
+
+ // generate the sql needed to create this column
+ const char* create();
+
char* m_name;
char* m_create_sql;
uint32_t m_type; // SQLITE_* type definition
Modified: branches/PR-7489777/darwinup/Database.cpp
===================================================================
--- branches/PR-7489777/darwinup/Database.cpp 2010-02-24 16:03:53 UTC (rev 717)
+++ branches/PR-7489777/darwinup/Database.cpp 2010-02-24 16:18:52 UTC (rev 718)
@@ -40,8 +40,7 @@
}
Database::Database() {
- // XXX: make the initial allocation for 2 to tailor to darwinup usage
- m_table_max = 1;
+ m_table_max = 2;
m_table_count = 0;
m_tables = (Table**)malloc(sizeof(Table*) * m_table_max);
this->init_cache();
@@ -52,7 +51,7 @@
}
Database::Database(const char* path) {
- m_table_max = 1;
+ m_table_max = 2;
m_table_count = 0;
m_tables = (Table**)malloc(sizeof(Table*) * m_table_max);
this->init_cache();
@@ -572,7 +571,7 @@
}
/**
- * Given a table, value_column, and value to set, plus a va_list of Column,value for WHERE clause
+ * Given a table, value_column, and value to set, plus a va_list of Column,compare,value for WHERE clause
* set the value_column to value when WHERE is true
*/
int Database::update_value(const char* name, Table* table, Column* value_column, void** value,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20100224/90adb6d6/attachment-0001.html>
More information about the darwinbuild-changes
mailing list