本文整理汇总了C++中Filename::setName方法的典型用法代码示例。如果您正苦于以下问题:C++ Filename::setName方法的具体用法?C++ Filename::setName怎么用?C++ Filename::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filename
的用法示例。
在下文中一共展示了Filename::setName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
/**
* Program entry point.
*/
int main(int argc, char *argv[ ])
{
SetupSharedThread::install();
SetupSharedDebug::install(4096);
{
SetupSharedFoundation::Data data(SetupSharedFoundation::Data::D_console);
#ifdef WIN32
char buffer[1024];
GetModuleFileName(GetModuleHandle(NULL), buffer, 1024);
Filename configName;
configName.setName(buffer);
configName.setName("templateCompiler.cfg");
data.configFile = configName.getFullFilename().c_str();
#endif
SetupSharedFoundation::install (data);
}
SetupSharedRegex::install();
SetupSharedCompression::install();
SetupSharedFile::install(false);
// setup the random number generator
// @todo need a better seed
SetupSharedRandom::install(static_cast<uint32>(time(NULL)));
int result = processArgs(argc, argv);
// cleanup
SetupSharedFoundation::remove();
PerThreadData::threadRemove();
return result;
} // main
示例2: processArgs
/**
* 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
示例3: parse
/**
* Main parser for a tdf file. Parses initialization data, creates the header and
* source files, and passes parameter definitions to the appropriate function.
*
* @param fp file to parse
*
* @return 0 on success, -1 on fail
*/
int TemplateDefinitionFile::parse(File &fp)
{
static const int BUFFER_SIZE = 1024;
int lineLen;
char buffer[BUFFER_SIZE];
char token[BUFFER_SIZE];
TemplateData *currentTemplate = NULL;
cleanup();
setTemplateFilename(fp.getFilename().getName());
for (;;)
{
lineLen = fp.readLine(buffer, BUFFER_SIZE);
if (lineLen == -1)
break;
else if (lineLen == -2)
return -1;
const char *line = buffer;
line = getNextWhitespaceToken(line, token);
if (*token == '\0')
break;
if (strcmp(token, "version") == 0)
{
if (m_templateName.size() == 0)
{
fp.printError("no template name defined");
return -1;
}
else if (m_templateId.tag == NO_TAG)
{
fp.printError("no template id defined");
return -1;
}
else if (m_path.getPath().size() == 0)
{
fp.printError("no path defined");
return -1;
}
else if (m_compilerPath.getPath().size() == 0)
{
fp.printError("no compiler path defined");
return -1;
}
// if (m_baseName.size() == 0 && m_templateName != ROOT_TEMPLATE_NAME)
// m_baseName = ROOT_TEMPLATE_NAME;
line = getNextWhitespaceToken(line, token);
int version = atoi(token);
if (version < 0 || version > 9999)
{
fp.printError("version out of range");
return -1;
}
if (m_templateMap.find(version) != m_templateMap.end())
{
fp.printError("version already defined");
return -1;
}
if (version > m_highestVersion)
m_highestVersion = version;
currentTemplate = new TemplateData(version, *this);
m_templateMap[version] = currentTemplate;
}
else if (currentTemplate != NULL)
{
line = currentTemplate->parseLine(fp, buffer, token);
if (line == CHAR_ERROR)
return -1;
}
else if (*token == '/' && *(token + 1) == '/')
{
if (m_baseName.size() == 0 && m_templateId.tag == NO_TAG)
m_fileComments.push_back(buffer);
}
else if (strcmp(token, "base") == 0)
{
if (m_baseName.size() != 0)
{
fp.printError("base name already defined");
return -1;
}
line = getNextWhitespaceToken(line, token);
setBaseFilename(token);
// load and parse the base template
Filename baseFileName = fp.getFilename();
baseFileName.setName(token);
File baseFp(baseFileName, "rt");
//.........这里部分代码省略.........