Skip to content
Browse files

Initial commit

  • Loading branch information...
1 parent f36a1d5 commit a8c828da2276f1fbd727d98f0ea04c2e6b838345 @davedelong committed Nov 26, 2010
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
79 DDUnitConverter.1
@@ -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
View
384 DDUnitConverter.xcodeproj/project.pbxproj
@@ -0,0 +1,384 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 45;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 55B5ABC7129F11F400FBF75C /* DDUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55B5ABC6129F11F400FBF75C /* DDUnitConverter.m */; };
+ 55B5ABCA129F162500FBF75C /* DDLengthUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55B5ABC9129F162500FBF75C /* DDLengthUnitConverter.m */; };
+ 55B5ABDB129F1C2400FBF75C /* DDAccelerationUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55B5ABDA129F1C2400FBF75C /* DDAccelerationUnitConverter.m */; };
+ 55B5ABF2129F6F7B00FBF75C /* DDAngleUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55B5ABF1129F6F7B00FBF75C /* DDAngleUnitConverter.m */; };
+ 55B5ABF5129F780E00FBF75C /* NSDecimalNumber+DDConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 55B5ABF4129F780E00FBF75C /* NSDecimalNumber+DDConstants.m */; };
+ 55B5ABF8129F875800FBF75C /* DDAreaUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55B5ABF7129F875800FBF75C /* DDAreaUnitConverter.m */; };
+ 55BBF06612A03828004DDAB0 /* DDCurrentUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF06512A03827004DDAB0 /* DDCurrentUnitConverter.m */; };
+ 55BBF06912A03955004DDAB0 /* DDByteUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF06812A03955004DDAB0 /* DDByteUnitConverter.m */; };
+ 55BBF07A12A04925004DDAB0 /* DDEnergyUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF07912A04925004DDAB0 /* DDEnergyUnitConverter.m */; };
+ 55BBF09612A04B4B004DDAB0 /* DDForceUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF09512A04B4B004DDAB0 /* DDForceUnitConverter.m */; };
+ 55BBF0A312A04C9E004DDAB0 /* DDIlluminationUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF0A212A04C9E004DDAB0 /* DDIlluminationUnitConverter.m */; };
+ 55BBF0A612A04F6B004DDAB0 /* DDInductanceUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF0A512A04F6B004DDAB0 /* DDInductanceUnitConverter.m */; };
+ 55BBF0A912A051F0004DDAB0 /* DDMagnitudeUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF0A812A051F0004DDAB0 /* DDMagnitudeUnitConverter.m */; };
+ 55BBF0AE12A054B1004DDAB0 /* DDMassUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF0AD12A054B1004DDAB0 /* DDMassUnitConverter.m */; };
+ 55BBF0B312A05CFE004DDAB0 /* DDPowerUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF0B212A05CFE004DDAB0 /* DDPowerUnitConverter.m */; };
+ 55BBF0B812A05EAA004DDAB0 /* DDPressureUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF0B712A05EAA004DDAB0 /* DDPressureUnitConverter.m */; };
+ 55BBF0CD12A06048004DDAB0 /* DDRadiationUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF0CC12A06048004DDAB0 /* DDRadiationUnitConverter.m */; };
+ 55BBF0D212A060E9004DDAB0 /* DDTemperatureUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF0D112A060E9004DDAB0 /* DDTemperatureUnitConverter.m */; };
+ 55BBF0D712A063A6004DDAB0 /* DDTimeUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF0D612A063A6004DDAB0 /* DDTimeUnitConverter.m */; };
+ 55BBF0DA12A07699004DDAB0 /* DDTorqueUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF0D912A07699004DDAB0 /* DDTorqueUnitConverter.m */; };
+ 55BBF0E112A08079004DDAB0 /* DDVelocityUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF0E012A08079004DDAB0 /* DDVelocityUnitConverter.m */; };
+ 55BBF0E612A08422004DDAB0 /* DDVolumeUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF0E512A08422004DDAB0 /* DDVolumeUnitConverter.m */; };
+ 55BBF0FC12A0C347004DDAB0 /* DDCurrencyUnitConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = 55BBF0FB12A0C347004DDAB0 /* DDCurrencyUnitConverter.m */; };
+ 8DD76F9A0486AA7600D96B5E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* main.m */; settings = {ATTRIBUTES = (); }; };
+ 8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; };
+ 8DD76F9F0486AA7600D96B5E /* DDUnitConverter.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6859EA3029092ED04C91782 /* DDUnitConverter.1 */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ 8DD76F9E0486AA7600D96B5E /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 8;
+ dstPath = /usr/share/man/man1/;
+ dstSubfolderSpec = 0;
+ files = (
+ 8DD76F9F0486AA7600D96B5E /* DDUnitConverter.1 in CopyFiles */,
+ );
+ runOnlyForDeploymentPostprocessing = 1;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+ 08FB7796FE84155DC02AAC07 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ 08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
+ 32A70AAB03705E1F00C91783 /* DDUnitConverter_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDUnitConverter_Prefix.pch; sourceTree = "<group>"; };
+ 55B5ABC5129F11F400FBF75C /* DDUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDUnitConverter.h; sourceTree = "<group>"; };
+ 55B5ABC6129F11F400FBF75C /* DDUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDUnitConverter.m; sourceTree = "<group>"; };
+ 55B5ABC8129F162500FBF75C /* DDLengthUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDLengthUnitConverter.h; sourceTree = "<group>"; };
+ 55B5ABC9129F162500FBF75C /* DDLengthUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDLengthUnitConverter.m; sourceTree = "<group>"; };
+ 55B5ABD9129F1C2400FBF75C /* DDAccelerationUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDAccelerationUnitConverter.h; sourceTree = "<group>"; };
+ 55B5ABDA129F1C2400FBF75C /* DDAccelerationUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDAccelerationUnitConverter.m; sourceTree = "<group>"; };
+ 55B5ABF0129F6F7B00FBF75C /* DDAngleUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDAngleUnitConverter.h; sourceTree = "<group>"; };
+ 55B5ABF1129F6F7B00FBF75C /* DDAngleUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDAngleUnitConverter.m; sourceTree = "<group>"; };
+ 55B5ABF3129F780E00FBF75C /* NSDecimalNumber+DDConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDecimalNumber+DDConstants.h"; sourceTree = "<group>"; };
+ 55B5ABF4129F780E00FBF75C /* NSDecimalNumber+DDConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDecimalNumber+DDConstants.m"; sourceTree = "<group>"; };
+ 55B5ABF6129F875800FBF75C /* DDAreaUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDAreaUnitConverter.h; sourceTree = "<group>"; };
+ 55B5ABF7129F875800FBF75C /* DDAreaUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDAreaUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF06412A03827004DDAB0 /* DDCurrentUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDCurrentUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF06512A03827004DDAB0 /* DDCurrentUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDCurrentUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF06712A03955004DDAB0 /* DDByteUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDByteUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF06812A03955004DDAB0 /* DDByteUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDByteUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF07812A04925004DDAB0 /* DDEnergyUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDEnergyUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF07912A04925004DDAB0 /* DDEnergyUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDEnergyUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF09412A04B4B004DDAB0 /* DDForceUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDForceUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF09512A04B4B004DDAB0 /* DDForceUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDForceUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF0A112A04C9E004DDAB0 /* DDIlluminationUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDIlluminationUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF0A212A04C9E004DDAB0 /* DDIlluminationUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDIlluminationUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF0A412A04F6B004DDAB0 /* DDInductanceUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDInductanceUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF0A512A04F6B004DDAB0 /* DDInductanceUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDInductanceUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF0A712A051F0004DDAB0 /* DDMagnitudeUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDMagnitudeUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF0A812A051F0004DDAB0 /* DDMagnitudeUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDMagnitudeUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF0AC12A054B1004DDAB0 /* DDMassUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDMassUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF0AD12A054B1004DDAB0 /* DDMassUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDMassUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF0B112A05CFE004DDAB0 /* DDPowerUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDPowerUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF0B212A05CFE004DDAB0 /* DDPowerUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDPowerUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF0B612A05EAA004DDAB0 /* DDPressureUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDPressureUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF0B712A05EAA004DDAB0 /* DDPressureUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDPressureUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF0CB12A06048004DDAB0 /* DDRadiationUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDRadiationUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF0CC12A06048004DDAB0 /* DDRadiationUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDRadiationUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF0D012A060E9004DDAB0 /* DDTemperatureUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDTemperatureUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF0D112A060E9004DDAB0 /* DDTemperatureUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDTemperatureUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF0D512A063A6004DDAB0 /* DDTimeUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDTimeUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF0D612A063A6004DDAB0 /* DDTimeUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDTimeUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF0D812A07699004DDAB0 /* DDTorqueUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDTorqueUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF0D912A07699004DDAB0 /* DDTorqueUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDTorqueUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF0DF12A08079004DDAB0 /* DDVelocityUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDVelocityUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF0E012A08079004DDAB0 /* DDVelocityUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDVelocityUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF0E412A08422004DDAB0 /* DDVolumeUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDVolumeUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF0E512A08422004DDAB0 /* DDVolumeUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDVolumeUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF0FA12A0C347004DDAB0 /* DDCurrencyUnitConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDCurrencyUnitConverter.h; sourceTree = "<group>"; };
+ 55BBF0FB12A0C347004DDAB0 /* DDCurrencyUnitConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDCurrencyUnitConverter.m; sourceTree = "<group>"; };
+ 55BBF0FD12A0CF28004DDAB0 /* DDUnitConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDUnitConversion.h; sourceTree = "<group>"; };
+ 8DD76FA10486AA7600D96B5E /* DDUnitConverter */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DDUnitConverter; sourceTree = BUILT_PRODUCTS_DIR; };
+ C6859EA3029092ED04C91782 /* DDUnitConverter.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = DDUnitConverter.1; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 8DD76F9B0486AA7600D96B5E /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 08FB7794FE84155DC02AAC07 /* DDUnitConverter */ = {
+ isa = PBXGroup;
+ children = (
+ 08FB7795FE84155DC02AAC07 /* Source */,
+ C6859EA2029092E104C91782 /* Documentation */,
+ 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */,
+ 1AB674ADFE9D54B511CA2CBB /* Products */,
+ );
+ name = DDUnitConverter;
+ sourceTree = "<group>";
+ };
+ 08FB7795FE84155DC02AAC07 /* Source */ = {
+ isa = PBXGroup;
+ children = (
+ 32A70AAB03705E1F00C91783 /* DDUnitConverter_Prefix.pch */,
+ 08FB7796FE84155DC02AAC07 /* main.m */,
+ 55BBF16912A0D67A004DDAB0 /* DDUnitConverter */,
+ );
+ name = Source;
+ sourceTree = "<group>";
+ };
+ 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */ = {
+ isa = PBXGroup;
+ children = (
+ 08FB779EFE84155DC02AAC07 /* Foundation.framework */,
+ );
+ name = "External Frameworks and Libraries";
+ sourceTree = "<group>";
+ };
+ 1AB674ADFE9D54B511CA2CBB /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 8DD76FA10486AA7600D96B5E /* DDUnitConverter */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 55B5ABDE129F1E0900FBF75C /* Converters */ = {
+ isa = PBXGroup;
+ children = (
+ 55B5ABD9129F1C2400FBF75C /* DDAccelerationUnitConverter.h */,
+ 55B5ABDA129F1C2400FBF75C /* DDAccelerationUnitConverter.m */,
+ 55B5ABF0129F6F7B00FBF75C /* DDAngleUnitConverter.h */,
+ 55B5ABF1129F6F7B00FBF75C /* DDAngleUnitConverter.m */,
+ 55B5ABF6129F875800FBF75C /* DDAreaUnitConverter.h */,
+ 55B5ABF7129F875800FBF75C /* DDAreaUnitConverter.m */,
+ 55BBF06712A03955004DDAB0 /* DDByteUnitConverter.h */,
+ 55BBF06812A03955004DDAB0 /* DDByteUnitConverter.m */,
+ 55BBF0FA12A0C347004DDAB0 /* DDCurrencyUnitConverter.h */,
+ 55BBF0FB12A0C347004DDAB0 /* DDCurrencyUnitConverter.m */,
+ 55BBF06412A03827004DDAB0 /* DDCurrentUnitConverter.h */,
+ 55BBF06512A03827004DDAB0 /* DDCurrentUnitConverter.m */,
+ 55BBF07812A04925004DDAB0 /* DDEnergyUnitConverter.h */,
+ 55BBF07912A04925004DDAB0 /* DDEnergyUnitConverter.m */,
+ 55BBF09412A04B4B004DDAB0 /* DDForceUnitConverter.h */,
+ 55BBF09512A04B4B004DDAB0 /* DDForceUnitConverter.m */,
+ 55BBF0A112A04C9E004DDAB0 /* DDIlluminationUnitConverter.h */,
+ 55BBF0A212A04C9E004DDAB0 /* DDIlluminationUnitConverter.m */,
+ 55BBF0A412A04F6B004DDAB0 /* DDInductanceUnitConverter.h */,
+ 55BBF0A512A04F6B004DDAB0 /* DDInductanceUnitConverter.m */,
+ 55B5ABC8129F162500FBF75C /* DDLengthUnitConverter.h */,
+ 55B5ABC9129F162500FBF75C /* DDLengthUnitConverter.m */,
+ 55BBF0A712A051F0004DDAB0 /* DDMagnitudeUnitConverter.h */,
+ 55BBF0A812A051F0004DDAB0 /* DDMagnitudeUnitConverter.m */,
+ 55BBF0AC12A054B1004DDAB0 /* DDMassUnitConverter.h */,
+ 55BBF0AD12A054B1004DDAB0 /* DDMassUnitConverter.m */,
+ 55BBF0B112A05CFE004DDAB0 /* DDPowerUnitConverter.h */,
+ 55BBF0B212A05CFE004DDAB0 /* DDPowerUnitConverter.m */,
+ 55BBF0B612A05EAA004DDAB0 /* DDPressureUnitConverter.h */,
+ 55BBF0B712A05EAA004DDAB0 /* DDPressureUnitConverter.m */,
+ 55BBF0CB12A06048004DDAB0 /* DDRadiationUnitConverter.h */,
+ 55BBF0CC12A06048004DDAB0 /* DDRadiationUnitConverter.m */,
+ 55BBF0D012A060E9004DDAB0 /* DDTemperatureUnitConverter.h */,
+ 55BBF0D112A060E9004DDAB0 /* DDTemperatureUnitConverter.m */,
+ 55BBF0D512A063A6004DDAB0 /* DDTimeUnitConverter.h */,
+ 55BBF0D612A063A6004DDAB0 /* DDTimeUnitConverter.m */,
+ 55BBF0D812A07699004DDAB0 /* DDTorqueUnitConverter.h */,
+ 55BBF0D912A07699004DDAB0 /* DDTorqueUnitConverter.m */,
+ 55BBF0DF12A08079004DDAB0 /* DDVelocityUnitConverter.h */,
+ 55BBF0E012A08079004DDAB0 /* DDVelocityUnitConverter.m */,
+ 55BBF0E412A08422004DDAB0 /* DDVolumeUnitConverter.h */,
+ 55BBF0E512A08422004DDAB0 /* DDVolumeUnitConverter.m */,
+ );
+ name = Converters;
+ sourceTree = "<group>";
+ };
+ 55BBF16912A0D67A004DDAB0 /* DDUnitConverter */ = {
+ isa = PBXGroup;
+ children = (
+ 55BBF0FD12A0CF28004DDAB0 /* DDUnitConversion.h */,
+ 55B5ABC5129F11F400FBF75C /* DDUnitConverter.h */,
+ 55B5ABC6129F11F400FBF75C /* DDUnitConverter.m */,
+ 55B5ABF3129F780E00FBF75C /* NSDecimalNumber+DDConstants.h */,
+ 55B5ABF4129F780E00FBF75C /* NSDecimalNumber+DDConstants.m */,
+ 55B5ABDE129F1E0900FBF75C /* Converters */,
+ );
+ path = DDUnitConverter;
+ sourceTree = "<group>";
+ };
+ C6859EA2029092E104C91782 /* Documentation */ = {
+ isa = PBXGroup;
+ children = (
+ C6859EA3029092ED04C91782 /* DDUnitConverter.1 */,
+ );
+ name = Documentation;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 8DD76F960486AA7600D96B5E /* DDUnitConverter */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "DDUnitConverter" */;
+ buildPhases = (
+ 8DD76F990486AA7600D96B5E /* Sources */,
+ 8DD76F9B0486AA7600D96B5E /* Frameworks */,
+ 8DD76F9E0486AA7600D96B5E /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = DDUnitConverter;
+ productInstallPath = "$(HOME)/bin";
+ productName = DDUnitConverter;
+ productReference = 8DD76FA10486AA7600D96B5E /* DDUnitConverter */;
+ productType = "com.apple.product-type.tool";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 08FB7793FE84155DC02AAC07 /* Project object */ = {
+ isa = PBXProject;
+ buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "DDUnitConverter" */;
+ compatibilityVersion = "Xcode 3.1";
+ developmentRegion = English;
+ hasScannedForEncodings = 1;
+ knownRegions = (
+ English,
+ Japanese,
+ French,
+ German,
+ );
+ mainGroup = 08FB7794FE84155DC02AAC07 /* DDUnitConverter */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 8DD76F960486AA7600D96B5E /* DDUnitConverter */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 8DD76F990486AA7600D96B5E /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 8DD76F9A0486AA7600D96B5E /* main.m in Sources */,
+ 55B5ABC7129F11F400FBF75C /* DDUnitConverter.m in Sources */,
+ 55B5ABCA129F162500FBF75C /* DDLengthUnitConverter.m in Sources */,
+ 55B5ABDB129F1C2400FBF75C /* DDAccelerationUnitConverter.m in Sources */,
+ 55B5ABF2129F6F7B00FBF75C /* DDAngleUnitConverter.m in Sources */,
+ 55B5ABF5129F780E00FBF75C /* NSDecimalNumber+DDConstants.m in Sources */,
+ 55B5ABF8129F875800FBF75C /* DDAreaUnitConverter.m in Sources */,
+ 55BBF06612A03828004DDAB0 /* DDCurrentUnitConverter.m in Sources */,
+ 55BBF06912A03955004DDAB0 /* DDByteUnitConverter.m in Sources */,
+ 55BBF07A12A04925004DDAB0 /* DDEnergyUnitConverter.m in Sources */,
+ 55BBF09612A04B4B004DDAB0 /* DDForceUnitConverter.m in Sources */,
+ 55BBF0A312A04C9E004DDAB0 /* DDIlluminationUnitConverter.m in Sources */,
+ 55BBF0A612A04F6B004DDAB0 /* DDInductanceUnitConverter.m in Sources */,
+ 55BBF0A912A051F0004DDAB0 /* DDMagnitudeUnitConverter.m in Sources */,
+ 55BBF0AE12A054B1004DDAB0 /* DDMassUnitConverter.m in Sources */,
+ 55BBF0B312A05CFE004DDAB0 /* DDPowerUnitConverter.m in Sources */,
+ 55BBF0B812A05EAA004DDAB0 /* DDPressureUnitConverter.m in Sources */,
+ 55BBF0CD12A06048004DDAB0 /* DDRadiationUnitConverter.m in Sources */,
+ 55BBF0D212A060E9004DDAB0 /* DDTemperatureUnitConverter.m in Sources */,
+ 55BBF0D712A063A6004DDAB0 /* DDTimeUnitConverter.m in Sources */,
+ 55BBF0DA12A07699004DDAB0 /* DDTorqueUnitConverter.m in Sources */,
+ 55BBF0E112A08079004DDAB0 /* DDVelocityUnitConverter.m in Sources */,
+ 55BBF0E612A08422004DDAB0 /* DDVolumeUnitConverter.m in Sources */,
+ 55BBF0FC12A0C347004DDAB0 /* DDCurrencyUnitConverter.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 1DEB927508733DD40010E9CD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ COPY_PHASE_STRIP = NO;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_MODEL_TUNING = G5;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = DDUnitConverter_Prefix.pch;
+ INSTALL_PATH = /usr/local/bin;
+ PRODUCT_NAME = DDUnitConverter;
+ };
+ name = Debug;
+ };
+ 1DEB927608733DD40010E9CD /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_MODEL_TUNING = G5;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = DDUnitConverter_Prefix.pch;
+ INSTALL_PATH = /usr/local/bin;
+ PRODUCT_NAME = DDUnitConverter;
+ };
+ name = Release;
+ };
+ 1DEB927908733DD40010E9CD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ PREBINDING = NO;
+ SDKROOT = macosx10.6;
+ };
+ name = Debug;
+ };
+ 1DEB927A08733DD40010E9CD /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ PREBINDING = NO;
+ SDKROOT = macosx10.6;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "DDUnitConverter" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB927508733DD40010E9CD /* Debug */,
+ 1DEB927608733DD40010E9CD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "DDUnitConverter" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB927908733DD40010E9CD /* Debug */,
+ 1DEB927A08733DD40010E9CD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
+}
View
32 DDUnitConverter/DDAccelerationUnitConverter.h
@@ -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
View
44 DDUnitConverter/DDAccelerationUnitConverter.m
@@ -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
View
38 DDUnitConverter/DDAngleUnitConverter.h
@@ -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
View
55 DDUnitConverter/DDAngleUnitConverter.m
@@ -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
View
41 DDUnitConverter/DDAreaUnitConverter.h
@@ -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
View
59 DDUnitConverter/DDAreaUnitConverter.m
@@ -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
View
70 DDUnitConverter/DDByteUnitConverter.h
@@ -0,0 +1,70 @@
+//
+// DDByteUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDByteUnitConverter)
+
++ (id) byteUnitConverter;
+
+@end
+
+enum {
+ DDByteUnitBit = 0,
+ DDByteUnitCrumb,
+ DDByteUnitNibble,
+ DDByteUnitByte,
+
+ DDByteUnitDecabit,
+ DDByteUnitHectobit,
+ DDByteUnitKilobit,
+ DDByteUnitMegabit,
+ DDByteUnitGigabit,
+ DDByteUnitTerabit,
+ DDByteUnitPetabit,
+ DDByteUnitExabit,
+ DDByteUnitZettabit,
+ DDByteUnitYottabit,
+
+ DDByteUnitDecabyte,
+ DDByteUnitHectobyte,
+ DDByteUnitKilobyte,
+ DDByteUnitMegabyte,
+ DDByteUnitGigabyte,
+ DDByteUnitTerabyte,
+ DDByteUnitPetabyte,
+ DDByteUnitExabyte,
+ DDByteUnitZettabyte,
+ DDByteUnitYottabyte,
+
+ DDByteUnitKibibit,
+ DDByteUnitMebibit,
+ DDByteUnitGibibit,
+ DDByteUnitTebibit,
+ DDByteUnitPebibit,
+ DDByteUnitExbibit,
+// DDByteUnitZebibit,
+// DDByteUnitYobibit,
+
+ DDByteUnitKibibyte,
+ DDByteUnitMebibyte,
+ DDByteUnitGibibyte,
+ DDByteUnitTebibyte,
+ DDByteUnitPebibyte,
+ DDByteUnitExbibyte,
+// DDByteUnitZebibyte,
+// DDByteUnitYobibyte
+};
+typedef NSUInteger DDByteUnit;
+
+@interface DDByteUnitConverter : DDUnitConverter {
+
+}
+
+@end
View
115 DDUnitConverter/DDByteUnitConverter.m
@@ -0,0 +1,115 @@
+//
+// DDByteUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDByteUnitConverter.h"
+
+@implementation DDUnitConverter (DDByteUnitConverter)
+
++ (id) byteUnitConverter {
+ return [[[DDByteUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDByteUnitConverter
+
++ (NSDecimalNumber *) multiplierForUnit:(DDUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ switch (unit) {
+ case DDByteUnitBit:
+ break;
+ case DDByteUnitCrumb:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:2 exponent:0 isNegative:NO]; break;
+ case DDByteUnitNibble:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:4 exponent:0 isNegative:NO]; break;
+ case DDByteUnitByte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:8 exponent:0 isNegative:NO]; break;
+
+ case DDByteUnitDecabit:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:1 isNegative:NO]; break;
+ case DDByteUnitHectobit:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:2 isNegative:NO]; break;
+ case DDByteUnitKilobit:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:3 isNegative:NO]; break;
+ case DDByteUnitMegabit:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:6 isNegative:NO]; break;
+ case DDByteUnitGigabit:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:9 isNegative:NO]; break;
+ case DDByteUnitTerabit:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:12 isNegative:NO]; break;
+ case DDByteUnitPetabit:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:15 isNegative:NO]; break;
+ case DDByteUnitExabit:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:18 isNegative:NO]; break;
+ case DDByteUnitZettabit:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:21 isNegative:NO]; break;
+ case DDByteUnitYottabit:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:24 isNegative:NO]; break;
+
+ case DDByteUnitDecabyte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:8 exponent:1 isNegative:NO]; break;
+ case DDByteUnitHectobyte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:8 exponent:2 isNegative:NO]; break;
+ case DDByteUnitKilobyte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:8 exponent:3 isNegative:NO]; break;
+ case DDByteUnitMegabyte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:8 exponent:6 isNegative:NO]; break;
+ case DDByteUnitGigabyte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:8 exponent:9 isNegative:NO]; break;
+ case DDByteUnitTerabyte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:8 exponent:12 isNegative:NO]; break;
+ case DDByteUnitPetabyte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:8 exponent:15 isNegative:NO]; break;
+ case DDByteUnitExabyte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:8 exponent:18 isNegative:NO]; break;
+ case DDByteUnitZettabyte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:8 exponent:21 isNegative:NO]; break;
+ case DDByteUnitYottabyte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:8 exponent:24 isNegative:NO]; break;
+
+ case DDByteUnitKibibit:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:(1ULL << 10) exponent:0 isNegative:NO]; break;
+ case DDByteUnitMebibit:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:(1ULL << 20) exponent:0 isNegative:NO]; break;
+ case DDByteUnitGibibit:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:(1ULL << 30) exponent:0 isNegative:NO]; break;
+ case DDByteUnitTebibit:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:(1ULL << 40) exponent:0 isNegative:NO]; break;
+ case DDByteUnitPebibit:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:(1ULL << 50) exponent:0 isNegative:NO]; break;
+ case DDByteUnitExbibit:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:(1ULL << 60) exponent:0 isNegative:NO]; break;
+// case DDByteUnitZebibit:
+// multiplier = [NSDecimalNumber decimalNumberWithMantissa:(1ULL << 70) exponent:0 isNegative:NO]; break; //overflows, unreliable
+// case DDByteUnitYobibit:
+// multiplier = [NSDecimalNumber decimalNumberWithMantissa:(1ULL << 80) exponent:0 isNegative:NO]; break; //overflows, unreliable
+
+ case DDByteUnitKibibyte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:(8ULL << 10) exponent:0 isNegative:NO]; break;
+ case DDByteUnitMebibyte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:(8ULL << 20) exponent:0 isNegative:NO]; break;
+ case DDByteUnitGibibyte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:(8ULL << 30) exponent:0 isNegative:NO]; break;
+ case DDByteUnitTebibyte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:(8ULL << 40) exponent:0 isNegative:NO]; break;
+ case DDByteUnitPebibyte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:(8ULL << 50) exponent:0 isNegative:NO]; break;
+ case DDByteUnitExbibyte:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:(8ULL << 60) exponent:0 isNegative:NO]; break;
+// case DDByteUnitZebibyte:
+// multiplier = [NSDecimalNumber decimalNumberWithMantissa:(8ULL << 70) exponent:0 isNegative:NO]; break; //overflows, unreliable
+// case DDByteUnitYobibyte:
+// multiplier = [NSDecimalNumber decimalNumberWithMantissa:(8ULL << 80) exponent:0 isNegative:NO]; break; //overflows, unreliable
+ default:
+ break;
+ }
+ return multiplier;
+}
+
+@end
View
81 DDUnitConverter/DDCurrencyUnitConverter.h
@@ -0,0 +1,81 @@
+//
+// DDCurrencyUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDCurrencyUnitConverter)
+
++ (id) currencyUnitConverter;
+
+@end
+
+enum {
+ DDCurrencyUnitEuro = 0,
+ DDCurrencyUnitJapaneseYen,
+ DDCurrencyUnitUKPoundSterling,
+ DDCurrencyUnitUSDollar,
+ DDCurrencyUnitAlgerianDinar,
+ DDCurrencyUnitArgentinePeso,
+ DDCurrencyUnitAustralianDollar,
+ DDCurrencyUnitBahrainDinar,
+ DDCurrencyUnitBotswanaPula,
+ DDCurrencyUnitBrazilianReal,
+ DDCurrencyUnitBruneiDollar,
+ DDCurrencyUnitCanadianDollar,
+ DDCurrencyUnitChileanPeso,
+ DDCurrencyUnitChineseYuan,
+ DDCurrencyUnitColombianPeso,
+ DDCurrencyUnitCzechKoruna,
+ DDCurrencyUnitDanishKrone,
+ DDCurrencyUnitHungarianForint,
+ DDCurrencyUnitIcelandicKrona,
+ DDCurrencyUnitIndianRupee,
+ DDCurrencyUnitIndonesianRupiah,
+ DDCurrencyUnitIranianRial,
+ DDCurrencyUnitIsraeliNewSheqel,
+ DDCurrencyUnitKazakhstaniTenge,
+ DDCurrencyUnitKoreanWon,
+ DDCurrencyUnitKuwaitiDinar,
+ DDCurrencyUnitLibyanDinar,
+ DDCurrencyUnitMalaysianRinggit,
+ DDCurrencyUnitMauritianRupee,
+ DDCurrencyUnitMexicanPeso,
+ DDCurrencyUnitNepaleseRupee,
+ DDCurrencyUnitNewZealandDollar,
+ DDCurrencyUnitNorwegianKrone,
+ DDCurrencyUnitRialOmani,
+ DDCurrencyUnitPakistaniRupee,
+ DDCurrencyUnitNuevoSol,
+ DDCurrencyUnitPhilippinePeso,
+ DDCurrencyUnitPolishZloty,
+ DDCurrencyUnitQatarRiyal,
+ DDCurrencyUnitRussianRuble,
+ DDCurrencyUnitSaudiArabianRiyal,
+ DDCurrencyUnitSingaporeDollar,
+ DDCurrencyUnitSouthAfricanRand,
+ DDCurrencyUnitSriLankaRupee,
+ DDCurrencyUnitSwedishKrona,
+ DDCurrencyUnitSwissFranc,
+ DDCurrencyUnitThaiBaht,
+ DDCurrencyUnitTrinidadAndTobagoDollar,
+ DDCurrencyUnitTunisianDinar,
+ DDCurrencyUnitUAEDirham,
+ DDCurrencyUnitPesoUruguayo,
+ DDCurrencyUnitBolivarFuerte,
+ DDCurrencyUnitSDR
+};
+typedef NSUInteger DDCurrencyUnit;
+
+@interface DDCurrencyUnitConverter : DDUnitConverter {
+
+}
+
+- (void) refreshExchangeRates;
+
+@end
View
106 DDUnitConverter/DDCurrencyUnitConverter.m
@@ -0,0 +1,106 @@
+//
+// DDCurrencyUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDCurrencyUnitConverter.h"
+
+static double _DDCurrencyExchangeRates[DDCurrencyUnitSDR];
+
+static BOOL _ratesUpdated = NO;
+static NSLock * updatingLock = nil;
+
+@implementation DDUnitConverter (DDCurrencyUnitConverter)
+
++ (id) currencyUnitConverter {
+ return [[[DDCurrencyUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDCurrencyUnitConverter
+
++ (void) initialize {
+ if (self == [DDCurrencyUnitConverter class]) {
+ updatingLock = [[NSLock alloc] init];
+ }
+}
+
++ (NSDecimalNumber *) multiplierForUnit:(DDUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ if (unit < DDCurrencyUnitSDR) {
+ NSNumber * exchangeRate = [NSNumber numberWithDouble:_DDCurrencyExchangeRates[unit]];
+ multiplier = [NSDecimalNumber decimalNumberWithDecimal:[exchangeRate decimalValue]];
+ }
+ return multiplier;
+}
+
+- (id) init {
+ self = [super init];
+ if (self) {
+ [self refreshExchangeRates];
+ }
+ return self;
+}
+
+- (NSNumber *) convertNumber:(NSNumber *)number fromUnit:(DDUnit)from toUnit:(DDUnit)to {
+ [updatingLock lock];
+ [updatingLock unlock];
+
+ return [super convertNumber:number fromUnit:from toUnit:to];
+}
+
+- (void) refreshExchangeRates {
+ [self performSelectorInBackground:@selector(refreshExchangeRatesInBackground) withObject:nil];
+}
+
+- (void) refreshExchangeRatesInBackground {
+ if ([NSThread currentThread] == [NSThread mainThread]) { return; }
+ [updatingLock lock];
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ NSURL * imfURL = [NSURL URLWithString:@"http://www.imf.org/external/np/fin/data/rms_five.aspx?tsvflag=Y"];
+ NSError * error = nil;
+ NSString * raw = [NSString stringWithContentsOfURL:imfURL encoding:NSUTF8StringEncoding error:&error];
+
+ if (error == nil) {
+ NSArray * rows = [raw componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
+ BOOL hasStartedCulling = NO;
+ short rowIndex = 0;
+ for (NSString * row in rows) {
+ if ([row length] == 0) { continue; }
+ if (hasStartedCulling == NO) {
+ if ([row hasPrefix:@"Currency"]) {
+ hasStartedCulling = YES;
+ }
+ } else {
+ if ([row hasPrefix:@"Currency"]) {
+ break;
+ } else {
+ NSArray * fields = [row componentsSeparatedByString:@"\t"];
+ double conversionValue = 0.0f;
+ for (int i = 1; i < [fields count]; ++i) {
+ NSString * field = [fields objectAtIndex:i];
+ if ([field length] > 0) {
+ conversionValue = [field doubleValue];
+ break;
+ }
+ }
+ _DDCurrencyExchangeRates[rowIndex] = conversionValue;
+ rowIndex++;
+ }
+ }
+ }
+
+ _ratesUpdated = YES;
+ }
+
+ [pool drain];
+ [updatingLock unlock];
+}
+
+@end
View
29 DDUnitConverter/DDCurrentUnitConverter.h
@@ -0,0 +1,29 @@
+//
+// DDCurrentUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDCurrentUnitConverter)
+
++ (id) currentUnitConverter;
+
+@end
+
+enum {
+ DDCurrentUnitAmperes = 0,
+ DDCurrentUnitElectromagneticUnits,
+ DDCurrentUnitMilliamperes
+};
+typedef NSUInteger DDCurrentUnit;
+
+@interface DDCurrentUnitConverter : DDUnitConverter {
+
+}
+
+@end
View
37 DDUnitConverter/DDCurrentUnitConverter.m
@@ -0,0 +1,37 @@
+//
+// DDCurrentUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDCurrentUnitConverter.h"
+
+@implementation DDUnitConverter (DDCurrentUnitConverter)
+
++ (id) currentUnitConverter {
+ return [[[DDCurrentUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDCurrentUnitConverter
+
++ (NSDecimalNumber *) multiplierForUnit:(DDUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ switch (unit) {
+ case DDCurrentUnitAmperes:
+ break;
+ case DDCurrentUnitElectromagneticUnits:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:1 isNegative:NO]; break;
+ case DDCurrentUnitMilliamperes:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-3 isNegative:NO]; break;
+ default:
+ break;
+ }
+ return multiplier;
+}
+
+@end
View
37 DDUnitConverter/DDEnergyUnitConverter.h
@@ -0,0 +1,37 @@
+//
+// DDEnergyUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDEnergyUnitConverter)
+
++ (id) energyUnitConverter;
+
+@end
+
+enum {
+ DDEnergyUnitBTUs = 0,
+ DDEnergyUnitCalories,
+ DDEnergyUnitElectronVolts,
+ DDEnergyUnitErgs,
+ DDEnergyUnitFootPoundForces,
+ DDEnergyUnitJoules,
+ DDEnergyUnitKilogramForceMeters,
+ DDEnergyUnitKilowattHours,
+ DDEnergyUnitNewtonMeters,
+ DDEnergyUnitTherms,
+ DDEnergyUnitWattHours
+};
+typedef NSUInteger DDEnergyUnit;
+
+@interface DDEnergyUnitConverter : DDUnitConverter {
+
+}
+
+@end
View
54 DDUnitConverter/DDEnergyUnitConverter.m
@@ -0,0 +1,54 @@
+//
+// DDEnergyUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDEnergyUnitConverter.h"
+#import "NSDecimalNumber+DDConstants.h"
+
+@implementation DDUnitConverter (DDEnergyUnitConverter)
+
++ (id) energyUnitConverter {
+ return [[[DDEnergyUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDEnergyUnitConverter
+
++ (NSDecimalNumber *) multiplierForUnit:(DDUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ switch (unit) {
+ case DDEnergyUnitBTUs:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:105506 exponent:-2 isNegative:NO]; break;
+ case DDEnergyUnitCalories:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:41868 exponent:-4 isNegative:NO]; break;
+ case DDEnergyUnitElectronVolts:
+ multiplier = [NSDecimalNumber electronChargeConstant_dd]; break;
+ case DDEnergyUnitErgs:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-7 isNegative:NO]; break;
+ case DDEnergyUnitFootPoundForces:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:135582 exponent:-5 isNegative:NO]; break;
+ case DDEnergyUnitJoules:
+ break;
+ case DDEnergyUnitKilogramForceMeters:
+ multiplier = [NSDecimalNumber gConstant_dd]; break;
+ case DDEnergyUnitKilowattHours:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:3600000 exponent:0 isNegative:NO]; break;
+ case DDEnergyUnitNewtonMeters:
+ break;
+ case DDEnergyUnitTherms:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:105506000 exponent:0 isNegative:NO]; break;
+ case DDEnergyUnitWattHours:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:3600 exponent:0 isNegative:NO]; break;
+ default:
+ break;
+ }
+ return multiplier;
+}
+
+@end
View
32 DDUnitConverter/DDForceUnitConverter.h
@@ -0,0 +1,32 @@
+//
+// DDForceUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDForceUnitConverter)
+
++ (id) forceUnitConverter;
+
+@end
+
+enum {
+ DDForceUnitDynes = 0,
+ DDForceUnitKilogramForces,
+ DDForceUnitNewtons,
+ DDForceUnitPoundals,
+ DDForceUnitPoundForces,
+ DDForceUnitSthenes
+};
+typedef NSUInteger DDForceUnit;
+
+@interface DDForceUnitConverter : DDUnitConverter {
+
+}
+
+@end
View
44 DDUnitConverter/DDForceUnitConverter.m
@@ -0,0 +1,44 @@
+//
+// DDForceUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDForceUnitConverter.h"
+#import "NSDecimalNumber+DDConstants.h"
+
+@implementation DDUnitConverter (DDForceUnitConverter)
+
++ (id) forceUnitConverter {
+ return [[[DDForceUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDForceUnitConverter
+
++ (NSDecimalNumber *) multiplierForUnit:(DDUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ switch (unit) {
+ case DDForceUnitDynes:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-5 isNegative:NO]; break;
+ case DDForceUnitKilogramForces:
+ multiplier = [NSDecimalNumber gConstant_dd]; break;
+ case DDForceUnitNewtons:
+ break;
+ case DDForceUnitPoundals:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:138255 exponent:-6 isNegative:NO]; break;
+ case DDForceUnitPoundForces:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:44822 exponent:-4 isNegative:NO]; break;
+ case DDForceUnitSthenes:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:3 isNegative:NO]; break;
+ default:
+ break;
+ }
+ return multiplier;
+}
+
+@end
View
33 DDUnitConverter/DDIlluminationUnitConverter.h
@@ -0,0 +1,33 @@
+//
+// DDIlluminationUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDIlluminationUnitConverter)
+
++ (id) illuminationUnitConverter;
+
+@end
+
+enum {
+ DDIlluminationUnitFootCandles = 0,
+ DDIlluminationUnitLumensPerSquareCentimeter,
+ DDIlluminationUnitLumensPerSquareFoot,
+ DDIlluminationUnitLumensPerSquareMeter,
+ DDIlluminationUnitNox,
+ DDIlluminationUnitPhots,
+ DDIlluminationClearDaySunIllumination
+};
+typedef NSUInteger DDIlluminationUnit;
+
+@interface DDIlluminationUnitConverter : DDUnitConverter {
+
+}
+
+@end
View
42 DDUnitConverter/DDIlluminationUnitConverter.m
@@ -0,0 +1,42 @@
+//
+// DDIlluminationUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDIlluminationUnitConverter.h"
+
+@implementation DDUnitConverter (DDIlluminationUnitConverter)
+
++ (id) illuminationUnitConverter {
+ return [[[DDIlluminationUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDIlluminationUnitConverter
+
++ (NSDecimalNumber *) multiplierForUnit:(DDUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ switch (unit) {
+ case DDIlluminationUnitFootCandles:
+ case DDIlluminationUnitLumensPerSquareFoot:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:107639104167097 exponent:-13 isNegative:NO]; break;
+ case DDIlluminationUnitLumensPerSquareCentimeter:
+ case DDIlluminationUnitNox:
+ case DDIlluminationUnitPhots:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:4 isNegative:NO]; break;
+ case DDIlluminationUnitLumensPerSquareMeter:
+ break;
+ case DDIlluminationClearDaySunIllumination:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:5 isNegative:NO]; break;
+ default:
+ break;
+ }
+ return multiplier;
+}
+
+@end
View
31 DDUnitConverter/DDInductanceUnitConverter.h
@@ -0,0 +1,31 @@
+//
+// DDInductanceUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDInductanceUnitConverter)
+
++ (id) inductanceUnitConverter;
+
+@end
+
+enum {
+ DDInductanceUnitElectromagneticUnits = 0,
+ DDInductanceUnitElectrostaticUnits,
+ DDInductanceUnitHenrys,
+ DDInductanceUnitMillihenrys,
+ DDInductanceUnitMicrohenrys
+};
+typedef NSUInteger DDInductanceUnit;
+
+@interface DDInductanceUnitConverter : DDUnitConverter {
+
+}
+
+@end
View
41 DDUnitConverter/DDInductanceUnitConverter.m
@@ -0,0 +1,41 @@
+//
+// DDInductanceUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDInductanceUnitConverter.h"
+
+@implementation DDUnitConverter (DDInductanceUnitConverter)
+
++ (id) inductanceUnitConverter {
+ return [[[DDInductanceUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDInductanceUnitConverter
+
++ (NSDecimalNumber *) multiplierForUnit:(DDUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ switch (unit) {
+ case DDInductanceUnitElectromagneticUnits:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-9 isNegative:NO]; break;
+ case DDInductanceUnitElectrostaticUnits:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:898755 exponent:-6 isNegative:NO]; break;
+ case DDInductanceUnitHenrys:
+ break;
+ case DDInductanceUnitMillihenrys:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-3 isNegative:NO]; break;
+ case DDInductanceUnitMicrohenrys:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-6 isNegative:NO]; break;
+ default:
+ break;
+ }
+ return multiplier;
+}
+
+@end
View
43 DDUnitConverter/DDLengthUnitConverter.h
@@ -0,0 +1,43 @@
+//
+// DDLengthUnitConverter.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 (DDLengthUnitConverter)
+
++ (id) lengthUnitConverter;
+
+@end
+
+enum {
+ DDLengthUnitAstronomicUnits = 0,
+ DDLengthUnitCentimeters,
+ DDLengthUnitChains,
+ DDLengthUnitInches,
+ DDLengthUnitFathoms,
+ DDLengthUnitFeet,
+ DDLengthUnitFurlongs,
+ DDLengthUnitKilometers,
+ DDLengthUnitLightyears,
+ DDLengthUnitMeters,
+ DDLengthUnitMillimeters,
+ DDLengthUnitMiles,
+ DDLengthUnitInternationalNauticalMiles,
+ DDLengthUnitUKNauticalMiles,
+ DDLengthUnitParsecs,
+ DDLengthUnitYards,
+ DDLengthUnitAngstroms
+};
+typedef NSUInteger DDLengthUnit;
+
+@interface DDLengthUnitConverter : DDUnitConverter {
+
+}
+
+@end
View
65 DDUnitConverter/DDLengthUnitConverter.m
@@ -0,0 +1,65 @@
+//
+// DDLengthUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/25/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDLengthUnitConverter.h"
+
+
+@implementation DDUnitConverter (DDLengthUnitConverter)
+
++ (id) lengthUnitConverter {
+ return [[[DDLengthUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+@implementation DDLengthUnitConverter
+
++ (NSDecimalNumber *) multiplierForUnit:(DDLengthUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ switch (unit) {
+ case DDLengthUnitAstronomicUnits:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:14959787 exponent:4 isNegative:NO]; break;
+ case DDLengthUnitCentimeters:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-2 isNegative:NO]; break;
+ case DDLengthUnitChains:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:201168 exponent:-4 isNegative:NO]; break;
+ case DDLengthUnitInches:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:254 exponent:-4 isNegative:NO]; break;
+ case DDLengthUnitFathoms:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:18288 exponent:-4 isNegative:NO]; break;
+ case DDLengthUnitFeet:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:3048 exponent:-4 isNegative:NO]; break;
+ case DDLengthUnitFurlongs:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:201168 exponent:-3 isNegative:NO]; break;
+ case DDLengthUnitKilometers:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:3 isNegative:NO]; break;
+ case DDLengthUnitLightyears:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:94607 exponent:11 isNegative:NO]; break;
+ case DDLengthUnitMeters:
+ break;
+ case DDLengthUnitMillimeters:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-3 isNegative:NO]; break;
+ case DDLengthUnitMiles:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1609344 exponent:-3 isNegative:NO]; break;
+ case DDLengthUnitInternationalNauticalMiles:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1852 exponent:0 isNegative:NO]; break;
+ case DDLengthUnitUKNauticalMiles:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1853184 exponent:-3 isNegative:NO]; break;
+ case DDLengthUnitParsecs:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:930857 exponent:12 isNegative:NO]; break;
+ case DDLengthUnitYards:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:9144 exponent:-4 isNegative:NO]; break;
+ case DDLengthUnitAngstroms:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-10 isNegative:NO]; break;
+ default:
+ break;
+ }
+ return multiplier;
+}
+
+@end
View
47 DDUnitConverter/DDMagnitudeUnitConverter.h
@@ -0,0 +1,47 @@
+//
+// DDMagnitudeUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDMagnitudeUnitConverter)
+
++ (id) magnitudeUnitConverter;
+
+@end
+
+enum {
+ DDMagnitudeUnitYocto = 0,
+ DDMagnitudeUnitZepto,
+ DDMagnitudeUnitAtto,
+ DDMagnitudeUnitFemto,
+ DDMagnitudeUnitPico,
+ DDMagnitudeUnitNano,
+ DDMagnitudeUnitMicro,
+ DDMagnitudeUnitMilli,
+ DDMagnitudeUnitCenti,
+ DDMagnitudeUnitDeci,
+ DDMagnitudeUnitNormal,
+ DDMagnitudeUnitDeka,
+ DDMagnitudeUnitHecto,
+ DDMagnitudeUnitKilo,
+ DDMagnitudeUnitMega,
+ DDMagnitudeUnitGiga,
+ DDMagnitudeUnitTera,
+ DDMagnitudeUnitPeta,
+ DDMagnitudeUnitExa,
+ DDMagnitudeUnitZetta,
+ DDMagnitudeUnitYotta
+};
+typedef NSUInteger DDMagnitudeUnit;
+
+@interface DDMagnitudeUnitConverter : DDUnitConverter {
+
+}
+
+@end
View
73 DDUnitConverter/DDMagnitudeUnitConverter.m
@@ -0,0 +1,73 @@
+//
+// DDMagnitudeUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDMagnitudeUnitConverter.h"
+
+@implementation DDUnitConverter (DDMagnitudeUnitConverter)
+
++ (id) magnitudeUnitConverter {
+ return [[[DDMagnitudeUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDMagnitudeUnitConverter
+
++ (NSDecimalNumber *) multiplierForUnit:(DDUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ switch (unit) {
+ case DDMagnitudeUnitYocto:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-24 isNegative:NO]; break;
+ case DDMagnitudeUnitZepto:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-21 isNegative:NO]; break;
+ case DDMagnitudeUnitAtto:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-18 isNegative:NO]; break;
+ case DDMagnitudeUnitFemto:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-15 isNegative:NO]; break;
+ case DDMagnitudeUnitPico:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-12 isNegative:NO]; break;
+ case DDMagnitudeUnitNano:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-9 isNegative:NO]; break;
+ case DDMagnitudeUnitMicro:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-6 isNegative:NO]; break;
+ case DDMagnitudeUnitMilli:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-3 isNegative:NO]; break;
+ case DDMagnitudeUnitCenti:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-2 isNegative:NO]; break;
+ case DDMagnitudeUnitDeci:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-1 isNegative:NO]; break;
+ case DDMagnitudeUnitNormal:
+ break;
+ case DDMagnitudeUnitDeka:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:1 isNegative:NO]; break;
+ case DDMagnitudeUnitHecto:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:2 isNegative:NO]; break;
+ case DDMagnitudeUnitKilo:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:3 isNegative:NO]; break;
+ case DDMagnitudeUnitMega:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:6 isNegative:NO]; break;
+ case DDMagnitudeUnitGiga:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:9 isNegative:NO]; break;
+ case DDMagnitudeUnitTera:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:12 isNegative:NO]; break;
+ case DDMagnitudeUnitPeta:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:15 isNegative:NO]; break;
+ case DDMagnitudeUnitExa:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:18 isNegative:NO]; break;
+ case DDMagnitudeUnitZetta:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:21 isNegative:NO]; break;
+ case DDMagnitudeUnitYotta:
+ return [NSDecimalNumber decimalNumberWithMantissa:1 exponent:24 isNegative:NO]; break;
+ default:
+ break;
+ }
+ return multiplier;
+}
+
+@end
View
47 DDUnitConverter/DDMassUnitConverter.h
@@ -0,0 +1,47 @@
+//
+// DDMassUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDMassUnitConverter)
+
++ (id) massUnitConverter;
+
+@end
+
+enum {
+ DDMassUnitAtomicMassUnits = 0,
+ DDMassUnitDrachms,
+ DDMassUnitDrams,
+ DDMassUnitGrains,
+ DDMassUnitGrams,
+ DDMassUnitHundredWeights,
+ DDMassUnitKilograms,
+ DDMassUnitMilligrams,
+ DDMassUnitTroyOunces,
+ DDMassUnitUSOunces,
+ DDMassUnitPennyweights,
+ DDMassUnitTroyPounds,
+ DDMassUnitUSPounds,
+ DDMassUnitQuarters,
+ DDMassUnitScruples,
+ DDMassUnitShortHundredWeights,
+ DDMassUnitShortTons,
+ DDMassUnitSlugs,
+ DDMassUnitStones,
+ DDMassUnitUKTons,
+ DDMassUnitTonnes
+};
+typedef NSUInteger DDMassUnit;
+
+@interface DDMassUnitConverter : DDUnitConverter {
+
+}
+
+@end
View
73 DDUnitConverter/DDMassUnitConverter.m
@@ -0,0 +1,73 @@
+//
+// DDMassUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDMassUnitConverter.h"
+
+@implementation DDUnitConverter (DDMassUnitConverter)
+
++ (id) massUnitConverter {
+ return [[[DDMassUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDMassUnitConverter
+
++ (NSDecimalNumber *) multiplierForUnit:(DDUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ switch (unit) {
+ case DDMassUnitAtomicMassUnits:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:16605 exponent:-31 isNegative:NO]; break;
+ case DDMassUnitDrachms:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:388793 exponent:-8 isNegative:NO]; break;
+ case DDMassUnitDrams:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:177185 exponent:-8 isNegative:NO]; break;
+ case DDMassUnitGrains:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:6479891 exponent:-11 isNegative:NO]; break;
+ case DDMassUnitGrams:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-3 isNegative:NO]; break;
+ case DDMassUnitHundredWeights:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:508023 exponent:-4 isNegative:NO]; break;
+ case DDMassUnitKilograms:
+ break;
+ case DDMassUnitMilligrams:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-6 isNegative:NO]; break;
+ case DDMassUnitTroyOunces:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:311035 exponent:-7 isNegative:NO]; break;
+ case DDMassUnitUSOunces:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:283495 exponent:-7 isNegative:NO]; break;
+ case DDMassUnitPennyweights:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:155517 exponent:-8 isNegative:NO]; break;
+ case DDMassUnitTroyPounds:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:373242 exponent:-6 isNegative:NO]; break;
+ case DDMassUnitUSPounds:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:45359237 exponent:-8 isNegative:NO]; break;
+ case DDMassUnitQuarters:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:127006 exponent:-4 isNegative:NO]; break;
+ case DDMassUnitScruples:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:129598 exponent:-8 isNegative:NO]; break;
+ case DDMassUnitShortHundredWeights:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:453592 exponent:-4 isNegative:NO]; break;
+ case DDMassUnitShortTons:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:907185 exponent:-7 isNegative:NO]; break;
+ case DDMassUnitSlugs:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:145939 exponent:-4 isNegative:NO]; break;
+ case DDMassUnitStones:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:635029 exponent:-5 isNegative:NO]; break;
+ case DDMassUnitUKTons:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1016047 exponent:-3 isNegative:NO]; break;
+ case DDMassUnitTonnes:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:3 isNegative:NO]; break;
+ default:
+ break;
+ }
+ return multiplier;
+}
+
+@end
View
32 DDUnitConverter/DDPowerUnitConverter.h
@@ -0,0 +1,32 @@
+//
+// DDPowerUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDPowerUnitConverter)
+
++ (id) powerUnitConverter;
+
+@end
+
+enum {
+ DDPowerUnitFootPoundForcesPerSecond = 0,
+ DDPowerUnitHorsepower,
+ DDPowerUnitMetricHorsepower,
+ DDPowerUnitJoulesPerSecond,
+ DDPowerUnitKilogramForceMetersPerSecond,
+ DDPowerUnitWatts
+};
+typedef NSUInteger DDPowerUnit;
+
+@interface DDPowerUnitConverter : DDUnitConverter {
+
+}
+
+@end
View
43 DDUnitConverter/DDPowerUnitConverter.m
@@ -0,0 +1,43 @@
+//
+// DDPowerUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDPowerUnitConverter.h"
+#import "NSDecimalNumber+DDConstants.h"
+
+@implementation DDUnitConverter (DDPowerUnitConverter)
+
++ (id) powerUnitConverter {
+ return [[[DDPowerUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDPowerUnitConverter
+
++ (NSDecimalNumber *) multiplierForUnit:(DDUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ switch (unit) {
+ case DDPowerUnitFootPoundForcesPerSecond:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:135582 exponent:-5 isNegative:NO]; break;
+ case DDPowerUnitHorsepower:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:7457 exponent:-1 isNegative:NO]; break;
+ case DDPowerUnitMetricHorsepower:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:735499 exponent:-3 isNegative:NO]; break;
+ case DDPowerUnitJoulesPerSecond:
+ case DDPowerUnitWatts:
+ break;
+ case DDPowerUnitKilogramForceMetersPerSecond:
+ multiplier = [NSDecimalNumber gConstant_dd]; break;
+ default:
+ break;
+ }
+ return multiplier;
+}
+
+@end
View
36 DDUnitConverter/DDPressureUnitConverter.h
@@ -0,0 +1,36 @@
+//
+// DDPressureUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDPressureUnitConverter)
+
++ (id) pressureUnitConverter;
+
+@end
+
+enum {
+ DDPressureUnitAtmospheres = 0,
+ DDPressureUnitBars,
+ DDPressureUnitInchesOfMercury,
+ DDPressureUnitInchesOfWater,
+ DDPressureUnitMillimetersOfMercury,
+ DDPressureUnitNewtonsPerSquareMeter,
+ DDPressureUnitPascals,
+ DDPressureUnitPoundForcesPerSquareFoot,
+ DDPressureUnitPoundForcesPerSquareInch,
+ DDPressureUnitTorrs
+};
+typedef NSUInteger DDPressureUnit;
+
+@interface DDPressureUnitConverter : DDUnitConverter {
+
+}
+
+@end
View
49 DDUnitConverter/DDPressureUnitConverter.m
@@ -0,0 +1,49 @@
+//
+// DDPressureUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDPressureUnitConverter.h"
+
+@implementation DDUnitConverter (DDPressureUnitConverter)
+
++ (id) pressureUnitConverter {
+ return [[[DDPressureUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDPressureUnitConverter
+
++ (NSDecimalNumber *) multiplierForUnit:(DDUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ switch (unit) {
+ case DDPressureUnitAtmospheres:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:101325 exponent:0 isNegative:NO]; break;
+ case DDPressureUnitBars:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:5 isNegative:NO]; break;
+ case DDPressureUnitInchesOfMercury:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:338639 exponent:-2 isNegative:NO]; break;
+ case DDPressureUnitInchesOfWater:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:249089 exponent:-3 isNegative:NO]; break;
+ case DDPressureUnitMillimetersOfMercury:
+ case DDPressureUnitTorrs:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:133322368421052632 exponent:-15 isNegative:NO]; break;
+ case DDPressureUnitNewtonsPerSquareMeter:
+ case DDPressureUnitPascals:
+ break;
+ case DDPressureUnitPoundForcesPerSquareFoot:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:478803 exponent:-4 isNegative:NO]; break;
+ case DDPressureUnitPoundForcesPerSquareInch:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:689476 exponent:-2 isNegative:NO]; break;
+ default:
+ break;
+ }
+ return multiplier;
+}
+
+@end
View
28 DDUnitConverter/DDRadiationUnitConverter.h
@@ -0,0 +1,28 @@
+//
+// DDRadiationUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDRadiationUnitConverter)
+
++ (id) radiationUnitConverter;
+
+@end
+
+enum {
+ DDRadiationUnitBecquerels = 0,
+ DDRadiationUnitCuries
+};
+typedef NSUInteger DDRadiationUnit;
+
+@interface DDRadiationUnitConverter : DDUnitConverter {
+
+}
+
+@end
View
35 DDUnitConverter/DDRadiationUnitConverter.m
@@ -0,0 +1,35 @@
+//
+// DDRadiationUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDRadiationUnitConverter.h"
+
+@implementation DDUnitConverter (DDRadiationUnitConverter)
+
++ (id) radiationUnitConverter {
+ return [[[DDRadiationUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDRadiationUnitConverter
+
++ (NSDecimalNumber *) multiplierForUnit:(DDUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ switch (unit) {
+ case DDRadiationUnitBecquerels:
+ break;
+ case DDRadiationUnitCuries:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:37 exponent:9 isNegative:NO]; break;
+ default:
+ break;
+ }
+ return multiplier;
+}
+
+@end
View
31 DDUnitConverter/DDTemperatureUnitConverter.h
@@ -0,0 +1,31 @@
+//
+// DDTemperatureUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDTemperatureUnitConverter)
+
++ (id) temperatureUnitConverter;
+
+@end
+
+enum {
+ DDTemperatureUnitCelcius = 0,
+ DDTemperatureUnitFarenheit,
+ DDTemperatureUnitKelvin,
+ DDTemperatureUnitReaumur,
+ DDTemperatureUnitRankine
+};
+typedef NSUInteger DDTemperatureUnit;
+
+@interface DDTemperatureUnitConverter : DDUnitConverter {
+
+}
+
+@end
View
72 DDUnitConverter/DDTemperatureUnitConverter.m
@@ -0,0 +1,72 @@
+//
+// DDTemperatureUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDTemperatureUnitConverter.h"
+
+@implementation DDUnitConverter (DDTemperatureUnitConverter)
+
++ (id) temperatureUnitConverter {
+ return [[[DDTemperatureUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDTemperatureUnitConverter
+
+- (NSNumber *) convertNumber:(NSNumber *)number fromUnit:(DDUnit)from toUnit:(DDUnit)to {
+ if (from == to) { return number; }
+
+ NSDecimalNumber * original = [NSDecimalNumber decimalNumberWithDecimal:[number decimalValue]];
+ NSDecimalNumber * numberInCelcius = original;
+
+ NSDecimalNumber * fiveNinths = [NSDecimalNumber decimalNumberWithMantissa:555555555555 exponent:-12 isNegative:NO];
+ NSDecimalNumber * nineFifths = [NSDecimalNumber decimalNumberWithMantissa:18 exponent:-1 isNegative:NO];
+
+ switch (from) {
+ case DDTemperatureUnitFarenheit:
+ numberInCelcius = [numberInCelcius decimalNumberBySubtracting:[NSDecimalNumber decimalNumberWithMantissa:32 exponent:0 isNegative:NO]];
+ numberInCelcius = [numberInCelcius decimalNumberByMultiplyingBy:fiveNinths];
+ break;
+ case DDTemperatureUnitKelvin:
+ numberInCelcius = [numberInCelcius decimalNumberBySubtracting:[NSDecimalNumber decimalNumberWithMantissa:27315 exponent:-2 isNegative:NO]];
+ break;
+ case DDTemperatureUnitReaumur:
+ numberInCelcius = [numberInCelcius decimalNumberByMultiplyingBy:[NSDecimalNumber decimalNumberWithMantissa:8 exponent:-1 isNegative:NO]];
+ break;
+ case DDTemperatureUnitRankine:
+ numberInCelcius = [numberInCelcius decimalNumberBySubtracting:[NSDecimalNumber decimalNumberWithMantissa:49167 exponent:-2 isNegative:NO]];
+ numberInCelcius = [numberInCelcius decimalNumberByMultiplyingBy:fiveNinths];
+ default:
+ break;
+ }
+
+ NSDecimalNumber * numberInTarget = numberInCelcius;
+ switch (to) {
+ case DDTemperatureUnitFarenheit:
+ numberInTarget = [numberInTarget decimalNumberByMultiplyingBy:nineFifths];
+ numberInTarget = [numberInTarget decimalNumberByAdding:[NSDecimalNumber decimalNumberWithMantissa:32 exponent:0 isNegative:NO]];
+ break;
+ case DDTemperatureUnitKelvin:
+ numberInTarget = [numberInTarget decimalNumberByAdding:[NSDecimalNumber decimalNumberWithMantissa:27315 exponent:-2 isNegative:NO]];
+ break;
+ case DDTemperatureUnitReaumur:
+ numberInTarget = [numberInTarget decimalNumberByDividingBy:[NSDecimalNumber decimalNumberWithMantissa:8 exponent:-1 isNegative:NO]];
+ break;
+ case DDTemperatureUnitRankine:
+ numberInTarget = [numberInTarget decimalNumberByMultiplyingBy:nineFifths];
+ numberInTarget = [numberInTarget decimalNumberByAdding:[NSDecimalNumber decimalNumberWithMantissa:49167 exponent:-2 isNegative:NO]];
+ break;
+ default:
+ break;
+ }
+
+ return numberInTarget;
+}
+
+@end
View
51 DDUnitConverter/DDTimeUnitConverter.h
@@ -0,0 +1,51 @@
+//
+// DDTimeUnitConverter.h
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "DDUnitConverter.h"
+
+@interface DDUnitConverter (DDTimeUnitConverter)
+
++ (id) timeUnitConverter;
+
+@end
+
+enum {
+ DDTimeUnitBlinks = 0,
+ DDTimeUnitCenturies,
+ DDTimeUnitCesium133,
+ DDTimeUnitDays,
+ DDTimeUnitDecades,
+ DDTimeUnitFortnights,
+ DDTimeUnitHours,
+ DDTimeUnitMicroseconds,
+ DDTimeUnitMillenia,
+ DDTimeUnitMilliseconds,
+ DDTimeUnitMinutes,
+ DDTimeUnitMonths,
+ DDTimeUnitNanoseconds,
+ DDTimeUnitSeconds,
+ DDTimeUnitTicks,
+ DDTimeUnitWeeks,
+ DDTimeUnitYears,
+ DDTimeUnitLunarYears,
+
+ DDTimeUnitSiderealSeconds,
+ DDTimeUnitSiderealMinutes,
+ DDTimeUnitSiderealHours,
+ DDTimeUnitSiderealDays,
+ DDTimeUnitSiderealWeeks,
+ DDTimeUnitSiderealYears
+};
+typedef NSUInteger DDTimeUnit;
+
+@interface DDTimeUnitConverter : DDUnitConverter {
+
+}
+
+@end
View
79 DDUnitConverter/DDTimeUnitConverter.m
@@ -0,0 +1,79 @@
+//
+// DDTimeUnitConverter.m
+// DDUnitConverter
+//
+// Created by Dave DeLong on 11/26/10.
+// Copyright 2010 Home. All rights reserved.
+//
+
+#import "DDTimeUnitConverter.h"
+
+@implementation DDUnitConverter (DDTimeUnitConverter)
+
++ (id) timeUnitConverter {
+ return [[[DDTimeUnitConverter alloc] init] autorelease];
+}
+
+@end
+
+
+@implementation DDTimeUnitConverter
+
++ (NSDecimalNumber *) multiplierForUnit:(DDUnit)unit {
+ NSDecimalNumber * multiplier = [NSDecimalNumber one];
+ switch (unit) {
+ case DDTimeUnitBlinks:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:864 exponent:-3 isNegative:NO]; break;
+ case DDTimeUnitCenturies:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:3155692551 exponent:0 isNegative:NO]; break;
+ case DDTimeUnitCesium133:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1087827757078 exponent:-22 isNegative:NO]; break;
+ case DDTimeUnitDays:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:86400 exponent:0 isNegative:NO]; break;
+ case DDTimeUnitDecades:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:3155692551 exponent:-1 isNegative:NO]; break;
+ case DDTimeUnitFortnights:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1209600 exponent:0 isNegative:NO]; break;
+ case DDTimeUnitHours:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:3600 exponent:0 isNegative:NO]; break;
+ case DDTimeUnitMicroseconds:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-6 isNegative:NO]; break;
+ case DDTimeUnitMillenia:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:3155692551 exponent:1 isNegative:NO]; break;
+ case DDTimeUnitMilliseconds:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-3 isNegative:NO]; break;
+ case DDTimeUnitMinutes:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:60 exponent:0 isNegative:NO]; break;
+ case DDTimeUnitMonths:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:2548979939168 exponent:-6 isNegative:NO]; break;
+ case DDTimeUnitNanoseconds:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:1 exponent:-9 isNegative:NO]; break;
+ case DDTimeUnitSeconds:
+ break;
+ case DDTimeUnitTicks:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:16666666666666 exponent:-15 isNegative:NO]; break;
+ case DDTimeUnitWeeks:
+ multiplier = [NSDecimalNumber decimalNumberWithMantissa:604800 exponent:0 isNegative:NO]; break;