/** * Processes the args sent to main. */ int processArgs(int argc, char *argv[ ]) { if (argc < 3) { printSyntax(); return 0; } //if (strcmp(argv[1], "-edit") == 0) //{ // for (int i = 2; i < argc; ++i) // { // int result = checkOut(argv[i]); // if (result != 0) // return result; // } //} //else if (strcmp(argv[1], "-submit") == 0) //{ // for (int i = 2; i < argc; ++i) // { // int result = checkIn(argv[i]); // if (result != 0) // return result; // } //} if (strcmp(argv[1], "-compile") == 0) { Filename filename; for (int i = 2; i < argc; ++i) { File::setBasePath(""); filename.clear(); filename.setExtension(TEMPLATE_DEFINITION_EXTENSION); filename.setName(argv[i]); File fp(filename, "rt"); if (!fp.isOpened()) { fprintf(stderr, "cannot open file %s\n", argv[i]); return -1; } else { File::setBasePath(filename.getPath().c_str()); int result = parseTemplateDefinitionFile(fp); fp.close(); if (result != 0) return result; } } } else { printSyntax(); return 0; } return 0; } // processArgs
/** * Prepends a path to our path, unless our path is an an absolute path. * * @param path the path to prepend */ void Filename::prependPath(const Filename &path) { if (m_path.size() != 0 && m_path[0] != PATH_SEPARATOR) { m_path = path.getPath() + m_path; convertToSystemPath(m_path); makeFullPath(); } } // Filename::prependPath
/** * Appends a path to our path. If the path is an absolute path, replaces our path. * * @param path the path to append */ void Filename::appendPath(const Filename &path) { std::string localpath = path.getPath(); convertToSystemPath(localpath); if (localpath.size() != 0 && localpath[0] == PATH_SEPARATOR) m_path = localpath; else m_path += localpath; makeFullPath(); } // Filename::appendPath
/** * Writes the header and source files for a template. * * @param tdfFile the parsed template definition file * @param path path to write the file to * * @return 0 on success, -1 on error */ int writeTemplate(TemplateDefinitionFile &tdfFile, const Filename &path) { int result; // std::string oldTemplateName = tdfFile.getTemplateName(); // std::string oldBaseName = tdfFile.getBaseName(); Filename fullName(NULL, path.getPath().c_str(), tdfFile.getTemplateName().c_str(), NULL); writeTemplateHeader(tdfFile, fullName); result = writeTemplateSource(tdfFile, fullName); // tdfFile.setTemplateName(oldTemplateName); // tdfFile.setBaseName(oldBaseName); return result; } // writeTemplate