Example #1
0
bool CppCodeGenerator::GenerateCode(PObjectBase project)
{
  m_header->Clear();
  m_source->Clear();
  string date(__DATE__);
  string time(__TIME__);
  string code_header (
   "///////////////////////////////////////////////////////////////////////////\n"
   "// C++ code generated with wxFormBuilder (version " __DATE__ ")\n" 
   "// http://wxformbuilder.software-libre.org/\n"
   "//\n"
   "// PLEASE DO \"NOT\" EDIT THIS FILE!\n"
   "///////////////////////////////////////////////////////////////////////////\n");
   
  m_header->WriteLn(code_header);
  m_source->WriteLn(code_header);
  
  string file = project->GetProperty("file")->GetValue();
  
  m_header->WriteLn("#ifndef __" + file + "__");
  m_header->WriteLn("#define __" + file + "__");

  m_source->WriteLn("#include \""+file+".h\"");
  
  
  GenIncludes(project);
  GenDefines(project);
  
  for (unsigned int i=0; i<project->GetChildCount(); i++)
  {
    GenClassDeclaration(project->GetChild(i));
    GenConstructor(project->GetChild(i));
  }
  
  m_header->WriteLn("#endif //__" + file + "__");
  m_header->WriteLn("");
  
  return true;
}
Example #2
0
File: code.c Project: Pakrik/libdb
int
main(int argc, char *argv[])
{
	int ch;
	char *cfile, *hfile;

	/* Initialize globals. */
	if ((progname = strrchr(argv[0], '/')) == NULL)
		progname = argv[0];
	else
		++progname;

	/* Initialize arguments. */
	cfile = "csv_local.c";		/* Default header/source files */
	hfile = "csv_local.h";

	/* Process arguments. */
	while ((ch = getopt(argc, argv, "c:f:h:v")) != EOF)
		switch (ch) {
		case 'c':
			cfile = optarg;
			break;
		case 'f':
			if (freopen(optarg, "r", stdin) == NULL) {
				fprintf(stderr,
				    "%s: %s\n", optarg, strerror(errno));
				return (EXIT_FAILURE);
			}
			break;
		case 'h':
			hfile = optarg;
			break;
		case 'v':
			++verbose;
			break;
		case '?':
		default:
			return (usage());
		}
	argc -= optind;
	argv += optind;

	if (*argv != NULL)
		return (usage());

	/* Load records from the input file. */
	if (desc_load())
		return (EXIT_FAILURE);

	/* Dump records for debugging. */
	if (verbose && desc_dump())
		return (EXIT_FAILURE);

	/* Open output files. */
	if ((cfp = fopen(cfile, "w")) == NULL) {
		fprintf(stderr,
		    "%s: %s: %s\n", progname, cfile, strerror(errno));
		return (EXIT_FAILURE);
	}
	if ((hfp = fopen(hfile, "w")) == NULL) {
		fprintf(stderr,
		    "%s: %s: %s\n", progname, hfile, strerror(errno));
		return (EXIT_FAILURE);
	}

	/* Build the source and header files. */
	if (code_header())
		return (EXIT_FAILURE);
	if (code_source())
		return (EXIT_FAILURE);

	return (EXIT_SUCCESS);
}
Example #3
0
int
main(int argc, char *argv[])
{
	int ch;

	/* Initialize globals. */
	if ((progname = strrchr(argv[0], '/')) == NULL)
		progname = argv[0];
	else
		++progname;

	/* Initialize arguments. */
    verbose = 0;

    if (argc < 2)
        return(usage());

	/* Process arguments. */
	while ((ch = getopt(argc, argv, "c:f:h:v")) != EOF){
		switch (ch) {
		case 'c':
			cfile = optarg;
			break;
		case 'f':
			if (freopen(optarg, "r", stdin) == NULL) {
				fprintf(stderr,
				    "%s: %s\n", optarg, strerror(errno));
				return (EXIT_FAILURE);
			}
			break;
		case 'h':
			hfile = optarg;
			break;
        case 'v':
			++verbose;
			break;
		case '?':
		default:
			return (usage());
        }
    }

	argc -= optind;
	argv += optind;

	if (*argv != NULL)
		return (usage());

    /* Open header file. Some lines will be copied directly to header
       file while loading the description file.*/
    if ((hfp = fopen(hfile, "w")) == NULL) {
		fprintf(stderr,
		    "%s: %s: %s\n", progname, hfile, strerror(errno));
		return (EXIT_FAILURE);
	}

    if (code_header_start())
        return(EXIT_FAILURE);

	/* Load records from the input file. */
	if (sp_desc_load())
		return (EXIT_FAILURE);

	/* Dump records for debugging. */
	if (verbose && sp_desc_dump())
		return (EXIT_FAILURE);

	/* Open source file. */
	if ((cfp = fopen(cfile, "w")) == NULL) {
		fprintf(stderr,
		    "%s: %s: %s\n", progname, cfile, strerror(errno));
		return (EXIT_FAILURE);
	}
		/* Build the source and header files. */
	if (code_header())
		return (EXIT_FAILURE);
	if (code_source())
		return (EXIT_FAILURE);

    fclose(hfp);
    fclose(cfp);

    if((trhfp = fopen(tr_hfile, "w")) == NULL){
        fprintf(stderr,
		    "%s: %s: %s\n", progname, tr_hfile, strerror(errno));
		return (EXIT_FAILURE);
    }

    if((trcfp = fopen(tr_cfile, "w")) == NULL){
        fprintf(stderr,
		    "%s: %s: %s\n", progname, tr_cfile, strerror(errno));
		return (EXIT_FAILURE);
	}

    if (tr_code_header())
        return(EXIT_FAILURE);
    if (tr_code_source())
        return(EXIT_FAILURE);

    fclose(trhfp);
    fclose(trcfp);
    
    //for(f = fields; field_cnt > 0; --field_cnt, ++f)
    //    free_subfields(f);

    //free(sp_fields);

	return (EXIT_SUCCESS);
}