PageRenderTime 26ms CodeModel.GetById 11ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 1ms

/core/externals/update-engine/externals/google-toolbox-for-mac/Foundation/GTMNSAppleEventDescriptor+Foundation.h

http://macfuse.googlecode.com/
C++ Header | 102 lines | 31 code | 18 blank | 53 comment | 0 complexity | 83f221ed187e92a36fde7d1f83789f5e MD5 | raw file
  1//
  2//  GTMNSAppleEventDescriptor+Foundation.h
  3//
  4//  Copyright 2008 Google Inc.
  5//
  6//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
  7//  use this file except in compliance with the License.  You may obtain a copy
  8//  of the License at
  9//
 10//  http://www.apache.org/licenses/LICENSE-2.0
 11//
 12//  Unless required by applicable law or agreed to in writing, software
 13//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 14//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 15//  License for the specific language governing permissions and limitations under
 16//  the License.
 17//
 18
 19#import <Foundation/Foundation.h>
 20#import "GTMDefines.h"
 21#import "GTMFourCharCode.h"
 22
 23// A category for dealing with NSAppleEventDescriptors and NSArrays.
 24@interface NSAppleEventDescriptor (GTMAppleEventDescriptorArrayAdditions)
 25// Used to register the types you know how to convert into
 26// NSAppleEventDescriptors.
 27// See examples in GTMNSAppleEventDescriptor+Foundation.
 28// Args:
 29//  selector - selector to call for any of the types in |types|
 30//    -(NSAppleEventDesc *)selector_name;
 31//  types - an std c array of types of length |count|
 32//  count - number of types in |types|
 33+ (void)gtm_registerSelector:(SEL)selector
 34                    forTypes:(DescType*)types
 35                       count:(NSUInteger)count;
 36
 37// Returns an NSObject for any NSAppleEventDescriptor
 38// Uses types registerd by registerSelector:forTypes:count: to determine
 39// what type of object to create. If it doesn't know a type, it attempts
 40// to return [self stringValue].
 41- (id)gtm_objectValue;
 42
 43// Return an NSArray for an AEList
 44// Returns nil on failure.
 45- (NSArray*)gtm_arrayValue;
 46
 47// Return an NSDictionary for an AERecord
 48// Returns nil on failure.
 49- (NSDictionary*)gtm_dictionaryValue;
 50
 51// Return an NSNull for a desc of typeNull
 52// Returns nil on failure.
 53- (NSNull*)gtm_nullValue;
 54
 55// Return a NSAppleEventDescriptor for a double value.
 56+ (NSAppleEventDescriptor*)gtm_descriptorWithDouble:(double)real;
 57
 58// Return a NSAppleEventDescriptor for a float value.
 59+ (NSAppleEventDescriptor*)gtm_descriptorWithFloat:(float)real;
 60
 61// Return a NSAppleEventDescriptor for a CGFloat value.
 62+ (NSAppleEventDescriptor*)gtm_descriptorWithCGFloat:(CGFloat)real;
 63
 64// Attempt to extract a double value. Returns NAN on error.
 65- (double)gtm_doubleValue;
 66
 67// Attempt to extract a float value. Returns NAN on error.
 68- (float)gtm_floatValue;
 69
 70// Attempt to extract a CGFloat value. Returns NAN on error.
 71- (CGFloat)gtm_cgFloatValue;
 72
 73// Attempt to extract a NSNumber. Returns nil on error.
 74- (NSNumber*)gtm_numberValue;
 75
 76// Attempt to return a GTMFourCharCode. Returns nil on error.
 77- (GTMFourCharCode*)gtm_fourCharCodeValue;
 78@end
 79
 80@interface NSObject (GTMAppleEventDescriptorObjectAdditions)
 81// A informal protocol that objects can override to return appleEventDescriptors
 82// for their type. The default is to return [self description] rolled up
 83// in an NSAppleEventDescriptor. Built in support for:
 84// NSArray, NSDictionary, NSNull, NSString, NSNumber and NSProcessInfo
 85- (NSAppleEventDescriptor*)gtm_appleEventDescriptor;
 86@end
 87
 88@interface NSAppleEventDescriptor (GTMAppleEventDescriptorAdditions)
 89// Allows you to send events.
 90// Returns YES if send was successful.
 91- (BOOL)gtm_sendEventWithMode:(AESendMode)mode
 92                      timeOut:(NSTimeInterval)timeout
 93                        reply:(NSAppleEventDescriptor**)reply;
 94@end
 95
 96@interface GTMFourCharCode (GTMAppleEventDescriptorObjectAdditions)
 97
 98// if you call gtm_appleEventDescriptor on GTMFourCharCode it will be of
 99// type typeType. If you need something different (like typeProperty) this
100// allows you to define the type you want.
101- (NSAppleEventDescriptor*)gtm_appleEventDescriptorOfType:(DescType)type;
102@end