Skip to content

Commit

Permalink
修复bug.
Browse files Browse the repository at this point in the history
修复bug.
  • Loading branch information
huangzhibiao committed May 4, 2018
1 parent 8253ec1 commit 261e83a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 28 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,5 @@
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "BGFMDB/libs/BG/BGDB.m"
timestampString = "547109505.006078"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "1555"
endingLineNumber = "1555"
landmarkName = "-insertWithObject:ignoredKeys:complete:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
31 changes: 19 additions & 12 deletions BGFMDB/libs/BG/BGTool.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
#define BGMapTable @"BGMapTable"
#define BGHashTable @"BGHashTable"

#define bg_typeHead_NS @"@\"NS"
#define bg_typeHead__NS @"@\"__NS"

#define bg_typeHead_UI @"@\"UI"
#define bg_typeHead__UI @"@\"__UI"


//100M大小限制.
#define MaxData @(838860800)

Expand Down Expand Up @@ -519,7 +526,7 @@ +(NSString*)stringWithDate:(NSDate*)date{
+(id)getSqlValue:(id)value type:(NSString*)type encode:(BOOL)encode{
if(!value || [value isKindOfClass:[NSNull class]])return nil;

if(([type hasPrefix:@"@\"NS"]||[type hasPrefix:@"@\"__NS"])&&[type containsString:@"String"]){
if(([type hasPrefix:bg_typeHead_NS]||[type hasPrefix:bg_typeHead__NS])&&[type containsString:@"String"]){
if([type containsString:@"AttributedString"]){//处理富文本.
if(encode) {
return [[NSKeyedArchiver archivedDataWithRootObject:value] base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
Expand All @@ -530,31 +537,31 @@ +(id)getSqlValue:(id)value type:(NSString*)type encode:(BOOL)encode{
}else{
return value;
}
}else if(([type hasPrefix:@"@\"NS"]||[type hasPrefix:@"@\"__NS"])&&[type containsString:@"Number"]){
}else if(([type hasPrefix:bg_typeHead_NS]||[type hasPrefix:bg_typeHead__NS])&&[type containsString:@"Number"]){
if(encode) {
return [NSString stringWithFormat:@"%@",value];
}else{
return [[NSNumberFormatter new] numberFromString:value];
}
}else if(([type hasPrefix:@"@\"NS"]||[type hasPrefix:@"@\"__NS"])&&[type containsString:@"Array"]){
}else if(([type hasPrefix:bg_typeHead_NS]||[type hasPrefix:bg_typeHead__NS])&&[type containsString:@"Array"]){
if(encode){
return [self jsonStringWithArray:value];
}else{
return [self arrayFromJsonString:value];
}
}else if(([type hasPrefix:@"@\"NS"]||[type hasPrefix:@"@\"__NS"])&&[type containsString:@"Dictionary"]){
}else if(([type hasPrefix:bg_typeHead_NS]||[type hasPrefix:bg_typeHead__NS])&&[type containsString:@"Dictionary"]){
if(encode){
return [self jsonStringWithDictionary:value];
}else{
return [self dictionaryFromJsonString:value];
}
}else if(([type hasPrefix:@"@\"NS"]||[type hasPrefix:@"@\"__NS"])&&[type containsString:@"Set"]){
}else if(([type hasPrefix:bg_typeHead_NS]||[type hasPrefix:bg_typeHead__NS])&&[type containsString:@"Set"]){
if(encode){
return [self jsonStringWithArray:value];
}else{
return [self arrayFromJsonString:value];
}
}else if(([type hasPrefix:@"@\"NS"]||[type hasPrefix:@"@\"__NS"])&&[type containsString:@"Data"]){
}else if(([type hasPrefix:bg_typeHead_NS]||[type hasPrefix:bg_typeHead__NS])&&[type containsString:@"Data"]){
if(encode){
NSData* data = value;
NSNumber* maxLength = MaxData;
Expand All @@ -563,31 +570,31 @@ +(id)getSqlValue:(id)value type:(NSString*)type encode:(BOOL)encode{
}else{
return [[NSData alloc] initWithBase64EncodedString:value options:NSDataBase64DecodingIgnoreUnknownCharacters];
}
}else if(([type hasPrefix:@"@\"NS"]||[type hasPrefix:@"@\"__NS"])&&[type containsString:@"MapTable"]){
}else if(([type hasPrefix:bg_typeHead_NS]||[type hasPrefix:bg_typeHead__NS])&&[type containsString:@"MapTable"]){
if(encode){
return [self jsonStringWithMapTable:value];
}else{
return [self mapTableFromJsonString:value];
}
}else if(([type hasPrefix:@"@\"NS"]||[type hasPrefix:@"@\"__NS"])&&[type containsString:@"HashTable"]){
}else if(([type hasPrefix:bg_typeHead_NS]||[type hasPrefix:bg_typeHead__NS])&&[type containsString:@"HashTable"]){
if(encode){
return [self jsonStringWithNSHashTable:value];
}else{
return [self hashTableFromJsonString:value];
}
}else if(([type hasPrefix:@"@\"NS"]||[type hasPrefix:@"@\"__NS"])&&[type containsString:@"Date"]){
}else if(([type hasPrefix:bg_typeHead_NS]||[type hasPrefix:bg_typeHead__NS])&&[type containsString:@"Date"]){
if(encode){
return [self stringWithDate:value];
}else{
return [self dateFromString:value];
}
}else if(([type hasPrefix:@"@\"NS"]||[type hasPrefix:@"@\"__NS"])&&[type containsString:@"URL"]){
}else if(([type hasPrefix:bg_typeHead_NS]||[type hasPrefix:bg_typeHead__NS])&&[type containsString:@"URL"]){
if(encode){
return [value absoluteString];
}else{
return [NSURL URLWithString:value];
}
}else if(([type hasPrefix:@"@\"UI"]||[type hasPrefix:@"@\"__UI"])&&[type containsString:@"Image"]){
}else if(([type hasPrefix:bg_typeHead_UI]||[type hasPrefix:bg_typeHead__UI])&&[type containsString:@"Image"]){
if(encode){
NSData* data = UIImageJPEGRepresentation(value, 1);
NSNumber* maxLength = MaxData;
Expand All @@ -596,7 +603,7 @@ +(id)getSqlValue:(id)value type:(NSString*)type encode:(BOOL)encode{
}else{
return [UIImage imageWithData:[[NSData alloc] initWithBase64EncodedString:value options:NSDataBase64DecodingIgnoreUnknownCharacters]];
}
}else if(([type hasPrefix:@"@\"UI"]||[type hasPrefix:@"@\"__UI"])&&[type containsString:@"Color"]){
}else if(([type hasPrefix:bg_typeHead_UI]||[type hasPrefix:bg_typeHead__UI])&&[type containsString:@"Color"]){
if(encode){
CGFloat r, g, b, a;
[value getRed:&r green:&g blue:&b alpha:&a];
Expand Down

0 comments on commit 261e83a

Please sign in to comment.