geary/src/engine/sqlite/abstract/sqlite-row.vala
Jim Nelson 41faa36103 New file naming scheme and organization for the Engine.
The code base is growing much faster than expected, faster than Shotwell it seems (not necessarily line count, but files and necessary organization of the library vs. Shotwell's initial flat directory).  After some thought decided to move to a more standard Vala/GTK naming scheme of all lowercase with dashes for spaces starting with namespace (minus the "geary-", unless the class was in the topmost namespace).  Three motivations:

1. Often confusing when working on code to see three "Folder.vala" in the gedit tabs: one IMAP, one SQLite, and one the interface definition.
2. This paves the way for waf integration, as right now we're held up using it because it barfs on projects with two files of the same name in different directories.
3. I find the CamelCase in the file browser becoming hard on the eyes, and this scheme seems a little more browsable.
2011-06-27 11:24:39 -07:00

38 lines
1.2 KiB
Vala

/* Copyright 2011 Yorba Foundation
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
*/
public abstract class Geary.Sqlite.Row {
public const int64 INVALID_ID = -1;
private Table table;
public Row(Table table) {
this.table = table;
}
public int fetch_int_for(SQLHeavy.QueryResult result, int col) throws SQLHeavy.Error {
return result.fetch_int(field_index(result, col));
}
public int64 fetch_int64_for(SQLHeavy.QueryResult result, int col) throws SQLHeavy.Error {
return result.fetch_int64(field_index(result, col));
}
public string fetch_string_for(SQLHeavy.QueryResult result, int col) throws SQLHeavy.Error {
return result.fetch_string(field_index(result, col));
}
private int field_index(SQLHeavy.QueryResult result, int col) throws SQLHeavy.Error {
try {
return result.field_index(table.get_field_name(col));
} catch (SQLHeavy.Error err) {
debug("Bad column #%d in %s: %s", col, table.to_string(), err.message);
throw err;
}
}
}