/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. // GDataValueConstruct.h
  17. //
  18. // GDataValueConstruct is meant to be subclassed for elements that
  19. // store just a single string either as an attribute or as the
  20. // element child text.
  21. //
  22. // See the examples with each subclass below.
  23. #import "GDataObject.h"
  24. #import "GDataDateTime.h"
  25. // an element with a value="" attribute, as in
  26. // <gCal:timezone value="America/Los_Angeles"/>
  27. // (subclasses may override the attribute name)
  28. @interface GDataValueConstruct : GDataObject
  29. // convenience functions: subclasses may call into these and
  30. // return the result, cast to the appropriate type
  31. //
  32. // if nil is passed in for pointer type args for these, nil is returned
  33. + (id)valueWithString:(NSString *)str;
  34. + (id)valueWithNumber:(NSNumber *)num;
  35. + (id)valueWithInt:(int)val;
  36. + (id)valueWithLongLong:(long long)val;
  37. + (id)valueWithDouble:(double)val;
  38. + (id)valueWithBool:(BOOL)flag;
  39. + (id)valueWithDateTime:(GDataDateTime *)dateTime;
  40. - (NSString *)stringValue;
  41. - (void)setStringValue:(NSString *)str;
  42. - (NSString *)attributeName; // defaults to "value", subclasses can override
  43. // subclass value utilities
  44. - (NSNumber *)intNumberValue;
  45. - (int)intValue;
  46. - (void)setIntValue:(int)val;
  47. - (NSNumber *)longLongNumberValue;
  48. - (long long)longLongValue;
  49. - (void)setLongLongValue:(long long)val;
  50. - (NSNumber *)doubleNumberValue;
  51. - (double)doubleValue;
  52. - (void)setDoubleValue:(double)value;
  53. - (NSNumber *)boolNumberValue;
  54. - (BOOL)boolValue;
  55. - (void)setBoolValue:(BOOL)flag;
  56. - (GDataDateTime *)dateTimeValue;
  57. - (void)setDateTimeValue:(GDataDateTime *)dateTime;
  58. @end
  59. // GDataValueElementConstruct is for subclasses that keep the value
  60. // in the child text nodes, like <yt:books>Pride and Prejudice</yt:books>
  61. @interface GDataValueElementConstruct : GDataValueConstruct
  62. - (NSString *)attributeName; // returns nil
  63. @end
  64. // GDataImplicitValueConstruct is for subclasses that want a fixed value
  65. // because the element is merely present or absent, like <gd:deleted/>
  66. @interface GDataImplicitValueConstruct : GDataValueElementConstruct
  67. + (id)implicitValue;
  68. - (NSString *)stringValue; // returns nil
  69. @end
  70. // an element with a value=true or false attribute, as in
  71. // <gCal:sendEventNotifications value="true"/>
  72. @interface GDataBoolValueConstruct : GDataValueConstruct
  73. + (id)boolValueWithBool:(BOOL)flag;
  74. @end
  75. // GDataNameValueConstruct is for subclasses that have "name" and "value"
  76. // attributes
  77. @interface GDataNameValueConstruct : GDataValueConstruct
  78. + (id)valueWithName:(NSString *)name stringValue:(NSString *)value;
  79. - (NSString *)name;
  80. - (void)setName:(NSString *)str;
  81. - (NSString *)nameAttributeName; // the default implementation returns @"name"
  82. @end