Daniel Tull avatar Daniel Tull committed 815f643

Added many files.

Comments (0)

Files changed (17)

DTFoundation.xcodeproj/project.pbxproj

 		24083D2810CF9922009B758E /* NSNumber+DTMaths.m in Sources */ = {isa = PBXBuildFile; fileRef = 24083D1C10CF9922009B758E /* NSNumber+DTMaths.m */; };
 		24083D2910CF9922009B758E /* NSSet+DTExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 24083D1E10CF9922009B758E /* NSSet+DTExtras.m */; };
 		24083D2A10CF9922009B758E /* NSString+DTPrefixString.m in Sources */ = {isa = PBXBuildFile; fileRef = 24083D2010CF9922009B758E /* NSString+DTPrefixString.m */; };
+		241E2A0D10F6A10F0076D698 /* DTOrderedDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 24083D0D10CF9922009B758E /* DTOrderedDictionary.h */; };
+		241E2A0E10F6A10F0076D698 /* DTOrderedDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 24083D0E10CF9922009B758E /* DTOrderedDictionary.m */; };
+		241E2A0F10F6A1100076D698 /* DTQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 24083D0F10CF9922009B758E /* DTQueue.h */; };
+		241E2A1010F6A1100076D698 /* DTQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 24083D1010CF9922009B758E /* DTQueue.m */; };
+		241E2A1110F6A1110076D698 /* DTSortedArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 24083D1110CF9922009B758E /* DTSortedArray.h */; };
+		241E2A1210F6A1110076D698 /* DTSortedArray.m in Sources */ = {isa = PBXBuildFile; fileRef = 24083D1210CF9922009B758E /* DTSortedArray.m */; };
+		241E2A1310F6A1120076D698 /* DTStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 24083D1310CF9922009B758E /* DTStack.h */; };
+		241E2A1410F6A1120076D698 /* DTStack.m in Sources */ = {isa = PBXBuildFile; fileRef = 24083D1410CF9922009B758E /* DTStack.m */; };
+		241E2A1510F6A1190076D698 /* DTTraversableDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 24083D1510CF9922009B758E /* DTTraversableDictionary.h */; };
+		241E2A1610F6A1190076D698 /* DTTraversableDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 24083D1610CF9922009B758E /* DTTraversableDictionary.m */; };
+		241E2A1710F6A11A0076D698 /* NSArray+DTExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 24083D1710CF9922009B758E /* NSArray+DTExtras.h */; };
+		241E2A1810F6A11A0076D698 /* NSArray+DTExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 24083D1810CF9922009B758E /* NSArray+DTExtras.m */; };
+		241E2A1910F6A11A0076D698 /* NSDate+DTComponentExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 24083D1910CF9922009B758E /* NSDate+DTComponentExtension.h */; };
+		241E2A1A10F6A11B0076D698 /* NSDate+DTComponentExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 24083D1A10CF9922009B758E /* NSDate+DTComponentExtension.m */; };
+		241E2A1B10F6A11B0076D698 /* NSNumber+DTMaths.h in Headers */ = {isa = PBXBuildFile; fileRef = 24083D1B10CF9922009B758E /* NSNumber+DTMaths.h */; };
+		241E2A1C10F6A11C0076D698 /* NSNumber+DTMaths.m in Sources */ = {isa = PBXBuildFile; fileRef = 24083D1C10CF9922009B758E /* NSNumber+DTMaths.m */; };
+		241E2A1D10F6A11D0076D698 /* NSSet+DTExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 24083D1D10CF9922009B758E /* NSSet+DTExtras.h */; };
+		241E2A1E10F6A11D0076D698 /* NSSet+DTExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 24083D1E10CF9922009B758E /* NSSet+DTExtras.m */; };
+		241E2A1F10F6A11E0076D698 /* NSString+DTPrefixString.h in Headers */ = {isa = PBXBuildFile; fileRef = 24083D1F10CF9922009B758E /* NSString+DTPrefixString.h */; };
+		241E2A2010F6A11E0076D698 /* NSString+DTPrefixString.m in Sources */ = {isa = PBXBuildFile; fileRef = 24083D2010CF9922009B758E /* NSString+DTPrefixString.m */; };
+		241E2A2110F6A11F0076D698 /* NSDate+DTHTTPDateStrings.h in Headers */ = {isa = PBXBuildFile; fileRef = 24ECCBDF10DC028100AB1388 /* NSDate+DTHTTPDateStrings.h */; };
+		241E2A2210F6A11F0076D698 /* NSDate+DTHTTPDateStrings.m in Sources */ = {isa = PBXBuildFile; fileRef = 24ECCBE010DC028100AB1388 /* NSDate+DTHTTPDateStrings.m */; };
+		24ECCBE110DC028100AB1388 /* NSDate+DTHTTPDateStrings.m in Sources */ = {isa = PBXBuildFile; fileRef = 24ECCBE010DC028100AB1388 /* NSDate+DTHTTPDateStrings.m */; };
 		288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; };
 		28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; };
 /* End PBXBuildFile section */
 		24083D1E10CF9922009B758E /* NSSet+DTExtras.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSSet+DTExtras.m"; sourceTree = "<group>"; };
 		24083D1F10CF9922009B758E /* NSString+DTPrefixString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+DTPrefixString.h"; sourceTree = "<group>"; };
 		24083D2010CF9922009B758E /* NSString+DTPrefixString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+DTPrefixString.m"; sourceTree = "<group>"; };
+		241E2A0A10F6A0F50076D698 /* libDTFoundation.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libDTFoundation.a; sourceTree = BUILT_PRODUCTS_DIR; };
+		24ECCBDF10DC028100AB1388 /* NSDate+DTHTTPDateStrings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+DTHTTPDateStrings.h"; sourceTree = "<group>"; };
+		24ECCBE010DC028100AB1388 /* NSDate+DTHTTPDateStrings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+DTHTTPDateStrings.m"; sourceTree = "<group>"; };
 		288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
 		28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = "<group>"; };
 		29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
+		241E2A0810F6A0F50076D698 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
 			isa = PBXGroup;
 			children = (
 				1D6058910D05DD3D006BFB54 /* DTFoundation.app */,
+				241E2A0A10F6A0F50076D698 /* libDTFoundation.a */,
 			);
 			name = Products;
 			sourceTree = "<group>";
 				24083D1E10CF9922009B758E /* NSSet+DTExtras.m */,
 				24083D1F10CF9922009B758E /* NSString+DTPrefixString.h */,
 				24083D2010CF9922009B758E /* NSString+DTPrefixString.m */,
+				24ECCBDF10DC028100AB1388 /* NSDate+DTHTTPDateStrings.h */,
+				24ECCBE010DC028100AB1388 /* NSDate+DTHTTPDateStrings.m */,
 			);
 			path = DTFoundation;
 			sourceTree = "<group>";
 		};
 /* End PBXGroup section */
 
+/* Begin PBXHeadersBuildPhase section */
+		241E2A0610F6A0F50076D698 /* Headers */ = {
+			isa = PBXHeadersBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				241E2A0D10F6A10F0076D698 /* DTOrderedDictionary.h in Headers */,
+				241E2A0F10F6A1100076D698 /* DTQueue.h in Headers */,
+				241E2A1110F6A1110076D698 /* DTSortedArray.h in Headers */,
+				241E2A1310F6A1120076D698 /* DTStack.h in Headers */,
+				241E2A1510F6A1190076D698 /* DTTraversableDictionary.h in Headers */,
+				241E2A1710F6A11A0076D698 /* NSArray+DTExtras.h in Headers */,
+				241E2A1910F6A11A0076D698 /* NSDate+DTComponentExtension.h in Headers */,
+				241E2A1B10F6A11B0076D698 /* NSNumber+DTMaths.h in Headers */,
+				241E2A1D10F6A11D0076D698 /* NSSet+DTExtras.h in Headers */,
+				241E2A1F10F6A11E0076D698 /* NSString+DTPrefixString.h in Headers */,
+				241E2A2110F6A11F0076D698 /* NSDate+DTHTTPDateStrings.h in Headers */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXHeadersBuildPhase section */
+
 /* Begin PBXNativeTarget section */
-		1D6058900D05DD3D006BFB54 /* DTFoundation */ = {
+		1D6058900D05DD3D006BFB54 /* DTFoundationApp */ = {
 			isa = PBXNativeTarget;
-			buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "DTFoundation" */;
+			buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "DTFoundationApp" */;
 			buildPhases = (
 				1D60588D0D05DD3D006BFB54 /* Resources */,
 				1D60588E0D05DD3D006BFB54 /* Sources */,
 			);
 			dependencies = (
 			);
-			name = DTFoundation;
+			name = DTFoundationApp;
 			productName = DTFoundation;
 			productReference = 1D6058910D05DD3D006BFB54 /* DTFoundation.app */;
 			productType = "com.apple.product-type.application";
 		};
+		241E2A0910F6A0F50076D698 /* DTFoundation */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 241E2A3610F6A1430076D698 /* Build configuration list for PBXNativeTarget "DTFoundation" */;
+			buildPhases = (
+				241E2A0610F6A0F50076D698 /* Headers */,
+				241E2A0710F6A0F50076D698 /* Sources */,
+				241E2A0810F6A0F50076D698 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = DTFoundation;
+			productName = DTFoundation;
+			productReference = 241E2A0A10F6A0F50076D698 /* libDTFoundation.a */;
+			productType = "com.apple.product-type.library.static";
+		};
 /* End PBXNativeTarget section */
 
 /* Begin PBXProject section */
 			projectDirPath = "";
 			projectRoot = "";
 			targets = (
-				1D6058900D05DD3D006BFB54 /* DTFoundation */,
+				1D6058900D05DD3D006BFB54 /* DTFoundationApp */,
+				241E2A0910F6A0F50076D698 /* DTFoundation */,
 			);
 		};
 /* End PBXProject section */
 				24083D2810CF9922009B758E /* NSNumber+DTMaths.m in Sources */,
 				24083D2910CF9922009B758E /* NSSet+DTExtras.m in Sources */,
 				24083D2A10CF9922009B758E /* NSString+DTPrefixString.m in Sources */,
+				24ECCBE110DC028100AB1388 /* NSDate+DTHTTPDateStrings.m in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		241E2A0710F6A0F50076D698 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				241E2A0E10F6A10F0076D698 /* DTOrderedDictionary.m in Sources */,
+				241E2A1010F6A1100076D698 /* DTQueue.m in Sources */,
+				241E2A1210F6A1110076D698 /* DTSortedArray.m in Sources */,
+				241E2A1410F6A1120076D698 /* DTStack.m in Sources */,
+				241E2A1610F6A1190076D698 /* DTTraversableDictionary.m in Sources */,
+				241E2A1810F6A11A0076D698 /* NSArray+DTExtras.m in Sources */,
+				241E2A1A10F6A11B0076D698 /* NSDate+DTComponentExtension.m in Sources */,
+				241E2A1C10F6A11C0076D698 /* NSNumber+DTMaths.m in Sources */,
+				241E2A1E10F6A11D0076D698 /* NSSet+DTExtras.m in Sources */,
+				241E2A2010F6A11E0076D698 /* NSString+DTPrefixString.m in Sources */,
+				241E2A2210F6A11F0076D698 /* NSDate+DTHTTPDateStrings.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 			};
 			name = Release;
 		};
+		241E2A0B10F6A0F50076D698 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				PREBINDING = NO;
+				PRODUCT_NAME = DTFoundation;
+			};
+			name = Debug;
+		};
+		241E2A0C10F6A0F50076D698 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				PREBINDING = NO;
+				PRODUCT_NAME = DTFoundation;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
 		C01FCF4F08A954540054247B /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
 /* End XCBuildConfiguration section */
 
 /* Begin XCConfigurationList section */
-		1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "DTFoundation" */ = {
+		1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "DTFoundationApp" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (
 				1D6058940D05DD3E006BFB54 /* Debug */,
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;
 		};
+		241E2A3610F6A1430076D698 /* Build configuration list for PBXNativeTarget "DTFoundation" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				241E2A0B10F6A0F50076D698 /* Debug */,
+				241E2A0C10F6A0F50076D698 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
 		C01FCF4E08A954540054247B /* Build configuration list for PBXProject "DTFoundation" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (

DTFoundation/DTDataStore.h

+//
+//  DTDataStore.h
+//  DTFoundation
+//
+//  Created by Daniel Tull on 18.12.2009.
+//  Copyright 2009 Daniel Tull. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+@interface DTDataStore : NSObject {
+	NSString *name;
+}
+
+- (id)initWithName:(NSString *)storeName;
+- (void)setData:(NSData *)data forKey:(NSString *)key;
+- (NSData *)dataForKey:(NSString *)key;
+
+@end

DTFoundation/DTDataStore.m

+//
+//  DTDataStore.m
+//  DTFoundation
+//
+//  Created by Daniel Tull on 18.12.2009.
+//  Copyright 2009 Daniel Tull. All rights reserved.
+//
+
+#import "DTDataStore.h"
+
+@interface DTDataStore ()
+- (NSDictionary *)cacheDictionary;
+- (NSString *)cacheDictionaryPath;
+- (NSString *)pathForKey:(NSString *)key;
+- (NSString *)pathForFilename:(NSString *)filename;
+- (NSString *)filenameForKey:(NSString *)key;
+- (NSString *)baseDirectoryPath;
+@end
+
+NSString *const DTDataStoreFilePrefix = @"DTDataStore";
+NSString *const DTDataStoreDictionaryPath = @"DTDataStoreDictionary";
+
+@implementation DTDataStore
+
+- (id)initWithName:(NSString *)storeName {
+	
+	if (!(self = [super init])) return nil;
+	
+	name = [storeName copy];
+	
+	return self;	
+}
+
+- (void)dealloc {
+	[name release];
+	[super dealloc];
+}
+
+- (void)deleteDataForKey:(NSString *)key {
+		
+	NSString *path = [self pathForKey:key];
+	
+	if (!path) return;
+	
+	NSMutableDictionary *dict = [[self cacheDictionary] mutableCopy];
+	
+	[dict removeObjectForKey:key];
+	
+	NSError *error = nil;
+	if ([[NSFileManager defaultManager] removeItemAtPath:path error:&error])
+		[dict writeToFile:[self cacheDictionaryPath] atomically:NO];
+	
+	[dict release];
+}
+
+- (void)setData:(NSData *)data forKey:(NSString *)key {
+	
+	NSString *filename = [self filenameForKey:key];
+	
+	if (!filename) {
+		NSString *uniqueString = [[NSProcessInfo processInfo] globallyUniqueString];
+		filename = [NSString stringWithFormat:@"%@-%@", DTDataStoreFilePrefix, uniqueString];
+		
+		NSMutableDictionary *dict = [[self cacheDictionary] mutableCopy];
+		[dict setObject:filename forKey:key];
+		[dict writeToFile:[self cacheDictionaryPath] atomically:NO];
+		[dict release];
+	}
+	
+	[data writeToFile:[self pathForFilename:filename] atomically:NO];
+}
+
+- (NSData *)dataForKey:(NSString *)key {
+	return [NSData dataWithContentsOfFile:[self filenameForKey:key]];
+}
+
+#pragma mark -
+
+- (NSDictionary *)cacheDictionary {
+	
+	NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:[self cacheDictionaryPath]];
+	if (!dict) dict = [NSDictionary dictionary];
+	
+	return dict;
+}
+
+- (NSString *)cacheDictionaryPath {	
+	return [[self baseDirectoryPath] stringByAppendingPathComponent:DTDataStoreDictionaryPath];
+}
+
+- (NSString *)pathForFilename:(NSString *)filename {
+	return [[self baseDirectoryPath] stringByAppendingPathComponent:filename];
+}
+
+- (NSString *)pathForKey:(NSString *)key {
+	return [self pathForFilename:[self filenameForKey:key]];
+}
+
+- (NSString *)filenameForKey:(NSString *)key {
+	return [[self cacheDictionary] objectForKey:key];
+}
+
+- (NSString *)baseDirectoryPath {
+	
+	NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:name];
+	
+	NSFileManager *fileManager = [NSFileManager defaultManager];
+	
+	if (![fileManager fileExistsAtPath:path])
+		[fileManager createDirectoryAtPath:path attributes:nil];
+	
+	return path;
+}
+
+@end

DTFoundation/DTFoundation.h

+//
+//  DTFoundation.h
+//  DTDocumentationMaker
+//
+//  Created by Daniel Tull on 15.12.2009.
+//  Copyright 2009 Daniel Tull. All rights reserved.
+//
+
+#import "DTOrderedDictionary.h"
+#import "DTQueue.h"
+#import "DTSortedArray.h"
+#import "DTStack.h"
+#import "DTTraversableDictionary.h"
+#import "NSArray+DTExtras.h"
+#import "NSDate+DTComponentExtension.h"
+#import "NSNumber+DTMaths.h"
+#import "NSSet+DTExtras.h"
+#import "NSString+DTPrefixString.h"

DTFoundation/DTOrderedDictionary.m

 	
 	sortSelector = aSelector;
 	sortedKeys = [[NSArray alloc] init];
+	
 	return self;
 }
 
 #pragma mark NSMutableDictionary specific overrides
 
 - (void)setObject:(id)anObject forKey:(id)aKey {
-	if (![[superDictionary allKeys] containsObject:aKey])
-		self.sortedKeys = [[sortedKeys arrayByAddingObject:aKey] sortedArrayUsingSelector:sortSelector];
+	if (![self.sortedKeys containsObject:aKey])
+		self.sortedKeys = [sortedKeys arrayByAddingObject:aKey];//[[sortedKeys arrayByAddingObject:aKey] sortedArrayUsingSelector:sortSelector];
 	
 	[superDictionary setObject:anObject forKey:aKey];
 }
 - (void)removeObjectForKey:(id)aKey {
 	NSMutableArray *newArray = [self.sortedKeys mutableCopy];
 	[newArray removeObject:aKey];
-	self.sortedKeys = [newArray sortedArrayUsingSelector:sortSelector];
+	self.sortedKeys = newArray;//[newArray sortedArrayUsingSelector:sortSelector];
 	[newArray release];
 	
 	[superDictionary removeObjectForKey:aKey];
 	return self.sortedKeys;
 }
 
+- (NSString *)description {
+	return [superDictionary description];
+}
+
 @end

DTFoundation/DTQueue.h

 //
 //  DTQueue.h
-//  DTKit
+//  DTFoundation
 //
 //  Created by Daniel Tull on 05.04.2009.
 //  Copyright 2009 Daniel Tull. All rights reserved.
 
 #import <Foundation/Foundation.h>
 
-
+/** This represents a queue (first in, first out) data structure in computer science. It has the
+ push and pop operations usually found in stacks, plus a few other methods
+ to make it more useful.
+ */
 @interface DTQueue : NSObject {
 	NSMutableArray *queue;
 }
 
+/** @name Standard queue operations
+ @{
+ */
+
+/** @brief The number of items in the queue.
+ 
+ @return The number of items in the queue.
+ */
 - (NSUInteger)count;
+
+/** @brief Add an object to the end of the queue.
+ 
+ @param object The object to add.
+ */
+- (void)enqueue:(id)object;
 - (void)push:(id)object;
+
+/** @brief Remove the object at the front of the queue and return it.
+ 
+ @return The object at the front of the queue.
+ */
+- (id)dequeue;
 - (id)pop;
 
+/** @brief Return the object at the front of the queue without removing it from the queue.
+ 
+ @return The object at the front of the queue.
+ */
+- (id)front;
+
+/**
+ @}
+ */
+
 @end

DTFoundation/DTQueue.m

 //
 //  DTQueue.m
-//  DTKit
+//  DTFoundation
 //
 //  Created by Daniel Tull on 05.04.2009.
 //  Copyright 2009 Daniel Tull. All rights reserved.
 	return [queue count];
 }
 
-- (void)push:(id)object {
+- (void)enqueue:(id)object {
 	[queue addObject:object];
 }
 
-- (id)pop {
+- (void)push:(id)object {
+	[self enqueue:object];
+}
+
+- (id)dequeue {
 	id object = [[queue objectAtIndex:0] retain];
 	[queue removeObjectAtIndex:0];
 	return [object autorelease];
 }
 
+- (id)pop {
+	return [self dequeue];
+}
+
+- (id)front {
+	return [[[queue objectAtIndex:0] retain] autorelease];
+}
+
 @end

DTFoundation/DTStack.h

 //
 //  DTStack.h
-//  DTKit
+//  DTFoundation
 //
 //  Created by Daniel Tull on 05.04.2009.
 //  Copyright 2009 Daniel Tull. All rights reserved.
 
 #import <Foundation/Foundation.h>
 
-
+/** This represents a stack (last in, first out) data structure in computer science. It has the
+ push and pop operations usually found in stacks, plus a few other methods
+ to make it more useful.
+ */
 @interface DTStack : NSObject {
-	NSMutableArray *queue;
+	NSMutableArray *stack;
 }
 
+/** @name Standard stack operations
+ @{
+ */
+
+/** @brief The number of items on the stack.
+ 
+ @return The number of items on the stack.
+ */
 - (NSUInteger)count;
+
+/** @brief Pushes the given object onto the top of the stack.
+ 
+ @param object The object to be pushed onto the stack.
+ */
 - (void)push:(id)object;
+
+/** @brief Removes the top object from the stack.
+ 
+ @return The object that has just been popped off the top of the stack.
+ */
 - (id)pop;
 
-- (NSArray *)allObjects;
-- (NSArray *)popToObject:(id)object;
-- (NSArray *)popToRootObject;
+/** @brief Returns the top object without popping it from the stack.
+ 
+ @return The top object on the stack.
+ */
+- (id)top;
+
+
+/**
+ @}
+ */
+
+
 - (id)topObject;
 
+/** @name Extra functionality
+ @{
+ */
+
+
+/** @brief Returns an NSArray of all the objects in the stack.
+ 
+ @return An array of all the objects in the stack.
+ */
+- (NSArray *)allObjects;
+
+/** @brief Pops the stack until it reaches the given object.
+ 
+ @param object The object to pop to in the stack.
+ @return An array of all objects that have been removed from the stack.
+ */
+- (NSArray *)popToObject:(id)object;
+
+/** @brief Pops the stack until it has only one item left.
+ 
+ @return An array of all objects that have been removed from the stack.
+ */
+- (NSArray *)popToRootObject;
+
+/**
+ @}
+ */
+
 @end

DTFoundation/DTStack.m

 //
 //  DTStack.m
-//  DTKit
+//  DTFoundation
 //
 //  Created by Daniel Tull on 05.04.2009.
 //  Copyright 2009 Daniel Tull. All rights reserved.
 
 #import "DTStack.h"
 
-
 @implementation DTStack
 
 - (id)init {
 	
 	if (!(self = [super init])) return nil;
 	
-	queue = [[NSMutableArray alloc] init];
+	stack = [[NSMutableArray alloc] init];
 	
 	return self;
 }
 
 - (void)dealloc {
-	[queue release];
+	[stack release];
 	[super dealloc];
 }
 
 - (NSUInteger)count {
-	return [queue count];
+	return [stack count];
 }
 
 - (void)push:(id)object {
-	[queue addObject:object];
+	[stack addObject:object];
 }
 
 - (id)pop {
-	id object = [[queue lastObject] retain];
-	[queue removeLastObject];
+	id object = [[stack lastObject] retain];
+	[stack removeLastObject];
 	return [object autorelease];
 }
 
+- (id)topObject {
+	return [self top];
+}
+
+- (id)top {
+	return [[[stack lastObject] retain] autorelease];
+}
+
 - (NSArray *)allObjects {
-	return [[queue retain] autorelease];
+	return [[stack retain] autorelease];
 }
 
 - (NSArray *)popToObject:(id)object {
 }
 
 - (NSArray *)popToRootObject {
-	return [self popToObject:[queue objectAtIndex:0]];
+	return [self popToObject:[stack objectAtIndex:0]];
 }
 
-- (id)topObject {
-	return [[[queue lastObject] retain] autorelease];
-}
+
 
 @end

DTFoundation/NSArray+DTExtras.h

 
 
 @interface NSArray (DTExtras)
+/** @brief Returns whether or not the receiving array is empty.
+ 
+ @return A boolean indicating whether or not the receiving array is empty.
+ */
 - (BOOL)isEmpty;
+
+- (id)firstObject;
 @end

DTFoundation/NSArray+DTExtras.m

 	return ([self count] == 0);
 }
 
+- (id)firstObject {
+	if ([self isEmpty])
+		return nil;
+	
+	return [self objectAtIndex:0];
+}
+
 @end

DTFoundation/NSDate+DTComponentExtension.h

 
 #import <Foundation/Foundation.h>
 
+/** An extension to NSDate to have easier access to the individual components
+ based on the gregorian calendar.
+ */
+@interface NSDate (DTComponentExtension)
 
-@interface NSDate (DTComponentExtension)
+/** @name Getting Gregorian date components
+ @{
+ */
+
 - (NSDateComponents *)gregorianCalendarComponents;
 
+/**
+ @}
+ */
+
+/** @name Getting individual components
+ @{
+ */
+
+/** @brief The second component of the receiver.
+ 
+ @return The second component of the receiver as an integer.
+ */
 - (NSInteger)second;
+
+/** @brief The minute component of the receiver.
+ 
+ @return The minute component of the receiver as an integer.
+ */
 - (NSInteger)minute;
+
+/** @brief The hour component of the receiver.
+ 
+ @return The hour component of the receiver as an integer.
+ */
 - (NSInteger)hour;
+
+/** @brief The day component of the receiver.
+ 
+ @return The day component of the receiver as an integer.
+ */
 - (NSInteger)day;
+
+/** @brief The weekday component of the receiver.
+ 
+ @return The weekday component of the receiver as an integer.
+ */
 - (NSInteger)weekday;
+
+/** @brief The weekdayOrdinal component of the receiver.
+ 
+ @return The weekdayOrdinal component of the receiver as an integer.
+ */
 - (NSInteger)weekdayOrdinal;
+
+/** @brief The week component of the receiver.
+ 
+ @return The week component of the receiver as an integer.
+ */
 - (NSInteger)week;
+
+/** @brief The month component of the receiver.
+ 
+ @return The month component of the receiver as an integer.
+ */
 - (NSInteger)month;
+
+/** @brief The year component of the receiver.
+ 
+ @return The year component of the receiver as an integer.
+ */
 - (NSInteger)year;
+
+/** @brief The era component of the receiver.
+ 
+ @return The era component of the receiver as an integer.
+ */
 - (NSInteger)era;
 
+/**
+ @}
+ */
+
+/** @name Creating a date
+ @{
+ */
+
+/** @brief Creates a data with a month and year.
+ 
+ @param month The month of the date.
+ @param year The year of the date.
+ 
+ @return The newly created date.
+ */
 + (NSDate *)dateWithMonth:(NSInteger)month year:(NSInteger)year;
-+ (NSDate *)dateWithYear:(NSInteger)year month:(NSInteger)year  day:(NSInteger)day hour:(NSInteger)hour;
+
+/** @brief Creates a data with a year.
+ 
+ @param year The year of the date.
+ 
+ @return The newly created date.
+ */
++ (NSDate *)dateWithYear:(NSInteger)year;
+
+/** @brief Creates a data with a year and month.
+ 
+ @param year The year of the date.
+ @param month The month of the date.
+ 
+ @return The newly created date.
+ */
++ (NSDate *)dateWithYear:(NSInteger)year month:(NSInteger)month;
+
+/** @brief Creates a data with a year, month and day.
+ 
+ @param year The year of the date.
+ @param month The month of the date.
+ @param day The day of the date.
+ 
+ @return The newly created date.
+ */
++ (NSDate *)dateWithYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day;
+
+/** @brief Creates a data with a year, month, day and hour.
+ 
+ @param year The year of the date.
+ @param month The month of the date.
+ @param day The day of the date.
+ @param hour The hour of the date.
+ 
+ @return The newly created date.
+ */
++ (NSDate *)dateWithYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day hour:(NSInteger)hour;
+
+/** @brief Creates a data with a year, month, day, hour and minute.
+ 
+ @param year The year of the date.
+ @param month The month of the date.
+ @param day The day of the date.
+ @param hour The hour of the date.
+ @param minute The minute of the date.
+ 
+ @return The newly created date.
+ */
 + (NSDate *)dateWithYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day hour:(NSInteger)hour minute:(NSInteger)minute;
+
+/** @brief Creates a data with a year, month, day, hour, minute and second.
+ 
+ @param year The year of the date.
+ @param month The month of the date.
+ @param day The day of the date.
+ @param hour The hour of the date.
+ @param minute The minute of the date.
+ @param second The second of the date.
+ 
+ @return The newly created date.
+ */
++ (NSDate *)dateWithYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day hour:(NSInteger)hour minute:(NSInteger)minute second:(NSInteger)second;
+
+/**
+ @}
+ */
+
 @end

DTFoundation/NSDate+DTComponentExtension.m

 }
 
 + (NSDate *)dateWithMonth:(NSInteger)month year:(NSInteger)year {
+	return [self dateWithYear:year month:month];
+}
+
++ (NSDate *)dateWithYear:(NSInteger)year {
 	NSDateComponents *comps = [[NSDateComponents alloc] init];
+	[comps setYear:year];
+	NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
+	NSDate *date = [gregorian dateFromComponents:comps];
+	[comps release];
+	[gregorian release];
+	return date;
+}
+
++ (NSDate *)dateWithYear:(NSInteger)year month:(NSInteger)month {
+	NSDateComponents *comps = [[NSDateComponents alloc] init];
+	[comps setYear:year];
 	[comps setMonth:month];
+	NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
+	NSDate *date = [gregorian dateFromComponents:comps];
+	[comps release];
+	[gregorian release];
+	return date;
+}
+
++ (NSDate *)dateWithYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day {
+	NSDateComponents *comps = [[NSDateComponents alloc] init];
 	[comps setYear:year];
+	[comps setMonth:month];
+	[comps setDay:day];
 	NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
 	NSDate *date = [gregorian dateFromComponents:comps];
 	[comps release];
 	return date;
 }
 
++ (NSDate *)dateWithYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day hour:(NSInteger)hour minute:(NSInteger)minute second:(NSInteger)second {
+	NSDateComponents *comps = [[NSDateComponents alloc] init];
+	[comps setYear:year];
+	[comps setMonth:month];
+	[comps setDay:day];
+	[comps setHour:hour];
+	[comps setMinute:minute];
+	[comps setSecond:second];
+	NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
+	NSDate *date = [gregorian dateFromComponents:comps];
+	[comps release];
+	[gregorian release];
+	return date;
+}
+
 @end

DTFoundation/NSDate+DTHTTPDateStrings.h

+//
+//  NSDate+DTHTTPDateStrings.h
+//  DTFoundation
+//
+//  Created by Daniel Tull on 18.12.2009.
+//  Copyright 2009 Daniel Tull. All rights reserved.
+//
+//	http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
+//
+
+#import <Foundation/Foundation.h>
+@interface NSDate (DTHTTPDateStrings)
+
++ (NSDate *)dateFromHTTPFormattedDateString:(NSString *)string;
++ (NSDate *)dateFromRFC1123String:(NSString *)string;
++ (NSDate *)dateFromRFC1036String:(NSString *)string;
++ (NSDate *)dateFromANSICString:(NSString *)string;
+
+
+- (NSString *)HTTPFormattedDateString;
+- (NSString *)RFC1123String;
+- (NSString *)RFC1036String;
+- (NSString *)ANSICString;
+
+@end

DTFoundation/NSDate+DTHTTPDateStrings.m

+//
+//  NSDate+DTHTTPDateStrings.m
+//  DTFoundation
+//
+//  Created by Daniel Tull on 18.12.2009.
+//  Copyright 2009 Daniel Tull. All rights reserved.
+//
+
+#import "NSDate+DTHTTPDateStrings.h"
+
+
+
+/*
+ Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123
+ Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
+ Sun Nov  6 08:49:37 1994       ; ANSI C's asctime() format
+ */
+
+
+@implementation NSDate (DTHTTPDateStrings)
+
++ (NSDate *)dateFromHTTPFormattedDateString:(NSString *)string {
+	
+    if (!string) return nil;
+	
+	NSDate *returnDate = [self dateFromRFC1123String:string];
+	if (returnDate) return returnDate;
+	
+	returnDate = [self dateFromRFC1036String:string];
+	if (returnDate) return returnDate;
+	
+	return [self dateFromANSICString:string];
+}
+
++ (NSDate *)dateFromRFC1123String:(NSString *)string {
+	NSDateFormatter *df = [[NSDateFormatter alloc] init];
+	df.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease];
+	df.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
+	df.dateFormat = @"EEE',' dd MMM yyyy HH':'mm':'ss z";
+    NSDate *returnDate = [df dateFromString:string];
+	[df release];
+	return returnDate;	
+}
+
++ (NSDate *)dateFromRFC1036String:(NSString *)string {
+	NSDateFormatter *df = [[NSDateFormatter alloc] init];
+	df.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease];
+	df.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
+	df.dateFormat = @"EEEE',' dd'-'MMM'-'yy HH':'mm':'ss z";
+    NSDate *returnDate = [df dateFromString:string];
+	[df release];
+	return returnDate;	
+}
+
++ (NSDate *)dateFromANSICString:(NSString *)string {
+	NSDateFormatter *df = [[NSDateFormatter alloc] init];
+	df.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease];
+	df.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
+	df.dateFormat = @"EEE MMM d HH':'mm':'ss yyyy";
+    NSDate *returnDate = [df dateFromString:string];
+	[df release];
+	return returnDate;
+}
+
+- (NSString *)HTTPFormattedDateString {
+	return [self RFC1123String];
+}
+
+- (NSString *)RFC1123String {
+	NSDateFormatter *df = [[NSDateFormatter alloc] init];
+	df.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease];
+	df.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
+	df.dateFormat = @"EEE',' dd MMM yyyy HH':'mm':'ss 'GMT'";
+    return [df stringFromDate:self];
+}
+
+- (NSString *)RFC1036String {
+	NSDateFormatter *df = [[NSDateFormatter alloc] init];
+	df.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease];
+	df.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
+	df.dateFormat = @"EEEE',' dd'-'MMM'-'yy HH':'mm':'ss z";
+    return [df stringFromDate:self];
+}
+
+- (NSString *)ANSICString {
+	NSDateFormatter *df = [[NSDateFormatter alloc] init];
+	df.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease];
+	df.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
+	df.dateFormat = @"EEE MMM d HH':'mm':'ss yyyy";
+    return [df stringFromDate:self];
+}
+
+@end

DTFoundation/NSSet+DTExtras.h

 #import <Foundation/Foundation.h>
 
 @interface NSSet (DTExtras)
+/** @brief Returns whether or not the receiving set is empty.
+ 
+ @return A boolean indicating whether or not the receiving set is empty.
+ */
 - (BOOL)isEmpty;
 @end

DTFoundation/NSString+DTPrefixString.h

 #import <Foundation/Foundation.h>
 
 @interface NSString (DTPrefixString)
+/** @brief prefixes the receiver with the given string to make it a certain length.
+ 
+ 
+ 
+ @param insertString The string to insert.
+ @param desiredStringLength The deisred length of the resulting string. 
+ @return The prefixed string of desired length.
+ */
 - (NSString *)stringByPrefixingWithString:(NSString *)insertString resultingInLength:(NSInteger)desiredStringLength;
 @end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.