本文整理汇总了C++中DNA::parse方法的典型用法代码示例。如果您正苦于以下问题:C++ DNA::parse方法的具体用法?C++ DNA::parse怎么用?C++ DNA::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DNA
的用法示例。
在下文中一共展示了DNA::parse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
if (argc <= 1)
{
printf("Usage: %s infile\n", argv[0]);
return 1;
}
FILE *fp = fopen(argv[1], "rb");
if (!fp)
{
printf("File loading failed %s\n", argv[1]);
return 1;
}
fseek(fp, 0L, SEEK_END);
int len = ftell(fp);
fseek(fp, 0L, SEEK_SET);
char *buf = new char[len+1];
fread(buf, len, 1, fp);
fclose(fp);
bool blender = !strncmp("BLENDER", buf, 6);
bool bullet = !strncmp("BULLET", buf, 5);
if (!blender && !bullet)
{
printf("Invalid header, compressed file ?\n");
delete []buf;
return 1;
}
char *ver = buf+9;
int version = atoi(ver);
bool is64Bit = false;
if (buf[7]=='-')
is64Bit = true;
int dnastart = -1;
char *tbuf = buf;
for (int i=0; i<len; ++i)
{
if (!strncmp("SDNA", tbuf, 4))
{
dnastart = i;
break;
}
++tbuf;
}
if (dnastart != -1)
{
DNA *dna = new DNA;
dna->parse(buf + dnastart);
char specname[12], fname[12];
sprintf(specname, "%s", (bullet ? "Bullet" : "Blender"));
sprintf(fname, "%s.h", (bullet ? "Bullet" : "Blender"));
FILE *bfp= fopen(fname, "wb");
if (bfp)
{
printf("Writing %s header from file version %i...\n", specname, version);
fprintf(bfp, "#ifndef _%s_h_\n", specname);
fprintf(bfp, "#define _%s_h_\n", specname);
fprintf(bfp, "// Generated from a %s(%i) file.\n\n", specname, version);
if (blender)
{
fprintf(bfp, "#ifdef near\n");
fprintf(bfp, "#undef near\n");
fprintf(bfp, "#endif\n");
fprintf(bfp, "#ifdef far\n");
fprintf(bfp, "#undef far\n");
fprintf(bfp, "#endif\n");
fprintf(bfp, "#ifdef rad2\n");
fprintf(bfp, "#undef rad2\n");
fprintf(bfp, "#endif\n");
}
fprintf(bfp, "\n\n");
fprintf(bfp, "namespace %s {\n", specname);
#if ADD_DOXYGEN_COMMENTS
fprintf(bfp, "/** \\addtogroup %s\n"
"* @{\n"
"*/\n\n",
//.........这里部分代码省略.........