Class DData

Inherits from:
Object
Conforms to:
DComparable, DDataReadable, DDataWritable, DDatable, DSizeable, DTextScannable, DTextable
Declared in:
DData.h

Class Hierarchy

    Object
      |
      +---DData

Class Description

The DData class implements a number of methods for manipulating data strings.

Example:
#include <stdio.h>
#include "ofc/DData.h"

int main(int argc, char *argv[])
{
  DData *dat1 = [DData alloc];
  DData *dat2 = [DData new  ];
  DText *str;

  [dat1 init :"DData stores data strings" :25]; // Init with a data string

  printf("Length of data string1:%ld\n", [dat1 length]);

  str = [dat1 tohexString];
  printf("Hex string of data string:%s.\n", [str cstring]);
  [str free];

  str = [dat1 toBase64];
  printf("Base64 string of data string:%s.\n", [str cstring]);
  [str free];

  printf("Hash value of data string:%ld.\n", [dat1 hash]);

  printf("Index of \"data\" in data string is:%ld.\n", [dat1 index :"data" :4 :0 :-1]);

  [dat2 set :"DData stores data strings" :1 :17]; // Set with substring

  [dat2 put :16 :'!'];                 // Put a character in the string

  [dat2 insert :16 :16 :" strings" :9]; // Insert a data string

  [dat2 delete :11 :15];               // Delete a substring

  str = [dat2 toText];
  printf("Data string2:%s.\n", [str cstring]);
  [str free];

  printf("Data string1 is ");          // Compare strings
  if ([dat1 compare :dat2] > 0)
    printf("greater");
  else if ([dat1 compare :dat2] < 0)
    printf("smaller");
  else
    printf("equal");
  printf(" than data string2.\n");

  [dat1 free];                         // Cleanup
  [dat2 free];

  return 0;
}
Last modified:
20-Jul-2008 (DData.h)

Instance Variables

private unsigned long _size
the allocated size for the data
private unsigned _extra
the extra size amount
private unsigned long _length
the length of the data
private unsigned char *_data
the data
private unsigned long _pntr
the 'file pointer' for the protocols
private int _error
the last reported error (or 0)

Method Index


generated 06-Sep-2008 by ObjcDoc 3.0.0