odmcreate 命令

用途

产生 .c(源)和 .h(包含)文件,对于 ODM 应用程序开发和创建空的对象类是必要的。

语法

odmcreate[-p ] [-c |-h]ClassDescriptionFile

描述

odmcreate 命令是 ODM 类编译器。 此命令以描述用户希望在特定的应用程序中使用的对象的 ASCII 文件为输入。 odmcreate 命令能够创建空的对象类,作为它的执行的一部分。

odmcreate 命令的输出是 .h 文件(一个包含文件),它包含了定义在 ASCII ClassDescriptionFile 文件中的对象类的 C 语言定义。 结果包含文件使用在访问存储在 ODM 中对象的应用程序中。 odmcreate 命令也产生需要编译和绑定在应用程序中的 .c 文件。 .c 文件包含在运行时由 ODM 内部使用的结构和定义。

ClassDescriptionFile 参数指定了包含一个或多个对象类的描述的 ASCII 文件。 ClassDescriptionFile 参数的常规语法如下:

描述
文件 : classes
classes : class | classes class
class : head body tail
head :struct ClassName {
tail : }
body : elements
elements : elements | elements element
element :char DescriptorName [ DescriptorSize ];

vchar DescriptorName [ DescriptorSize ];

二进制 DescriptorName [ DescriptorSize ];

DescriptorName

long DescriptorName

long64 or int64 or ODM_LONG_LONG DescriptorName ;

方法 DescriptorName

link StdClassName StdClassName ColName DescriptorName

ClassDescriptionFile 文件的缺省后缀是 .cre。 如果在 odmcreate 命令中没有指定后缀,那么附加一个.cre 后缀。 文件能够有 C 语言注释,如果运行时带有 -p 标志,并能预先包含 #define #include 行,这些可以被预处理的,如果在文件中使用了 -p 标志运行 C 语言预处理器。

注意:ODM 数据库为 32 位数据库。 长型当在类描述文件中使用时,它是 32 位的数据项。 长型 64 或整型 64 当在类描述文件中使用时,它是 64 位的数据项。 生成的文件对于 32 位和 64 位应用程序具有相同功能。

标志

描述
-c 只创建空的对象类;不生成 C 语言 .h.c 文件。
-h 只生成 .c.h 文件;不创建空类。
-p ClassDescriptionFile 文件运行 C 语言预处理器。

示例

假设 "ClassDescriptionFile文件名为FileName.creexists ,以下命令创建对象类:

odmcreate FileName.cre

以下是FileName.cre源文件和生成的 .h 文件:

/* This is an example odmcreate input file */
/* FileName.cre */
   
       class Class2 {
            char keys[32];
            method card;
            long cash;
            };
      class TstObj {
            long a;
            char b[80];
            link Class2 Class2 card Class2Ln;
            };
   
/* End of FileName.cre */
   
/* This is the generated header file FileName.h */
  
#include <odmi.h>
   
struct Class2 {
     long _id;         /* unique object id within object class */
     long _reserved;   /* reserved field */
     long _scratch;    /* extra field for application use */
     char keys[32];
     char card[256];   /* method */
     long cash;
     };
#define Class2_Descs 3
   
extern struct Class Class2_CLASS[];
#define get_Class2_list (a,b,c,d,e) (struct Class2 * ) odm_get_list (a,b,c,d,e)
   
struct TstObj {
     long _id;         /* unique object id within object class */
     long _reserved;   /* reserved field */
     long _scratch;    /* extra field for application use */
     long a;
     char b[80];
     struct Class2 *Class2Ln;  /* link */
     struct objlistinfo *Class2Ln_info; /* link */
     char Class2Ln_Lvalue[256];        /* link */
     };
#define TstObj_Descs 3
   
extern struct Class TstObj_CLASS[];
#define get_TstObj_list (a,b,c,d,e) (struct TstObj * ) odm_get_list (a,b,c,d,e)
   
/* End of generated header file FileName.h */