aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDataAdditions.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2012-03-20 22:43:34 +0000
committerstuconnolly <stuart02@gmail.com>2012-03-20 22:43:34 +0000
commit1f18d0eb40a1bc0551dbabdfe355c9632a47c6c6 (patch)
treef2983b3e79cb542b3a4297a14cf93d9847871b6c /Source/SPDataAdditions.m
parent008b8291ebaf3042c7229350ca1c77a110f4b65d (diff)
downloadsequelpro-1f18d0eb40a1bc0551dbabdfe355c9632a47c6c6.tar.gz
sequelpro-1f18d0eb40a1bc0551dbabdfe355c9632a47c6c6.tar.bz2
sequelpro-1f18d0eb40a1bc0551dbabdfe355c9632a47c6c6.zip
- When exporting a query result or filtered table view make sure we're including the entire content of BLOBs, not just what we display. Fixes issue #1124.
- Move SPTableContent's table view datasource and delegate methods to separate categories in order to reduce it's size.
Diffstat (limited to 'Source/SPDataAdditions.m')
-rw-r--r--Source/SPDataAdditions.m40
1 files changed, 23 insertions, 17 deletions
diff --git a/Source/SPDataAdditions.m b/Source/SPDataAdditions.m
index 0329395c..b1aad389 100644
--- a/Source/SPDataAdditions.m
+++ b/Source/SPDataAdditions.m
@@ -76,7 +76,6 @@
- (NSData *)dataDecryptedWithPassword:(NSString *)password
{
-
// Create the key from the password hash
unsigned char passwordDigest[20];
SHA1((const unsigned char *)[password UTF8String], strlen([password UTF8String]), passwordDigest);
@@ -190,10 +189,10 @@
return [NSData dataWithData: zipData];
}
-- (NSString *)dataToFormattedHexString
-/*
- returns the hex representation of the given data
+/**
+ * Returns the hex representation of the given data.
*/
+- (NSString *)dataToFormattedHexString
{
NSUInteger i, j;
NSUInteger totalLength = [self length];
@@ -258,26 +257,33 @@
return retVal;
}
+/**
+ * Converts data instances to their string representation.
+ */
+- (NSString *)stringRepresentationUsingEncoding:(NSStringEncoding)encoding
+{
+ NSString *string = [[[NSString alloc] initWithData:self encoding:encoding] autorelease];
+
+ return !string ? [[[NSString alloc] initWithData:self encoding:NSASCIIStringEncoding] autorelease] : string;
+}
+
/*
* Convert data objects to their string representation (max 255 chars)
* in the current encoding, falling back to ascii. (Mainly used for displaying
* large blob data in a tableView)
*/
-- (NSString *) shortStringRepresentationUsingEncoding:(NSStringEncoding)encoding
+- (NSString *)shortStringRepresentationUsingEncoding:(NSStringEncoding)encoding
{
- NSString *tmp = [[[NSString alloc] initWithData:self encoding:encoding] autorelease];
-
- if (tmp == nil)
- tmp = [[[NSString alloc] initWithData:self encoding:NSASCIIStringEncoding] autorelease];
- if (tmp == nil)
- return @"- cannot be displayed -";
- else {
- if([tmp length] > 255)
- return [tmp substringToIndex:255];
- else
- return tmp;
+ NSString *string = [self stringRepresentationUsingEncoding:encoding];
+
+ if (!string) {
+ string = @"-- cannot display --";
+ }
+ else if ([string length] > 255) {
+ string = [string substringToIndex:255];
}
- return @"- cannot be displayed -";
+
+ return string;
}
@end