本文整理汇总了C++中FileType::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ FileType::getName方法的具体用法?C++ FileType::getName怎么用?C++ FileType::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileType
的用法示例。
在下文中一共展示了FileType::getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DString
FileType *ColorerFilter::selectType(HRCParser *hrcParser, String *fline)
{
FileType *type = null;
if (typeDescription != null) {
type = hrcParser->getFileType(typeDescription);
if (type == null) {
for(int idx = 0;; idx++)
{
type = hrcParser->enumerateFileTypes(idx);
if (type == null) {
break;
}
if (type->getDescription() != null &&
type->getDescription()->length() >= typeDescription->length() &&
DString(type->getDescription(), 0, typeDescription->length()).equalsIgnoreCase(typeDescription)) {
break;
}
if (type->getName()->length() >= typeDescription->length() &&
DString(type->getName(), 0, typeDescription->length()).equalsIgnoreCase(typeDescription)) {
break;
}
type = null;
}
}
}
if (typeDescription == null || type == null) {
type = hrcParser->chooseFileType(inputFileName, fline, 0);
}
return type;
}
示例2: DString
FileType *ConsoleTools::selectType(HRCParser *hrcParser, LineSource *lineSource){
FileType *type = null;
if (typeDescription != null){
type = hrcParser->getFileType(typeDescription);
if (type == null){
for(int idx = 0;; idx++){
type = hrcParser->enumerateFileTypes(idx);
if (type == null) break;
if (type->getDescription() != null &&
type->getDescription()->length() >= typeDescription->length() &&
DString(type->getDescription(), 0, typeDescription->length()).equalsIgnoreCase(typeDescription))
break;
if (type->getName()->length() >= typeDescription->length() &&
DString(type->getName(), 0, typeDescription->length()).equalsIgnoreCase(typeDescription))
break;
type = null;
}
}
}
if (typeDescription == null || type == null){
StringBuffer textStart;
int totalLength = 0;
for(int i = 0; i < 4; i++){
String *iLine = lineSource->getLine(i);
if (iLine == null) break;
textStart.append(iLine);
textStart.append(DString("\n"));
totalLength += iLine->length();
if (totalLength > 500) break;
}
type = hrcParser->chooseFileType(inputFileName, &textStart, 0);
}
return type;
}
示例3: listTypes
void ConsoleTools::listTypes(bool load, bool useNames){
Writer *writer = null;
try{
writer = new StreamWriter(stdout, outputEncodingIndex, bomOutput);
ParserFactory pf(catalogPath);
HRCParser *hrcParser = pf.getHRCParser();
fprintf(stderr, "\nloading file types...\n");
for(int idx = 0;; idx++){
FileType *type = hrcParser->enumerateFileTypes(idx);
if (type == null) break;
if (useNames){
writer->write(StringBuffer(type->getName())+"\n");
}else{
if (type->getGroup() != null){
writer->write(StringBuffer(type->getGroup()) + ": ");
}
writer->write(type->getDescription());
writer->write(DString("\n"));
}
if (load) type->getBaseScheme();
}
delete writer;
}catch(Exception &e){
delete writer;
fprintf(stderr, "%s\n", e.getMessage()->getChars());
}
}
示例4: genOutput
void ConsoleTools::genOutput(bool useTokens){
try{
// Source file text lines store.
TextLinesStore textLinesStore;
textLinesStore.loadFile(inputFileName, inputEncoding, true);
// parsers factory
ParserFactory pf(catalogPath);
// HRC loading
HRCParser *hrcParser = pf.getHRCParser();
// HRD RegionMapper creation
bool useMarkup = false;
RegionMapper *mapper = null;
if (!useTokens){
try{
mapper = pf.createStyledMapper(&DString("rgb"), hrdName);
}catch(ParserFactoryException &){
useMarkup = true;
mapper = pf.createTextMapper(hrdName);
}
}
// Base editor to make primary parse
BaseEditor baseEditor(&pf, &textLinesStore);
// Using compact regions
baseEditor.setRegionCompact(true);
baseEditor.setRegionMapper(mapper);
baseEditor.lineCountEvent(textLinesStore.getLineCount());
// Choosing file type
FileType *type = selectType(hrcParser, &textLinesStore);
baseEditor.setFileType(type);
// writing result into HTML colored stream...
const RegionDefine *rd = null;
if (mapper != null) rd = baseEditor.rd_def_Text;
Writer *escapedWriter = null;
Writer *commonWriter = null;
try{
if (outputFileName != null) commonWriter = new FileWriter(outputFileName, outputEncodingIndex, bomOutput);
else commonWriter = new StreamWriter(stdout, outputEncodingIndex, bomOutput);
if (htmlEscaping) escapedWriter = new HtmlEscapesWriter(commonWriter);
else escapedWriter = commonWriter;
}catch(Exception &e){
fprintf(stderr, "can't open file '%s' for writing:\n", outputFileName->getChars());
fprintf(stderr, e.getMessage()->getChars());
return;
}
if (htmlWrapping && useTokens){
commonWriter->write(DString("<html>\n<head>\n<style></style>\n</head>\n<body><pre>\n"));
}else if (htmlWrapping && rd != null){
if (useMarkup){
commonWriter->write(TextRegion::cast(rd)->stext);
}else{
commonWriter->write(DString("<html><body style='"));
ParsedLineWriter::writeStyle(commonWriter, StyledRegion::cast(rd));
commonWriter->write(DString("'><pre>\n"));
}
}
if (copyrightHeader){
commonWriter->write(DString("Created with colorer-take5 library. Type '"));
commonWriter->write(type->getName());
commonWriter->write(DString("'\n\n"));
}
int lni = 0;
int lwidth = 1;
int lncount = textLinesStore.getLineCount();
for(lni = lncount/10; lni > 0; lni = lni/10, lwidth++);
for(int i = 0; i < lncount; i++){
if (lineNumbers){
int iwidth = 1;
for(lni = i/10; lni > 0; lni = lni/10, iwidth++);
for(lni = iwidth; lni < lwidth; lni++) commonWriter->write(0x0020);
commonWriter->write(SString(i));
commonWriter->write(DString(": "));
}
if (useTokens){
ParsedLineWriter::tokenWrite(commonWriter, escapedWriter, docLinkHash, textLinesStore.getLine(i), baseEditor.getLineRegions(i));
}else if (useMarkup){
ParsedLineWriter::markupWrite(commonWriter, escapedWriter, docLinkHash, textLinesStore.getLine(i), baseEditor.getLineRegions(i));
}else{
ParsedLineWriter::htmlRGBWrite(commonWriter, escapedWriter, docLinkHash, textLinesStore.getLine(i), baseEditor.getLineRegions(i));
}
commonWriter->write(DString("\n"));
}
if (htmlWrapping && useTokens){
commonWriter->write(DString("</pre></body></html>\n"));
}else if (htmlWrapping && rd != null){
if (useMarkup){
commonWriter->write(TextRegion::cast(rd)->etext);
}else{
commonWriter->write(DString("</pre></body></html>\n"));
}
}
if (htmlEscaping) delete commonWriter;
delete escapedWriter;
//.........这里部分代码省略.........