updated at: 20050307 CET

Rocs Object Generator



top

Introduction:

Ogen generates C-Objects from an XML input file.
It generates 4 to 5 things:

  1. a public header file
  2. an implementation header file
  3. a function map file (*.fm)
  4. and if not jet exist the implementation C file
  5. HTML documentation
And with those files C has got an Object like syntax:

e.g.:
#include "myapp/public/item.h"
...
  iOItem item = ItemOp.inst( "id007" );
  const char* id = ItemOp.getId( item ); 
...
The ItemOp structure is filled with the right function addresses in the item.fm file.
All C objects also implements the OBase functions: name, count, equals, serialize, deserialize, toString, getPropeties, del, clone.


top

Example XML input file:


<Project name="myapp" title="MyApp API" tolower="true" docname="myappapi" source="$Source: /cvsroot/rojav/rocs/gen/ogen.html,v $" revision="$Revision: 1.3 $">

  <object name="Item" use="node" remark="An Item object.">
    <const name="version" vt="string" val="0.10"/>
    <fun name="inst" vt="this" remark="">
      <param name="id" vt="const char*" range="*" unit="-" remark="ID for this new item."/>
    </fun>
    <fun name="getId" vt="void" remark="Get the item ID.">
      <param name="inst" vt="this" remark="Item instance."/>
    </fun>
    <data>
      <var name="id" vt="const char*" remark="The ID."/>
    </data>
  </object>
  
</Project>
After running in the directory myapp the command ../bin/ogen myapp.xml the following directories and files will be generated:

top

Definition of XML input files:

NodeParent node
Attribute/Constant
RemarkDefaultRange
project*root*
nameThe real application directory or cvs module.-*
docnameFile name for the HTML documentation.-*
titleHTML documentation title.-*
tolowerMake all C files lower case.falsetrue,false
sourceCVS keyword.-$Source: /cvsroot/rojav/rocs/gen/ogen.html,v $
revisionCVS keyword.-$Revision: 1.3 $
objectchildnode of projectObject definition.
nameObject name.-*
interfaceInterface to implement. Should be defined first, or external: "$../module/xmlfile:interfacename"-*
nobaseObject does not implements the base interface if set true.falsetrue,false
filenameOverwrite the default generated filename.-*
usePublic headers from the librocs to include in the public header.(csv)
Use $-prefix to include from other modules, or #-prefix for stdlib.
-*
includePublic headers from the module to include in the public header.(csv)
Use $-prefix to include from other modules, or #-prefix for stdlib.
-*
remarkObject description.-*
constchildnode of objectConstant value.
nameConstant name.-*
vtVariable type.
(all possible C- and typedefs were string is translated in const char*)
-*
valValue of constant.-*
remarkDescription of the constant.-*
typedefchildnode of objectType definition.
defValid C typedef.-*
defchildnode of objectA define.
nameDefine name.-*
valDefine value.-*
funchildnode of objectFunction definition.
nameFunction name.-*
vtReturn type.-this-*
remarkDescription of the function.-*
paramchildnode of funFunction parameter definition.
nameParameter name.-*
vtVariable type.-this-*
remarkDescription of the parameter.-*
datachildnode of objectObject private data definition.
includePublic headers from the module to include in the impl header.(csv)
Use $-prefix to include from other modules, or #-prefix for stdlib.
-*
varchildnode of dataData variable.
nameVariable name.-*
vtVariable type.
(all possible C- and typedefs were string is translated in const char*)
-*
remarkDescription of the variable.-*
structchildnode of objectObject structure definition.
nameStructure name.-*
typedefOptional struct typedef.-*
remarkDescription of structure.-*
varchildnode of structStructure variable.
nameVariable name.-*
vtVariable type.
(all possible C- and typedefs were string is translated in const char*)
-*
remarkDescription of the variable.-*
interfacechildnode of projectInterface definition.
nameInterface name.-*

top

Base functions:

Every rocs object can be down casted to an obj or OBase. (see: rocs/public/rocs.h)
 
  obj o = (obj)item;
  char* str = o->toString( o );
or:
 
  char* str = item->base.toString( item );
Method Summary of obj
voiddel( obj inst );
Free this object.
const char*name( void );
Returns name of object.
intcount( void );
Returns object count.
objclone( obj inst );
Clones this object.
Booleanequals( obj inst1, obj inst2 );
Compairs both objects at contents.
byte*serialize( obj inst1, long* size );
Serializes object contents.
voiddeserialize( obj inst1, byte* bytes );
Serializes object contents.
char*toString( obj inst );
String representation of this obj.
const void*
properties(obj inst );
If object has properties this should return an iONode.