//
// SQLitePersistentObject.h
// ----------------------------------------------------------------------
// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
//
// (c) 2008 Jeff LaMarche ([email protected])
// ----------------------------------------------------------------------
// This code may be used without restriction in any software, commercial,
// free, or otherwise. There are no attribution requirements, and no
// requirement that you distribute your changes, although bugfixes and
// enhancements are welcome.
//
// If you do choose to re-distribute the source code, you must retain the
// copyright notice and this license information. I also request that you
// place comments in to identify your changes.
//
// For information on how to use these classes, take a look at the
// included eadme.txt file
// ----------------------------------------------------------------------
#import <Foundation/Foundation.h>
#import "/usr/include/sqlite3.h"
#if (! TARGET_OS_IPHONE)
#import <objc/objc-runtime.h>
#else
#import <objc/runtime.h>
#import <objc/message.h>
#endif
#define isNSArrayType(x) ([x isEqualToString:@"NSArray"] || [x isEqualToString:@"NSMutableArray"])
#define isNSDictionaryType(x) ([x isEqualToString:@"NSDictionary"] || [x isEqualToString:@"NSMutableDictionary"])
#define isNSSetType(x) ([x isEqualToString:@"NSSet"] || [x isEqualToString:@"NSMutableSet"])
/*!
Any class that subclasses this class can have their properties automatically persisted into a sqlite database. There are some limits - currently certain property types aren't supported like void *, char *, structs and unions. Anything that doesn't work correctly with Key Value Coding will not work with this. Ordinary scalars (ints, floats, etc) will be converted to NSNumber, as will BOOL.
SQLite is very good about converting types, so you can search on a number field passing in a number in a string, and can search on a string field by passing in a number. The only limitation we place on the search methods is that we don't allow searching on blobs, which is simply for performance reasons.
*/
// TODO: Look at marking object "dirty" when changes are made, and if it's not dirty, save becomes a no-op.
@interface SQLitePersistentObject : NSObject {
@private
NSInteger pk;
}
/*!
Returns the name of the table that this object will use to save its data
*/
+ (NSString *)tableName;
/*!
Find by criteria lets you specify the SQL conditions that will be used. The string passed in should start with the word WHERE. So, to search for a value with a pk value of 1, you would pass in @"WHERE pk = 1". When comparing to strings, the string comparison must be in single-quotes like this @"WHERE name = 'smith'".
*/
+(NSArray *)findByCriteria:(NSString *)criteriaString;
+(SQLitePersistentObject *)findFirstByCriteria:(NSString *)criteriaString;
+(SQLitePersistentObject *)findByPK:(int)inPk;
/*!
This method should be overridden by subclasses in order to specify performance indices on the underyling table.
@result Should return an array of arrays. Each array represents one index, and should contain a list of the properties that the index should be created on, in the order the database should use to create it. This is case sensitive, and the values must match the value of property names
*/
+(NSArray *)indices;
/*!
Deletes this object's corresponding row from the database table. This version does NOT cascade to child objects in other tables.
*/
-(void)deleteObject;
/*!
Deletes this object's corresponding row from the database table.
@param cascade Specifies whether child rows should be also deleted
*/
-(void)deleteObjectCascade:(BOOL)cascade;
/*!
This is just a convenience routine; in several places we have to iterate through the properties and take some action based
on their type. This method creates an array with all the property names and their types in a dictionary. The values for
the encoded types will be one of:
c A char
i An int
s A short
l A long
q A long long
C An unsigned char
I An unsigned int
S An unsigned short
L An unsigned long
Q An unsigned long long
f A float
d A double
B A C++ bool or a C99 _Bool
v A void
* A character string (char *)
@ An object (whether statically typed or typed id)
# A class object (Class)
: A method selector (SEL)
[array type] An array
{name=type...} A structure
(name=type...) A union
bnum A bit field of num bits
^type A pointer to type
? An unknown type (among other things, this code is used for function pointers)
Currently, the following properties cannot be persisted using this class: C, c, v, #, :, [array type], *, {name=type...}, (name=type...), bnum, ^type, or ?
TODO: Look at finding ways to allow people to use some or all of the currently unsupported types... we could probably use sizeof to store the structs and unions maybe??.
TODO: Look at overriding valueForUndefinedKey: to handle the char, char * and unsigned char property types - valueForKey: doesn't return anything for these, so currently they do not work.
*/
+ (NSDictionary *)propertiesWithEncodedTypes;
/*!
Indicates whether this object has ever been saved to the database. It does not indicate that the data matches what's in the database, just that there is a corresponding row
*/
-(BOOL) existsInDB;
/*!
Saves this object's current data to the database. If it has never been saved before, it will assign a primary key value based on the database contents. Scalar values (ints, floats, doubles, etc.) will be stored in appropriate database columns, objects will be stored using the SQLitePersistence protocol methods - objects that don't implement that protocol will be archived into the database. Collection clases will be stored in child cross-reference tables that serve double duty. Any object they contain that is a subclass of SQLItePersistentObject will be stored as a foreign key to the appropriate table, otherwise objects will be stored in a column according to SQLitePersistence. Currently, collection classes inside collection classes are simply serialized into the x-ref table, which works, but is not the most efficient means.
//TODO: Look at adding recursion of some form to allow collection objects within collection objects to be stored in a normalized fashion
*/
-(void)save;
/*!
Returns this objects primary key
*/
-(int)pk;
/*!
This method will return a dictionary using the value for one specified field as the key and the pk stored as an NSNumber as the object. This is designed for letting you retrieve a list for display without having to load all objects into memory.
*/
+(NSMutableDictionary *)sortedFieldValuesWithKeysForProperty:(NSString *)theProp;
+ (NSInteger)count;
+ (NSInteger)countByCriteria:(NSString *)criteriaString;
// TODO: These really belong in a category on NSObject - not sure why these don't exist on the iPhone...
#if (TARGET_OS_IPHONE)
- (NSString *)className;
+ (NSString *)className;
#endif
@end
没有合适的资源?快使用搜索试试~ 我知道了~
ios源码一款日志工具.zip
共77个文件
h:30个
m:29个
xib:7个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 84 浏览量
2022-07-09
14:18:46
上传
评论
收藏 224KB ZIP 举报
温馨提示
ios源码一款日志工具.zip
资源推荐
资源详情
资源评论
收起资源包目录
ios源码一款日志工具.zip (77个子文件)
packlog
main.m 346B
Default.png 14KB
Icon.png 4KB
libPinchAnalytics.a 336KB
Beacon.h 861B
README.textile 2KB
LICENSE 1KB
README 2KB
.gitignore 101B
PackLog.xcodeproj
project.pbxproj 37KB
Info.plist 1KB
Classes
Models
StatusEntryModel.m 262B
StatusEntryModel.h 552B
Vendor
SQLitePersistentObjects
SQLiteInstanceManager.h 1KB
NSString-SQLiteColumnName.m 2KB
SQLitePersistentObject.m 41KB
NSMutableData-SQLitePersistence.h 1KB
NSDate-SQLitePersistence.h 2KB
NSMutableData-SQLitePersistence.m 1KB
NSString-SQLitePersistence.m 1KB
UIImage-SQLitePersistence.m 1KB
NSString-UppercaseFirst.m 2KB
NSData-SQLitePersistence.h 2KB
SQLitePersistentObject.h 7KB
SQLiteInstanceManager.m 4KB
NSNumber-SQLitePersistence.h 2KB
NSString-SQLitePersistence.h 2KB
NSData-SQLitePersistence.m 1KB
NSObject-SQLitePersistence.h 4KB
NSNumber-SQLitePersistence.m 2KB
NSString-SQLiteColumnName.h 1KB
NSDate-SQLitePersistence.m 2KB
NSString-UppercaseFirst.h 1KB
NSObject-SQLitePersistence.m 2KB
UIImage-SQLitePersistence.h 1KB
TouchXML
CXMLDocument_PrivateExtensions.h 431B
CXMLNode_XPathExtensions.h 356B
CXMLElement.h 824B
CXMLDocument.m 4KB
CXMLNode_PrivateExtensions.m 1KB
CXMLElement.m 3KB
CXMLNode_XPathExtensions.m 2KB
TouchXML.h 243B
CXMLNode.h 2KB
CXMLDocument_PrivateExtensions.m 555B
CXMLNode_PrivateExtensions.h 336B
CXMLNode.m 6KB
CXMLDocument.h 1KB
Controllers
SettingsController.m 4KB
UserController.m 2KB
JournalController.m 6KB
UserController.h 265B
SettingsController.h 874B
StatusController.m 5KB
JournalController.h 1KB
StatusController.h 798B
PackLogAppDelegate.m 3KB
Managers
JournalManager.h 489B
StatusManager.m 8KB
JournalManager.m 8KB
UserManager.m 4KB
UserManager.h 415B
StatusManager.h 471B
Views
StatusView.xib 14KB
EditableCell.xib 10KB
JournalView.xib 14KB
SettingsView.xib 16KB
MainWindow.xib 16KB
UserView.xib 6KB
EntryCell.xib 13KB
TableViewCells
EntryCell.h 580B
EntryCell.m 2KB
EditableCell.m 819B
EditableCell.h 459B
PackLogAppDelegate.h 890B
.gitattributes 29B
PackLog_Prefix.pch 183B
共 77 条
- 1
资源评论
reg183
- 粉丝: 1815
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- JAVA实现Modbus RTU或Modbus TCPIP案例.zip
- 基于YOLOv8的FPS TPS AI自动锁定源码+使用步骤说明.zip
- JAVA实现Modbus RTU或Modbus TCPIP案例.zip
- 基于yolov8+streamlit的火灾检测部署源码+模型.zip
- 测试aaaaaaabbbbb
- VID20240521070643.mp4
- Android系统原理与开发学习要点详解-培训课件.zip
- 部署yolov8的tensorrt模型支持检测分割姿态估计的C++源码+部署步骤.zip
- 以简单、易用、高性能为目标、开源的时序数据库,支持Linux及Windows, Time Series Database.zip
- python-leetcode面试题解之第198题打家劫舍-题解.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功