IOS Streaming Browser 1.0
An IOS streaming browser to stream the display to others or to a projector

/Users/willrubel/IOS-Streaming-Browser/IOS-Streaming-Browser/DDRange.h

Go to the documentation of this file.
00001 /**
00002  * DDRange is the functional equivalent of a 64 bit NSRange.
00003  * The HTTP Server is designed to support very large files.
00004  * On 32 bit architectures (ppc, i386) NSRange uses unsigned 32 bit integers.
00005  * This only supports a range of up to 4 gigabytes.
00006  * By defining our own variant, we can support a range up to 16 exabytes.
00007  * 
00008  * All effort is given such that DDRange functions EXACTLY the same as NSRange.
00009 **/
00010 
00011 #import <Foundation/NSValue.h>
00012 #import <Foundation/NSObjCRuntime.h>
00013 
00014 @class NSString;
00015 
00016 /**
00017  
00018 **/
00019 typedef struct _DDRange {
00020     UInt64 location;
00021     UInt64 length;
00022 } DDRange;
00023 
00024 typedef DDRange *DDRangePointer;
00025 
00026 
00027 // Makes a range with a location and length
00028 NS_INLINE DDRange DDMakeRange(UInt64 loc, UInt64 len) {
00029     DDRange r;
00030     r.location = loc;
00031     r.length = len;
00032     return r;
00033 }
00034 
00035 // Returns the location and length
00036 NS_INLINE UInt64 DDMaxRange(DDRange range) {
00037     return (range.location + range.length);
00038 }
00039 
00040 // Returns the location within a range
00041 NS_INLINE BOOL DDLocationInRange(UInt64 loc, DDRange range) {
00042     return (loc - range.location < range.length);
00043 }
00044 
00045 NS_INLINE BOOL DDEqualRanges(DDRange range1, DDRange range2) {
00046     return ((range1.location == range2.location) && (range1.length == range2.length));
00047 }
00048 
00049 FOUNDATION_EXPORT DDRange DDUnionRange(DDRange range1, DDRange range2);
00050 FOUNDATION_EXPORT DDRange DDIntersectionRange(DDRange range1, DDRange range2);
00051 FOUNDATION_EXPORT NSString *DDStringFromRange(DDRange range);
00052 FOUNDATION_EXPORT DDRange DDRangeFromString(NSString *aString);
00053 
00054 NSInteger DDRangeCompare(DDRangePointer pDDRange1, DDRangePointer pDDRange2);
00055 
00056 @interface NSValue (NSValueDDRangeExtensions)
00057 
00058 /**
00059     Class method
00060     param DDRange
00061     returns NSValue
00062 **/
00063 + (NSValue *)valueWithDDRange:(DDRange)range;
00064 
00065 /**
00066     returns DDRange
00067 **/
00068 - (DDRange)ddrangeValue;
00069 
00070 /**
00071     param NSValue
00072     returns NSInteger
00073 **/
00074 - (NSInteger)ddrangeCompare:(NSValue *)ddrangeValue;
00075 
00076 @end
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Defines