Skip to content

Commit f770bc7

Browse files
committed
Update 2.1.0.0
2 parents 58dbf15 + 8d1b39c commit f770bc7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+6380
-4694
lines changed

xivModdingFramework/Cache/XivCache.cs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public class XivCache
2121
{
2222
private GameInfo _gameInfo;
2323
private DirectoryInfo _dbPath;
24-
private static readonly Version CacheVersion = new Version("0.0.0.25");
24+
public static readonly Version CacheVersion = new Version("0.0.0.25");
2525
private const string dbFileName = "mod_cache.db";
26-
private const string creationScript = "CreateDB.sql";
26+
private const string creationScript = "CreateCacheDB.sql";
2727
private string _connectionString { get
2828
{
2929
return "Data Source=" + _dbPath + ";Pooling=True;Max Pool Size=100;";
@@ -814,6 +814,11 @@ private string GetMetaValue(string key)
814814
return val?.ToString();
815815
}
816816

817+
private async Task<List<T>> BuildListFromTable<T>(string table, WhereClause where, Func<CacheReader, Task<T>> func)
818+
{
819+
return await BuildListFromTable<T>(_connectionString, table, where, func);
820+
}
821+
817822
/// <summary>
818823
/// Creates a list from the data entries in a cache table, using the given where clause and predicate.
819824
/// </summary>
@@ -822,10 +827,10 @@ private string GetMetaValue(string key)
822827
/// <param name="where"></param>
823828
/// <param name="func"></param>
824829
/// <returns></returns>
825-
private async Task<List<T>> BuildListFromTable<T>(string table, WhereClause where, Func<CacheReader, Task<T>> func)
830+
public static async Task<List<T>> BuildListFromTable<T>(string connectionString, string table, WhereClause where, Func<CacheReader, Task<T>> func)
826831
{
827832
List<T> list = new List<T>();
828-
using (var db = new SQLiteConnection(_connectionString))
833+
using (var db = new SQLiteConnection(connectionString))
829834
{
830835
db.Open();
831836
// Check how large the result set will be so we're not constantly
@@ -886,7 +891,7 @@ private async Task<List<T>> BuildListFromTable<T>(string table, WhereClause wher
886891
/// A [WhereClause] with any [Inner] entries is considered
887892
/// a parenthetical group and has its own Column/Value/Comparer ignored.
888893
/// </summary>
889-
private class WhereClause
894+
public class WhereClause
890895
{
891896
public enum ComparisonType
892897
{
@@ -1018,7 +1023,7 @@ public void AddParameters(SQLiteCommand cmd)
10181023
/// ensures the underlying reader is properly closed and destroyed to help
10191024
/// avoid lingering file handles.
10201025
/// </summary>
1021-
private class CacheReader : IDisposable
1026+
public class CacheReader : IDisposable
10221027
{
10231028
private SQLiteDataReader _reader;
10241029
private Dictionary<string, int> _headers;
@@ -1058,6 +1063,24 @@ public CacheReader(SQLiteDataReader reader)
10581063
}
10591064
}
10601065

1066+
public byte GetByte(string fieldName)
1067+
{
1068+
if (_reader[_headers[fieldName]].GetType() == NullType)
1069+
{
1070+
return 0;
1071+
}
1072+
return _reader.GetByte(_headers[fieldName]);
1073+
}
1074+
1075+
public float GetFloat(string fieldName)
1076+
{
1077+
if (_reader[_headers[fieldName]].GetType() == NullType)
1078+
{
1079+
return 0f;
1080+
}
1081+
return _reader.GetFloat(_headers[fieldName]);
1082+
}
1083+
10611084
public int GetInt32(string fieldName)
10621085
{
10631086
if(_reader[_headers[fieldName]].GetType() == NullType)

0 commit comments

Comments
 (0)