Class DConfigWriter

Inherits from:
Object
Conforms to:
DConfigHandler
Declared in:
DConfig.h

Class Hierarchy

    Object
      |
      +---DConfigWriter

Class Description

The config writer class implements methods for writing a config file.

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

int main(int argc, char *argv[])
{
  DConfigWriter *wrtr = [DConfigWriter new];
  DText         *dest = [DText         new];

  if (![wrtr startConfig :dest])       // Use text string as destination
    printf("Error in startConfig.\n");

  if (![wrtr comment :"Example config file"]) // Write a comment
    printf("Error in comment.\n");

  if (![wrtr section :"Section1"])      // Write a section in the 'config file'
    printf("Error in section.\n");

  if (![wrtr option :"Section1" :"Option1" :"Value1"]) // Write an option in the 'file'
    printf("Error in option.\n");

  if (![wrtr option :"Section1" :"Option2" :"Value2"])
    printf("Error in option.\n");

  if (![wrtr option :"Section2" :"Option1" :"Value1"]) // Write an option in the next section
    printf("Error in option.\n");

  [wrtr endConfig];

  printf("Config file:\n%s", [dest cstring]);

  [dest free];                         // Cleanup
  [wrtr free];

  return 0;
}
Last modified:
25-Aug-2008 (DConfig.h)

Instance Variables

private id <DTextWritable> _dest
the config file
private DText *_section
the current section

Method Index


generated 06-Sep-2008 by ObjcDoc 3.0.0