home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Source / MiscMergeKit / _MiscMergeCopyCommand.m < prev    next >
Encoding:
Text File  |  1995-07-08  |  1.5 KB  |  53 lines

  1. //
  2. //    _MiscMergeCopyCommand.m -- "copy" merge command implementation
  3. //        Written by Don Yacktman Copyright (c) 1995 by Don Yacktman.
  4. //                Version 1.0.  All rights reserved.
  5. //        This notice may not be removed from this source code.
  6. //
  7. //    This object is included in the MiscKit by permission from the author
  8. //    and its use is governed by the MiscKit license, found in the file
  9. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  10. //    for a list of all applicable permissions and restrictions.
  11. //    
  12.  
  13.  
  14. #import <misckit/miscmerge.h>
  15. #import "_MiscMergeCopyCommand.h"
  16.  
  17. @implementation _MiscMergeCopyCommand
  18.  
  19. static MiscString *myKey = nil;
  20.  
  21. - parseFromString:(MiscString *)aString
  22. {
  23.     MiscString *escapedStart = [MiscString newWithString:"\\"];
  24.     MiscString *escapedEnd = [MiscString newWithString:"\\"];
  25.  
  26.     if (!myKey) {
  27.         myKey = [MiscString new];
  28.         [myKey setStringValue:"copy"];
  29.     }
  30.     if ([self eatKeyWord:myKey from:aString isOptional:YES])
  31.         [aString trimLeadWhiteSpaces];
  32.     theText = [aString copy];
  33.     [escapedStart addChar:[MiscMergeTemplate startFieldDelimiter]];
  34.     [escapedEnd   addChar:[MiscMergeTemplate   endFieldDelimiter]];
  35.     [theText replaceEveryOccurrenceOfString:escapedStart
  36.             withChar:[MiscMergeTemplate startFieldDelimiter]
  37.             caseSensitive:NO overlap:NO];
  38.     [theText replaceEveryOccurrenceOfString:escapedEnd
  39.             withChar:[MiscMergeTemplate endFieldDelimiter]
  40.             caseSensitive:NO overlap:NO];
  41.     [escapedEnd free];
  42.     [escapedStart free];
  43.     return self;
  44. }
  45.  
  46. - executeForMerge:(MiscMergeEngine *)aMerger
  47. {
  48.     [aMerger appendToOutput:theText];
  49.     return self;
  50. }
  51.  
  52. @end
  53.