aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDataAdditions.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2012-04-16 20:16:52 +0000
committerstuconnolly <stuart02@gmail.com>2012-04-16 20:16:52 +0000
commit4cad6f0e6e4fb497b480256c2abe3de34ebf225c (patch)
treeb66d6a72a1537cf98624acf3c685f1a4d916fd86 /Source/SPDataAdditions.m
parent0d3b69f964a8d9d93ca794d457b461463f1ec95d (diff)
downloadsequelpro-4cad6f0e6e4fb497b480256c2abe3de34ebf225c.tar.gz
sequelpro-4cad6f0e6e4fb497b480256c2abe3de34ebf225c.tar.bz2
sequelpro-4cad6f0e6e4fb497b480256c2abe3de34ebf225c.zip
Bring outline view branch up to date with trunk.
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