home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.bin / SourceCode / MiscKit1.2.6 / Source / MiscStringDebugging.m < prev    next >
Encoding:
Text File  |  1994-05-19  |  1.6 KB  |  55 lines

  1. //
  2. //    MiscStringDebugging.m
  3. //        Written by Don Yacktman (c) 1993 by Don Yacktman.
  4. //                Version 1.95  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. #import <misckit/MiscString.h>
  14.  
  15. @implementation MiscString(Debugging)
  16.  
  17. // This category is composed of methods which are useful when debugging apps.
  18.  
  19. // The next three methods are based on methods in Mike Ferri's MOString and
  20. // are used with his permission.
  21.  
  22. - buildInstanceImageIn:(char *)buf
  23. // Build a nice representation of all our instance vars in buf.
  24. {
  25.     sprintf(buf, "\tstr = '%s' (%#x)\n\tlen = %d\tAllocated len = %d\n", 
  26.                 buffer, (unsigned int)buffer, length, _length);
  27.     return self;
  28. }
  29.  
  30. - printForDebugger:(NXStream *)stream
  31. // Overriden to use our nice instance printer as well as what it used to do.
  32. {
  33.     char buf[200 + length]; // should be plenty big enough
  34.     
  35.     [super printForDebugger:stream];
  36.     [self buildInstanceImageIn:buf];
  37.     NXWrite(stream, buf, strlen(buf));
  38.     
  39.     return self;
  40. }
  41.  
  42. - printToStdErr:(const char *)label
  43. // Prints a nice representation of our string to the stderr labeled with
  44. // the given label.
  45. {
  46.     char buf[200 + length]; // should be plenty big enough
  47.     fprintf(stderr, "%s <%s:%#x>\n", label, [[self class] name],
  48.             (unsigned int)self);
  49.     [self buildInstanceImageIn:buf];
  50.     fprintf(stderr, "%s", buf);
  51.     return self;
  52. }
  53.  
  54. @end
  55.