]> err.no Git - sope/blobdiff - sope-ical/NGiCal/NGVCardValue.m
more work on vCard parsing
[sope] / sope-ical / NGiCal / NGVCardValue.m
index dd4457b9383a5aa5093a2003fc8c0faf89905952..b5476a8ed53fcf45dbeeb238e9bfee70dc1c219d 100644 (file)
 
 @implementation NGVCardValue
 
+- (id)initWithGroup:(NSString *)_group types:(NSArray *)_types
+  arguments:(NSDictionary *)_a
+{
+  if ((self = [super init]) != nil) {
+    self->group     = [_group copy];
+    self->types     = [_types copy];
+    self->arguments = [_a copy];
+  }
+  return self;
+}
+- (id)init {
+  return [self initWithGroup:nil types:nil arguments:nil];
+}
+
 - (void)dealloc {
   [self->group     release];
   [self->types     release];
   return self;
 }
 
+/* description */
+
+- (void)appendDictionary:(NSDictionary *)_d compactTo:(NSMutableString *)_s {
+  NSEnumerator *keys;
+  NSString *k;
+  
+  keys = [_d keyEnumerator];
+  while ((k = [keys nextObject]) != nil) {
+    NSString *v;
+    
+    v = [_d objectForKey:k];
+    [_s appendFormat:@"%@='%@';", k, v];
+  }
+}
+
+- (void)appendAttributesToDescription:(NSMutableString *)_ms {
+  if (self->group != nil) [_ms appendFormat:@" group='%@'", self->group];
+  if ([self->types count] > 0) {
+    [_ms appendFormat:@" types=%@", 
+          [self->types componentsJoinedByString:@","]];
+  }
+  if ([self->arguments count] > 0) {
+    [_ms appendString:@" args="];
+    [self appendDictionary:self->arguments compactTo:_ms];
+  }
+}
+
+- (NSString *)description {
+  NSMutableString *str = nil;
+  
+  str = [NSMutableString stringWithCapacity:64];
+  [str appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
+  [self appendAttributesToDescription:str];
+  [str appendString:@">"];
+  return str;
+}
+
 @end /* NGVCardValue */