Permalink
Browse files

Initial commit

  • Loading branch information...
davedelong committed Nov 27, 2010
1 parent f36a1d5 commit a8c828da2276f1fbd727d98f0ea04c2e6b838345
Showing with 2,915 additions and 0 deletions.
  1. +79 −0 DDUnitConverter.1
  2. +384 −0 DDUnitConverter.xcodeproj/project.pbxproj
  3. +32 −0 DDUnitConverter/DDAccelerationUnitConverter.h
  4. +44 −0 DDUnitConverter/DDAccelerationUnitConverter.m
  5. +38 −0 DDUnitConverter/DDAngleUnitConverter.h
  6. +55 −0 DDUnitConverter/DDAngleUnitConverter.m
  7. +41 −0 DDUnitConverter/DDAreaUnitConverter.h
  8. +59 −0 DDUnitConverter/DDAreaUnitConverter.m
  9. +70 −0 DDUnitConverter/DDByteUnitConverter.h
  10. +115 −0 DDUnitConverter/DDByteUnitConverter.m
  11. +81 −0 DDUnitConverter/DDCurrencyUnitConverter.h
  12. +106 −0 DDUnitConverter/DDCurrencyUnitConverter.m
  13. +29 −0 DDUnitConverter/DDCurrentUnitConverter.h
  14. +37 −0 DDUnitConverter/DDCurrentUnitConverter.m
  15. +37 −0 DDUnitConverter/DDEnergyUnitConverter.h
  16. +54 −0 DDUnitConverter/DDEnergyUnitConverter.m
  17. +32 −0 DDUnitConverter/DDForceUnitConverter.h
  18. +44 −0 DDUnitConverter/DDForceUnitConverter.m
  19. +33 −0 DDUnitConverter/DDIlluminationUnitConverter.h
  20. +42 −0 DDUnitConverter/DDIlluminationUnitConverter.m
  21. +31 −0 DDUnitConverter/DDInductanceUnitConverter.h
  22. +41 −0 DDUnitConverter/DDInductanceUnitConverter.m
  23. +43 −0 DDUnitConverter/DDLengthUnitConverter.h
  24. +65 −0 DDUnitConverter/DDLengthUnitConverter.m
  25. +47 −0 DDUnitConverter/DDMagnitudeUnitConverter.h
  26. +73 −0 DDUnitConverter/DDMagnitudeUnitConverter.m
  27. +47 −0 DDUnitConverter/DDMassUnitConverter.h
  28. +73 −0 DDUnitConverter/DDMassUnitConverter.m
  29. +32 −0 DDUnitConverter/DDPowerUnitConverter.h
  30. +43 −0 DDUnitConverter/DDPowerUnitConverter.m
  31. +36 −0 DDUnitConverter/DDPressureUnitConverter.h
  32. +49 −0 DDUnitConverter/DDPressureUnitConverter.m
  33. +28 −0 DDUnitConverter/DDRadiationUnitConverter.h
  34. +35 −0 DDUnitConverter/DDRadiationUnitConverter.m
  35. +31 −0 DDUnitConverter/DDTemperatureUnitConverter.h
  36. +72 −0 DDUnitConverter/DDTemperatureUnitConverter.m
  37. +51 −0 DDUnitConverter/DDTimeUnitConverter.h
  38. +79 −0 DDUnitConverter/DDTimeUnitConverter.m
  39. +36 −0 DDUnitConverter/DDTorqueUnitConverter.h
  40. +52 −0 DDUnitConverter/DDTorqueUnitConverter.m
  41. +32 −0 DDUnitConverter/DDUnitConversion.h
  42. +19 −0 DDUnitConverter/DDUnitConverter.h
  43. +33 −0 DDUnitConverter/DDUnitConverter.m
  44. +47 −0 DDUnitConverter/DDVelocityUnitConverter.h
  45. +74 −0 DDUnitConverter/DDVelocityUnitConverter.m
  46. +69 −0 DDUnitConverter/DDVolumeUnitConverter.h
  47. +117 −0 DDUnitConverter/DDVolumeUnitConverter.m
  48. +21 −0 DDUnitConverter/NSDecimalNumber+DDConstants.h
  49. +38 −0 DDUnitConverter/NSDecimalNumber+DDConstants.m
  50. +7 −0 DDUnitConverter_Prefix.pch
  51. +67 −0 README.markdown
  52. +15 −0 main.m
View
@@ -0,0 +1,79 @@
+.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
+.\"See Also:
+.\"man mdoc.samples for a complete listing of options
+.\"man mdoc for the short list of editing options
+.\"/usr/share/misc/mdoc.template
+.Dd 11/25/10 \" DATE
+.Dt DDUnitConverter 1 \" Program name and manual section number
+.Os Darwin
+.Sh NAME \" Section Header - required - don't modify
+.Nm DDUnitConverter,
+.\" The following lines are read in generating the apropos(man -k) database. Use only key
+.\" words here as the database is built based on the words here and in the .ND line.
+.Nm Other_name_for_same_program(),
+.Nm Yet another name for the same program.
+.\" Use .Nm macro to designate other names for the documented program.
+.Nd This line parsed for whatis database.
+.Sh SYNOPSIS \" Section Header - required - don't modify
+.Nm
+.Op Fl abcd \" [-abcd]
+.Op Fl a Ar path \" [-a path]
+.Op Ar file \" [file]
+.Op Ar \" [file ...]
+.Ar arg0 \" Underlined argument - use .Ar anywhere to underline
+arg2 ... \" Arguments
+.Sh DESCRIPTION \" Section Header - required - don't modify
+Use the .Nm macro to refer to your program throughout the man page like such:
+.Nm
+Underlining is accomplished with the .Ar macro like this:
+.Ar underlined text .
+.Pp \" Inserts a space
+A list of items with descriptions:
+.Bl -tag -width -indent \" Begins a tagged list
+.It item a \" Each item preceded by .It macro
+Description of item a
+.It item b
+Description of item b
+.El \" Ends the list
+.Pp
+A list of flags and their descriptions:
+.Bl -tag -width -indent \" Differs from above in tag removed
+.It Fl a \"-a flag as a list item
+Description of -a flag
+.It Fl b
+Description of -b flag
+.El \" Ends the list
+.Pp
+.\" .Sh ENVIRONMENT \" May not be needed
+.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
+.\" .It Ev ENV_VAR_1
+.\" Description of ENV_VAR_1
+.\" .It Ev ENV_VAR_2
+.\" Description of ENV_VAR_2
+.\" .El
+.Sh FILES \" File used or created by the topic of the man page
+.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
+.It Pa /usr/share/file_name
+FILE_1 description
+.It Pa /Users/joeuser/Library/really_long_file_name
+FILE_2 description
+.El \" Ends the list
+.\" .Sh DIAGNOSTICS \" May not be needed
+.\" .Bl -diag
+.\" .It Diagnostic Tag
+.\" Diagnostic informtion here.
+.\" .It Diagnostic Tag
+.\" Diagnostic informtion here.
+.\" .El
+.Sh SEE ALSO
+.\" List links in ascending order by section, alphabetically within a section.
+.\" Please do not reference files that do not exist without filing a bug report
+.Xr a 1 ,
+.Xr b 1 ,
+.Xr c 1 ,
+.Xr a 2 ,
+.Xr b 2 ,
+.Xr a 3 ,
+.Xr b 3
+.\" .Sh BUGS \" Document known, unremedied bugs
+.\" .Sh HISTORY \" Document history if command behaves in a unique manner

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,32 @@
+//
+// DDAccelerationUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/25/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDAccelerationUnitConverter)
+
++ (id) accelerationUnitConverter;
+
+@end
+
+enum {
+ DDAccelerationUnitFeetPerSecondsSquared = 0,
+ DDAccelerationUnitGalileos,
+ DDAccelerationUnitGForces,
+ DDAccelerationUnitKilometersPerSecondsSquared,
+ DDAccelerationUnitMetersPerSecondsSquared,
+ DDAccelerationUnitMilesPerSecondsSquared
+};
+typedef NSUInteger DDAccelerationUnit;
+
+@interface DDAccelerationUnitConverter : DDUnitConverter {
+
+}
+
+@end
@@ -0,0 +1,44 @@
+//
+// DDAccelerationUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/25/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDAccelerationUnitConverter.h"
+#import "NSDecimalNumber+DDConstants.h"
+
+@implementation DDUnitConverter (DDAccelerationUnitConverter)
+
++ (id) accelerationUnitConverter {
+ return [[[DDAccelerationUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDAccelerationUnitConverter
+
++ (NSDecimalNumber *) multiplierForUnit:(DDAccelerationUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ switch (unit) {
+ case DDAccelerationUnitFeetPerSecondsSquared:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:3048 exponent:-4 isNegative:NO]; break;
+ case DDAccelerationUnitGalileos:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:2 isNegative:NO]; break;
+ case DDAccelerationUnitGForces:
+ multiplier = [NSDecimalNumber gConstant_dd]; break;
+ case DDAccelerationUnitKilometersPerSecondsSquared:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:3 isNegative:NO]; break;
+ case DDAccelerationUnitMetersPerSecondsSquared:
+ break;
+ case DDAccelerationUnitMilesPerSecondsSquared:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1609344 exponent:-3 isNegative:NO]; break;
+ default:
+ break;
+ }
+ return multiplier;
+}
+
+@end
@@ -0,0 +1,38 @@
+//
+// DDAngleUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/25/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDAngleUnitConverter)
+
++ (id) angleUnitConverter;
+
+@end
+
+enum {
+ DDAngleUnitCircles = 0,
+ DDAngleUnitDegrees,
+ DDAngleUnitGons,
+ DDAngleUnitGrades,
+ DDAngleUnitMinutes,
+ DDAngleUnitMils,
+ DDAngleUnitNauticalRhumbs,
+ DDAngleUnitQuadrants,
+ DDAngleUnitRadians,
+ DDAngleUnitRevolutions,
+ DDAngleUnitSeconds,
+ DDAngleUnitTurns
+};
+typedef NSUInteger DDAngleUnit;
+
+@interface DDAngleUnitConverter : DDUnitConverter {
+
+}
+
+@end
@@ -0,0 +1,55 @@
+//
+// DDAngleUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/25/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDAngleUnitConverter.h"
+#import "NSDecimalNumber+DDConstants.h"
+
+@implementation DDUnitConverter (DDAngleUnitConverter)
+
++ (id) angleUnitConverter {
+ return [[[DDAngleUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDAngleUnitConverter
+
++ (NSDecimalNumber *) multiplierForUnit:(DDUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ switch (unit) {
+ case DDAngleUnitCircles:
+ case DDAngleUnitRevolutions:
+ case DDAngleUnitTurns:
+ //circles, revolutions, and turns are all a multipler of 360
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:360 exponent:0 isNegative:NO]; break;
+ case DDAngleUnitDegrees:
+ break;
+ case DDAngleUnitGons:
+ case DDAngleUnitGrades:
+ //gons and grades are both a multiplier of 0.9
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:9 exponent:-1 isNegative:NO]; break;
+ case DDAngleUnitMinutes:
+ multiplier = [[NSDecimalNumber one] decimalNumberByDividingBy:[NSDecimalNumber decimalNumberWithMantissa:60 exponent:0 isNegative:NO]]; break;
+ case DDAngleUnitMils:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:5625 exponent:-5 isNegative:NO]; break;
+ case DDAngleUnitNauticalRhumbs:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1125 exponent:-2 isNegative:NO]; break;
+ case DDAngleUnitQuadrants:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:90 exponent:0 isNegative:NO]; break;
+ case DDAngleUnitRadians:
+ multiplier = [[NSDecimalNumber decimalNumberWithMantissa:180 exponent:0 isNegative:NO] decimalNumberByDividingBy:[NSDecimalNumber piConstant_dd]]; break;
+ case DDAngleUnitSeconds:
+ multiplier = [[NSDecimalNumber one] decimalNumberByDividingBy:[NSDecimalNumber decimalNumberWithMantissa:3600 exponent:0 isNegative:NO]]; break;
+ default:
+ break;
+ }
+ return multiplier;
+}
+
+@end
@@ -0,0 +1,41 @@
+//
+// DDAreaUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/25/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDAreaUnitConverter)
+
++ (id) areaUnitConverter;
+
+@end
+
+enum {
+ DDAreaUnitAcres = 0,
+ DDAreaUnitBarns,
+ DDAreaUnitHectares,
+ DDAreaUnitRoods,
+ DDAreaUnitSquareCentimeters,
+ DDAreaUnitSquareDecimeters,
+ DDAreaUnitSquareFeet,
+ DDAreaUnitSquareInches,
+ DDAreaUnitSquareKilometers,
+ DDAreaUnitSquareMeters,
+ DDAreaUnitSquareMiles,
+ DDAreaUnitSquareMillimeters,
+ DDAreaUntiSquareRods,
+ DDAreaUnitSquareYards,
+};
+
+typedef NSUInteger DDAreaUnit;
+
+@interface DDAreaUnitConverter : DDUnitConverter {
+
+}
+
+@end
@@ -0,0 +1,59 @@
+//
+// DDAreaUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/25/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDAreaUnitConverter.h"
+
+@implementation DDUnitConverter (DDAreaUnitConverter)
+
++ (id) areaUnitConverter {
+ return [[[DDAreaUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDAreaUnitConverter
+
++ (NSDecimalNumber *) multiplierForUnit:(DDUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ switch (unit) {
+ case DDAreaUnitAcres:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:40468564224 exponent:-7 isNegative:NO]; break;
+ case DDAreaUnitBarns:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-28 isNegative:NO]; break;
+ case DDAreaUnitHectares:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:10000 exponent:0 isNegative:NO]; break;
+ case DDAreaUnitRoods:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:101171 exponent:-2 isNegative:NO]; break;
+ case DDAreaUnitSquareCentimeters:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-4 isNegative:NO]; break;
+ case DDAreaUnitSquareDecimeters:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-2 isNegative:NO]; break;
+ case DDAreaUnitSquareFeet:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:9290304 exponent:-8 isNegative:NO]; break;
+ case DDAreaUnitSquareInches:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:64516 exponent:-8 isNegative:NO]; break;
+ case DDAreaUnitSquareKilometers:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:6 isNegative:NO]; break;
+ case DDAreaUnitSquareMeters:
+ break;
+ case DDAreaUnitSquareMiles:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:258998811 exponent:-2 isNegative:NO]; break;
+ case DDAreaUnitSquareMillimeters:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-6 isNegative:NO]; break;
+ case DDAreaUntiSquareRods:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:25292953811512 exponent:-12 isNegative:NO]; break;
+ case DDAreaUnitSquareYards:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:83612736 exponent:-8 isNegative:NO]; break;
+ default:
+ break;
+ }
+ return multiplier;
+}
+
+@end
Oops, something went wrong.

0 comments on commit a8c828d

Please sign in to comment.