PageRenderTime 57ms CodeModel.GetById 46ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Elements/GDataValueConstruct.h

http://macfuse.googlecode.com/
C++ Header | 102 lines | 44 code | 20 blank | 38 comment | 0 complexity | ae9359b034c0ba65cb4301a8fdb46283 MD5 | raw file
  1/* Copyright (c) 2007-2008 Google Inc.
  2*
  3* Licensed under the Apache License, Version 2.0 (the "License");
  4* you may not use this file except in compliance with the License.
  5* You may obtain a copy of the License at
  6*
  7*     http://www.apache.org/licenses/LICENSE-2.0
  8*
  9* Unless required by applicable law or agreed to in writing, software
 10* distributed under the License is distributed on an "AS IS" BASIS,
 11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12* See the License for the specific language governing permissions and
 13* limitations under the License.
 14*/
 15
 16//
 17//  GDataValueConstruct.h
 18//
 19
 20// GDataValueConstruct is meant to be subclassed for elements that
 21// store just a single string either as an attribute or as the
 22// element child text.
 23//
 24// See the examples with each subclass below.
 25
 26#import "GDataObject.h"
 27#import "GDataDateTime.h"
 28
 29// an element with a value="" attribute, as in
 30// <gCal:timezone value="America/Los_Angeles"/>
 31// (subclasses may override the attribute name)
 32@interface GDataValueConstruct : GDataObject
 33
 34// convenience functions: subclasses may call into these and
 35// return the result, cast to the appropriate type
 36//
 37// if nil is passed in for pointer type args for these, nil is returned
 38+ (id)valueWithString:(NSString *)str;
 39+ (id)valueWithNumber:(NSNumber *)num;
 40+ (id)valueWithInt:(int)val;
 41+ (id)valueWithLongLong:(long long)val;
 42+ (id)valueWithDouble:(double)val;
 43+ (id)valueWithBool:(BOOL)flag;
 44+ (id)valueWithDateTime:(GDataDateTime *)dateTime;
 45
 46- (NSString *)stringValue;
 47- (void)setStringValue:(NSString *)str;
 48
 49- (NSString *)attributeName; // defaults to "value", subclasses can override
 50
 51// subclass value utilities
 52- (NSNumber *)intNumberValue;
 53- (int)intValue;
 54- (void)setIntValue:(int)val;
 55
 56- (NSNumber *)longLongNumberValue;
 57- (long long)longLongValue;
 58- (void)setLongLongValue:(long long)val;
 59
 60- (NSNumber *)doubleNumberValue;
 61- (double)doubleValue;
 62- (void)setDoubleValue:(double)value;
 63
 64- (NSNumber *)boolNumberValue;
 65- (BOOL)boolValue;
 66- (void)setBoolValue:(BOOL)flag;
 67
 68- (GDataDateTime *)dateTimeValue;
 69- (void)setDateTimeValue:(GDataDateTime *)dateTime;
 70
 71@end
 72
 73// GDataValueElementConstruct is for subclasses that keep the value
 74// in the child text nodes, like <yt:books>Pride and Prejudice</yt:books>
 75@interface GDataValueElementConstruct : GDataValueConstruct
 76- (NSString *)attributeName; // returns nil
 77@end
 78
 79// GDataImplicitValueConstruct is for subclasses that want a fixed value
 80// because the element is merely present or absent, like <gd:deleted/>
 81@interface GDataImplicitValueConstruct : GDataValueElementConstruct
 82+ (id)implicitValue;
 83- (NSString *)stringValue; // returns nil
 84@end
 85
 86// an element with a value=true or false attribute, as in
 87//   <gCal:sendEventNotifications value="true"/>
 88@interface GDataBoolValueConstruct : GDataValueConstruct
 89+ (id)boolValueWithBool:(BOOL)flag;
 90@end
 91
 92// GDataNameValueConstruct is for subclasses that have "name" and "value"
 93// attributes
 94@interface GDataNameValueConstruct : GDataValueConstruct
 95+ (id)valueWithName:(NSString *)name stringValue:(NSString *)value;
 96
 97- (NSString *)name;
 98- (void)setName:(NSString *)str;
 99
100- (NSString *)nameAttributeName; // the default implementation returns @"name"
101@end
102