Monotone-Parent: 2b7803f8e993e96ff4490197722ef0a2a5faad70

Monotone-Revision: 7d9ee580367f7631b0793eae0e55ae9255d331bc

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2012-04-19T02:49:25
maint-2.0.2
Wolfgang Sourdeau 2012-04-19 02:49:25 +00:00
parent dbd99fac84
commit 5753cf3384
7 changed files with 58 additions and 5 deletions

View File

@ -106,6 +106,9 @@
- (void) addType: (NSString *) aType; - (void) addType: (NSString *) aType;
- (NSArray *) orderOfAttributeKeys;
- (NSArray *) orderOfValueKeys;
- (NSString *) versitString; - (NSString *) versitString;
- (CardGroup *) searchParentOfClass: (Class) parentClass; - (CardGroup *) searchParentOfClass: (Class) parentClass;

View File

@ -471,6 +471,16 @@ _orderedValuesAreVoid (NSArray *orderedValues)
return result; return result;
} }
- (NSArray *) orderOfAttributeKeys
{
return nil;
}
- (NSArray *) orderOfValueKeys
{
return nil;
}
- (NSString *) versitString - (NSString *) versitString
{ {
NSString *string; NSString *string;

View File

@ -78,13 +78,17 @@
if ([attributes count]) if ([attributes count])
{ {
[rendering appendString: @";"]; [rendering appendString: @";"];
[attributes versitRenderInString: rendering asAttributes: YES]; [attributes versitRenderInString: rendering
withKeyOrdering: [anElement orderOfAttributeKeys]
asAttributes: YES];
} }
/* values */ /* values */
values = [anElement values]; values = [anElement values];
[rendering appendString: @":"]; [rendering appendString: @":"];
[values versitRenderInString: rendering asAttributes: NO]; [values versitRenderInString: rendering
withKeyOrdering: [anElement orderOfValueKeys]
asAttributes: NO];
if ([rendering length] > 0) if ([rendering length] > 0)
[rendering appendString: @"\r\n"]; [rendering appendString: @"\r\n"];

View File

@ -1,3 +1,15 @@
2012-04-18 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* NSDictionary+NGCards.m
(-versitRenderInString:withKeyOrdering:asAttributes:): now takes
an "ordering" parameter resulting from the methods below and
reorder the dictionary keys as specified.
* CardElement.m (-orderOfAttributeKeys, -orderOfValueKeys): new
methods that return an ordered array of value keys, used for
rendering data in a way that is acceptable to certain picky
clients.
2012-04-11 Francis Lachapelle <flachapelle@inverse.ca> 2012-04-11 Francis Lachapelle <flachapelle@inverse.ca>
* iCalWeeklyRecurrenceCalculator.m * iCalWeeklyRecurrenceCalculator.m

View File

@ -30,6 +30,7 @@
- (id) objectForCaseInsensitiveKey: (NSString *) aKey; - (id) objectForCaseInsensitiveKey: (NSString *) aKey;
- (void) versitRenderInString: (NSMutableString *) aString - (void) versitRenderInString: (NSMutableString *) aString
withKeyOrdering: (NSArray *) ordering
asAttributes: (BOOL) asAttribute; /* handling of ":" */ asAttributes: (BOOL) asAttribute; /* handling of ":" */
@end @end

View File

@ -123,15 +123,37 @@
} }
- (void) versitRenderInString: (NSMutableString *) aString - (void) versitRenderInString: (NSMutableString *) aString
withKeyOrdering: (NSArray *) ordering
asAttributes: (BOOL) asAttributes asAttributes: (BOOL) asAttributes
{ {
NSArray *keys; NSMutableArray *keys;
NSUInteger count, max, rendered = 0; NSUInteger count, max, rendered = 0, keyIndex, newKeyIndex;
NSArray *orderedValues; NSArray *orderedValues;
NSString *key; NSString *key;
NSMutableString *substring; NSMutableString *substring;
keys = [self allKeys]; keys = [[self allKeys] mutableCopy];
[keys autorelease];
/* We reorder the fields based on the "ordering" array, by first placing
those that are specified and then the rest of them. */
newKeyIndex = 0;
max = [ordering count];
for (count = 0; count < max; count++)
{
key = [ordering objectAtIndex: count];
keyIndex = [keys indexOfObject: key];
if (keyIndex != NSNotFound)
{
if (keyIndex != newKeyIndex)
{
[keys removeObjectAtIndex: keyIndex];
[keys insertObject: key atIndex: newKeyIndex];
}
newKeyIndex++;
}
}
max = [keys count]; max = [keys count];
for (count = 0; count < max; count++) for (count = 0; count < max; count++)
{ {

View File

@ -59,6 +59,7 @@
rule = [rules objectAtIndex:i]; rule = [rules objectAtIndex:i];
ruleString = [NSMutableString new]; ruleString = [NSMutableString new];
[[rule values] versitRenderInString: ruleString [[rule values] versitRenderInString: ruleString
withKeyOrdering: [rule orderOfValueKeys]
asAttributes: NO]; asAttributes: NO];
[ma addObject: ruleString]; [ma addObject: ruleString];
[ruleString release]; [ruleString release];